comparison src/org/dancres/blitz/tools/ReconfigLookup.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.tools;
2
3 import org.dancres.blitz.remote.LookupStorage;
4 import org.dancres.blitz.config.ConfigurationFactory;
5 import org.dancres.blitz.disk.Disk;
6
7 /**
8 * Reimport specified lookup data from specified configuration
9 */
10 public class ReconfigLookup {
11 private static String[] OPTIONS =
12 new String[] {"-attrs", "-locators", "-groups"};
13
14 private static byte[] FLAGS =
15 new byte[] {LookupStorage.INIT_ATTRS, LookupStorage.INIT_LOCATORS,
16 LookupStorage.INIT_GROUPS};
17
18 public static void main(String anArgs[]) throws Exception {
19 if (anArgs.length < 2) {
20 System.err.println(
21 "Usage: blitz_config_URL [-attrs | -locators | -groups]+ ");
22 }
23
24 String[] myURL = new String[] {anArgs[0]};
25 byte myFlags = 0;
26
27 for (int i = 1; i < anArgs.length; i++) {
28 myFlags = (byte) (myFlags | convert(anArgs[i]));
29 }
30
31 ConfigurationFactory.setup(myURL);
32
33 Disk.init();
34
35 LookupStorage myStorage = new LookupStorage();
36 myStorage.reinit(ConfigurationFactory.getConfig(), myFlags);
37 myStorage.saveState();
38
39 Disk.sync();
40 Disk.stop();
41 }
42
43 private static byte convert(String anOption)
44 throws IllegalArgumentException {
45
46 for (int i = 0; i < OPTIONS.length; i++) {
47 if (OPTIONS[i].equals(anOption))
48 return FLAGS[i];
49 }
50
51 throw new IllegalArgumentException("Invalid option: " + anOption);
52 }
53 }