protected NodeRef createEnvRepository(String site, String envRepoName) {
   PersistenceManagerService persistenceManagerService =
       getServicesManager().getService(PersistenceManagerService.class);
   String siteRoot = SITE_ENVIRONMENT_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
   siteRoot = siteRoot.replaceAll(ENVIRONMENT_REPLACEMENT_PATTERN, "");
   NodeRef siteRootNode = persistenceManagerService.getNodeRef(siteRoot);
   NodeRef result = persistenceManagerService.createNewFolder(siteRootNode, envRepoName);
   return result;
 }
  protected NodeRef createLiveRepositoryCopy(
      NodeRef liveRepoRoot, String relativePath, NodeRef nodeRef) {
    logger.debug("[PUBLISHING POST PROCESSOR] creating live repository copy of " + relativePath);
    PersistenceManagerService persistenceManagerService =
        getServicesManager().getService(PersistenceManagerService.class);
    NodeRef result = null;

    String[] pathSegments = relativePath.split("/");
    NodeRef helperNode = liveRepoRoot;
    NodeRef parent = null;
    for (int i = 0; i < pathSegments.length - 1; i++) {
      if (!"".equals(pathSegments[i])) {
        parent = helperNode;
        helperNode =
            persistenceManagerService.getChildByName(
                helperNode, ContentModel.ASSOC_CONTAINS, pathSegments[i]);
        if (helperNode == null) {
          logger.debug("[WORKFLOW] creating a node with name: " + pathSegments[i]);
          Map<QName, Serializable> properties = new FastMap<QName, Serializable>();
          properties.put(ContentModel.PROP_NAME, pathSegments[i]);
          helperNode =
              persistenceManagerService.createNewFolder(parent, pathSegments[i], properties);
        }
      }
    }
    String nodeName =
        (String) persistenceManagerService.getProperty(nodeRef, ContentModel.PROP_NAME);
    QName assocQName =
        QName.createQName(
            ContentModel.TYPE_CONTENT.getNamespaceURI(), QName.createValidLocalName(nodeName));
    result =
        persistenceManagerService.copy(
            nodeRef, helperNode, ContentModel.ASSOC_CONTAINS, assocQName);
    persistenceManagerService.setProperty(result, ContentModel.PROP_NAME, nodeName);
    return result;
  }