List of usage examples for org.apache.commons.lang StringUtils isBlank
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
From source file:de.burlov.amazon.s3.S3Utils.java
public static void main(String[] args) { Options opts = new Options(); OptionGroup gr = new OptionGroup(); gr.setRequired(true);/*from w ww. j a v a 2 s. co m*/ gr.addOption(new Option(LIST, false, "")); gr.addOption(new Option(DELETE, false, "")); opts.addOptionGroup(gr); opts.addOption(new Option("k", true, "Access key for AWS account")); opts.addOption(new Option("s", true, "Secret key for AWS account")); opts.addOption(new Option("b", true, "Bucket")); CommandLine cmd = null; try { cmd = new PosixParser().parse(opts, args); String accessKey = cmd.getOptionValue("k"); if (StringUtils.isBlank(accessKey)) { System.out.println("Missing amazon access key"); return; } String secretKey = cmd.getOptionValue("s"); if (StringUtils.isBlank(secretKey)) { System.out.println("Missing secret key"); return; } String bucket = cmd.getOptionValue("b"); if (cmd.hasOption(LIST)) { if (StringUtils.isBlank(bucket)) { printBuckets(accessKey, secretKey); } else { printBucket(accessKey, secretKey, bucket); } } else if (cmd.hasOption(DELETE)) { if (StringUtils.isBlank(bucket)) { System.out.println("Bucket name required"); return; } int count = deleteBucket(accessKey, secretKey, bucket); System.out.println("Deleted objects in bucket: " + count); } } catch (ParseException e) { System.out.println(e.getMessage()); printUsage(opts); return; } catch (Exception e) { e.printStackTrace(System.err); } }
From source file:edu.uci.ics.crawler4j.weatherCrawler.BasicCrawlController.java
public static void main(String[] args) { String folder = ConfigUtils.getFolder(); String crawlerCount = ConfigUtils.getCrawlerCount(); args = new String[2]; if (StringUtils.isBlank(folder) || StringUtils.isBlank(crawlerCount)) { args[0] = "weather"; args[1] = "10"; System.out.println("No parameters in config.properties ......."); System.out.println("[weather] will be used as rootFolder (it will contain intermediate crawl data)"); System.out.println("[10] will be used as numberOfCralwers (number of concurrent threads)"); } else {/* w ww.ja v a 2 s. c om*/ args[0] = folder; args[1] = crawlerCount; } /* * crawlStorageFolder is a folder where intermediate crawl data is * stored. */ String crawlStorageFolder = args[0]; /* * numberOfCrawlers shows the number of concurrent threads that should * be initiated for crawling. */ int numberOfCrawlers = Integer.parseInt(args[1]); CrawlConfig config = new CrawlConfig(); if (crawlStorageFolder != null && IO.deleteFolderContents(new File(crawlStorageFolder))) System.out.println(""); config.setCrawlStorageFolder(crawlStorageFolder + "/d" + System.currentTimeMillis()); /* * Be polite: Make sure that we don't send more than 1 request per * second (1000 milliseconds between requests). */ config.setPolitenessDelay(1000); config.setConnectionTimeout(1000 * 60); // config1.setPolitenessDelay(1000); /* * You can set the maximum crawl depth here. The default value is -1 for * unlimited depth */ config.setMaxDepthOfCrawling(StringUtils.isBlank(ConfigUtils.getCrawlerDepth()) ? 40 : Integer.valueOf(ConfigUtils.getCrawlerDepth())); // config1.setMaxDepthOfCrawling(0); /* * You can set the maximum number of pages to crawl. The default value * is -1 for unlimited number of pages */ config.setMaxPagesToFetch(100000); // config1.setMaxPagesToFetch(10000); /* * Do you need to set a proxy? If so, you can use: * config.setProxyHost("proxyserver.example.com"); * config.setProxyPort(8080); * * If your proxy also needs authentication: * config.setProxyUsername(username); config.getProxyPassword(password); */ if (ConfigUtils.getValue("useProxy", "false").equalsIgnoreCase("true")) { System.out.println("?============"); List<ProxySetting> proxys = ConfigUtils.getProxyList(); ProxySetting proxy = proxys.get(RandomUtils.nextInt(proxys.size() - 1)); /* test the proxy is alaviable or not */ while (!TestProxy.testProxyAvailable(proxy)) { proxy = proxys.get(RandomUtils.nextInt(proxys.size() - 1)); } System.out.println("??" + proxy.getIp() + ":" + proxy.getPort()); config.setProxyHost(proxy.getIp()); config.setProxyPort(proxy.getPort()); // config.setProxyHost("127.0.0.1"); // config.setProxyPort(8087); } else { System.out.println("??============"); } /* * This config parameter can be used to set your crawl to be resumable * (meaning that you can resume the crawl from a previously * interrupted/crashed crawl). Note: if you enable resuming feature and * want to start a fresh crawl, you need to delete the contents of * rootFolder manually. */ config.setResumableCrawling(false); // config1.setResumableCrawling(false); /* * Instantiate the controller for this crawl. */ PageFetcher pageFetcher = new PageFetcher(config); // PageFetcher pageFetcher1 = new PageFetcher(config1); RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); try { /* * For each crawl, you need to add some seed urls. These are the * first URLs that are fetched and then the crawler starts following * links which are found in these pages */ CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer); controller.addSeed(StringUtils.isBlank(ConfigUtils.getSeed()) ? "http://www.tianqi.com/chinacity.html" : ConfigUtils.getSeed()); // controller.addSeed("http://www.ics.uci.edu/~lopes/"); // controller.addSeed("http://www.ics.uci.edu/~welling/"); /* * Start the crawl. This is a blocking operation, meaning that your * code will reach the line after this only when crawling is * finished. */ String isDaily = null; isDaily = ConfigUtils.getValue("isDaily", "true"); System.out .println("?=======" + ConfigUtils.getValue("table", "weather_data") + "======="); if (isDaily.equalsIgnoreCase("true")) { System.out.println("???=============="); controller.start(BasicDailyCrawler.class, numberOfCrawlers); } else { System.out.println("???=============="); controller.start(BasicCrawler.class, numberOfCrawlers); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.hiperium.commons.client.soap.AuthenticationSOAPTest.java
/** * This class test the services using the generated JAXWS service client classes. * //from w w w . j a v a 2 s . co m * @param args */ public static void main(String[] args) { UserCredentialDTO credentialsDTO = new UserCredentialDTO("andres_solorzano85@hotmail.com", "andres123"); UserAuthenticationWSService authenticationWS = new UserAuthenticationWSService(); UserAuthenticationWSInterface authenticationSEI = authenticationWS.getUserAuthenticationWSPort(); try { String sessionId = authenticationSEI.userAuthentication(credentialsDTO); LOGGER.debug(sessionId); if (StringUtils.isBlank(sessionId)) { LOGGER.error("No session identifier was obtained from the Service."); } else { HomeSelectionWSService homeSelectionWS = new HomeSelectionWSService(); homeSelectionWS.setHandlerResolver(new ClientHandlerResolver(credentialsDTO.getEmail(), CLIENT_APPLICATION_TOKEN, AuthenticationObjectFactory._SelectHome_QNAME)); HomeSelectionWSInterface homeSelectionSEI = homeSelectionWS.getHomeSelectionWSPort(); CommonsUtil.mantainSessionProperty(homeSelectionSEI, sessionId); // Get the associated homes to the user in the actual session List<SelectionDTO> homeSelectionList = homeSelectionSEI.findHomeByUserId(); for (SelectionDTO dto : homeSelectionList) { LOGGER.debug("HOME: " + dto); } // Get the associated profiles to the home in the actual session List<SelectionDTO> profileSelectionList = homeSelectionSEI.findProfileByHomeId(1L); for (SelectionDTO dto : profileSelectionList) { LOGGER.debug("PROFILE: " + dto); } // Select a home and a profile associated to the user in that home HomeSelectionDTO homeSelectionDTO = new HomeSelectionDTO(1L, 1L); String response = homeSelectionSEI.selectHome(homeSelectionDTO); LOGGER.debug("HOME SELECTION: " + response); // Logout to the actual session. MenuWSService menuWS = new MenuWSService(); menuWS.setHandlerResolver(new ClientHandlerResolver(credentialsDTO.getEmail(), CLIENT_APPLICATION_TOKEN, GeneralObjectFactory._EndSession_QNAME)); MenuWSInterface menuSEI = menuWS.getMenuWSPort(); CommonsUtil.mantainSessionProperty(menuSEI, sessionId); response = menuSEI.endSession(); LOGGER.debug("MENU END SESSION: " + response); } } catch (InformationException_Exception e) { LOGGER.error(e.getMessage(), e); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } }
From source file:com.axiomine.largecollections.generator.GeneratorPrimitivePrimitive.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];/*from ww w . ja v a 2s . c om*/ //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions String KPACKAGE = args[2]; //Package of your value serializer class. Use com.axiomine.bigcollections.functions String VPACKAGE = args[3]; //Class name (no packages) of the Key class Ex. String String K = args[4]; //Class name (no packages) of the value class Ex. Integer String V = args[5]; String kCls = K; String vCls = V; if (kCls.equals("byte[]")) { kCls = "BytesArray"; } if (vCls.equals("byte[]")) { vCls = "BytesArray"; } String CLASS_NAME = kCls + vCls + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString( new File(root.getAbsolutePath() + "/src/main/resources/JavaLangBasedMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#K#", K); program = program.replaceAll("#V#", V); program = program.replaceAll("#KCLS#", kCls); program = program.replaceAll("#VCLS#", vCls); program = program.replaceAll("#KPACKAGE#", KPACKAGE); program = program.replaceAll("#VPACKAGE#", VPACKAGE); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.axiomine.largecollections.generator.GeneratorWritableKeyWritableValue.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];//from ww w . j av a 2 s.c om //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions String KPACKAGE = args[2]; //Package of your value serializer class. Use com.axiomine.bigcollections.functions String VPACKAGE = args[3]; //Class name (no packages) of the Key class Ex. String String K = args[4]; //Class name (no packages) of the value class Ex. Integer String V = args[5]; String kCls = K; String vCls = V; if (kCls.equals("byte[]")) { kCls = "BytesArray"; } if (vCls.equals("byte[]")) { vCls = "BytesArray"; } String CLASS_NAME = kCls + vCls + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString(new File( root.getAbsolutePath() + "/src/main/resources/WritableKeyWritableValueMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#K#", K); program = program.replaceAll("#V#", V); program = program.replaceAll("#KCLS#", kCls); program = program.replaceAll("#VCLS#", vCls); program = program.replaceAll("#KPACKAGE#", KPACKAGE); program = program.replaceAll("#VPACKAGE#", VPACKAGE); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.axiomine.largecollections.generator.GeneratorWritableKeyPrimitiveValue.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];// www.j a v a 2 s.c o m //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions String KPACKAGE = args[2]; //Package of your value serializer class. Use com.axiomine.bigcollections.functions String VPACKAGE = args[3]; //Class name (no packages) of the Key class Ex. String String K = args[4]; //Class name (no packages) of the value class Ex. Integer String V = args[5]; String kCls = K; String vCls = V; if (kCls.equals("byte[]")) { kCls = "BytesArray"; } if (vCls.equals("byte[]")) { vCls = "BytesArray"; } String CLASS_NAME = kCls + vCls + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString(new File( root.getAbsolutePath() + "/src/main/resources/WritableKeyPrimitiveValueMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#K#", K); program = program.replaceAll("#V#", V); program = program.replaceAll("#KCLS#", kCls); program = program.replaceAll("#VCLS#", vCls); program = program.replaceAll("#KPACKAGE#", KPACKAGE); program = program.replaceAll("#VPACKAGE#", VPACKAGE); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.axiomine.largecollections.generator.GeneratorKryoKPrimitiveValue.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];/*from w w w . j a va2 s . co m*/ //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions //Package of your value serializer class. Use com.axiomine.bigcollections.functions String VPACKAGE = args[2]; //Class name (no packages) of the Key class Ex. String //Class name (no packages) of the value class Ex. Integer String V = args[3]; //Specify if you are using a KryoTemplate to generate your classes //If true the template used to generate the class is KryoBasedMapTemplte, if false the JavaLangBasedMapTemplate is used //You can customize the name of the class generated String vCls = V; if (vCls.equals("byte[]")) { vCls = "BytesArray"; } String CLASS_NAME = "KryoK" + vCls + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString( new File(root.getAbsolutePath() + "/src/main/resources/KryoKeyPrimitiveValueMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#V#", V); program = program.replaceAll("#VPACKAGE#", VPACKAGE); program = program.replaceAll("#VCLS#", vCls); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveKeyKryoValue.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];/*from w w w . j av a2 s . c om*/ //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions //Package of your value serializer class. Use com.axiomine.bigcollections.functions String KPACKAGE = args[2]; //Class name (no packages) of the Key class Ex. String //Class name (no packages) of the value class Ex. Integer String K = args[3]; //Specify if you are using a KryoTemplate to generate your classes //If true the template used to generate the class is KryoBasedMapTemplte, if false the JavaLangBasedMapTemplate is used //You can customize the name of the class generated String kCls = K; if (kCls.equals("byte[]")) { kCls = "BytesArray"; } String CLASS_NAME = kCls + "KryoV" + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString( new File(root.getAbsolutePath() + "/src/main/resources/PrimitiveKeyKryoValueMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#K#", K); program = program.replaceAll("#KCLS#", kCls); program = program.replaceAll("#KPACKAGE#", KPACKAGE); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveKeyWritableValue.java
public static void main(String[] args) throws Exception { //Package of the new class you are generating Ex. com.mypackage String MY_PACKAGE = args[0];//from www . j a v a 2 s . c om //Any custom imports you need (: seperated). Use - if no custom imports are included //Ex. java.util.*:java.lang.Random String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1]; //Package of your Key serializer class. Use com.axiomine.bigcollections.functions String KPACKAGE = args[2]; //Package of your value serializer class. Use com.axiomine.bigcollections.functions String VPACKAGE = args[3]; //Class name (no packages) of the Key class Ex. String String K = args[4]; //Class name (no packages) of the value class Ex. Integer String V = args[5]; String vWritableCls = args[6]; String kCls = K; String vCls = V; if (kCls.equals("byte[]")) { kCls = "BytesArray"; } if (vCls.equals("byte[]")) { vCls = "BytesArray"; } String CLASS_NAME = kCls + vCls + "Map"; //Default //String templatePath = args[5]; File root = new File(""); File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/" + CLASS_NAME + ".java"); if (outFile.exists()) { System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again"); } { String[] imports = null; String importStr = ""; if (!StringUtils.isBlank(CUSTOM_IMPORTS)) { CUSTOM_IMPORTS.split(":"); for (String s : imports) { importStr = "import " + s + ";\n"; } } String program = FileUtils.readFileToString(new File( root.getAbsolutePath() + "/src/main/resources/PrimitiveKeyWritableValueMapTemplate.java")); program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE); program = program.replaceAll("#CUSTOM_IMPORTS#", importStr); program = program.replaceAll("#CLASS_NAME#", CLASS_NAME); program = program.replaceAll("#K#", K); program = program.replaceAll("#V#", V); program = program.replaceAll("#KCLS#", kCls); program = program.replaceAll("#VCLS#", vCls); program = program.replaceAll("#VWRITABLECLS#", vWritableCls); program = program.replaceAll("#KPACKAGE#", KPACKAGE); program = program.replaceAll("#VPACKAGE#", VPACKAGE); System.out.println(outFile.getAbsolutePath()); FileUtils.writeStringToFile(outFile, program); } }
From source file:com.sfs.jbtimporter.JBTImporter.java
/** * The main method.// w w w .j a va 2 s . co m * * @param args the arguments */ public static void main(final String[] args) { System.out.println(); System.out.println("--------------------------------"); System.out.println("| Jira BugTrack issue importer |"); System.out.println("--------------------------------"); System.out.println(); JBTProcessor jbt = null; try { jbt = processArguments(args); } catch (JBTException jbte) { System.out.println("ERROR: " + jbte.getMessage()); } if (jbt != null) { if (jbt.getRevert()) { // Revert the transformed issues revertTransformation(jbt); } else { if (StringUtils.isBlank(jbt.getXsltFileName())) { // Import the issues into Jira performImport(jbt); } else { // An XSLT transformation has been requested performTransformation(jbt); } } } else { // Print the usage System.out.println( "Usage (import): -u=username -p=password -h=jira_base_url " + "-d=bugtrack_export_directory"); System.out.println("Usage (transform): -x=xslt_filename " + "-d=bugtrack_export_directory"); System.out.println("Usage (revert): -d=bugtrack_export_directory -r"); } System.out.println(); }