mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V4.0-BUG-FIX to HEAD
37121: ALF-12796: Ensure that only visible nodes are shown via Category search in Repository view when libraryRoot is changed from company home. 37124: ALF-14220: Parallel reviews now takes into account maximum percentage of approval rate possible when deciding to add new task 37128: Fixes: ALF-14322. Translation update from Gloria 37135: Fix for ALF-13993 It fails to find documents whose tag is longer than 255 characters - TAGS are truncated as QNAMES - default to 255. - TAGS longer then 255 characters can be created. - TAGS equal in the first 255 characters can not be created (as they would be treated as duplicates by search) 37181: Merged V3.4-BUG-FIX to V4.0-BUG-FIX Merge HEAD to V3.4-BUG-FIX 33880: ALF-12777 / ALF-14259: MMT should not install AMPs which override pre-existing files in the war file, unless -force is provided. The MMT is moving toward more of a validation phase (checks things, calculate changes) then an execution phase (makes the changes). 37192: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 37081: ALF-13054 Rule action "Transform and copy image" fails if transformation cannot be performed by transformer.ImageMagick - (Problem 3 only) - TransformerDebug is now issued from ContentService.isTransformable(...) and ImageTransformActionExecuter.doTransform(...) 37088: ALF-10217: Updated parse-args.lib.js to support sites having two parent nodes. 37143: Fixes: ALF-14322: Translation update from Gloria. 37145: ALF-14303 Alfresco crashes when viewing doclib / previewing - PDF with CMap Adding temporary workaround: Modified fail over transformers for PDF to PNG to be PDFRenderer, ImageMagick (new) and the PDFBox. If Ghostscript is installed on the server, ImageMagick will be able to perform the transformation. If not installed, it fails with an unsupported transformation and fails over to PDFBox as it does today and will encounter this issue if the supplied PDF. If this issues takes place, install Ghostscript. 37190: Merged PATCHES/V3.4.6 to V3.4-BUG-FIX 37189: ALF-13404: Performance: 'Content I'm Editing' dashlet is slow to render when there is lots of data/sites - Additional query improvement by Pavel 37191: ALF-13379: Fix IsImmutableProperty to react to locks again and stop unit test from confusing a lock with a checkout 37193: Merged V4.0 to V4.0-BUG-FIX 37070: ALF-14310: alfresco-enterprise-webeditor-4.0.2.zip fails with HTTP Status 500 - Due to more incomplete dependency updates 37146: (RECORD ONLY) ALF-13745: Merged V3.4-BUG-FIX (3.4.10) to V4.0 (4.0.2) 37145: ALF-14303 Alfresco crashes when viewing doclib / previewing - PDF with CMap Adding temporary workaround: Modified fail over transformers for PDF to PNG to be PDFRenderer, ImageMagick (new) and the PDFBox. If Ghostscript is installed on the server, ImageMagick will be able to perform the transformation. If not installed, it fails with an unsupported transformation and fails over to PDFBox as it does today and will encounter this issue if the supplied PDF. If this issues takes place, install Ghostscript. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37196 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -422,6 +422,9 @@
|
|||||||
<property name="imageMagickContentTransformer">
|
<property name="imageMagickContentTransformer">
|
||||||
<ref bean="transformer.ImageMagick" />
|
<ref bean="transformer.ImageMagick" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="transformerDebug">
|
||||||
|
<ref bean="transformerDebug" />
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="copy" class="org.alfresco.repo.action.executer.CopyActionExecuter" parent="action-executer">
|
<bean id="copy" class="org.alfresco.repo.action.executer.CopyActionExecuter" parent="action-executer">
|
||||||
|
@@ -328,6 +328,14 @@
|
|||||||
class="org.alfresco.repo.content.transform.PdfBoxPdfToImageContentTransformer"
|
class="org.alfresco.repo.content.transform.PdfBoxPdfToImageContentTransformer"
|
||||||
parent="unregisteredBaseContentTransformer" />
|
parent="unregisteredBaseContentTransformer" />
|
||||||
|
|
||||||
|
<bean id="failover.transformer.ImageMagick"
|
||||||
|
class="org.alfresco.repo.content.transform.ProxyContentTransformer"
|
||||||
|
parent="unregisteredBaseContentTransformer" >
|
||||||
|
<property name="worker">
|
||||||
|
<ref bean="transformer.worker.ImageMagick" />
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Content Transformations -->
|
<!-- Content Transformations -->
|
||||||
<bean id="transformer.StringExtracter"
|
<bean id="transformer.StringExtracter"
|
||||||
class="org.alfresco.repo.content.transform.StringExtractingContentTransformer"
|
class="org.alfresco.repo.content.transform.StringExtractingContentTransformer"
|
||||||
@@ -390,11 +398,12 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="transformer.PdfToImage"
|
<bean id="transformer.PdfToImage"
|
||||||
class="org.alfresco.repo.content.transform.FailoverContentTransformer"
|
class="org.alfresco.repo.content.transform.FailoverPdfToImageContentTransformer"
|
||||||
parent="baseContentTransformer" >
|
parent="baseContentTransformer" >
|
||||||
<property name="transformers">
|
<property name="transformers">
|
||||||
<list>
|
<list>
|
||||||
<ref bean="failover.transformer.PdfRenderer.PdfToImage"/>
|
<ref bean="failover.transformer.PdfRenderer.PdfToImage"/>
|
||||||
|
<ref bean="failover.transformer.ImageMagick"/>
|
||||||
<ref bean="failover.transformer.PdfBox.PdfToImage"/>
|
<ref bean="failover.transformer.PdfBox.PdfToImage"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -69,10 +69,13 @@ public abstract class AbstractVersioningProperty extends AbstractProperty
|
|||||||
return getServiceRegistry().getCheckOutCheckInService().isWorkingCopy(nodeRef);
|
return getServiceRegistry().getCheckOutCheckInService().isWorkingCopy(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isImmutable(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
return getServiceRegistry().getLockService().getLockType(nodeRef) == LockType.READ_ONLY_LOCK;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasWorkingCopy(NodeRef nodeRef)
|
public boolean hasWorkingCopy(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
final ServiceRegistry serviceRegistry = getServiceRegistry();
|
return isImmutable(nodeRef) && getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef) != null;
|
||||||
return serviceRegistry.getLockService().getLockType(nodeRef) == LockType.READ_ONLY_LOCK
|
|
||||||
&& serviceRegistry.getCheckOutCheckInService().getWorkingCopy(nodeRef) != null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -191,13 +191,13 @@ public class CMISPropertyServiceTest extends BaseCMISTest
|
|||||||
|
|
||||||
properties = cmisService.getProperties(content);
|
properties = cmisService.getProperties(content);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false);
|
||||||
assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL));
|
assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL));
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString());
|
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString());
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName());
|
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null);
|
||||||
assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null);
|
assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null);
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ public class IsImmutableProperty extends AbstractVersioningProperty
|
|||||||
}
|
}
|
||||||
if (getVersionSeries(nodeRef).equals(nodeRef))
|
if (getVersionSeries(nodeRef).equals(nodeRef))
|
||||||
{
|
{
|
||||||
return hasWorkingCopy(nodeRef);
|
return isImmutable(nodeRef);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
|||||||
import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
|
|
||||||
@@ -211,10 +212,14 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
TransformationOptions options = new TransformationOptions();
|
TransformationOptions options = new TransformationOptions();
|
||||||
options.setSourceNodeRef(textDocument);
|
options.setSourceNodeRef(textDocument);
|
||||||
|
|
||||||
if (contentService.isTransformable(contentReader, contentWriter, options))
|
try
|
||||||
{
|
{
|
||||||
contentService.transform(contentReader, contentWriter, options);
|
contentService.transform(contentReader, contentWriter, options);
|
||||||
}
|
}
|
||||||
|
catch (NoTransformerException e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
fileFolderService.delete(textDocument);
|
fileFolderService.delete(textDocument);
|
||||||
|
|
||||||
|
@@ -18,10 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.action.executer;
|
package org.alfresco.repo.action.executer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
|
import org.alfresco.repo.content.transform.TransformerDebug;
|
||||||
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
@@ -38,42 +40,50 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*/
|
*/
|
||||||
public class ImageTransformActionExecuter extends TransformActionExecuter
|
public class ImageTransformActionExecuter extends TransformActionExecuter
|
||||||
{
|
{
|
||||||
|
private TransformerDebug transformerDebug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action constants
|
* Action constants
|
||||||
*/
|
*/
|
||||||
public static final String NAME = "transform-image";
|
public static final String NAME = "transform-image";
|
||||||
public static final String PARAM_CONVERT_COMMAND = "convert-command";
|
public static final String PARAM_CONVERT_COMMAND = "convert-command";
|
||||||
|
|
||||||
private ContentTransformer imageMagickContentTransformer;
|
private ContentTransformer imageMagickContentTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the image magick content transformer
|
* Set the image magick content transformer
|
||||||
*
|
*
|
||||||
* @param imageMagickContentTransformer the conten transformer
|
* @param imageMagickContentTransformer
|
||||||
*/
|
* the conten transformer
|
||||||
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
*/
|
||||||
{
|
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
||||||
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
{
|
||||||
}
|
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add parameter definitions
|
* Add parameter definitions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
{
|
{
|
||||||
super.addParameterDefinitions(paramList);
|
super.addParameterDefinitions(paramList);
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_CONVERT_COMMAND, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_CONVERT_COMMAND)));
|
paramList.add(new ParameterDefinitionImpl(PARAM_CONVERT_COMMAND, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_CONVERT_COMMAND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setTransformerDebug(TransformerDebug transformerDebug)
|
||||||
|
{
|
||||||
|
this.transformerDebug = transformerDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see org.alfresco.repo.action.executer.TransformActionExecuter#doTransform(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter)
|
* @see org.alfresco.repo.action.executer.TransformActionExecuter#doTransform(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter)
|
||||||
*/
|
*/
|
||||||
protected void doTransform( Action ruleAction,
|
protected void doTransform(Action ruleAction,
|
||||||
NodeRef sourceNodeRef, ContentReader contentReader,
|
NodeRef sourceNodeRef, ContentReader contentReader,
|
||||||
NodeRef destinationNodeRef, ContentWriter contentWriter)
|
NodeRef destinationNodeRef, ContentWriter contentWriter)
|
||||||
{
|
{
|
||||||
// Try and transform the content
|
// Try and transform the content
|
||||||
String convertCommand = (String) ruleAction.getParameterValue(PARAM_CONVERT_COMMAND);
|
String convertCommand = (String) ruleAction.getParameterValue(PARAM_CONVERT_COMMAND);
|
||||||
// create some options for the transform
|
// create some options for the transform
|
||||||
ImageTransformationOptions imageOptions = new ImageTransformationOptions();
|
ImageTransformationOptions imageOptions = new ImageTransformationOptions();
|
||||||
@@ -81,12 +91,28 @@ public class ImageTransformActionExecuter extends TransformActionExecuter
|
|||||||
imageOptions.setSourceNodeRef(sourceNodeRef);
|
imageOptions.setSourceNodeRef(sourceNodeRef);
|
||||||
|
|
||||||
// check if the transformer is going to work, i.e. is available
|
// check if the transformer is going to work, i.e. is available
|
||||||
if (!this.imageMagickContentTransformer.isTransformable(contentReader.getMimetype(), contentReader.getSize(), contentWriter
|
String sourceMimetype = contentReader.getMimetype();
|
||||||
.getMimetype(), imageOptions))
|
String targetMimetype = contentWriter.getMimetype();
|
||||||
|
long sourceSize = contentReader.getSize();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
throw new NoTransformerException(contentReader.getMimetype(), contentWriter.getMimetype());
|
transformerDebug.pushAvailable(contentReader.getContentUrl(), sourceMimetype, targetMimetype, imageOptions);
|
||||||
}
|
List<ContentTransformer> transformers = new ArrayList<ContentTransformer>(1);
|
||||||
|
if (imageMagickContentTransformer.isTransformable(sourceMimetype, contentReader.getSize(), targetMimetype, imageOptions))
|
||||||
|
{
|
||||||
|
transformers.add(imageMagickContentTransformer);
|
||||||
|
}
|
||||||
|
transformerDebug.availableTransformers(transformers, sourceSize, "ImageTransformActionExecuter.doTransform(...)");
|
||||||
|
if (transformers.size() == 0)
|
||||||
|
{
|
||||||
|
throw new NoTransformerException(sourceMimetype, targetMimetype);
|
||||||
|
}
|
||||||
|
|
||||||
this.imageMagickContentTransformer.transform(contentReader, contentWriter, imageOptions);
|
imageMagickContentTransformer.transform(contentReader, contentWriter, imageOptions);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
transformerDebug.popAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -310,13 +310,7 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
|
|||||||
TransformationOptions options = new TransformationOptions(
|
TransformationOptions options = new TransformationOptions(
|
||||||
sourceNodeRef, ContentModel.PROP_NAME, destinationNodeRef, ContentModel.PROP_NAME);
|
sourceNodeRef, ContentModel.PROP_NAME, destinationNodeRef, ContentModel.PROP_NAME);
|
||||||
|
|
||||||
// try to pre-empt the lack of a transformer
|
// transform - will throw NoTransformerException if there are no transformers
|
||||||
if (this.contentService.isTransformable(contentReader, contentWriter, options) == false)
|
|
||||||
{
|
|
||||||
throw new NoTransformerException(contentReader.getMimetype(), contentWriter.getMimetype());
|
|
||||||
}
|
|
||||||
|
|
||||||
// transform
|
|
||||||
this.contentService.transform(contentReader, contentWriter, options);
|
this.contentService.transform(contentReader, contentWriter, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -963,9 +963,20 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
|
|||||||
throw new AlfrescoRuntimeException("The content writer mimetype must be set: " + writer);
|
throw new AlfrescoRuntimeException("The content writer mimetype must be set: " + writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for a transformer
|
long sourceSize = reader.getSize();
|
||||||
ContentTransformer transformer = transformerRegistry.getTransformer(sourceMimetype, reader.getSize(), targetMimetype, options);
|
try
|
||||||
return (transformer != null);
|
{
|
||||||
|
// look for a transformer
|
||||||
|
transformerDebug.pushAvailable(reader.getContentUrl(), sourceMimetype, targetMimetype, options);
|
||||||
|
List<ContentTransformer> transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options);
|
||||||
|
transformerDebug.availableTransformers(transformers, sourceSize, "ContentService.isTransformable(...)");
|
||||||
|
|
||||||
|
return transformers.size() > 0;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
transformerDebug.popAvailable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.content.transform;
|
||||||
|
|
||||||
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ALF-14303 Only support PDF to PNG rather than all the possible transformations from transformer.worker.ImageMagick
|
||||||
|
*/
|
||||||
|
public class FailoverPdfToImageContentTransformer extends FailoverContentTransformer
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||||
|
{
|
||||||
|
return MimetypeMap.MIMETYPE_PDF.equals(sourceMimetype) &&
|
||||||
|
MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -180,6 +180,14 @@ public abstract class AbstractImageMagickContentTransformerWorker extends Conten
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add limited support (so lots of other transforms are not supported) for PDF to PNG. An ALF-14303 workaround.
|
||||||
|
// Will only be used as part of failover transformer.PdfToImage
|
||||||
|
if (sourceMimetype.equals(MimetypeMap.MIMETYPE_PDF) && targetMimetype.equals(MimetypeMap.MIMETYPE_IMAGE_PNG))
|
||||||
|
{
|
||||||
|
return true; // ALF-14303 workaround
|
||||||
|
}
|
||||||
|
|
||||||
if (!AbstractImageMagickContentTransformerWorker.isSupported(sourceMimetype) ||
|
if (!AbstractImageMagickContentTransformerWorker.isSupported(sourceMimetype) ||
|
||||||
!AbstractImageMagickContentTransformerWorker.isSupported(targetMimetype))
|
!AbstractImageMagickContentTransformerWorker.isSupported(targetMimetype))
|
||||||
{
|
{
|
||||||
|
@@ -75,6 +75,7 @@ import org.alfresco.service.cmr.repository.ContentData;
|
|||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
@@ -2472,11 +2473,15 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
|||||||
TransformationOptions options = new TransformationOptions();
|
TransformationOptions options = new TransformationOptions();
|
||||||
options.setSourceNodeRef(sourceNodeRef);
|
options.setSourceNodeRef(sourceNodeRef);
|
||||||
|
|
||||||
if (contentService.isTransformable(reader, writer, options))
|
try
|
||||||
{
|
{
|
||||||
contentService.transform(reader, writer, options);
|
contentService.transform(reader, writer, options);
|
||||||
transformedNode = newInstance(nodeRef, services, scope);
|
transformedNode = newInstance(nodeRef, services, scope);
|
||||||
}
|
}
|
||||||
|
catch (NoTransformerException e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
return transformedNode;
|
return transformedNode;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -37,6 +37,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
|||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||||
|
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||||
@@ -610,7 +611,7 @@ public abstract class BaseContentNode implements TemplateContent
|
|||||||
options.setSourceNodeRef(nodeRef);
|
options.setSourceNodeRef(nodeRef);
|
||||||
|
|
||||||
// try and transform the content
|
// try and transform the content
|
||||||
if (contentService.isTransformable(reader, writer, options))
|
try
|
||||||
{
|
{
|
||||||
contentService.transform(reader, writer, options);
|
contentService.transform(reader, writer, options);
|
||||||
|
|
||||||
@@ -627,6 +628,10 @@ public abstract class BaseContentNode implements TemplateContent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (NoTransformerException e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -300,22 +300,7 @@ public interface ContentService
|
|||||||
public ContentTransformer getImageTransformer();
|
public ContentTransformer getImageTransformer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a transformer exists that can read the content from
|
* @deprecated use {@link #isTransformable(String, String, long, String, TransformationOptions).
|
||||||
* the reader and write the content back out to the writer.
|
|
||||||
* <p>
|
|
||||||
* Since no transformation options are specified, only the source and target
|
|
||||||
* mimetypes will be considered when making this decision.
|
|
||||||
* <p>
|
|
||||||
* The mimetypes used for the transformation must be set both on
|
|
||||||
* the {@link ContentAccessor#getMimetype() reader} and on the
|
|
||||||
* {@link ContentAccessor#getMimetype() writer}.
|
|
||||||
*
|
|
||||||
* @param reader the source content location and mimetype
|
|
||||||
* @param writer the target content location and mimetype
|
|
||||||
*
|
|
||||||
* @return true if a transformer exists, false otherwise
|
|
||||||
*
|
|
||||||
* @see org.alfresco.service.cmr.repository.ContentService.isTransformable(ContentReader, ContentWriter, TransformationOptions)
|
|
||||||
*/
|
*/
|
||||||
@Auditable(parameters = {"reader", "writer"})
|
@Auditable(parameters = {"reader", "writer"})
|
||||||
public boolean isTransformable(ContentReader reader, ContentWriter writer);
|
public boolean isTransformable(ContentReader reader, ContentWriter writer);
|
||||||
@@ -325,6 +310,10 @@ public interface ContentService
|
|||||||
* the reader and write the content back out to the writer with the
|
* the reader and write the content back out to the writer with the
|
||||||
* provided tranformation options.
|
* provided tranformation options.
|
||||||
* <p>
|
* <p>
|
||||||
|
* <b>If you are about to call {@link #transform(ContentReader, ContentWriter, TransformationOptions)}
|
||||||
|
* it is best NOT to call this method first as it must perform the same steps and will throw
|
||||||
|
* NoTransformerException if there are no transformers.</b><p>
|
||||||
|
*
|
||||||
* The mimetypes used for the transformation must be set both on
|
* The mimetypes used for the transformation must be set both on
|
||||||
* the {@link ContentAccessor#getMimetype() reader} and on the
|
* the {@link ContentAccessor#getMimetype() reader} and on the
|
||||||
* {@link ContentAccessor#getMimetype() writer}.
|
* {@link ContentAccessor#getMimetype() writer}.
|
||||||
|
Reference in New Issue
Block a user