import java.io.*; public class CurlClient implements FilenameFilter { String searchPattern = ""; public static void main(String args[]){ //Syntax Check, returns usage of not correct if (args.length != 5){ System.out.println("Usage: java CurlClient "); System.out.println("For file content type the following values are valid"); System.out.println("\t'Data' , 'Products' , 'Misc'"); System.out.println(""); System.out.println("\tNo values are needed for VLBI"); System.exit(0); } //Creates new instance of CurlClient with all the command line arguments being passed // args[0] = homespace (where cookie file should be located // args[1] = directory containing data files to be uploaded // args[2] = pattern all the file names contain. Used to not upload extra files // args[3] = fileType (values can be GNSS/GNSSV2/DORIS/SLR/VLBI/MISC) // args[4] = data parameters (depends on type of data, see documentation) new CurlClient().runClient(args[0],args[1], args[2],args[3],args[4]); } public void runClient(String cookieLocation, String fileDirectory, String searchPattern, String fileType, String fileContentType){ try { this.searchPattern = searchPattern; //Defines the loginCmd, included location of cookiesFile //May need to include full path to cURL if not found String loginCmd = "curl -n -L -b " + cookieLocation + File.separator + ".urs_cookies -c " + cookieLocation + File.separator + ".urs_cookies http://cddis-basin.gsfc.nasa.gov/CDDIS_FileUpload/login"; //Set the directory containing the upload files to the folder variable File folder = new File(fileDirectory); //Filter files in directory, store only those that match pattern in array String[] allFilesInThatFolder = folder.list(this); //Build the fileUpload options //Creates a StringBuffer object that will contain the file type specific options StringBuffer uploadOptions = new StringBuffer(); uploadOptions.append(" -F \"fileType=" + fileType + "\""); uploadOptions.append(" -F \"fileContentType=" + fileContentType + "\""); //Begin building the upload command StringBuffer uploadCmd = new StringBuffer(); //Begin building upload command uploadCmd.append("curl -X POST -b " + cookieLocation + File.separator + ".urs_cookies -c " + cookieLocation + File.separator + ".urs_cookies -n ").append(uploadOptions); //Include all files that match in upload command for (int i=0;i