@@ -97,15 +97,15 @@ public static void main(String[] args) throws SQLException {
9797 options .addOption ("h" , "help" , false , "Help" );
9898 options .addOption ("d" , "duration" , true , "Checking duration" );
9999 options .addOption ("c" , "count" , true , "Check count" );
100- options .addOption ("a " , "handle" , true , "Specify a handle to check" );
100+ options .addOption ("i " , "handle" , true , "Specify a handle to check" );
101101 options .addOption ("v" , "verbose" , false , "Report all processing" );
102102
103103 Option option ;
104104
105105 option = Option .builder ("b" )
106106 .longOpt ("bitstream-ids" )
107107 .hasArgs ()
108- .desc ("Space separated list of bitstream ids " )
108+ .desc ("Space separated list of bitstream UUIDs " )
109109 .build ();
110110 options .addOption (option );
111111
@@ -131,6 +131,17 @@ public static void main(String[] args) throws SQLException {
131131 try {
132132 context = new Context ();
133133
134+ int mutuallyExclusiveOpts = 0 ;
135+ for (char c : new char []{'l' , 'L' , 'd' , 'b' , 'i' ,'c' }) {
136+ if (line .hasOption (c )) {
137+ mutuallyExclusiveOpts ++;
138+ }
139+ }
140+ if (mutuallyExclusiveOpts > 1 ) {
141+ System .err .println ("Please use only one option of -l, -L, -d, -b, -i, or -c" );
142+ LOG .error ("Please use only one option of -l, -L, -d, -b, -i, or -c" );
143+ System .exit (1 );
144+ }
134145
135146 // Prune stage
136147 if (line .hasOption ('p' )) {
@@ -168,20 +179,22 @@ public static void main(String[] args) throws SQLException {
168179 bitstreams .add (bitstreamService .find (context , UUID .fromString (ids [i ])));
169180 } catch (NumberFormatException nfe ) {
170181 System .err .println ("The following argument: " + ids [i ]
171- + " is not an integer " );
182+ + " is not an UUID " );
172183 System .exit (0 );
173184 }
174185 }
175186 dispatcher = new IteratorDispatcher (bitstreams .iterator ());
176- } else if (line .hasOption ('a ' )) {
177- dispatcher = new HandleDispatcher (context , line .getOptionValue ('a ' ));
187+ } else if (line .hasOption ('i ' )) {
188+ dispatcher = new HandleDispatcher (context , line .getOptionValue ('i ' ));
178189 } else if (line .hasOption ('d' )) {
179190 // run checker process for specified duration
180191 try {
181192 dispatcher = new LimitedDurationDispatcher (
182193 new SimpleDispatcher (context , processStart , true ), Instant .ofEpochMilli (
183194 Instant .now ().toEpochMilli () + Utils .parseDuration (line .getOptionValue ('d' ))));
184195 } catch (Exception e ) {
196+ System .err .println ("Couldn't parse " + line .getOptionValue ('d' )
197+ + " as a duration" );
185198 LOG .fatal ("Couldn't parse " + line .getOptionValue ('d' )
186199 + " as a duration: " , e );
187200 System .exit (0 );
@@ -225,18 +238,24 @@ public static void main(String[] args) throws SQLException {
225238 private static void printHelp (Options options ) {
226239 HelpFormatter myhelp = new HelpFormatter ();
227240
228- myhelp .printHelp ("Checksum Checker\n " , options );
229- System .out .println ("\n Specify a duration for checker process, using s(seconds),"
230- + "m(minutes), or h(hours): ChecksumChecker -d 30s"
231- + " OR ChecksumChecker -d 30m"
232- + " OR ChecksumChecker -d 2h" );
233- System .out .println ("\n Specify bitstream IDs: ChecksumChecker -b 13 15 17 20" );
234- System .out .println ("\n Loop once through all bitstreams: "
235- + "ChecksumChecker -l" );
236- System .out .println ("\n Loop continuously through all bitstreams: ChecksumChecker -L" );
237- System .out .println ("\n Check a defined number of bitstreams: ChecksumChecker -c 10" );
238- System .out .println ("\n Report all processing (verbose)(default reports only errors): ChecksumChecker -v" );
239- System .out .println ("\n Default (no arguments) is equivalent to '-c 1'" );
241+ myhelp .printHelp ("checker\n " , options );
242+ System .out .println ("\n Checksum Checker usage examples:" );
243+ System .out .println ("\n The following options are mutually exclusive:" );
244+ System .out .println (" - Specify a duration for checker process, using s(seconds),"
245+ + "m(minutes), or h(hours): checker -d 30s"
246+ + " OR checker -d 30m"
247+ + " OR checker -d 2h" );
248+ System .out .println (" - Specify bitstream UUIDs: checker -b 550e8400-e29b-41d4-a716-446655440000"
249+ + " f3f2e850-b5d4-11ef-ac7e-96584d5248b2" );
250+ System .out .println (" - Specify handle: checker -i 12345/100" );
251+ System .out .println (" - Loop once through all bitstreams: "
252+ + "checker -l" );
253+ System .out .println (" - Loop continuously through all bitstreams: checker -L" );
254+ System .out .println (" - Check a defined number of bitstreams: checker -c 10" );
255+ System .out .println ("\n The following options can be used in combination with others above:" );
256+ System .out .println (" - Report all processing to checker.log (by default logs only errors): checker -v" );
257+ System .out .println (" - Prune old results from the database: checker -p" );
258+ System .out .println ("\n Default (no arguments) is equivalent to 'checker -c 1'\n " );
240259 System .exit (0 );
241260 }
242261
0 commit comments