Beispiel #1
0
  /**
   * Constructor
   *
   * @param name Name of the project
   * @param basedir the base directory for the Depot
   */
  public FrameworkProject(
      final String name, final File basedir, final IFrameworkProjectMgr resourceMgr) {
    super(name, basedir, resourceMgr);
    projectResourceMgr = resourceMgr;
    resourcesBaseDir = new File(getBaseDir(), "resources");
    etcDir = new File(getBaseDir(), ETC_DIR_NAME);
    if (!etcDir.exists()) {
      if (!etcDir.mkdirs()) {
        throw new FrameworkResourceException(
            "error while creating project structure. "
                + "failed creating directory: "
                + etcDir.getAbsolutePath(),
            this);
      }
    }

    if (!(new File(getEtcDir(), PROP_FILENAME).exists())) {
      generateProjectPropertiesFile(false);
    }
    final Properties ownProps = new Properties();
    ownProps.setProperty("project.name", name);
    final File fwkDepotPropertyFile =
        new File(projectResourceMgr.getFramework().getConfigDir(), PROP_FILENAME);
    final Properties nodeWideDepotProps = PropertyLookup.fetchProperties(fwkDepotPropertyFile);
    nodeWideDepotProps.putAll(ownProps);
    propertyFile = new File(getEtcDir(), PROP_FILENAME);
    if (propertyFile.exists()) {
      lookup =
          PropertyLookup.create(
              propertyFile,
              nodeWideDepotProps,
              projectResourceMgr.getFramework().getPropertyLookup());
      getLogger().debug("loading existing project.properties: " + propertyFile.getAbsolutePath());

    } else {
      lookup =
          PropertyLookup.create(
              fwkDepotPropertyFile,
              ownProps,
              projectResourceMgr.getFramework().getPropertyLookup());
      getLogger()
          .debug("loading instance-level project.properties: " + propertyFile.getAbsolutePath());
    }
    lookup.expand();

    final String resfilepath = getNodesResourceFilePath();
    File resfile = new File(resfilepath);
    if (!resfile.isFile() && shouldUpdateNodesResourceFile()) {
      try {
        updateNodesResourceFile();
      } catch (UpdateUtils.UpdateException e) {
        getLogger().error("Unable to retrieve resources file: " + e.getMessage());
      }
    } else if (!resfile.isFile()) {
      generateResourcesFile(resfile);
    }
    initialize();
  }
Beispiel #2
0
 public boolean hasProperty(final String key) {
   return lookup.hasProperty(key);
 }
Beispiel #3
0
 /**
  * Return the property value by name
  *
  * @param name
  * @return
  */
 public String getProperty(final String name) {
   return lookup.getProperty(name);
 }