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 |
|
|
13 |
|
|
14 |
|
|
15 |
|
public final class LocationStore extends AdminStore { |
16 |
|
|
17 |
|
public LocationStore(WorkingContext workingContext) { |
18 |
62 |
super(workingContext); |
19 |
62 |
} |
20 |
|
|
21 |
|
public LocationStore (WorkingContext workingContext, String moduleName, Location location) { |
22 |
448 |
super(workingContext, moduleName, location); |
23 |
510 |
} |
24 |
|
|
25 |
|
public final Module getModule() { |
26 |
|
|
27 |
496 |
if (module != null) { |
28 |
0 |
return module; |
29 |
|
} |
30 |
|
|
31 |
496 |
if (getModuleName() == null || "".equals(getModuleName())) { |
32 |
62 |
throw new KarmaRuntimeException("Module name for location store has not been set (correctly)."); |
33 |
|
} |
34 |
62 |
|
35 |
|
|
36 |
|
|
37 |
434 |
String name = getModuleName(); |
38 |
434 |
while (name.endsWith(File.separator)) { |
39 |
0 |
name.substring(0, name.length()); |
40 |
|
} |
41 |
434 |
if (name.lastIndexOf(File.separator) > 0) { |
42 |
0 |
name = name.substring(name.lastIndexOf(File.separator) + 1); |
43 |
|
} |
44 |
|
|
45 |
434 |
module = new LocationModule(name, getLocation()); |
46 |
434 |
module.setBaseDir(new File(getWorkingContext().getLocationStoreBasedir(), getModuleName())); |
47 |
|
|
48 |
434 |
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 |
|
} |