@Override
 public void clearRenamed(String site, String path) {
   String fullPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
   fullPath = fullPath + path;
   PersistenceManagerService persistenceManagerService =
       _servicesManager.getService(PersistenceManagerService.class);
   NodeRef nodeRef = persistenceManagerService.getNodeRef(fullPath);
   if (nodeRef != null) {
     persistenceManagerService.removeAspect(fullPath, CStudioContentModel.ASPECT_RENAMED);
     Map<QName, Serializable> props = persistenceManagerService.getProperties(nodeRef);
     props.remove(CStudioContentModel.PROP_RENAMED_OLD_URL);
     persistenceManagerService.setProperties(nodeRef, props);
   }
 }
  @Override
  public InputStream getMetadataStream(String site, String path) {
    PersistenceManagerService persistenceManagerService =
        _servicesManager.getService(PersistenceManagerService.class);
    NodeRef nodeRef =
        persistenceManagerService.getNodeRef(
            SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site), path);
    Map<QName, Serializable> contentProperties = persistenceManagerService.getProperties(nodeRef);
    Document metadataDoc = DocumentHelper.createDocument();
    Element root = metadataDoc.addElement("metadata");
    for (Map.Entry<QName, Serializable> property : contentProperties.entrySet()) {
      Element elem = root.addElement(property.getKey().getLocalName());
      elem.addText(String.valueOf(property.getValue()));
    }

    return IOUtils.toInputStream(metadataDoc.asXML());
  }
  @Override
  public void copyToEnvironment(String site, String environment, String path)
      throws DeploymentException {
    ServicesConfig servicesConfig = getServicesManager().getService(ServicesConfig.class);
    PersistenceManagerService persistenceManagerService =
        getServicesManager().getService(PersistenceManagerService.class);
    String siteRepoRootPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);

    String envRepoPath = SITE_ENVIRONMENT_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
    envRepoPath = envRepoPath.replaceAll(ENVIRONMENT_REPLACEMENT_PATTERN, environment);

    NodeRef envRepoRoot = persistenceManagerService.getNodeRef(envRepoPath);

    NodeRef envNode = persistenceManagerService.getNodeRef(envRepoRoot, path);
    NodeRef nodeRef = persistenceManagerService.getNodeRef(siteRepoRootPath, path);
    if (nodeRef != null) {
      if (envNode == null) {
        envNode = createLiveRepositoryCopy(envRepoRoot, path, nodeRef);
      } else {
        FileInfo envNodeInfo = persistenceManagerService.getFileInfo(envNode);
        if (envNodeInfo.isFolder()) {
          Map<QName, Serializable> copyNodeProps = persistenceManagerService.getProperties(nodeRef);
          copyNodeProps.put(ContentModel.PROP_NAME, envNodeInfo.getName());
          persistenceManagerService.setProperties(envNode, copyNodeProps);
        } else {
          persistenceManagerService.copy(nodeRef, envNode);
        }
      }
      Serializable sendEmailValue =
          persistenceManagerService.getProperty(
              nodeRef, CStudioContentModel.PROP_WEB_WF_SEND_EMAIL);
      boolean sendEmail = (sendEmailValue != null) && (Boolean) sendEmailValue;

      if (sendEmail) {
        Serializable submittedByValue =
            persistenceManagerService.getProperty(
                nodeRef, CStudioContentModel.PROP_WEB_WF_SUBMITTED_BY);
        String submittedBy = "";
        if (submittedByValue != null) {
          submittedBy = (String) submittedByValue;
        } else {
          logger.error("did not send approval notification as submitted by property is null");
          return;
        }
        // DmPathTO path = new DmPathTO(nodePath);
        String approver =
            (String)
                persistenceManagerService.getProperty(
                    nodeRef, CStudioContentModel.PROP_WEB_APPROVED_BY);
        NotificationService notificationService =
            getServicesManager().getService(NotificationService.class);
        notificationService.sendApprovalNotification(site, submittedBy, path, approver);
        /*
         * Remove this sendmail property as we are done sending email
         */
        persistenceManagerService.removeProperty(
            nodeRef, CStudioContentModel.PROP_WEB_WF_SEND_EMAIL);
      }

      Map<QName, Serializable> nodeProps = persistenceManagerService.getProperties(envNode);
      for (QName propName : DmConstants.SUBMITTED_PROPERTIES) {
        nodeProps.remove(propName);
      }
      persistenceManagerService.setProperties(envNode, nodeProps);

      nodeProps = persistenceManagerService.getProperties(nodeRef);
      for (QName propName : DmConstants.SUBMITTED_PROPERTIES) {
        nodeProps.remove(propName);
      }
      persistenceManagerService.setProperties(nodeRef, nodeProps);
    }
  }