List of usage examples for java.lang IllegalArgumentException IllegalArgumentException
public IllegalArgumentException(Throwable cause)
From source file:org.n52.iceland.statistics.api.utils.KibanaExporter.java
public static void main(String args[]) throws Exception { if (args.length != 2) { System.out.printf("Usage: java KibanaExporter.jar %s %s\n", "localhost:9300", "my-cluster-name"); System.exit(0);//from ww w . jav a 2s . c om } if (!args[0].contains(":")) { throw new IllegalArgumentException( String.format("%s not a valid format. Expected <hostname>:<port>.", args[0])); } // set ES address String split[] = args[0].split(":"); InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getByName(split[0]), Integer.parseInt(split[1], 10)); // set cluster name Builder tcSettings = Settings.settingsBuilder(); tcSettings.put("cluster.name", args[1]); System.out.println("Connection to " + args[1]); client = TransportClient.builder().settings(tcSettings).build(); client.addTransportAddress(address); // search index pattern for needle searchIndexPattern(); KibanaConfigHolderDto holder = new KibanaConfigHolderDto(); System.out.println("Reading .kibana index"); SearchResponse resp = client.prepareSearch(".kibana").setSize(1000).get(); Arrays.asList(resp.getHits().getHits()).stream().map(KibanaExporter::parseSearchHit).forEach(holder::add); System.out.println("Reading finished"); ObjectMapper mapper = new ObjectMapper(); // we love pretty things mapper.enable(SerializationFeature.INDENT_OUTPUT); File f = new File("kibana_config.json"); try (FileOutputStream out = new FileOutputStream(f, false)) { mapper.writeValue(out, holder); } System.out.println("File outputted to: " + f.getAbsolutePath()); client.close(); }
From source file:com.tacitknowledge.util.migration.jdbc.MigrationTableUnlock.java
/** * Get the migration level information for the given system name * * @param arguments the command line arguments, if any (none are used) * @throws Exception if anything goes wrong */// w w w . ja va 2 s. co m public static void main(String[] arguments) throws Exception { MigrationTableUnlock unlock = new MigrationTableUnlock(); String migrationName = System.getProperty("migration.systemname"); if (migrationName == null) { if ((arguments != null) && (arguments.length > 0)) { migrationName = arguments[0].trim(); } else { throw new IllegalArgumentException("The migration.systemname " + "system property is required"); } } unlock.tableUnlock(migrationName); }
From source file:com.jdom.word.playdough.model.gamepack.GamePackFileGenerator.java
/** * Usage: java GamePackFileGenerator <input file> <output directory> * //ww w . jav a 2s . c o m * @param args * @throws IOException */ public static void main(String[] args) throws IOException { File dictionaryFile = new File(args[0]); // Validate arguments first if (!dictionaryFile.isFile()) { throw new IllegalArgumentException("The specified file does not seem to be a valid file [" + dictionaryFile.getAbsolutePath() + "]!"); } File outputDir = new File(args[1]); if (!outputDir.isDirectory()) { throw new IllegalArgumentException("The specified directory does not seem to be a valid directory [" + outputDir.getAbsolutePath() + "]!"); } Set<String> words = GamePackFileGenerator.readWordsFromDictionaryFile(dictionaryFile); GamePackFileGenerator generator = new GamePackFileGenerator(words); List<Properties> properties = generator.generateGamePacks(20); for (int i = 0; i < properties.size(); i++) { Properties current = properties.get(i); File outputFile = new File(outputDir, i + ".properties"); PropertiesUtil.writePropertiesFile(current, outputFile); } }
From source file:com.jdom.mediadownloader.MediaDownloader.java
public static void main(String[] args) { if (args.length != 1) { throw new IllegalArgumentException( "You must pass the location to the properties file to the application!"); }/*from w w w . j av a 2 s . c om*/ File file = new File(args[0]); Properties properties = new Properties(); FileReader fileReader = null; try { fileReader = new FileReader(file); properties.load(fileReader); } catch (Exception e) { throw new RuntimeException(e); } finally { Closeables.closeQuietly(fileReader); } System.getProperties().putAll(properties); initializeContext(); MediaDownloader mediaDownloader = ctx.getBean(MediaDownloader.class); mediaDownloader.processDownloads(); }
From source file:com.tacitknowledge.util.migration.jdbc.DistributedMigrationTableUnlock.java
/** * Get the migration level information for the given system name * * @param arguments the command line arguments, if any (none are used) * @throws Exception if anything goes wrong *//*w ww .j a v a 2s . c om*/ public static void main(String[] arguments) throws Exception { DistributedMigrationTableUnlock unlock = new DistributedMigrationTableUnlock(); String migrationName = System.getProperty("migration.systemname"); if (migrationName == null) { if ((arguments != null) && (arguments.length > 0)) { migrationName = arguments[0].trim(); } else { throw new IllegalArgumentException("The migration.systemname " + "system property is required"); } } unlock.tableUnlock(migrationName); }
From source file:com.addthis.hydra.data.MakeBloom.java
public static void main(String[] args) throws java.io.IOException, com.addthis.maljson.JSONException { if (args.length != 1 && args.length != 2) { throw new IllegalArgumentException("usage: MakeBloom word-list-file [bloom-file]"); }//from ww w. j a v a2 s .co m File in = new File(args[0]); String[] words = getWords(in); BloomFilter bf = new BloomFilter(words.length, fp_rate); log.debug("Created: BloomFilter(" + bf.buckets() + " buckets, " + bf.getHashCount() + " hashes); FP rate = " + fp_rate); for (int i = 0; i < words.length; i++) { bf.add(words[i]); } log.debug("Added words"); File out = args.length == 2 ? new File(args[1]) : LessFiles.replaceSuffix(in, "-" + words.length + "-" + fpRate + ".bloom"); log.debug("Writing [" + out + "]"); LessFiles.write(out, org.apache.commons.codec.binary.Base64.encodeBase64(BloomFilter.serialize(bf)), false); log.debug("Wrote " + out.length() + " bytes to [" + out + "]"); }
From source file:ee.ria.xroad.common.conf.globalconfextension.OcspNextUpdateSchemaValidator.java
/** * Program entry point/*from www . ja v a 2 s.c o m*/ */ public static void main(String[] args) throws Exception { if (args.length != 1) { throw new IllegalArgumentException( "Please supply one argument, file name of the validated ocsp next update parameters xml."); } new OcspNextUpdateSchemaValidator().validateFile(args[0]); }
From source file:ee.ria.xroad.common.conf.globalconfextension.OcspFetchIntervalSchemaValidator.java
/** * Program entry point/*www. ja va 2s. co m*/ */ public static void main(String[] args) throws Exception { if (args.length != 1) { throw new IllegalArgumentException( "Please supply one argument, file name of the validated ocsp fetch interval parameters xml."); } new OcspFetchIntervalSchemaValidator().validateFile(args[0]); }
From source file:ee.ria.xroad.common.conf.monitoringconf.MonitoringParametersSchemaValidator.java
/** * Program entry point/*from ww w. j a v a 2 s. com*/ */ public static void main(String[] args) throws Exception { if (args.length != 1) { throw new IllegalArgumentException( "Please supply one argument, file name of the validated monitoring parameters xml."); } new MonitoringParametersSchemaValidator().validateFile(args[0]); }
From source file:org.syncope.hibernate.HibernateEnhancer.java
public static void main(final String[] args) throws Exception { if (args.length != 1) { throw new IllegalArgumentException("Expecting classpath as single argument"); }//w ww.j a v a2 s .com ClassPool classPool = ClassPool.getDefault(); classPool.appendClassPath(args[0]); PathMatchingResourcePatternResolver resResolver = new PathMatchingResourcePatternResolver( classPool.getClassLoader()); CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory(); for (Resource resource : resResolver.getResources("classpath*:org/syncope/core/**/*.class")) { MetadataReader metadataReader = cachingMetadataReaderFactory.getMetadataReader(resource); if (metadataReader.getAnnotationMetadata().isAnnotated(Entity.class.getName())) { Class entity = Class.forName(metadataReader.getClassMetadata().getClassName()); classPool.appendClassPath(new ClassClassPath(entity)); CtClass ctClass = ClassPool.getDefault().get(entity.getName()); if (ctClass.isFrozen()) { ctClass.defrost(); } ClassFile classFile = ctClass.getClassFile(); ConstPool constPool = classFile.getConstPool(); for (Field field : entity.getDeclaredFields()) { if (field.isAnnotationPresent(Lob.class)) { AnnotationsAttribute typeAttr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); Annotation typeAnnot = new Annotation("org.hibernate.annotations.Type", constPool); typeAnnot.addMemberValue("type", new StringMemberValue("org.hibernate.type.StringClobType", constPool)); typeAttr.addAnnotation(typeAnnot); CtField lobField = ctClass.getDeclaredField(field.getName()); lobField.getFieldInfo().addAttribute(typeAttr); } } ctClass.writeFile(args[0]); } } }