@Override public boolean isFolder(String site, String path) { boolean toRet = false; PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); String rootPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site); NodeRef nodeRef = persistenceManagerService.getNodeRef(rootPath, path); if (nodeRef != null) { FileInfo fileInfo = persistenceManagerService.getFileInfo(nodeRef); toRet = fileInfo.isFolder(); } return toRet; }
/** * get document from wcm content * * @param path * @return document * @throws ServiceException */ public InputStream getContent(String path) { InputStream retStream = null; PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); NodeRef nodeRef = persistenceManagerService.getNodeRef(path); if (nodeRef != null) { FileInfo fileInfo = persistenceManagerService.getFileInfo(nodeRef); if (fileInfo.isFolder()) { logger.info(MSG_CONTENT_FOR_FOLDER_REQUESTED, path); } else { ContentReader reader = persistenceManagerService.getReader(nodeRef); retStream = reader.getContentInputStream(); } } else { logger.info(MSG_NODE_REF_IS_NULL_FOR_PATH, path); } return retStream; }
@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); } }