List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.chargebee.CSV.PhoneBook.PhoneBook2.PhoneBook.java
public static void main(String[] args) throws IOException, Exception { String source = System.getProperty("user.home") + "/input2.csv"; PhoneBook pb = new PhoneBook(); CSVParser parser = new CSVParser(new FileReader(source), CSVFormat.EXCEL.withHeader()); pb.directory(parser);/*from w w w .j a va 2 s . co m*/ parser.close(); }
From source file:com.googlecode.dex2jar.v3.Main.java
public static void main(String... args) { System.err.println("this cmd is deprecated, use the d2j-dex2jar if possible"); System.out.println("dex2jar version: translator-" + Main.class.getPackage().getImplementationVersion()); if (args.length == 0) { System.err.println("dex2jar file1.dexORapk file2.dexORapk ..."); return;//from w ww . j ava2 s. c o m } String jreVersion = System.getProperty("java.specification.version"); if (jreVersion.compareTo("1.6") < 0) { System.err.println("A JRE version >=1.6 is required"); return; } boolean containsError = false; for (String file : args) { File dex = new File(file); final File gen = new File(dex.getParentFile(), FilenameUtils.getBaseName(file) + "_dex2jar.jar"); System.out.println("dex2jar " + dex + " -> " + gen); try { doFile(dex, gen); } catch (Exception e) { containsError = true; niceExceptionMessage(new DexException(e, "while process file: [%s]", dex), 0); } } System.out.println("Done."); System.exit(containsError ? -1 : 0); }
From source file:com.hygenics.parser.MainApp.java
/** * The entire programs main method.// w w w. j ava2s .c o m * * @param args */ public static void main(String[] args) { final Logger log = LoggerFactory.getLogger(MainApp.class); log.info("Starting Parse @ " + Calendar.getInstance().getTime().toString()); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( ("file:" + System.getProperty("beansfile").trim())); log.info("Found beans @ " + System.getProperty("beansfile").trim()); log.info("Starting"); ArrayList<String> results = null; String activity = null; log.info("Obtaining Activities"); ActivitiesStack stack = (ActivitiesStack) context.getBean("ActivitiesStack"); // integers keeping track of bean number to pull (e.g. DumpToText0 or // DumpToText1) // in keeping with the spirit of dumping out data int n = 0, srn = 0, mv = 0, cen = 0, pps = 0, sb = 0, kv = 0, cf = 0, zip = 0, bm = 0, dump = 0, kettle = 0, execute = 0, transfer = 0, sqls = 0, job = 0, parsepages = 0, getpages = 0, map = 0, js = 0, sdump = 0, transforms = 0, execs = 0, gim = 0, ems = 0, jd = 0; Pattern p = Pattern.compile("[A-Za-z]+[0-9]+"); Matcher m; // start stack init log.info("Stack Initialized with Size of " + stack.getSize() + " @ " + Calendar.getInstance().getTime().toString()); while (stack.getSize() > 0) { // pop activity form stack activity = stack.Pop(); log.info("Activities Remaining " + stack.getSize()); m = p.matcher(activity); log.info("\n\nACTIVITY: " + activity + "\n\n"); if (activity.toLowerCase().contains("manualrepconn")) { log.info("Manual Transformation Started @ " + Calendar.getInstance().getTime().toString()); ManualReplacement mrp = (ManualReplacement) context.getBean("ManualRepConn"); mrp.run(); log.info("Manual Transformation Finished @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("cleanfolder")) { log.info("Folder Cleanup Started @ " + Calendar.getInstance().getTime().toString()); CleanFolder c; if (cf == 0 || context.containsBean("CleanFolder")) { c = (CleanFolder) ((context.containsBean("CleanFolder")) ? context.getBean("CleanFolder") : context.getBean("CleanFolder" + cf)); } else { c = (CleanFolder) context.getBean("CleanFolder" + cf); } c.run(); cf++; log.info("File Cleanup Complete @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("zip")) { log.info("Zip File Creation Started @ " + Calendar.getInstance().getTime().toString()); Archiver a; if (zip == 0 || context.containsBean("Zip")) { a = (Archiver) ((context.containsBean("Zip")) ? context.getBean("Zip") : context.getBean("Zip" + zip)); } else { a = (Archiver) context.getBean("Zip" + zip); } a.run(); zip++; log.info("Zip File Creation Complete @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("transfer")) { log.info("File Transfer Started @ " + Calendar.getInstance().getTime().toString()); Upload u; if (transfer == 0 || context.containsBean("FileTransfer")) { u = (Upload) ((context.containsBean("FileTransfer")) ? context.getBean("FileTransfer") : context.getBean("FileTransfer" + transfer)); } else { u = (Upload) context.getBean("FileTransfer" + transfer); } u.run(); transfer++; log.info("File Transfer Complete @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("droptables")) { // drop tables log.info("Dropping Tables @ " + Calendar.getInstance().getTime().toString()); DropTables droptables = (DropTables) context.getBean("DropTables"); droptables.run(); droptables = null; log.info("Done Dropping Tables @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().equals("createtables")) { // create tables log.info("Creating Tables @ " + Calendar.getInstance().getTime().toString()); CreateTable create = (CreateTable) context.getBean("CreateTables"); create.run(); create = null; log.info("Done Creating Tables @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("createtableswithreference")) { // create tables log.info("Creating Tables @ " + Calendar.getInstance().getTime().toString()); CreateTablesWithReference create = (CreateTablesWithReference) context .getBean("CreateTablesWithReference"); create.run(); create = null; log.info("Done Creating Tables @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("truncate")) { // truncate table log.info("Truncating @ " + Calendar.getInstance().getTime().toString()); Truncate truncate = (Truncate) context.getBean("Truncate"); truncate.truncate(); truncate = null; log.info("Truncated @ " + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().equals("enforce")) { // enforce schema log.info("Enforcing Schema @" + Calendar.getInstance().getTime().toString()); ForceConformity ef = (ForceConformity) context.getBean("EnforceStandards"); ef.run(); log.info("Done Enforcing Schema @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().contains("enforcewithreference")) { // enforce schema ForceConformityWithReference ef = (ForceConformityWithReference) context .getBean("EnforceStandardsWithReference"); log.info("Enforcing Schema By Reference @" + Calendar.getInstance().getTime().toString()); ef.run(); log.info("Done Enforcing Schema @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().trim().equals("repconn")) { log.info("Replacing Transformation Connection Information @" + Calendar.getInstance().getTime().toString()); RepConn rep = (RepConn) context.getBean("repconn"); rep.run(); log.info("Finished Replacing Connection Information @" + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("job")) { // run a Pentaho job as opposed to a Pentaho Transformation log.info("Run Job kjb file @" + Calendar.getInstance().getTime().toString()); RunJob kjb = null; if (m.find()) { kjb = (RunJob) context.getBean(activity); } else { kjb = (RunJob) context.getBean("Job" + job); } kjb.run(); kjb = null; log.info("Pentaho Job Complete @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); } else if (activity.toLowerCase().compareTo("execute") == 0) { // Execute a process log.info("Executing Process @" + Calendar.getInstance().getTime().toString()); if (context.containsBean("Execute") && execs == 0) { ExecuteProcess proc = (ExecuteProcess) context.getBean(("Execute")); proc.Execute(); } else { ExecuteProcess proc = (ExecuteProcess) context.getBean(("Execute" + execute)); proc.Execute(); } execs++; log.info("Pages Obtained @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().contains("parsepageswithscala") || activity.toLowerCase().contains("parsepagesscala")) { //parse pages with scala log.info("Parsing Pages with Scala @ " + Calendar.getInstance().getTime().toString()); ScalaParseDispatcher pds = null; if (context.containsBean("ParsePagesScala" + pps)) { pds = (ScalaParseDispatcher) context.getBean("ParsePagesScala" + pps); } else if (context.containsBean("ParsePagesScala") && pps > 0) { pds = (ScalaParseDispatcher) context.getBean("ParsePagesScala"); } pps++; pds.run(); Runtime.getRuntime().gc(); log.info("Finished Parsing Pages with Scala @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("parsepages")) { // Parse Pages with java log.info("Parsing Individual Pages @" + Calendar.getInstance().getTime().toString()); if (context.containsBean("ParsePages") && parsepages == 0) { ParseDispatcher pd = (ParseDispatcher) context.getBean("ParsePages"); pd.run(); pd = null; } else { ParseDispatcher pd = (ParseDispatcher) context.getBean("ParsePages" + parsepages); pd.run(); pd = null; } parsepages++; log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().contains("kvparser")) { // Parse Pages using the KV Parser log.info("Parsing Individual Pages with Key Value Pairs @" + Calendar.getInstance().getTime().toString()); if (context.containsBean("KVParser") && parsepages == 0) { KVParser pd = (KVParser) context.getBean("KVParser"); pd.run(); pd = null; } else { KVParser pd = (KVParser) context.getBean("KVParser" + kv); pd.run(); pd = null; } parsepages++; log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().contains("parsewithsoup")) { // Parse Pages with Jsoup log.info("Parsing Pages with JSoup @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("ParseJSoup") && js == 0) { ParseJSoup psj = (ParseJSoup) context.getBean("ParseJSoup"); psj.run(); } else { ParseJSoup psj = (ParseJSoup) context.getBean("ParseJSoup" + Integer.toString(js)); psj.run(); } js++; log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); log.info("Finished Parsing with JSoup @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("breakmultiplescala") || activity.toLowerCase().contains("breakmultiplewithscala")) { log.info("Breaking Records"); BreakMultipleScala bms = null; if (context.containsBean("BreakMultipleScala" + ems)) { bms = (BreakMultipleScala) context.getBean("BreakMultipleScala" + sb); } else { bms = (BreakMultipleScala) context.getBean("BreakMultipleScala"); } bms.run(); bms = null; sb++; Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); log.info("Completed Breaking Tasks"); } else if (activity.toLowerCase().contains("breakmultiple")) { // break apart multi-part records log.info("Breaking apart Records (BreakMultiple) @" + Calendar.getInstance().getTime().toString()); if (context.containsBean("BreakMultiple") && bm == 0) { BreakMultiple br = (BreakMultiple) context.getBean(("BreakMultiple")); br.run(); br = null; } else { BreakMultiple br = (BreakMultiple) context.getBean(("BreakMultiple" + Integer.toString(bm))); br.run(); br = null; } bm++; log.info("Finished Breaking Apart Records @" + Calendar.getInstance().getTime().toString()); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().compareTo("mapper") == 0) { // remap data log.info("Mapping Records @" + Calendar.getInstance().getTime().toString()); if (context.containsBean("Mapper") && map == 0) { Mapper mp = (Mapper) context.getBean("Mapper"); mp.run(); mp = null; } else { Mapper mp = (Mapper) context.getBean("Mapper" + Integer.toString(map)); mp.run(); mp = null; } map++; log.info("Completed Mapping Records @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("getimages")) { // Get Images in a Separate Step log.info("Beggining Image Pull @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("getImages") && gim == 0) { GetImages gi = (GetImages) context.getBean("getImages"); gi.run(); log.info("Image Pull Complete @ " + Calendar.getInstance().getTime().toString()); gi = null; } else { GetImages gi = (GetImages) context.getBean("getImages"); gi.run(); log.info("Image Pull Complete @ " + Calendar.getInstance().getTime().toString()); gi = null; } gim++; Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().compareTo("sql") == 0) { // execute a sql command log.info("Executing SQL Query @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("SQL") && sqls == 0) { ExecuteSQL sql; if (m.find()) { sql = (ExecuteSQL) context.getBean(activity); } else { sql = (ExecuteSQL) context.getBean("SQL"); } sql.execute(); sql = null; } else { ExecuteSQL sql; if (m.find()) { sql = (ExecuteSQL) context.getBean(activity); } else { sql = (ExecuteSQL) context.getBean("SQL" + sqls); } sql.execute(); sql = null; } sqls++; log.info("Finished SQL Query @ " + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().compareTo("kettle") == 0) { // run one or more kettle transformation(s) log.info("Beginning Kettle Transformation @ " + Calendar.getInstance().getTime().toString()); RunTransformation rt = null; if (context.containsBean("kettle") && transforms == 0) { if (m.find()) { rt = (RunTransformation) context.getBean(activity); } else { rt = (RunTransformation) context.getBean(("kettle")); } rt.run(); rt = null; } else { if (m.find()) { rt = (RunTransformation) context.getBean(activity); } else { rt = (RunTransformation) context.getBean(("kettle" + kettle)); } rt.run(); rt = null; } transforms++; log.info("Ending Kettle Transformation @ " + Calendar.getInstance().getTime().toString()); Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); kettle++; } else if (activity.toLowerCase().contains("dumptotext")) { // dump to a text file via java log.info("Dumping to Text @ " + Calendar.getInstance().getTime().toString()); DumptoText dtt = null; if (m.find()) { dtt = (DumptoText) context.getBean(activity); } else { dtt = (DumptoText) context.getBean("DumpToText" + dump); } dtt.run(); dump++; log.info("Completed Dump @ " + Calendar.getInstance().getTime().toString()); dtt = null; Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().equals("jdump")) { log.info("Dumping via JDump @ " + Calendar.getInstance().getTime().toString()); if (jd == 0 && context.containsBean("JDump")) { JDump j = (JDump) context.getBean("JDump"); jd++; j.run(); } else { JDump j = (JDump) context.getBean("JDump" + jd); jd++; j.run(); } Runtime.getRuntime().gc(); System.gc(); log.info("Finished Dumping via JDump @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("jdumpwithreference")) { log.info("Dumping via JDump @ " + Calendar.getInstance().getTime().toString()); if (jd == 0 && context.containsBean("JDumpWithReference")) { JDumpWithReference j = (JDumpWithReference) context.getBean("JDumpWithReference"); jd++; j.run(); } else { JDumpWithReference j = (JDumpWithReference) context.getBean("JDumpWithReference" + jd); jd++; j.run(); } Runtime.getRuntime().gc(); System.gc(); log.info("Finished Dumping via JDump @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().compareTo("commanddump") == 0) { // dump to text using a client side sql COPY TO command log.info("Dumping via SQL @ " + Calendar.getInstance().getTime().toString()); CommandDump d = (CommandDump) context.getBean("dump"); d.run(); d = null; log.info("Completed Dump @ " + Calendar.getInstance().getTime().toString()); // most likely not needed by satisfies my paranoia Runtime.getRuntime().gc(); System.gc(); } else if (activity.toLowerCase().equals("specdump")) { // Specified Dump log.info("Dumping via Specified Tables, Files, and Attributes @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("SpecDump") && sdump == 0) { sdump++; SpecifiedDump sd = (SpecifiedDump) context.getBean("SpecDump"); sd.run(); sd = null; } else if (context.containsBean("SpecDump" + Integer.toString(sdump))) { SpecifiedDump sd = (SpecifiedDump) context.getBean("SpecDump" + Integer.toString(sdump)); sd.run(); sd = null; } sdump++; log.info("Completed Dumping via Specified Tables, Files, and Attributes @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("specdumpwithreference")) { // Specified Dump log.info("Dumping via Specified Tables, Files, and Attributes by Reference @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("SpecDumpWithReference") && sdump == 0) { sdump++; SpecDumpWithReference sd = (SpecDumpWithReference) context.getBean("SpecDumpWithReference"); sd.run(); sd = null; } else if (context.containsBean("SpecDumpWithReference" + Integer.toString(sdump))) { SpecDumpWithReference sd = (SpecDumpWithReference) context .getBean("SpecDumpWithReference" + Integer.toString(sdump)); sd.run(); sd = null; } else { log.info("Bean Not Found For " + activity); } sdump++; log.info("Completed Dumping via Specified Tables, Files, and Attributes @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().compareTo("email") == 0) { // email completion notice log.info("Sending Notice of Completion @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("Email") && ems == 0) { Send s = (Send) context.getBean("Email"); s.run(); s = null; } else { Send s = (Send) context.getBean("Email" + Integer.toString(ems)); s.run(); s = null; } ems++; Runtime.getRuntime().gc(); System.gc(); log.info("Completed Email @ " + Calendar.getInstance().getTime().toString()); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().equals("qa")) { // perform qa log.info("Performing Quality Assurance @ " + Calendar.getInstance().getTime().toString()); if (context.containsBean("QA")) { QualityAssurer qa = (QualityAssurer) context.getBean("QA"); qa.run(); qa = null; } // attempt to hint --> all tasks are really intense so anything // is nice Runtime.getRuntime().gc(); System.gc(); log.info("Completed QA @ " + Calendar.getInstance().getTime().toString()); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); } else if (activity.toLowerCase().equals("notify")) { log.info("Running Notification Tasks"); Notification nt = null; if (context.containsBean("Notify" + Integer.toString(n))) { nt = (Notification) context.getBean("Notify" + Integer.toString(n)); } else { nt = (Notification) context.getBean("Notify"); } nt.run(); nt = null; n++; if (context.containsBean("Email") && ems == 0) { Send s = (Send) context.getBean("Email"); s.run(); s = null; } else if (context.containsBean("Email" + ems)) { Send s = (Send) context.getBean("Email" + Integer.toString(ems)); s.run(); s = null; } ems++; Runtime.getRuntime().gc(); System.gc(); log.info("Free Memory: " + Runtime.getRuntime().freeMemory()); log.info("Completed Notification Tasks"); } else if (activity.toLowerCase().contains("move")) { log.info("Moving Files @ " + Calendar.getInstance().getTime().toString()); MoveFile mf = null; if (context.containsBean("Move" + Integer.toString(mv))) { mf = (MoveFile) context.getBean("Move" + Integer.toString(mv)); } else { mf = (MoveFile) context.getBean("Move"); } mf.run(); mv++; Runtime.getRuntime().gc(); log.info("Finished Moving Files @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("numericalcheck")) { log.info("Checking Counts"); NumericalChecker nc = (NumericalChecker) context.getBean("NumericalChecker"); nc.run(); Runtime.getRuntime().gc(); log.info("Finished Checking Counts @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("runscript")) { log.info("Running Script @ " + Calendar.getInstance().getTime().toString()); RunScript runner = null; if (context.containsBean("RunScript" + srn)) { runner = (RunScript) context.getBean("RunScript" + srn); } else { runner = (RunScript) context.getBean("RunScript"); } runner.run(); srn++; Runtime.getRuntime().gc(); log.info("Finished Running SCript @ " + Calendar.getInstance().getTime().toString()); } else if (activity.toLowerCase().contains("checkexistance")) { log.info("Checking Existance @ " + Calendar.getInstance().getTime().toString()); ExistanceChecker runner = null; if (context.containsBean("CheckExistance" + srn)) { runner = (ExistanceChecker) context.getBean("CheckExistance" + cen); } else { runner = (ExistanceChecker) context.getBean("CheckExistance"); } runner.run(); cen++; Runtime.getRuntime().gc(); log.info("Finished Checking Existance @ " + Calendar.getInstance().getTime().toString()); } else { log.info("Activity " + activity + " does not exist!"); } } log.info("Completed Parse @ " + Calendar.getInstance().getTime().toString()); context.destroy(); context.close(); }
From source file:accinapdf.ACCinaPDF.java
/** * @param args the command line arguments *//* w ww .ja v a 2 s. co m*/ public static void main(String[] args) { controller.Logger.create(); controller.Bundle.getBundle(); if (GraphicsEnvironment.isHeadless()) { // Headless // Erro String fich; if (args.length != 1) { System.err.println(Bundle.getBundle().getString("invalidArgs")); return; } else { fich = args[0]; } try { System.out.println(Bundle.getBundle().getString("validating") + " " + fich); ArrayList<SignatureValidation> alSv = CCInstance.getInstance().validatePDF(fich, null); if (alSv.isEmpty()) { System.out.println(Bundle.getBundle().getString("notSigned")); } else { String newLine = System.getProperty("line.separator"); String toWrite = "("; int numSigs = alSv.size(); if (numSigs == 1) { toWrite += "1 " + Bundle.getBundle().getString("signature"); } else { toWrite += numSigs + " " + Bundle.getBundle().getString("signatures"); } toWrite += ")" + newLine; for (SignatureValidation sv : alSv) { toWrite += "\t" + sv.getName() + " - "; toWrite += (sv.isCertification() ? WordUtils.capitalize(Bundle.getBundle().getString("certificate")) : WordUtils.capitalize(Bundle.getBundle().getString("signed"))) + " " + Bundle.getBundle().getString("by") + " " + sv.getSignerName(); toWrite += newLine + "\t\t"; if (sv.isChanged()) { toWrite += Bundle.getBundle().getString("certifiedChangedOrCorrupted"); } else { if (sv.isCertification()) { if (sv.isValid()) { if (sv.isChanged() || !sv.isCoversEntireDocument()) { toWrite += Bundle.getBundle().getString("certifiedButChanged"); } else { toWrite += Bundle.getBundle().getString("certifiedOk"); } } else { toWrite += Bundle.getBundle().getString("changedAfterCertified"); } } else { if (sv.isValid()) { if (sv.isChanged()) { toWrite += Bundle.getBundle().getString("signedButChanged"); } else { toWrite += Bundle.getBundle().getString("signedOk"); } } else { toWrite += Bundle.getBundle().getString("signedChangedOrCorrupted"); } } } toWrite += newLine + "\t\t"; if (sv.getOcspCertificateStatus().equals(CertificateStatus.OK) || sv.getCrlCertificateStatus().equals(CertificateStatus.OK)) { toWrite += Bundle.getBundle().getString("certOK"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.REVOKED) || sv.getCrlCertificateStatus().equals(CertificateStatus.REVOKED)) { toWrite += Bundle.getBundle().getString("certRevoked"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHECKED) && sv.getCrlCertificateStatus().equals(CertificateStatus.UNCHECKED)) { toWrite += Bundle.getBundle().getString("certNotVerified"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHAINED)) { toWrite += Bundle.getBundle().getString("certNotChained"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.EXPIRED)) { toWrite += Bundle.getBundle().getString("certExpired"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.CHAINED_LOCALLY)) { toWrite += Bundle.getBundle().getString("certChainedLocally"); } toWrite += newLine + "\t\t"; if (sv.isValidTimeStamp()) { toWrite += Bundle.getBundle().getString("validTimestamp"); } else { toWrite += Bundle.getBundle().getString("signerDateTime"); } toWrite += newLine + "\t\t"; toWrite += WordUtils.capitalize(Bundle.getBundle().getString("revision")) + ": " + sv.getRevision() + " " + Bundle.getBundle().getString("of") + " " + sv.getNumRevisions(); toWrite += newLine + "\t\t"; final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); final SimpleDateFormat sdf = new SimpleDateFormat("Z"); if (sv.getSignature().getTimeStampToken() == null) { Calendar cal = sv.getSignature().getSignDate(); String date = sdf.format(cal.getTime().toLocaleString()); toWrite += date + " " + sdf.format(cal.getTime()) + " (" + Bundle.getBundle().getString("signerDateTimeSmall") + ")"; } else { Calendar ts = sv.getSignature().getTimeStampDate(); String date = df.format(ts.getTime()); toWrite += Bundle.getBundle().getString("date") + " " + date + " " + sdf.format(ts.getTime()); } toWrite += newLine + "\t\t"; boolean ltv = (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK); toWrite += Bundle.getBundle().getString("isLtv") + ": " + (ltv ? Bundle.getBundle().getString("yes") : Bundle.getBundle().getString("no")); String reason = sv.getSignature().getReason(); toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("reason") + ": "; if (reason == null) { toWrite += Bundle.getBundle().getString("notDefined"); } else if (reason.isEmpty()) { toWrite += Bundle.getBundle().getString("notDefined"); } else { toWrite += reason; } String location = sv.getSignature().getLocation(); toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("location") + ": "; if (location == null) { toWrite += Bundle.getBundle().getString("notDefined"); } else if (location.isEmpty()) { toWrite += Bundle.getBundle().getString("notDefined"); } else { toWrite += location; } toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("allowsChanges") + ": "; try { int certLevel = CCInstance.getInstance().getCertificationLevel(sv.getFilename()); if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING) { toWrite += Bundle.getBundle().getString("onlyAnnotations"); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS) { toWrite += Bundle.getBundle().getString("annotationsFormFilling"); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) { toWrite += Bundle.getBundle().getString("no"); } else { toWrite += Bundle.getBundle().getString("yes"); } } catch (IOException ex) { controller.Logger.getLogger().addEntry(ex); } toWrite += newLine + "\t\t"; if (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK) { toWrite += (Bundle.getBundle().getString("validationCheck1") + " " + (sv.getOcspCertificateStatus() == CertificateStatus.OK ? Bundle.getBundle().getString("validationCheck2") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getOcsp().getCerts()[0].getSubject(), "CN") + " " + Bundle.getBundle().getString("at") + " " + df.format(sv.getSignature().getOcsp().getProducedAt()) : (sv.getCrlCertificateStatus() == CertificateStatus.OK ? "CRL" : "")) + (sv.getSignature().getTimeStampToken() != null ? Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance() .getCertificateProperty(sv.getSignature() .getTimeStampToken().getSID().getIssuer(), "O") : "")); } else if (sv.getSignature().getTimeStampToken() != null) { toWrite += (Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O")); } toWrite += newLine; } System.out.println(toWrite); System.out.println(Bundle.getBundle().getString("validationFinished")); } } catch (IOException | DocumentException | GeneralSecurityException ex) { System.err.println(Bundle.getBundle().getString("validationError")); Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } } else { // GUI CCSignatureSettings defaultSettings = new CCSignatureSettings(false); if (SystemUtils.IS_OS_WINDOWS) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } break; } } } else if (SystemUtils.IS_OS_LINUX) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } break; } } } else if (SystemUtils.IS_OS_MAC_OSX) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } } new SplashScreen().setVisible(true); } }
From source file:at.gv.egiz.pdfas.cli.test.SignaturProfileTest.java
public static void main(String[] args) { String user_home = System.getProperty("user.home"); String pdfas_dir = user_home + File.separator + ".pdfas"; PdfAs pdfas = PdfAsFactory.createPdfAs(new File(pdfas_dir)); try {//from w ww . j av a 2 s . c om Configuration config = pdfas.getConfiguration(); ISettings settings = (ISettings) config; List<String> signatureProfiles = new ArrayList<String>(); List<String> signaturePDFAProfiles = new ArrayList<String>(); Iterator<String> itKeys = settings.getFirstLevelKeys("sig_obj.types.").iterator(); while (itKeys.hasNext()) { String key = itKeys.next(); String profile = key.substring("sig_obj.types.".length()); System.out.println("[" + profile + "]: " + settings.getValue(key)); if (settings.getValue(key).equals("on")) { signatureProfiles.add(profile); if (profile.contains("PDFA")) { signaturePDFAProfiles.add(profile); } } } byte[] input = IOUtils.toByteArray(new FileInputStream(sourcePDF)); IPlainSigner signer = new PAdESSignerKeystore(KS_FILE, KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE); Iterator<String> itProfiles = signatureProfiles.iterator(); while (itProfiles.hasNext()) { String profile = itProfiles.next(); System.out.println("Testing " + profile); DataSource source = new ByteArrayDataSource(input); FileOutputStream fos = new FileOutputStream(targetFolder + profile + ".pdf"); SignParameter signParameter = PdfAsFactory.createSignParameter(config, source, fos); signParameter.setPlainSigner(signer); signParameter.setSignatureProfileId(profile); SignResult result = pdfas.sign(signParameter); fos.close(); } byte[] inputPDFA = IOUtils.toByteArray(new FileInputStream(sourcePDFA)); Iterator<String> itPDFAProfiles = signaturePDFAProfiles.iterator(); while (itPDFAProfiles.hasNext()) { String profile = itPDFAProfiles.next(); System.out.println("Testing " + profile); DataSource source = new ByteArrayDataSource(inputPDFA); FileOutputStream fos = new FileOutputStream(targetFolder + "PDFA_" + profile + ".pdf"); SignParameter signParameter = PdfAsFactory.createSignParameter(config, source, fos); signParameter.setPlainSigner(signer); signParameter.setSignatureProfileId(profile); SignResult result = pdfas.sign(signParameter); fos.close(); } } catch (Throwable e) { e.printStackTrace(); } }
From source file:org.eclipse.swt.snippets.Snippet283.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, Snippet283.class.getResourceAsStream("eclipse.png")); Shell shell = new Shell(display); shell.setText("Snippet 283"); shell.setLayout(new FillLayout()); final Table table = new Table(shell, SWT.FULL_SELECTION); for (int i = 0; i < 8; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i + " with long text that scrolls."); if (i % 2 == 1) item.setImage(image);/*from w ww. j a va2 s . co m*/ } table.addListener(SWT.MouseDown, event -> { Rectangle rect = table.getClientArea(); Point point = new Point(event.x, event.y); if (table.getItem(point) != null) return; for (int i = table.getTopIndex(); i < table.getItemCount(); i++) { TableItem item = table.getItem(i); Rectangle itemRect = item.getBounds(); if (!itemRect.intersects(rect)) return; itemRect.x = rect.x; itemRect.width = rect.width; if (itemRect.contains(point)) { table.setSelection(item); Event selectionEvent = new Event(); selectionEvent.item = item; table.notifyListeners(SWT.Selection, selectionEvent); return; } } }); /* * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly. * Therefore, it is critical for performance that these methods be * as efficient as possible. */ table.addListener(SWT.EraseItem, event -> { event.detail &= ~SWT.FOREGROUND; String osName = System.getProperty("os.name"); if (osName != null && osName.contains("Windows")) { if (osName.contains("Vista") || osName.contains("unknown")) { return; } } event.detail &= ~(SWT.FOREGROUND | SWT.SELECTED | SWT.HOT | SWT.FOCUSED); GC gc = event.gc; TableItem item = (TableItem) event.item; Rectangle rect = table.getClientArea(); Rectangle itemRect = item.getBounds(); itemRect.x = rect.x; itemRect.width = rect.width; gc.setClipping((Rectangle) null); gc.fillRectangle(itemRect); }); table.addListener(SWT.PaintItem, event -> { TableItem item = (TableItem) event.item; GC gc = event.gc; Image image1 = item.getImage(0); String text = item.getText(0); Point textExtent = gc.stringExtent(text); Rectangle imageRect = item.getImageBounds(0); Rectangle textRect = item.getTextBounds(0); int textY = textRect.y + Math.max(0, (textRect.height - textExtent.y) / 2); if (image1 == null) { gc.drawString(text, imageRect.x, textY, true); } else { Rectangle imageExtent = image1.getBounds(); int imageY = imageRect.y + Math.max(0, (imageRect.height - imageExtent.height) / 2); gc.drawImage(image1, imageRect.x, imageY); gc.drawString(text, textRect.x, textY, true); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:edu.uci.ics.asterix.transaction.management.service.locking.LockManagerRandomUnitTest.java
public static void main(String args[]) throws ACIDException, AsterixException, IOException { int i;/* w w w. j a v a2 s.c o m*/ //prepare configuration file File cwd = new File(System.getProperty("user.dir")); File asterixdbDir = cwd.getParentFile(); File srcFile = new File(asterixdbDir.getAbsoluteFile(), "asterix-app/src/main/resources/asterix-build-configuration.xml"); File destFile = new File(cwd, "target/classes/asterix-configuration.xml"); FileUtils.copyFile(srcFile, destFile); TransactionSubsystem txnProvider = new TransactionSubsystem("nc1", null, new AsterixTransactionProperties(new AsterixPropertiesAccessor())); rand = new Random(System.currentTimeMillis()); for (i = 0; i < MAX_NUM_OF_ENTITY_LOCK_JOB; i++) { System.out.println("Creating " + i + "th EntityLockJob.."); generateEntityLockThread(txnProvider); } for (i = 0; i < MAX_NUM_OF_DATASET_LOCK_JOB; i++) { System.out.println("Creating " + i + "th DatasetLockJob.."); generateDatasetLockThread(txnProvider); } for (i = 0; i < MAX_NUM_OF_UPGRADE_JOB; i++) { System.out.println("Creating " + i + "th EntityLockUpgradeJob.."); generateEntityLockUpgradeThread(txnProvider); } ((LogManager) txnProvider.getLogManager()).stop(false, null); }
From source file:com.aurel.track.exchange.docx.exporter.HyperlinkUtil.java
public static void main(String[] args) throws Exception { WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(); MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); // Create hyperlink Hyperlink link = createHyperlink(mdp, "http://slashdot.org", "Link text"); // Add it to a paragraph org.docx4j.wml.P paragraph = Context.getWmlObjectFactory().createP(); paragraph.getContent().add(link);/*w ww . ja v a2s.c om*/ mdp.addObject(paragraph); // Now save it wordMLPackage.save(new java.io.File(System.getProperty("user.dir") + "/OUT_HyperlinkTest.docx")); // Uncomment to display the result as Flat OPC XML }
From source file:org.mitre.mpf.rest.client.Main.java
public static void main(String[] args) throws RestClientException, IOException, InterruptedException { System.out.println("Starting rest-client!"); //not necessary for localhost, but left if a proxy configuration is needed //System.setProperty("http.proxyHost",""); //System.setProperty("http.proxyPort",""); String currentDirectory;/* w w w. j a v a 2 s . co m*/ currentDirectory = System.getProperty("user.dir"); System.out.println("Current working directory : " + currentDirectory); String username = "mpf"; String password = "mpf123"; byte[] encodedBytes = Base64.encodeBase64((username + ":" + password).getBytes()); String base64 = new String(encodedBytes); System.out.println("encodedBytes " + base64); final String mpfAuth = "Basic " + base64; RequestInterceptor authorize = new RequestInterceptor() { @Override public void intercept(HttpRequestBase request) { request.addHeader("Authorization", mpfAuth /*credentials*/); } }; //RestClient client = RestClient.builder().requestInterceptor(authorize).build(); CustomRestClient client = (CustomRestClient) CustomRestClient.builder() .restClientClass(CustomRestClient.class).requestInterceptor(authorize).build(); //getAvailableWorkPipelineNames String url = "http://localhost:8080/workflow-manager/rest/pipelines"; Map<String, String> params = new HashMap<String, String>(); List<String> availableWorkPipelines = client.get(url, params, new TypeReference<List<String>>() { }); System.out.println("availableWorkPipelines size: " + availableWorkPipelines.size()); System.out.println(Arrays.toString(availableWorkPipelines.toArray())); //processMedia JobCreationRequest jobCreationRequest = new JobCreationRequest(); URI uri = Paths.get(currentDirectory, "/trunk/workflow-manager/src/test/resources/samples/meds/aa/S001-01-t10_01.jpg").toUri(); jobCreationRequest.getMedia().add(new JobCreationMediaData(uri.toString())); uri = Paths.get(currentDirectory, "/trunk/workflow-manager/src/test/resources/samples/meds/aa/S008-01-t10_01.jpg").toUri(); jobCreationRequest.getMedia().add(new JobCreationMediaData(uri.toString())); jobCreationRequest.setExternalId("external id"); //get first DLIB pipeline String firstDlibPipeline = availableWorkPipelines.stream() //.peek(pipepline -> System.out.println("will filter - " + pipepline)) .filter(pipepline -> pipepline.startsWith("DLIB")).findFirst().get(); System.out.println("found firstDlibPipeline: " + firstDlibPipeline); jobCreationRequest.setPipelineName(firstDlibPipeline); //grabbed from 'rest/pipelines' - see #1 //two optional params jobCreationRequest.setBuildOutput(true); //jobCreationRequest.setPriority(priority); //will be set to 4 (default) if not set JobCreationResponse jobCreationResponse = client.customPostObject( "http://localhost:8080/workflow-manager/rest/jobs", jobCreationRequest, JobCreationResponse.class); System.out.println("jobCreationResponse job id: " + jobCreationResponse.getJobId()); System.out.println("\n---Sleeping for 10 seconds to let the job process---\n"); Thread.sleep(10000); //getJobStatus url = "http://localhost:8080/workflow-manager/rest/jobs"; // /status"; params = new HashMap<String, String>(); //OPTIONAL //params.put("v", "") - no versioning currently implemented //id is now a path var - if not set, all job info will returned url = url + "/" + Long.toString(jobCreationResponse.getJobId()); SingleJobInfo jobInfo = client.get(url, params, SingleJobInfo.class); System.out.println("jobInfo id: " + jobInfo.getJobId()); //getSerializedOutput String jobIdToGetOutputStr = Long.toString(jobCreationResponse.getJobId()); url = "http://localhost:8080/workflow-manager/rest/jobs/" + jobIdToGetOutputStr + "/output/detection"; params = new HashMap<String, String>(); //REQUIRED - job id is now a path var and required for this endpoint String serializedOutput = client.getAsString(url, params); System.out.println("serializedOutput: " + serializedOutput); }
From source file:LocalAddress.java
public static void main(String[] args) { System.out.println("OS: " + System.getProperty("os.name") + " vsn: " + System.getProperty("os.version") + " on: " + System.getProperty("os.arch")); InetAddress local = getLocalAddress(); if (local != null) { System.out.println("localAddress: " + local.getHostAddress()); } else {/*from www . j a v a2 s. c om*/ System.out.println("localAddress not found"); } }