View Javadoc

1   package nl.toolforge.karma.core.boot;
2   
3   import nl.toolforge.karma.core.KarmaRuntimeException;
4   import nl.toolforge.karma.core.location.Location;
5   import nl.toolforge.karma.core.module.BaseModule;
6   import nl.toolforge.karma.core.module.Module;
7   import nl.toolforge.karma.core.module.template.ModuleLayoutTemplate;
8   
9   import java.io.File;
10  
11  /***
12   * @author D.A. Smedes
13   * @version $Id: LocationStore.java,v 1.6 2004/11/10 23:53:07 asmedes Exp $
14   */
15  public final class LocationStore extends AdminStore {
16  
17    public LocationStore(WorkingContext workingContext) {
18      super(workingContext);
19    }
20  
21    public LocationStore (WorkingContext workingContext, String moduleName, Location location) {
22      super(workingContext, moduleName, location);
23    }
24  
25    public final Module getModule() {
26  
27      if (module != null) {
28        return module;
29      }
30  
31      if (getModuleName() == null || "".equals(getModuleName())) {
32        throw new KarmaRuntimeException("Module name for location store has not been set (correctly).");
33      }
34  
35      // Names for stores can contain an offset.
36      //
37      String name = getModuleName();
38      while (name.endsWith(File.separator)) {
39        name.substring(0, name.length());
40      }
41      if (name.lastIndexOf(File.separator) > 0) {
42        name = name.substring(name.lastIndexOf(File.separator) + 1);
43      }
44  
45      module = new LocationModule(name, getLocation());
46      module.setBaseDir(new File(getWorkingContext().getLocationStoreBasedir(), getModuleName()));
47  
48      return module;
49    }
50  
51    protected class LocationModule extends BaseModule {
52  
53      public LocationModule(String name, Location location) {
54        super(name, location);
55      }
56  
57      public ModuleLayoutTemplate getLayoutTemplate() {
58        return null;
59      }
60    }
61  }