View Javadoc

1   /*
2    * Copyright (c) 2004 Your Corporation. All Rights Reserved.
3    */
4   package nl.toolforge.karma.core.boot;
5   
6   import nl.toolforge.karma.core.KarmaRuntimeException;
7   import nl.toolforge.karma.core.location.Location;
8   import nl.toolforge.karma.core.module.BaseModule;
9   import nl.toolforge.karma.core.module.Module;
10  import nl.toolforge.karma.core.module.template.ModuleLayoutTemplate;
11  import nl.toolforge.karma.core.vc.AuthenticationException;
12  import nl.toolforge.karma.core.vc.Runner;
13  import nl.toolforge.karma.core.vc.RunnerFactory;
14  import nl.toolforge.karma.core.vc.VersionControlException;
15  
16  import java.io.File;
17  import java.util.ArrayList;
18  import java.util.List;
19  
20  /***
21   * Class representing the manifest store for a working context. A manifest store contains module(s) which - in turn -
22   * contain manifest files (albeit in
23   *
24   * @author D.A. Smedes
25   * @version $Id: ManifestStore.java,v 1.8 2004/11/12 14:15:20 asmedes Exp $
26   *
27   * @since Karma 1.0
28   */
29  public final class ManifestStore extends AdminStore {
30  
31    public ManifestStore(WorkingContext workingContext) {
32      super(workingContext);
33    }
34  
35    public ManifestStore(WorkingContext workingContext, String moduleName, Location location) {
36      super(workingContext, moduleName, location);
37    }
38  
39    /***
40     *
41     * @return
42     */
43    public List getManifestFiles() {
44      return new ArrayList();
45    }
46  
47    public final Module getModule() {
48  
49      if (module != null) {
50        return module;
51      }
52  
53      if (getModuleName() == null || "".equals(getModuleName())) {
54        throw new KarmaRuntimeException("Module name for manifest store has not been set (correctly).");
55      }
56  
57      // Names for stores can contain an offset.
58      //
59      String name = getModuleName();
60      while (name.endsWith(File.separator)) {
61        name.substring(0, name.length());
62      }
63      if (name.lastIndexOf(File.separator) > 0) {
64        name = name.substring(name.lastIndexOf(File.separator) + 1);
65      }
66  
67      module = new ManifestModule(name, getLocation());
68      module.setBaseDir(new File(getWorkingContext().getManifestStoreBasedir(), getModuleName()));
69  
70      return module;
71    }
72  
73    /***
74     * Commits the manifest file identified by <code>releaseName</code> to the repository. The file
75     *
76     * @param releaseName The name of the release that should be committed.
77     * @throws AuthenticationException
78     * @throws VersionControlException
79     */
80    public void commit(String releaseName) throws AuthenticationException, VersionControlException {
81  
82      File file = new File(module.getBaseDir(), releaseName + ".xml");
83  
84      Runner runner = RunnerFactory.getRunner(getLocation());
85      runner.commit(file);
86    }
87  
88    protected class ManifestModule extends BaseModule {
89  
90      public ManifestModule(String name, Location location) {
91        super(name, location);
92      }
93  
94      public ModuleLayoutTemplate getLayoutTemplate() {
95        return null;
96      }
97  
98    }
99  
100 }