/**
   * 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();
  }
  /**
   * Update the resources file given an input Nodes set
   *
   * @param source the source nodes
   * @throws UpdateUtils.UpdateException if an error occurs while trying to update the resources
   *     file or generate nodes
   */
  public void updateNodesResourceFile(final Nodes source) throws UpdateUtils.UpdateException {

    final Nodes.Format format;
    final String nodesResourceFilePath = getNodesResourceFilePath();
    if (nodesResourceFilePath.endsWith(".xml")) {
      format = Nodes.Format.resourcexml;
    } else if (nodesResourceFilePath.endsWith(".yaml")) {
      format = Nodes.Format.resourceyaml;
    } else {
      throw new UpdateUtils.UpdateException(
          "Unable to determine file format for file: " + nodesResourceFilePath);
    }
    File resfile = null;
    try {
      resfile = File.createTempFile("resource-temp", ".nodes");
      resfile.deleteOnExit();
    } catch (IOException e) {
      throw new UpdateUtils.UpdateException("Unable to create temp file: " + e.getMessage(), e);
    }
    // serialize nodes and replace the nodes resource file
    final NodesFileGenerator generator;
    if (Nodes.Format.resourcexml == format) {
      generator = new ResourceXMLGenerator(resfile);
    } else if (Nodes.Format.resourceyaml == format) {
      generator = new NodesYamlGenerator(resfile);
    } else {
      getLogger()
          .error(
              "Unable to generate resources file. Unrecognized extension for dest file: "
                  + resfile.getAbsolutePath());
      return;
    }
    generator.addNodes(source.listNodes());
    try {
      generator.generate();
    } catch (IOException e) {
      throw new UpdateUtils.UpdateException(
          "Unable to generate resources file: " + e.getMessage(), e);
    } catch (NodesGeneratorException e) {
      throw new UpdateUtils.UpdateException(
          "Unable to generate resources file: " + e.getMessage(), e);
    }

    updateNodesResourceFile(resfile);
    resfile.delete();
    getLogger().debug("generated resources file: " + resfile.getAbsolutePath());
  }