@Override public String getOldPath(String site, String path) { PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); NodeRef nodeRef = persistenceManagerService.getNodeRef( SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site), path); if (nodeRef != null) { if (persistenceManagerService.hasAspect(nodeRef, CStudioContentModel.ASPECT_RENAMED)) { String oldPath = DefaultTypeConverter.INSTANCE.convert( String.class, persistenceManagerService.getProperty( nodeRef, CStudioContentModel.PROP_RENAMED_OLD_URL)); return oldPath; } } return null; }
@Override public String getFilename(String site, String path) { if (path != null && !path.isEmpty()) { PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); NodeRef nodeRef = persistenceManagerService.getNodeRef( SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site), path); if (nodeRef != null) { return DefaultTypeConverter.INSTANCE.convert( String.class, persistenceManagerService.getProperty(nodeRef, ContentModel.PROP_NAME)); } else { int idx = path.lastIndexOf("/"); if (idx > 0) { return path.substring(idx + 1); } else { return path; } } } else { return ""; } }
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; }
@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); } }