List of usage examples for org.apache.commons.cli CommandLine getArgList
public List getArgList()
From source file:org.dcm4che2.tool.chess3d.Chess3D.java
private static CommandLine parse(String[] args) { Options opts = new Options(); Option oThickness = new Option("t", "thickness", true, "Slice Thickness, 1 by default"); oThickness.setArgName("thickness"); opts.addOption(oThickness);/*from w w w . j ava 2 s .c om*/ Option oLocation = new Option("l", "location", true, "Slice Location of first image, 0.0\\0.0\\0.0 by default"); oLocation.setArgName("location"); opts.addOption(oLocation); Option ox = new Option("x", "rectWidth", true, "Width of one chess rectangle (x-coord). 100 by default"); ox.setArgName("x"); opts.addOption(ox); Option oy = new Option("y", "rectDepth", true, "Heigth of one chess rectangle (y-coord). 100 by default"); oy.setArgName("y"); opts.addOption(oy); Option oX = new Option("X", "xRect", true, "Number of chess fields in x-coord, 10 by default"); oX.setArgName("X"); opts.addOption(oX); Option oY = new Option("Y", "yRect", true, "Number of chess fields in y-coord, 10 by default"); oY.setArgName("Y"); opts.addOption(oY); Option oZ = new Option("Z", "zRect", true, "Number of chess fields in z-coord, 5 by default"); oZ.setArgName("Z"); opts.addOption(oZ); Option oW = new Option("w", "white", true, "White field value (0-255), 225 by default"); oW.setArgName("w"); opts.addOption(oW); Option oB = new Option("b", "black", true, "Black field value (0-255), 0 by default"); oB.setArgName("b"); opts.addOption(oB); Option oWin = new Option("win", "window", true, "Window level. Format: <center>\\<width>. 128\\256 by default"); oWin.setArgName("win"); opts.addOption(oWin); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Destination directory, parent of xml file or current working directory by default"); opts.addOption(OptionBuilder.create("d")); opts.addOption("S", "studyUID", false, "Create new Study Instance UID. Only effective if xmlFile is specified and studyIUID is set"); opts.addOption("s", "seriesUID", false, "create new Series Instance UID. Only effective if xmlFile is specified and seriesIUID is set"); OptionBuilder.withArgName("prefix"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Generate UIDs with given prefix, 1.2.40.0.13.1.<host-ip> by default."); opts.addOption(OptionBuilder.create("uid")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("chess3d: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Chess3D.class.getPackage(); System.out.println("chess3d v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.dcm4che2.tool.dcm2dcm.Dcm2Dcm.java
private static CommandLine parse(String[] args) { Options opts = new Options(); opts.addOption(null, "no-fmi", false, "Encode result without File Meta Information. At default, " + " File Meta Information is included."); opts.addOption("e", "explicit", false, "Encode result with Explicit VR Little Endian Transfer Syntax. " + "At default, Implicit VR Little Endian is used."); opts.addOption("b", "big-endian", false, "Encode result with Explicit VR Big Endian Transfer Syntax. " + "At default, Implicit VR Little Endian is used."); opts.addOption("z", "deflated", false, "Encode result with Deflated Explicit VR Little Endian Syntax. " + "At default, Implicit VR Little Endian is used."); OptionBuilder.withArgName("[seq/]attr=value"); OptionBuilder.hasArgs(2);// w w w . j a v a 2 s . c o m OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription( "specify value to set in the output stream. Currently only works when transcoding images."); opts.addOption(OptionBuilder.create("s")); opts.addOption("t", "syntax", true, "Encode result with the specified transfer syntax - recodes" + " the image typically."); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default"); OptionBuilder.withLongOpt("buffer"); opts.addOption(OptionBuilder.create(null)); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new PosixParser().parse(opts, args); } catch (ParseException e) { exit("dcm2dcm: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Dcm2Dcm.class.getPackage(); System.out.println("dcm2dcm v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.dcm4che2.tool.dcm2dcm.Dcm2Dcm.java
@SuppressWarnings("unchecked") public static void main(String[] args) { System.setProperty("org.dcm4che2.imageio.ImageReaderFactory", "com/dicomgrid/imageio/ImageReaderFactory.properties"); System.setProperty("org.dcm4che2.imageio.ImageWriterFactory", "com/dicomgrid/imageio/ImageWriterFactory.properties"); IIORegistry.getDefaultInstance().registerServiceProvider(new CLibFragmentedJPEGImageReaderSpi(), ImageReaderSpi.class); CommandLine cl = parse(args); Dcm2Dcm dcm2dcm = new Dcm2Dcm(); dcm2dcm.setNoFileMetaInformation(cl.hasOption("no-fmi")); dcm2dcm.setTransferSyntax(transferSyntax(cl)); if (cl.hasOption("buffer")) { dcm2dcm.setTranscoderBufferSize( parseInt(cl.getOptionValue("buffer"), "illegal argument of option --buffer", 1, 10000) * KB); }/* ww w . java 2 s .c o m*/ if (cl.hasOption("s")) { dcm2dcm.overwriteObject = new BasicDicomObject(); String[] matchingKeys = cl.getOptionValues("s"); for (int i = 1; i < matchingKeys.length; i++, i++) { int[] tag = Tag.toTagPath(matchingKeys[i - 1]); String svalue = matchingKeys[i]; dcm2dcm.overwriteObject.putString(tag, null, svalue); } } List<String> argList = cl.getArgList(); int argc = argList.size(); File dest = new File(argList.get(argc - 1)); long t1 = System.currentTimeMillis(); int count; if (dest.isDirectory()) { count = dcm2dcm.mconvert(argList, 0, dest); } else { File src = new File(argList.get(0)); if (argc > 2 || src.isDirectory()) { exit("dcm2dcm: when converting several files, " + "last argument must be a directory\n"); } count = dcm2dcm.mconvert(src, dest); } long t2 = System.currentTimeMillis(); System.out.println("\nconverted " + count + " file(s) in " + (t2 - t1) / 1000f + " s."); }
From source file:org.dcm4che2.tool.dcm2jpg.Dcm2Jpg.java
@SuppressWarnings("unchecked") public static void main(String args[]) throws Exception { CommandLine cl = parse(args); Dcm2Jpg dcm2jpg = new Dcm2Jpg(); if (cl.hasOption("f")) { dcm2jpg.setFrameNumber(//from ww w . jav a 2s . co m parseInt(cl.getOptionValue("f"), "illegal argument of option -f", 1, Integer.MAX_VALUE)); } if (cl.hasOption("p")) { dcm2jpg.setPresentationState(loadDicomObject(new File(cl.getOptionValue("p")))); } if (cl.hasOption("pv2gray")) { dcm2jpg.setPValue2Gray(loadPVal2Gray(new File(cl.getOptionValue("pv2gray")))); } if (cl.hasOption("c")) { dcm2jpg.setWindowCenter(parseFloat(cl.getOptionValue("c"), "illegal argument of option -c")); } if (cl.hasOption("w")) { dcm2jpg.setWindowWidth(parseFloat(cl.getOptionValue("w"), "illegal argument of option -w")); } if (cl.hasOption("q")) { dcm2jpg.setImageQuality(parseInt(cl.getOptionValue("q"), "illegal argument of option -q", 0, 100)); } if (cl.hasOption("F")) { String fn = cl.getOptionValue("F"); dcm2jpg.setFormatName(fn.toUpperCase()); dcm2jpg.setImageWriter("*"); dcm2jpg.setFileExt("." + fn.toLowerCase()); dcm2jpg.setCompressionType("JPEG".equalsIgnoreCase(fn) ? "jpeg" : null); } if (cl.hasOption("T")) { String type = cl.getOptionValue("T"); dcm2jpg.setCompressionType("*".equals(type) ? null : type); } if (cl.hasOption("imagewriter")) { dcm2jpg.setImageWriter(cl.getOptionValue("imagewriter")); } if (cl.hasOption("sigmoid")) { dcm2jpg.setVoiLutFunction(DicomImageReadParam.SIGMOID); } dcm2jpg.setAutoWindowing(!cl.hasOption("noauto")); if (cl.hasOption("jpgext")) { dcm2jpg.setFileExt(cl.getOptionValue("jpgext")); } if (cl.hasOption("S")) { dcm2jpg.showFormatNames(); return; } if (cl.hasOption("s")) { dcm2jpg.showImageWriters(); return; } final List<String> argList = cl.getArgList(); int argc = argList.size(); File dest = new File(argList.get(argc - 1)); long t1 = System.currentTimeMillis(); int count = 1; if (dest.isDirectory()) { count = dcm2jpg.mconvert(argList, 0, dest); } else { File src = new File(argList.get(0)); if (argc > 2 || src.isDirectory()) { exit("dcm2jpg: when converting several files, " + "last argument must be a directory\n"); } if (!src.exists()) { exit("Cannot find the file specified: " + argList.get(0)); } dcm2jpg.convert(src, dest); } long t2 = System.currentTimeMillis(); System.out.println("\nconverted " + count + " files in " + (t2 - t1) / 1000f + " s."); }
From source file:org.dcm4che2.tool.dcm2jpg.Dcm2Jpg.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("frame"); OptionBuilder.hasArg();// ww w .j a v a2s. co m OptionBuilder.withDescription("frame to convert, 1 (= first frame) by default"); opts.addOption(OptionBuilder.create("f")); OptionBuilder.withArgName("imagequality"); OptionBuilder.hasArg(); OptionBuilder.withDescription("JPEG Image Quality (0-100)"); opts.addOption(OptionBuilder.create("q")); OptionBuilder.withArgName("ImageWriterClass"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "ImageWriter to be used [Default: JPEGImageEncoder instead of imageIO]. Use * to choose the first ImageIO Writer found for given image format"); opts.addOption(OptionBuilder.create("imagewriter")); opts.addOption("S", "showFormats", false, "Show all supported format names by registered ImageWriters."); opts.addOption("s", "showimagewriter", false, "Show all available Image Writer for specified format name."); OptionBuilder.withArgName("formatName"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Image Format Name. [default JPEG] This option will imply default values for ImageWriterClass='*' and jpgext='.<formatname>'"); opts.addOption(OptionBuilder.create("F")); OptionBuilder.withArgName("compressionType"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Compression Type. [default: '*' (exception: jpeg for format JPEG)] Only applicable if an ImageWriterClass is used! Use * to choose the first compression type."); opts.addOption(OptionBuilder.create("T")); OptionBuilder.withArgName("prfile"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path of presentation state to apply"); opts.addOption(OptionBuilder.create("p")); OptionBuilder.withArgName("center"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Window Center"); opts.addOption(OptionBuilder.create("c")); OptionBuilder.withArgName("width"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Window Width"); opts.addOption(OptionBuilder.create("w")); opts.addOption("sigmoid", false, "apply sigmoid VOI LUT function with given Window Center/Width"); opts.addOption("noauto", false, "disable auto-windowing for images w/o VOI attributes"); OptionBuilder.withArgName("file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path of P-Value to gray value map"); opts.addOption(OptionBuilder.create("pv2gray")); OptionBuilder.withArgName(".xxx"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "jpeg file extension used with destination directory argument," + " default: '.jpg'."); opts.addOption(OptionBuilder.create("jpgext")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcm2jpg: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Dcm2Jpg.class.getPackage(); System.out.println("dcm2jpg v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || !(cl.hasOption('s') || cl.hasOption('S')) && cl.getArgList().size() < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.dcm4che2.tool.dcmdir.DcmDir.java
public static void main(String[] args) throws IOException { CommandLine cl = parse(args); List argList = cl.getArgList(); long start = System.currentTimeMillis(); if (cl.hasOption("t")) { DcmDir dcmdir = new DcmDir(new File(cl.getOptionValue("t"))); if (cl.hasOption("w")) dcmdir.setMaxWidth(parseInt(cl.getOptionValue("w"), "w", MIN_MAX_WIDTH, MAX_MAX_WIDTH)); if (cl.hasOption("W")) dcmdir.setMaxValLen(parseInt(cl.getOptionValue("W"), "W", MIN_MAX_VAL_LEN, MAX_MAX_VAL_LEN)); dcmdir.openRO();/*from ww w .ja va 2 s. com*/ dcmdir.setShowInactiveRecords(cl.hasOption("inactive")); dcmdir.dump(); dcmdir.close(); } else if (cl.hasOption("p")) { String fpath = cl.getOptionValue("p"); File f = new File(fpath); DcmDir dcmdir = new DcmDir(f); dcmdir.open(); int count = dcmdir.purge(); dcmdir.close(); long end = System.currentTimeMillis(); System.out.println("Purge " + count + " directory records from " + f + " in " + (end - start) + "ms."); } else if (cl.hasOption("z")) { String fpath = cl.getOptionValue("z"); File f = new File(fpath); File out = new File(fpath + ".NEW"); File bak = new File(fpath + "~"); DcmDir dcmdir1 = new DcmDir(f); dcmdir1.openRO(); DcmDir dcmdir2 = new DcmDir(out); dcmdir2.fsinfo(dcmdir1.fsinfo()); createDicomDir(dcmdir2, cl); dcmdir2.copyFrom(dcmdir1); dcmdir2.close(); dcmdir1.close(); if (!f.renameTo(bak)) { throw new IOException("Failed to rename " + f + " to " + bak); } if (!out.renameTo(f)) { throw new IOException("Failed to rename " + out + " to " + f); } long end = System.currentTimeMillis(); System.out.println("Compact " + f + " from " + bak.length() + " to " + f.length() + " bytes in " + (end - start) + "ms."); } else if (cl.hasOption("d")) { File f = new File(cl.getOptionValue("d")); DcmDir dcmdir = new DcmDir(f); dcmdir.open(); int num = 0; for (int i = 0, n = argList.size(); i < n; ++i) { num += dcmdir.delFile(new File((String) argList.get(i))); } dcmdir.close(); long end = System.currentTimeMillis(); System.out.println(); System.out.println("Remove " + num + " references from " + f + " in " + (end - start) + "ms."); } else { DcmDir dcmdir; File f; if (cl.hasOption("c")) { f = new File(cl.getOptionValue("c")); dcmdir = new DcmDir(f); createDicomDir(dcmdir, cl); dcmdir.setCheckDuplicate(false); } else { // cl.hasOption("a") f = new File(cl.getOptionValue("a")); dcmdir = new DcmDir(f); dcmdir.open(); dcmdir.setCheckDuplicate(true); } int num = 0; for (int i = 0, n = argList.size(); i < n; ++i) { num += dcmdir.addFile(new File((String) argList.get(i))); } dcmdir.close(); long end = System.currentTimeMillis(); System.out.println(); System.out.println("Add " + num + (cl.hasOption("c") ? " directory records to new directory file " : " directory records to existing directory file ") + f + " in " + (end - start) + "ms."); } }
From source file:org.dcm4che2.tool.dcmecho.DcmEcho.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*from w w w. ja v a 2 s .co m*/ OptionBuilder.withDescription("set device name, use DCMECHO by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET and local address of local Application Entity, use " + "device name and pick up any valid local address to " + "bind the socket by default"); opts.addOption(OptionBuilder.create("L")); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_1.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 10s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("num"); OptionBuilder.hasArg(); OptionBuilder.withDescription("repeat C-ECHO RQ several times"); opts.addOption(OptionBuilder.create("repeat")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder .withDescription("delay in ms between repeated C-FIND RQ, immediately after C-FIND RSP by default"); opts.addOption(OptionBuilder.create("repeatdelay")); opts.addOption("reuseassoc", false, "Reuse association for repeated C-ECHO"); opts.addOption("closeassoc", false, "Close association after each C-ECHO"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmecho: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmEcho.class.getPackage(); System.out.println("dcmecho v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() != 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.dcm4che2.tool.dcmecho.DcmEcho.java
@SuppressWarnings("unchecked") public static void main(String[] args) { CommandLine cl = parse(args); DcmEcho dcmecho = new DcmEcho(cl.hasOption("device") ? cl.getOptionValue("device") : "DCMECHO"); final List<String> argList = cl.getArgList(); String remoteAE = argList.get(0); String[] calledAETAddress = split(remoteAE, '@'); dcmecho.setCalledAET(calledAETAddress[0], cl.hasOption("reuseassoc")); if (calledAETAddress[1] == null) { dcmecho.setRemoteHost("127.0.0.1"); dcmecho.setRemotePort(104);/* www .j a v a 2s. c o m*/ } else { String[] hostPort = split(calledAETAddress[1], ':'); dcmecho.setRemoteHost(hostPort[0]); dcmecho.setRemotePort(toPort(hostPort[1])); } if (cl.hasOption("L")) { String localAE = cl.getOptionValue("L"); String[] callingAETHost = split(localAE, '@'); dcmecho.setCalling(callingAETHost[0]); if (callingAETHost[1] != null) { dcmecho.setLocalHost(callingAETHost[1]); } } if (cl.hasOption("username")) { String username = cl.getOptionValue("username"); UserIdentity userId; if (cl.hasOption("passcode")) { String passcode = cl.getOptionValue("passcode"); userId = new UserIdentity.UsernamePasscode(username, passcode.toCharArray()); } else { userId = new UserIdentity.Username(username); } userId.setPositiveResponseRequested(cl.hasOption("uidnegrsp")); dcmecho.setUserIdentity(userId); } if (cl.hasOption("connectTO")) dcmecho.setConnectTimeout(parseInt(cl.getOptionValue("connectTO"), "illegal argument of option -connectTO", 1, Integer.MAX_VALUE)); dcmecho.setIdleTimeout(cl.hasOption("idleTO") ? parseInt(cl.getOptionValue("idleTO"), "illegal argument of option -idleTO", 1, Integer.MAX_VALUE) : 10000); if (cl.hasOption("reaper")) dcmecho.setAssociationReaperPeriod(parseInt(cl.getOptionValue("reaper"), "illegal argument of option -reaper", 1, Integer.MAX_VALUE)); if (cl.hasOption("rspTO")) dcmecho.setDimseRspTimeout(parseInt(cl.getOptionValue("rspTO"), "illegal argument of option -rspTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("acceptTO")) dcmecho.setAcceptTimeout(parseInt(cl.getOptionValue("acceptTO"), "illegal argument of option -acceptTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("releaseTO")) dcmecho.setReleaseTimeout(parseInt(cl.getOptionValue("releaseTO"), "illegal argument of option -releaseTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("soclosedelay")) dcmecho.setSocketCloseDelay(parseInt(cl.getOptionValue("soclosedelay"), "illegal argument of option -soclosedelay", 1, 10000)); int repeat = cl.hasOption("repeat") ? parseInt(cl.getOptionValue("repeat"), "illegal argument of option -repeat", 1, Integer.MAX_VALUE) : 0; int interval = cl.hasOption("repeatdelay") ? parseInt(cl.getOptionValue("repeatdelay"), "illegal argument of option -repeatdelay", 1, Integer.MAX_VALUE) : 0; boolean closeAssoc = cl.hasOption("closeassoc"); if (cl.hasOption("tls")) { String cipher = cl.getOptionValue("tls"); if ("NULL".equalsIgnoreCase(cipher)) { dcmecho.setTlsWithoutEncyrption(); } else if ("3DES".equalsIgnoreCase(cipher)) { dcmecho.setTls3DES_EDE_CBC(); } else if ("AES".equalsIgnoreCase(cipher)) { dcmecho.setTlsAES_128_CBC(); } else { exit("Invalid parameter for option -tls: " + cipher); } if (cl.hasOption("tls1")) { dcmecho.setTlsProtocol(TLS1); } else if (cl.hasOption("ssl3")) { dcmecho.setTlsProtocol(SSL3); } else if (cl.hasOption("no_tls1")) { dcmecho.setTlsProtocol(NO_TLS1); } else if (cl.hasOption("no_ssl3")) { dcmecho.setTlsProtocol(NO_SSL3); } else if (cl.hasOption("no_ssl2")) { dcmecho.setTlsProtocol(NO_SSL2); } dcmecho.setTlsNeedClientAuth(!cl.hasOption("noclientauth")); if (cl.hasOption("keystore")) { dcmecho.setKeyStoreURL(cl.getOptionValue("keystore")); } if (cl.hasOption("keystorepw")) { dcmecho.setKeyStorePassword(cl.getOptionValue("keystorepw")); } if (cl.hasOption("keypw")) { dcmecho.setKeyPassword(cl.getOptionValue("keypw")); } if (cl.hasOption("truststore")) { dcmecho.setTrustStoreURL(cl.getOptionValue("truststore")); } if (cl.hasOption("truststorepw")) { dcmecho.setTrustStorePassword(cl.getOptionValue("truststorepw")); } long t1 = System.currentTimeMillis(); try { dcmecho.initTLS(); } catch (Exception e) { System.err.println("ERROR: Failed to initialize TLS context:" + e.getMessage()); System.exit(2); } long t2 = System.currentTimeMillis(); System.out.println("Initialize TLS context in " + ((t2 - t1) / 1000F) + "s"); } long t1 = System.currentTimeMillis(); try { dcmecho.open(); } catch (Exception e) { System.err.println("ERROR: Failed to establish association:" + e.getMessage()); System.exit(2); } long t2 = System.currentTimeMillis(); System.out.println("Connected to " + remoteAE + " in " + ((t2 - t1) / 1000F) + "s"); for (;;) { try { dcmecho.echo(); long t3 = System.currentTimeMillis(); System.out.println("Perform Verification in " + ((t2 - t3) / 1000F) + "s"); if (repeat == 0 || closeAssoc) { dcmecho.close(); System.out.println("Released connection to " + remoteAE); } if (repeat-- == 0) break; Thread.sleep(interval); long t4 = System.currentTimeMillis(); dcmecho.open(); t2 = System.currentTimeMillis(); System.out.println( "Reconnect or reuse connection to " + remoteAE + " in " + ((t2 - t4) / 1000F) + "s"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:org.dcm4che2.tool.dcmgpwl.DcmGPWL.java
@SuppressWarnings("unchecked") public static void main(String[] args) { CommandLine cl = parse(args); DcmGPWL dcmgpwl = new DcmGPWL(cl.hasOption("device") ? cl.getOptionValue("device") : "DCMGPWL"); final List<String> argList = cl.getArgList(); String remoteAE = argList.get(0); String[] calledAETAddress = split(remoteAE, '@'); dcmgpwl.setCalledAET(calledAETAddress[0]); if (calledAETAddress[1] == null) { dcmgpwl.setRemoteHost("127.0.0.1"); dcmgpwl.setRemotePort(104);//from w ww . jav a2s . c o m } else { String[] hostPort = split(calledAETAddress[1], ':'); dcmgpwl.setRemoteHost(hostPort[0]); dcmgpwl.setRemotePort(toPort(hostPort[1])); } if (cl.hasOption("L")) { String localAE = cl.getOptionValue("L"); String[] callingAETHost = split(localAE, '@'); dcmgpwl.setCalling(callingAETHost[0]); if (callingAETHost[1] != null) { dcmgpwl.setLocalHost(callingAETHost[1]); } } if (cl.hasOption("username")) { String username = cl.getOptionValue("username"); UserIdentity userId; if (cl.hasOption("passcode")) { String passcode = cl.getOptionValue("passcode"); userId = new UserIdentity.UsernamePasscode(username, passcode.toCharArray()); } else { userId = new UserIdentity.Username(username); } userId.setPositiveResponseRequested(cl.hasOption("uidnegrsp")); dcmgpwl.setUserIdentity(userId); } if (cl.hasOption("connectTO")) dcmgpwl.setConnectTimeout(parseInt(cl.getOptionValue("connectTO"), "illegal argument of option -connectTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("reaper")) dcmgpwl.setAssociationReaperPeriod(parseInt(cl.getOptionValue("reaper"), "illegal argument of option -reaper", 1, Integer.MAX_VALUE)); if (cl.hasOption("rspTO")) dcmgpwl.setDimseRspTimeout(parseInt(cl.getOptionValue("rspTO"), "illegal argument of option -rspTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("acceptTO")) dcmgpwl.setAcceptTimeout(parseInt(cl.getOptionValue("acceptTO"), "illegal argument of option -acceptTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("releaseTO")) dcmgpwl.setReleaseTimeout(parseInt(cl.getOptionValue("releaseTO"), "illegal argument of option -releaseTO", 1, Integer.MAX_VALUE)); if (cl.hasOption("soclosedelay")) dcmgpwl.setSocketCloseDelay(parseInt(cl.getOptionValue("soclosedelay"), "illegal argument of option -soclosedelay", 1, 10000)); if (cl.hasOption("rcvpdulen")) dcmgpwl.setMaxPDULengthReceive( parseInt(cl.getOptionValue("rcvpdulen"), "illegal argument of option -rcvpdulen", 1, 10000) * KB); if (cl.hasOption("sndpdulen")) dcmgpwl.setMaxPDULengthSend( parseInt(cl.getOptionValue("sndpdulen"), "illegal argument of option -sndpdulen", 1, 10000) * KB); if (cl.hasOption("sosndbuf")) dcmgpwl.setSendBufferSize( parseInt(cl.getOptionValue("sosndbuf"), "illegal argument of option -sosndbuf", 1, 10000) * KB); if (cl.hasOption("sorcvbuf")) dcmgpwl.setReceiveBufferSize( parseInt(cl.getOptionValue("sorcvbuf"), "illegal argument of option -sorcvbuf", 1, 10000) * KB); dcmgpwl.setPackPDV(!cl.hasOption("pdv1")); dcmgpwl.setTcpNoDelay(!cl.hasOption("tcpdelay")); if (cl.hasOption("o")) { dcmgpwl.setOutDir(new File(cl.getOptionValue("o"))); } if (cl.hasOption("retrieve")) { dcmgpwl.setRetrieveAET(cl.getOptionValue("retrieve")); } if (cl.hasOption("action")) { dcmgpwl.initAction(); dcmgpwl.setTransactionUID(cl.getOptionValues("action")[1]); if (cl.hasOption("status")) { dcmgpwl.setSPSStatus(cl.getOptionValue("status").toUpperCase()); } if (cl.hasOption("perfcode")) { dcmgpwl.setActualHumanPerformer(cl.getOptionValues("perfcode"), cl.getOptionValue("perfname"), cl.getOptionValue("perforg")); } } else if (cl.hasOption("createpps")) { dcmgpwl.initCreatePPS(cl.getOptionValues("refsps")); if (cl.hasOption("A")) { String[] matchingKeys = cl.getOptionValues("A"); for (int i = 1; i < matchingKeys.length; i++, i++) dcmgpwl.addAttr(toTag(matchingKeys[i - 1]), matchingKeys[i]); } if (cl.hasOption("rqA")) { String[] matchingKeys = cl.getOptionValues("rqA"); for (int i = 1; i < matchingKeys.length; i++, i++) dcmgpwl.addRefRequestAttr(toTag(matchingKeys[i - 1]), matchingKeys[i]); } if (cl.hasOption("workitem")) { dcmgpwl.addCodeValueAndScheme(Tag.PerformedWorkitemCodeSequence, cl.getOptionValues("workitem")); } if (cl.hasOption("application")) { dcmgpwl.addCodeValueAndScheme(Tag.PerformedProcessingApplicationsCodeSequence, cl.getOptionValues("application")); } if (cl.hasOption("station")) { dcmgpwl.addCodeValueAndScheme(Tag.PerformedStationNameCodeSequence, cl.getOptionValues("station")); } if (cl.hasOption("class")) { dcmgpwl.addCodeValueAndScheme(Tag.PerformedStationClassCodeSequence, cl.getOptionValues("class")); } if (cl.hasOption("location")) { dcmgpwl.addCodeValueAndScheme(Tag.PerformedStationGeographicLocationCodeSequence, cl.getOptionValues("location")); } if (cl.hasOption("perfcode")) { dcmgpwl.setActualHumanPerformer(cl.getOptionValues("perfcode"), cl.getOptionValue("perfname"), cl.getOptionValue("perforg")); } for (int i = 1, n = argList.size(); i < n; i++) { addOutput(dcmgpwl, new File(argList.get(i))); } } else if (cl.hasOption("setpps")) { dcmgpwl.initSetPPS(); if (cl.hasOption("status")) { dcmgpwl.setPPSStatus(cl.getOptionValue("status").toUpperCase()); } for (int i = 1, n = argList.size(); i < n; i++) { addOutput(dcmgpwl, new File(argList.get(i))); } } else { dcmgpwl.initQuery(); if (cl.hasOption("status")) { dcmgpwl.setSPSStatus(cl.getOptionValue("status").toUpperCase()); } if (cl.hasOption("C")) dcmgpwl.setCancelAfter( parseInt(cl.getOptionValue("C"), "illegal argument of option -C", 1, Integer.MAX_VALUE)); if (cl.hasOption("lowprior")) dcmgpwl.setPriority(CommandUtils.LOW); if (cl.hasOption("highprior")) dcmgpwl.setPriority(CommandUtils.HIGH); if (cl.hasOption("fuzzy")) dcmgpwl.setFuzzySemanticPersonNameMatching(true); if (cl.hasOption("A")) { String[] matchingKeys = cl.getOptionValues("A"); for (int i = 1; i < matchingKeys.length; i++, i++) dcmgpwl.addAttr(toTag(matchingKeys[i - 1]), matchingKeys[i]); } if (cl.hasOption("rqA")) { String[] matchingKeys = cl.getOptionValues("rqA"); for (int i = 1; i < matchingKeys.length; i++, i++) dcmgpwl.addRefRequestAttr(toTag(matchingKeys[i - 1]), matchingKeys[i]); } if (cl.hasOption("D")) { dcmgpwl.addAttr(Tag.ScheduledProcedureStepStartDateTime, cl.getOptionValue("D")); } if (cl.hasOption("workitem")) { dcmgpwl.addCodeValueAndScheme(Tag.ScheduledWorkitemCodeSequence, cl.getOptionValues("workitem")); } if (cl.hasOption("application")) { dcmgpwl.addCodeValueAndScheme(Tag.ScheduledProcessingApplicationsCodeSequence, cl.getOptionValues("application")); } if (cl.hasOption("station")) { dcmgpwl.addCodeValueAndScheme(Tag.ScheduledStationNameCodeSequence, cl.getOptionValues("station")); } if (cl.hasOption("class")) { dcmgpwl.addCodeValueAndScheme(Tag.ScheduledStationClassCodeSequence, cl.getOptionValues("class")); } if (cl.hasOption("location")) { dcmgpwl.addCodeValueAndScheme(Tag.ScheduledStationGeographicLocationCodeSequence, cl.getOptionValues("location")); } if (cl.hasOption("performer")) { dcmgpwl.setScheduledHumanPerformerCodeValueAndScheme(cl.getOptionValues("performer")); } } dcmgpwl.configureTransferCapability(cl.hasOption("metasop") ? METASOP_CUID : SOP_CUIDS, cl.hasOption("ivrle") ? IVRLE_TS : LE_TS); if (cl.hasOption("tls")) { String cipher = cl.getOptionValue("tls"); if ("NULL".equalsIgnoreCase(cipher)) { dcmgpwl.setTlsWithoutEncyrption(); } else if ("3DES".equalsIgnoreCase(cipher)) { dcmgpwl.setTls3DES_EDE_CBC(); } else if ("AES".equalsIgnoreCase(cipher)) { dcmgpwl.setTlsAES_128_CBC(); } else { exit("Invalid parameter for option -tls: " + cipher); } if (cl.hasOption("tls1")) { dcmgpwl.setTlsProtocol(TLS1); } else if (cl.hasOption("ssl3")) { dcmgpwl.setTlsProtocol(SSL3); } else if (cl.hasOption("no_tls1")) { dcmgpwl.setTlsProtocol(NO_TLS1); } else if (cl.hasOption("no_ssl3")) { dcmgpwl.setTlsProtocol(NO_SSL3); } else if (cl.hasOption("no_ssl2")) { dcmgpwl.setTlsProtocol(NO_SSL2); } dcmgpwl.setTlsNeedClientAuth(!cl.hasOption("noclientauth")); if (cl.hasOption("keystore")) { dcmgpwl.setKeyStoreURL(cl.getOptionValue("keystore")); } if (cl.hasOption("keystorepw")) { dcmgpwl.setKeyStorePassword(cl.getOptionValue("keystorepw")); } if (cl.hasOption("keypw")) { dcmgpwl.setKeyPassword(cl.getOptionValue("keypw")); } if (cl.hasOption("truststore")) { dcmgpwl.setTrustStoreURL(cl.getOptionValue("truststore")); } if (cl.hasOption("truststorepw")) { dcmgpwl.setTrustStorePassword(cl.getOptionValue("truststorepw")); } long t1 = System.currentTimeMillis(); try { dcmgpwl.initTLS(); } catch (Exception e) { System.err.println("ERROR: Failed to initialize TLS context:" + e.getMessage()); System.exit(2); } long t2 = System.currentTimeMillis(); System.out.println("Initialize TLS context in " + ((t2 - t1) / 1000F) + "s"); } long t1 = System.currentTimeMillis(); try { dcmgpwl.open(); } catch (Exception e) { System.err.println("ERROR: Failed to establish association:"); e.printStackTrace(System.err); System.exit(2); } long t2 = System.currentTimeMillis(); System.out.println("Connected to " + remoteAE + " in " + ((t2 - t1) / 1000F) + "s"); try { if (cl.hasOption("action")) { dcmgpwl.action(cl.getOptionValues("action")[0]); long t3 = System.currentTimeMillis(); System.out.println("Modified GP-SPS in " + ((t3 - t2) / 1000F) + "s"); } else if (cl.hasOption("createpps")) { dcmgpwl.createpps(cl.getOptionValue("createpps")); long t3 = System.currentTimeMillis(); System.out.println("Create GP-PPS in " + ((t3 - t2) / 1000F) + "s"); } else if (cl.hasOption("setpps")) { dcmgpwl.setpps(cl.getOptionValue("setpps")); long t3 = System.currentTimeMillis(); System.out.println("Update GP-PPS in " + ((t3 - t2) / 1000F) + "s"); } else { int n = dcmgpwl.query(); long t3 = System.currentTimeMillis(); System.out.println("Received " + n + " matching entries in " + ((t3 - t2) / 1000F) + "s"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { dcmgpwl.close(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Released connection to " + remoteAE); }
From source file:org.dcm4che2.tool.dcmgpwl.DcmGPWL.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*from w w w . ja v a 2s. co m*/ OptionBuilder.withDescription("set device name, use DCMGPWL by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET and local address of local Application Entity, use " + "device name and pick up any valid local address to bind the " + "socket by default"); opts.addOption(OptionBuilder.create("L")); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_1.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); opts.addOption("metasop", false, "offer General Purpose Worklist Management Meta SOP Class."); opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax."); opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching."); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, pack command and data " + "PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("status"); OptionBuilder.hasArg(); OptionBuilder.withDescription("match/set GP-SPS/GP-PPS to specified <status>"); opts.addOption(OptionBuilder.create("status")); OptionBuilder.withArgName("iuid:tuid"); OptionBuilder.hasArgs(2); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription( "modify status of GP-SPS with SOP Instance UID <iuid> " + "using Transaction UID <tuid>."); opts.addOption(OptionBuilder.create("action")); OptionBuilder.withArgName("iuid"); OptionBuilder.hasArg(); OptionBuilder.withDescription("create GP-PPS with SOP Instance UID <iuid>."); opts.addOption(OptionBuilder.create("createpps")); OptionBuilder.withArgName("aet"); OptionBuilder.hasArg(); OptionBuilder.withDescription("retrieve AET used in SOP references in Output Information" + "Sequence in created or updated GP-PPS."); opts.addOption(OptionBuilder.create("retrieve")); OptionBuilder.withArgName("iuid"); OptionBuilder.hasArg(); OptionBuilder.withDescription("update GP-PPS with SOP Instance UID <iuid>."); opts.addOption(OptionBuilder.create("setpps")); OptionBuilder.withArgName("iuid:tuid"); OptionBuilder.hasArgs(2); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription( "reference GP-SPS with SOP Instance UID <iuid> and " + "Transaction UID <tuid> in created GP-PPS."); opts.addOption(OptionBuilder.create("refsps")); OptionBuilder.withArgName("attr=value"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription("specify matching key or PPS attribute. attr can be specified " + "by name or tag value (in hex), e.g. PatientName or 00100010."); opts.addOption(OptionBuilder.create("A")); OptionBuilder.withArgName("datetime"); OptionBuilder.hasArg(); OptionBuilder.withDescription("specify matching SPS start datetime (range)"); opts.addOption(OptionBuilder.create("D")); OptionBuilder.withArgName("attr=value"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription("specify matching Referenced Request key or PPS attribute. " + "attr can be specified by name or tag value (in hex)"); opts.addOption(OptionBuilder.create("rqA")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Workitem Code"); opts.addOption(OptionBuilder.create("workitem")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Processing Application Code"); opts.addOption(OptionBuilder.create("application")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Station Name Code"); opts.addOption(OptionBuilder.create("station")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Station Class Code"); opts.addOption(OptionBuilder.create("class")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Station Geographic Location Code"); opts.addOption(OptionBuilder.create("location")); OptionBuilder.withArgName("code:scheme:[name]"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify matching Scheduled Human Performer Code"); opts.addOption(OptionBuilder.create("performer")); OptionBuilder.withArgName("code:scheme:name"); OptionBuilder.hasArgs(3); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription("specify Actual Human Performer Code"); opts.addOption(OptionBuilder.create("perfcode")); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("specify Actual Human Performer Name"); opts.addOption(OptionBuilder.create("perfname")); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("specify Actual Human Performer Organisation"); opts.addOption(OptionBuilder.create("perforg")); OptionBuilder.withArgName("num"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "cancel query after receive of specified number of responses, " + "no cancel by default"); opts.addOption(OptionBuilder.create("C")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store query results in DICOM files in directory <dir>."); opts.addOption(OptionBuilder.create("o")); opts.addOption("lowprior", false, "LOW priority of the C-FIND operation, MEDIUM by default"); opts.addOption("highprior", false, "HIGH priority of the C-FIND operation, MEDIUM by default"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmgpwl: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmGPWL.class.getPackage(); System.out.println("dcmgpwl v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }