public MimeTypeUploadPlugin(InitParams initParams, ConfigurationManager configurationService) throws Exception { ValueParam param = initParams.getValueParam(MIMETYPE_PATH); URL filePath = configurationService.getURL(param.getValue()); URLConnection connection = filePath.openConnection(); mimeTypes.load(connection.getInputStream()); param = initParams.getValueParam(DEFAULT_MIMETYPE); if (param != null) mimetypeDefault = param.getValue(); }
public static String sanitize(String value) { try { cservice_ = WCMCoreUtils.getService(ConfigurationManager.class); InputStream in = cservice_.getInputStream(POLICY_FILE_LOCATION); Policy policy = Policy.getInstance(in); AntiSamy as = new AntiSamy(); CleanResults cr = as.scan(value, policy); value = cr.getCleanHTML(); return value; } catch (Exception ex) { return value; } }
private void addTemplate(TemplateConfig tempObject, Session session, String warViewPath) throws Exception { String type = tempObject.getTemplateType(); String alias = ""; if (type.equals(ECM_EXPLORER_TEMPLATE)) { alias = BasePath.ECM_EXPLORER_TEMPLATES; } String templateHomePath = nodeHierarchyCreator_.getJcrPath(alias); Node templateHomeNode = (Node) session.getItem(templateHomePath); String templateName = tempObject.getName(); if (templateHomeNode.hasNode(templateName) || Utils.getAllEditedConfiguredData( this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS_TEMPLATES, true) .contains(templateName)) return; String warPath = warViewPath + tempObject.getWarPath(); InputStream in = cservice_.getInputStream(warPath); templateService.createTemplate( templateHomeNode, templateName, templateName, in, new String[] {"*"}); configuredTemplate_.add(templateName); Utils.addEditedConfiguredData( templateName, this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS_TEMPLATES, true); }
/* * (non-Javadoc) * @see * org.exoplatform.services.wcm.portal.artifacts.BasePortalArtifactsPlugin * #deployToPortal(java.lang.String, * org.exoplatform.services.jcr.ext.common.SessionProvider) */ public void deployToPortal(SessionProvider sessionProvider, String portalName) throws Exception { Iterator iterator = initParams.getObjectParamIterator(); DeploymentDescriptor deploymentDescriptor = null; try { while (iterator.hasNext()) { ObjectParameter objectParameter = (ObjectParameter) iterator.next(); deploymentDescriptor = (DeploymentDescriptor) objectParameter.getObject(); Boolean cleanupPublication = deploymentDescriptor.getCleanupPublication(); String sourcePath = deploymentDescriptor.getSourcePath(); String versionHistoryPath = deploymentDescriptor.getVersionHistoryPath(); // sourcePath should start with: war:/, jar:/, classpath:/, file:/ String xmlData = (String) artifactsCache.get(sourcePath); if (xmlData == null) { InputStream stream = configurationManager.getInputStream(sourcePath); xmlData = IOUtil.getStreamContentAsString(stream); artifactsCache.put(sourcePath, xmlData); } ManageableRepository repository = repositoryService.getCurrentRepository(); Session session = sessionProvider.getSession(deploymentDescriptor.getTarget().getWorkspace(), repository); String targetPath = deploymentDescriptor.getTarget().getNodePath(); String realTargetFolder = StringUtils.replace(targetPath, "{portalName}", portalName); InputStream inputStream = configurationManager.getInputStream(sourcePath); session.importXML(realTargetFolder, inputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); if (cleanupPublication) { /** * This code allows to cleanup the publication lifecycle in the target folder after * importing the data. By using this, the publication live revision property will be * re-initialized and the content will be set as published directly. Thus, the content * will be visible in front side. */ QueryManager manager = session.getWorkspace().getQueryManager(); String statement = "select * from nt:base where jcr:path LIKE '" + realTargetFolder + "/%'"; Query query = manager.createQuery(statement.toString(), Query.SQL); NodeIterator iter = query.execute().getNodes(); while (iter.hasNext()) { Node node = iter.nextNode(); if (node.hasProperty("publication:liveRevision") && node.hasProperty("publication:currentState")) { if (LOG.isInfoEnabled()) { LOG.info("\"" + node.getName() + "\" publication lifecycle has been cleaned up"); } node.setProperty("publication:liveRevision", ""); node.setProperty("publication:currentState", "published"); } } } if (versionHistoryPath != null && versionHistoryPath.length() > 0) { // process import version history Node currentNode = (Node) session.getItem(deploymentDescriptor.getTarget().getNodePath()); Map<String, String> mapHistoryValue = Utils.getMapImportHistory(configurationManager.getInputStream(versionHistoryPath)); Utils.processImportHistory( currentNode, configurationManager.getInputStream(versionHistoryPath), mapHistoryValue); } session.save(); } Node portalNode = livePortalManagerService.getLivePortal(sessionProvider, portalName); configure(portalNode, portalName); portalNode.getSession().save(); } catch (Exception ex) { if (LOG.isErrorEnabled()) { LOG.error( "deploy the portal " + portalName + " from " + deploymentDescriptor.getSourcePath() + " into " + StringUtils.replace( deploymentDescriptor.getTarget().getNodePath(), "{portalName}", portalName) + " is FAILURE at " + new Date().toString() + "\n", ex); } throw ex; } }