Search in sources :

Example 6 with ContentProcessException

use of org.craftercms.studio.api.v1.exception.ContentProcessException in project studio by craftercms.

the class ProcessContentExecutorImpl method processContent.

@Override
public ResultTO processContent(String id, InputStream input, boolean isXml, Map<String, String> params, String chainName) throws ServiceLayerException {
    final ContentProcessorPipeline chain = processorChains.get(chainName);
    try {
        if (chain != null) {
            if (StringUtils.isEmpty(params.get(DmConstants.KEY_USER))) {
                String user = securityService.getCurrentUser();
                params.put(DmConstants.KEY_USER, user);
            }
            final ResultTO result = new ResultTO();
            try {
                final PipelineContent content = new PipelineContentImpl(id, input, isXml, null, StudioConstants.CONTENT_ENCODING, params);
                chain.processContent(content, result);
            } catch (ContentProcessException e) {
                logger.error("Error in chain for write content", e);
                throw e;
            } catch (RuntimeException e) {
                logger.error("Error in chain for write content", e);
                throw e;
            } finally {
                ContentUtils.release(input);
            }
            return result;
        } else {
            ContentUtils.release(input);
            throw new ServiceLayerException(chainName + " is not defined.");
        }
    } finally {
        String s = params.get(DmConstants.KEY_USER);
    // AuthenticationUtil.setFullyAuthenticatedUser(s);
    }
}
Also used : ContentProcessException(org.craftercms.studio.api.v1.exception.ContentProcessException) PipelineContentImpl(org.craftercms.studio.impl.v1.content.pipeline.PipelineContentImpl) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) PipelineContent(org.craftercms.studio.api.v1.content.pipeline.PipelineContent) ContentProcessorPipeline(org.craftercms.studio.api.v1.content.pipeline.ContentProcessorPipeline) ResultTO(org.craftercms.studio.api.v1.to.ResultTO)

Example 7 with ContentProcessException

use of org.craftercms.studio.api.v1.exception.ContentProcessException in project studio by craftercms.

the class ExtractAssetDependencyProcessor method process.

public void process(PipelineContent content, ResultTO result) throws ContentProcessException {
    String site = content.getProperty(DmConstants.KEY_SITE);
    String folderPath = content.getProperty(DmConstants.KEY_FOLDER_PATH);
    String fileName = content.getProperty(DmConstants.KEY_FILE_NAME);
    String path = (folderPath.endsWith(FILE_SEPARATOR)) ? folderPath + fileName : folderPath + FILE_SEPARATOR + fileName;
    try {
        dependencyService.upsertDependencies(site, path);
    } catch (ServiceLayerException e) {
        throw new ContentProcessException(e);
    }
}
Also used : ContentProcessException(org.craftercms.studio.api.v1.exception.ContentProcessException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Aggregations

ContentProcessException (org.craftercms.studio.api.v1.exception.ContentProcessException)6 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ContentAssetInfoTO (org.craftercms.studio.api.v1.to.ContentAssetInfoTO)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MimetypesFileTypeMap (javax.activation.MimetypesFileTypeMap)1 ContentProcessorPipeline (org.craftercms.studio.api.v1.content.pipeline.ContentProcessorPipeline)1 PipelineContent (org.craftercms.studio.api.v1.content.pipeline.PipelineContent)1 ResultTO (org.craftercms.studio.api.v1.to.ResultTO)1 PipelineContentImpl (org.craftercms.studio.impl.v1.content.pipeline.PipelineContentImpl)1 DocumentException (org.dom4j.DocumentException)1 SAXReader (org.dom4j.io.SAXReader)1 SAXException (org.xml.sax.SAXException)1