List of usage examples for org.apache.commons.cli ParseException printStackTrace
public void printStackTrace()
From source file:org.dcm4che.tool.hl72xml.HL72Xml.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {/* w w w .ja va 2 s.c om*/ CommandLine cl = parseComandLine(args); HL72Xml main = new HL72Xml(); if (cl.hasOption("x")) { String s = cl.getOptionValue("x"); main.setXSLT(new File(s).toURI().toURL()); } main.setCharacterSet(cl.getOptionValue("charset")); main.setIndent(cl.hasOption("I")); main.setIncludeNamespaceDeclaration(cl.hasOption("xmlns")); String fname = fname(cl.getArgList()); if (fname.equals("-")) { main.parse(System.in); } else { FileInputStream dis = new FileInputStream(fname); try { main.parse(dis); } finally { dis.close(); } } } catch (ParseException e) { System.err.println("hl72xml: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("hl72xml: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.hl7pix.HL7Pix.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {/*from w w w. j a v a 2 s.c om*/ CommandLine cl = parseComandLine(args); HL7Pix main = new HL7Pix(); configureConnect(main, cl); configureBind(main, cl); CLIUtils.configure(main.conn, cl); main.setCharacterSet(cl.getOptionValue("charset")); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); List<String> argList = cl.getArgList(); if (argList.isEmpty()) throw new ParseException(rb.getString("missing")); try { main.open(); main.query(argList.get(0), argList.subList(1, argList.size()).toArray(new String[0])); } finally { main.close(); } } catch (ParseException e) { System.err.println("hl7pix: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("hl7pix: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.hl7rcv.HL7Rcv.java
public static void main(String[] args) { try {/*from w ww. ja v a 2s .c o m*/ CommandLine cl = parseComandLine(args); HL7Rcv main = new HL7Rcv(); configure(main, cl); ExecutorService executorService = Executors.newCachedThreadPool(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setScheduledExecutor(scheduledExecutorService); main.device.setExecutor(executorService); main.device.bindConnections(); } catch (ParseException e) { System.err.println("hl7rcv: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("hl7rcv: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.ianscp.IanSCP.java
public static void main(String[] args) { try {//from w w w.j av a 2 s . c om CommandLine cl = parseComandLine(args); IanSCP main = new IanSCP(); CLIUtils.configureBindServer(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); configureTransferCapability(main.ae, cl); main.setStatus(CLIUtils.getIntOption(cl, "status", 0)); main.setStorageDirectory(getStorageDirectory(cl)); ExecutorService executorService = Executors.newCachedThreadPool(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.setScheduledExecutor(scheduledExecutorService); main.setExecutor(executorService); main.bindConnections(); } catch (ParseException e) { System.err.println("ianscp: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("ianscp: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.ianscu.IanSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {/*from w w w . j av a 2s . com*/ CommandLine cl = parseComandLine(args); final IanSCU main = new IanSCU(); configureIAN(main, cl); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); main.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { System.out.println(rb.getString("scanning")); DicomFiles.scan(argList, new DicomFiles.Callback() { @Override public boolean dicomFile(File f, Attributes fmi, long dsPos, Attributes ds) { if (UID.InstanceAvailabilityNotificationSOPClass .equals(fmi.getString(Tag.MediaStorageSOPClassUID))) { return main.addIAN(fmi.getString(Tag.MediaStorageSOPInstanceUID), ds); } return main.addInstance(ds); } }); } ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setExecutor(executorService); main.device.setScheduledExecutor(scheduledExecutorService); try { main.open(); if (echo) main.echo(); else main.sendIans(); } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("ianscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("ianscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.ihe.modality.Modality.java
@SuppressWarnings({ "unchecked" }) public static void main(String[] args) { try {// w w w. j a v a 2s. c o m CommandLine cl = parseComandLine(args); if (cl.getArgList().isEmpty()) throw new MissingOptionException(rb.getString("missing-i-file")); final Device device = new Device("modality"); final Connection conn = new Connection(); final ApplicationEntity ae = new ApplicationEntity("MODALITY"); checkOptions(cl); CLIUtils.configureBind(conn, ae, cl); CLIUtils.configure(conn, cl); device.addConnection(conn); device.addApplicationEntity(ae); ae.addConnection(conn); final MppsSCU mppsscu = new MppsSCU(ae); final StoreSCU storescu = new StoreSCU(ae); final StgCmtSCU stgcmtscu = new StgCmtSCU(ae); CLIUtils.configureConnect(mppsscu.getRemoteConnection(), mppsscu.getAAssociateRQ(), cl); CLIUtils.configureConnect(stgcmtscu.getRemoteConnection(), stgcmtscu.getAAssociateRQ(), cl); CLIUtils.configureConnect(storescu.getRemoteConnection(), storescu.getAAssociateRQ(), cl); calledAET = storescu.getAAssociateRQ().getCalledAET(); mppsscu.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); mppsscu.setCodes( CLIUtils.loadProperties(cl.getOptionValue("code-config", "resource:code.properties"), null)); if (cl.hasOption("dc")) mppsscu.setFinalStatus("DISCONTINUED"); if (cl.hasOption("dc-reason")) mppsscu.setDiscontinuationReason(cl.getOptionValue("dc-reason")); stgcmtscu.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); stgcmtscu.setStorageDirectory(StgCmtSCU.getStorageDirectory(cl)); StoreSCU.configureRelatedSOPClass(storescu, cl); storescu.setUIDSuffix(StoreSCU.uidSuffixOf(cl)); Attributes attrs = new Attributes(); CLIUtils.addAttributes(attrs, cl.getOptionValues("s")); mppsscu.setAttributes(attrs); storescu.setAttributes(attrs); stgcmtscu.setAttributes(attrs); setTlsParams(mppsscu.getRemoteConnection(), conn); setTlsParams(storescu.getRemoteConnection(), conn); setTlsParams(stgcmtscu.getRemoteConnection(), conn); String tmpPrefix = "iocmtest-"; String tmpSuffix = null; File tmpDir = null; configureTmpFile(storescu, tmpPrefix, tmpSuffix, tmpDir, cl); String mppsiuid = UIDUtils.createUID(); mppsscu.setPPSUID(mppsiuid); if (cl.hasOption("kos-title")) { List<String> fname = Arrays.asList(mkkos(cl)); scanFiles(fname, tmpPrefix, tmpSuffix, tmpDir, mppsscu, storescu, stgcmtscu); } else { stgcmtscu.setUIDSuffix(cl.getOptionValue("uid-suffix")); storescu.setUIDSuffix(cl.getOptionValue("uid-suffix")); mppsscu.setUIDSuffix(cl.getOptionValue("uid-suffix")); scanFiles(cl.getArgList(), tmpPrefix, tmpSuffix, tmpDir, mppsscu, storescu, stgcmtscu); } ExecutorService executorService = Executors.newCachedThreadPool(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); device.setExecutor(executorService); device.setScheduledExecutor(scheduledExecutorService); device.bindConnections(); try { boolean sendMpps = cl.hasOption("mpps"); boolean sendLateMpps = cl.hasOption("mpps-late"); if (sendMpps || sendLateMpps) sendMpps(mppsscu, sendMpps); addReferencedPerformedProcedureStepSequence(mppsiuid, storescu); sendObjects(storescu); if (sendLateMpps) sendMppsNSet(mppsscu); if (cl.hasOption("stgcmt")) sendStgCmt(stgcmtscu); } finally { if (conn.isListening()) { device.waitForNoOpenConnections(); device.unbindConnections(); } executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println(e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.movescu.MoveSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {/*w ww .j av a 2s . c o m*/ CommandLine cl = parseComandLine(args); MoveSCU main = new MoveSCU(); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); configureServiceClass(main, cl); configureKeys(main, cl); main.setPriority(CLIUtils.priorityOf(cl)); main.setDestination(destinationOf(cl)); ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.setExecutor(executorService); main.setScheduledExecutor(scheduledExecutorService); try { main.open(); List<String> argList = cl.getArgList(); if (argList.isEmpty()) main.retrieve(); else for (String arg : argList) main.retrieve(new File(arg)); } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("movescu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("movescu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.mppsscp.MppsSCP.java
public static void main(String[] args) { try {//from w w w.ja va 2s . c o m CommandLine cl = parseComandLine(args); MppsSCP main = new MppsSCP(); CLIUtils.configureBindServer(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); configureTransferCapability(main.ae, cl); configureStorageDirectory(main, cl); configureIODs(main, cl); ExecutorService executorService = Executors.newCachedThreadPool(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setScheduledExecutor(scheduledExecutorService); main.device.setExecutor(executorService); main.device.bindConnections(); } catch (ParseException e) { System.err.println("mppsscp: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("mppsscp: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.mppsscu.MppsSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {/*from w w w . ja v a 2 s . c o m*/ CommandLine cl = parseComandLine(args); Device device = new Device("mppsscu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("MPPSSCU"); device.addApplicationEntity(ae); ae.addConnection(conn); final MppsSCU main = new MppsSCU(ae); configureMPPS(main, cl); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(conn, main.ae, cl); CLIUtils.configure(conn, cl); main.remote.setTlsProtocols(conn.getTlsProtocols()); main.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); main.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); main.setAttributes(new Attributes()); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { System.out.println(rb.getString("scanning")); DicomFiles.scan(argList, new DicomFiles.Callback() { @Override public boolean dicomFile(File f, Attributes fmi, long dsPos, Attributes ds) { if (UID.ModalityPerformedProcedureStepSOPClass .equals(fmi.getString(Tag.MediaStorageSOPClassUID))) { return main.addMPPS(fmi.getString(Tag.MediaStorageSOPInstanceUID), ds); } return main.addInstance(ds); } }); } ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); device.setExecutor(executorService); device.setScheduledExecutor(scheduledExecutorService); try { main.open(); if (echo) main.echo(); else { main.createMpps(); main.updateMpps(); } } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("mppsscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("mppsscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.stgcmtscu.StgCmtSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {//from ww w . j a v a 2 s . co m CommandLine cl = parseComandLine(args); Device device = new Device("stgcmtscu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("STGCMTSCU"); device.addApplicationEntity(ae); ae.addConnection(conn); final StgCmtSCU stgcmtscu = new StgCmtSCU(ae); CLIUtils.configureConnect(stgcmtscu.remote, stgcmtscu.rq, cl); CLIUtils.configureBind(conn, stgcmtscu.ae, cl); CLIUtils.configure(conn, cl); stgcmtscu.remote.setTlsProtocols(conn.getTlsProtocols()); stgcmtscu.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); stgcmtscu.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); stgcmtscu.setStatus(CLIUtils.getIntOption(cl, "status", 0)); stgcmtscu.setSplitTag(getSplitTag(cl)); stgcmtscu.setKeepAlive(cl.hasOption("keep-alive")); stgcmtscu.setStorageDirectory(getStorageDirectory(cl)); stgcmtscu.setAttributes(new Attributes()); CLIUtils.addAttributes(stgcmtscu.attrs, cl.getOptionValues("s")); stgcmtscu.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { LOG.info(rb.getString("scanning")); DicomFiles.scan(argList, new DicomFiles.Callback() { @Override public boolean dicomFile(File f, Attributes fmi, long dsPos, Attributes ds) { return stgcmtscu.addInstance(ds); } }); } ExecutorService executorService = Executors.newCachedThreadPool(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); device.setExecutor(executorService); device.setScheduledExecutor(scheduledExecutorService); device.bindConnections(); try { stgcmtscu.open(); if (echo) stgcmtscu.echo(); else stgcmtscu.sendRequests(); } finally { stgcmtscu.close(); if (conn.isListening()) { device.waitForNoOpenConnections(); device.unbindConnections(); } executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("stgcmtscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("stgcmtscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }