diff --git a/config/alfresco/thumbnail-service-context.xml b/config/alfresco/thumbnail-service-context.xml index 61c02df622..a1d65beac1 100644 --- a/config/alfresco/thumbnail-service-context.xml +++ b/config/alfresco/thumbnail-service-context.xml @@ -39,10 +39,7 @@ - - - diff --git a/source/java/org/alfresco/repo/action/ActionImpl.java b/source/java/org/alfresco/repo/action/ActionImpl.java index da1b70c221..d8d8e5d337 100644 --- a/source/java/org/alfresco/repo/action/ActionImpl.java +++ b/source/java/org/alfresco/repo/action/ActionImpl.java @@ -35,7 +35,7 @@ import org.alfresco.service.cmr.repository.NodeRef; * * @author Roy Wetherall */ -public class ActionImpl extends ParameterizedItemImpl implements Serializable, Action +public class ActionImpl extends ParameterizedItemImpl implements Action { /** * Serial version UID @@ -432,4 +432,10 @@ public class ActionImpl extends ParameterizedItemImpl implements Serializable, A { this.nodeRef = nodeRef; } + + public void addParameterValues(Map values) + { + getParameterValues().putAll(values); + } + } diff --git a/source/java/org/alfresco/repo/rendition/AllRenditionTests.java b/source/java/org/alfresco/repo/rendition/AllRenditionTests.java index fd6d779f9e..f9c31a40e0 100644 --- a/source/java/org/alfresco/repo/rendition/AllRenditionTests.java +++ b/source/java/org/alfresco/repo/rendition/AllRenditionTests.java @@ -18,6 +18,7 @@ */ package org.alfresco.repo.rendition; +import org.alfresco.repo.rendition.executer.AbstractRenderingEngineTest; import org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest; import org.alfresco.repo.thumbnail.ThumbnailServiceImplTest; import org.junit.runner.RunWith; @@ -33,6 +34,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ RenditionServiceImplTest.class, + AbstractRenderingEngineTest.class, ThumbnailServiceImplParameterTest.class, ThumbnailServiceImplTest.class, StandardRenditionLocationResolverTest.class, diff --git a/source/java/org/alfresco/repo/rendition/PerformRenditionActionExecuter.java b/source/java/org/alfresco/repo/rendition/PerformRenditionActionExecuter.java index 94bc09818f..71714bb9be 100644 --- a/source/java/org/alfresco/repo/rendition/PerformRenditionActionExecuter.java +++ b/source/java/org/alfresco/repo/rendition/PerformRenditionActionExecuter.java @@ -492,6 +492,8 @@ public class PerformRenditionActionExecuter extends ActionExecuterAbstractBase log.debug(msg.toString()); } + QName type = nodeService.getType(sourceNode); + nodeService.setType(targetNode, type); Map newProps = nodeService.getProperties(sourceNode); for (QName propKey : unchangedProperties) { diff --git a/source/java/org/alfresco/repo/rendition/RenditionDefinitionImpl.java b/source/java/org/alfresco/repo/rendition/RenditionDefinitionImpl.java index c48fbccf6c..a0c4002b8f 100644 --- a/source/java/org/alfresco/repo/rendition/RenditionDefinitionImpl.java +++ b/source/java/org/alfresco/repo/rendition/RenditionDefinitionImpl.java @@ -19,6 +19,9 @@ package org.alfresco.repo.rendition; +import java.io.Serializable; +import java.util.Map; + import org.alfresco.repo.action.ActionImpl; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.rendition.RenderCallback; @@ -33,7 +36,6 @@ import org.alfresco.service.namespace.QName; */ public class RenditionDefinitionImpl extends ActionImpl implements RenditionDefinition { - /** * Serial version UID */ @@ -45,9 +47,12 @@ public class RenditionDefinitionImpl extends ActionImpl implements RenditionDefi private RenderCallback renderCallback; /** - * @param id the action id - * @param renditionName a unique name for the rendering action. - * @param renderingEngineName the name of the rendering action definition + * @param id + * the action id + * @param renditionName + * a unique name for the rendering action. + * @param renderingEngineName + * the name of the rendering action definition */ public RenditionDefinitionImpl(String id, QName renditionName, String renderingEngineName) { @@ -114,7 +119,10 @@ public class RenditionDefinitionImpl extends ActionImpl implements RenditionDefi /* * (non-Javadoc) - * @see org.alfresco.service.cmr.rendition.RenditionDefinition#setCallback(org.alfresco.service.cmr.rendition.RenderCallback) + * + * @see + * org.alfresco.service.cmr.rendition.RenditionDefinition#setCallback(org + * .alfresco.service.cmr.rendition.RenderCallback) */ public void setCallback(RenderCallback callback) { @@ -123,7 +131,10 @@ public class RenditionDefinitionImpl extends ActionImpl implements RenditionDefi /* * (non-Javadoc) - * @see org.alfresco.service.cmr.rendition.RenditionDefinition#setCallback(org.alfresco.service.cmr.rendition.RenderCallback) + * + * @see + * org.alfresco.service.cmr.rendition.RenditionDefinition#setCallback(org + * .alfresco.service.cmr.rendition.RenderCallback) */ public RenderCallback getCallback() { diff --git a/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java index b1de310959..a4eb723242 100644 --- a/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java +++ b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ - package org.alfresco.repo.rendition.executer; import static org.alfresco.service.cmr.rendition.RenditionService.*; @@ -326,7 +325,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase * @param renditionDefinition * @return */ - public QName getRenditionNodeType(RenditionDefinition renditionDefinition) + private QName getRenditionNodeType(RenditionDefinition renditionDefinition) { return getParamWithDefault(PARAM_RENDITION_NODETYPE, defaultRenditionNodeType, renditionDefinition); } @@ -378,7 +377,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase // The ThumbnailService puts a cm:name property on its thumbnail nodes. Map nodeProps = new HashMap(); nodeProps.put(ContentModel.PROP_NAME, renditionName.getLocalName()); - nodeProps.put(ContentModel.PROP_CONTENT_PROPERTY_NAME, getDefaultRenditionContentProp()); + nodeProps.put(ContentModel.PROP_CONTENT_PROPERTY_NAME, getRenditionContentProp(renditionDefinition)); QName assocName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, GUID.generate()); NodeRef parentNode = renditionDefinition.getRenditionParent(); QName assocType = renditionDefinition.getRenditionAssociationType(); @@ -387,6 +386,11 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase return childAssoc; } + private Serializable getRenditionContentProp(RenditionDefinition renditionDefinition) + { + return getParamWithDefault(PARAM_TARGET_CONTENT_PROPERTY, getDefaultRenditionContentProp(), renditionDefinition); + } + /** * Gets the value for the named parameter. Checks the type of the parameter * is correct and throws a {@link RenditionServiceException} if it isn't. diff --git a/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java new file mode 100644 index 0000000000..9a8c08bbe1 --- /dev/null +++ b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2005-2010 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 . + */ +package org.alfresco.repo.rendition.executer; + +import static org.mockito.Mockito.*; + +import java.io.Serializable; +import java.util.Map; + +import junit.framework.TestCase; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.action.executer.ActionExecuter; +import org.alfresco.repo.rendition.RenditionDefinitionImpl; +import org.alfresco.repo.rendition.executer.AbstractRenderingEngine.RenderingContext; +import org.alfresco.service.cmr.rendition.RenditionDefinition; +import org.alfresco.service.cmr.rendition.RenditionService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.mockito.ArgumentCaptor; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +/** + * @author Nick Smith + */ +public class AbstractRenderingEngineTest extends TestCase +{ + private ContentService contentService; + private NodeService nodeService; + private TestRenderingEngine engine; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + this.contentService = mock(ContentService.class); + NodeService nodeService1 = makeNodeService(); + this.nodeService = nodeService1; + engine = new TestRenderingEngine(); + engine.setContentService(contentService); + engine.setNodeService(nodeService); + } + + /** + * Creates a mock node service which fails with a helpful message by default if createNode is called. + * @return + */ + private NodeService makeNodeService() + { + NodeService nodeService1 = mock(NodeService.class); + return nodeService1; + } + + @SuppressWarnings("unchecked") + public void testCreateRenditionNodeAssoc() throws Exception + { + NodeRef source = new NodeRef("http://test/sourceId"); + when(nodeService.exists(source)).thenReturn(true); + + QName assocType = ContentModel.ASSOC_CONTAINS; + QName assocName = QName.createQName("url", "renditionName"); + QName nodeType = ContentModel.TYPE_CONTENT; + ChildAssociationRef renditionAssoc = mock(ChildAssociationRef.class); + + // Set up the rendition definition. + String id = "definitionId"; + RenditionDefinition definition = new RenditionDefinitionImpl(id, assocName, TestRenderingEngine.NAME); + definition.setRenditionAssociationType(assocType); + definition.setRenditionParent(source); + + // Stub the createNode() method to return renditionAssoc. + when(nodeService + .createNode(eq(source), eq(assocType), any(QName.class), any(QName.class), anyMap())) + .thenReturn(renditionAssoc); + engine.execute(definition, source); + + // Check the createNode method was called with the correct parameters. + // Check the nodeType defaults to cm:content. + ArgumentCaptor captor = ArgumentCaptor.forClass(Map.class); + verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture()); + Map props = captor.getValue(); + + // Check the node name is set to match teh rendition name local name. + assertEquals(assocName.getLocalName(), props.get(ContentModel.PROP_NAME)); + + // Check content property name defaults to cm:content + assertEquals(ContentModel.PROP_CONTENT, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME)); + + // Check the returned result is the association created by the call to nodeServcie.createNode(). + Serializable result = definition.getParameterValue(ActionExecuter.PARAM_RESULT); + assertEquals("The returned rendition association is not the one created by the node service!", + renditionAssoc, result); + + // Check that setting the default content property and default node type + // on the rendition engine works. + nodeType = QName.createQName("url", "someNodeType"); + QName contentPropName = QName.createQName("url", "someContentProp"); + engine.setDefaultRenditionContentProp(contentPropName.toString()); + engine.setDefaultRenditionNodeType(nodeType.toString()); + engine.execute(definition, source); + verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture()); + props=captor.getValue(); + assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME)); + + // Check that settign the rendition node type param works. + nodeType = ContentModel.TYPE_THUMBNAIL; + contentPropName = ContentModel.PROP_CONTENT; + definition.setParameterValue(RenditionService.PARAM_RENDITION_NODETYPE, nodeType); + definition.setParameterValue(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, contentPropName); + engine.execute(definition, source); + verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture()); + props=captor.getValue(); + assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME)); + } + + private static class TestRenderingEngine extends AbstractRenderingEngine + { + private RenderingContext context; + + public static String NAME = "Test"; + + @Override + protected void render(RenderingContext context1) + { + this.context = context1; + } + + public RenderingContext getContext() + { + return context; + } + } +} diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java index 01575ba27d..df4641cc57 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java @@ -24,10 +24,8 @@ import java.util.List; import java.util.Map; import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; import org.alfresco.repo.content.transform.swf.SWFTransformationOptions; -import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.rendition.executer.AbstractRenderingEngine; import org.alfresco.repo.rendition.executer.ImageRenderingEngine; import org.alfresco.repo.rendition.executer.ReformatRenderingEngine; @@ -37,7 +35,6 @@ import org.alfresco.service.cmr.rendition.RenditionService; import org.alfresco.service.cmr.rendition.RenditionServiceException; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.TransformationOptions; @@ -61,7 +58,7 @@ public class ThumbnailServiceImpl implements ThumbnailService private static Log logger = LogFactory.getLog(ThumbnailServiceImpl.class); /** Error messages */ - private static final String ERR_NO_CREATE = "Thumbnail could not be created as required transformation is not supported from {0} to {1}"; +// private static final String ERR_NO_CREATE = "Thumbnail could not be created as required transformation is not supported from {0} to {1}"; private static final String ERR_DUPLICATE_NAME = "Thumbnail could not be created because of a duplicate name"; private static final String ERR_NO_PARENT = "Thumbnail has no parent so update cannot take place."; @@ -71,15 +68,6 @@ public class ThumbnailServiceImpl implements ThumbnailService /** Node service */ private NodeService nodeService; - /** Content service */ - private ContentService contentService; - - /** Mimetype map */ - private MimetypeMap mimetypeMap; - - /** Behaviour filter */ - private BehaviourFilter behaviourFilter; - /** Thumbnail registry */ private ThumbnailRegistry thumbnailRegistry; @@ -106,34 +94,6 @@ public class ThumbnailServiceImpl implements ThumbnailService this.nodeService = nodeService; } - /** - * Set the content service - * - * @param contentService content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Sets the mimetype map - * - * @param mimetypeMap the mimetype map - */ - public void setMimetypeMap(MimetypeMap mimetypeMap) - { - this.mimetypeMap = mimetypeMap; - } - - /** - * @param behaviourFilter policy behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - /** * Set thumbnail registry * @@ -167,17 +127,38 @@ public class ThumbnailServiceImpl implements ThumbnailService final TransformationOptions transformationOptions, final String thumbnailName, final ThumbnailParentAssociationDetails assocDetails) { // Parameter check - ParameterCheck.mandatory("node", node); + ParameterCheck.mandatory("node", node); ParameterCheck.mandatory("contentProperty", contentProperty); - ParameterCheck.mandatoryString( "mimetype", mimetype); + ParameterCheck.mandatoryString("mimetype", mimetype); ParameterCheck.mandatory("transformationOptions", transformationOptions); - + if (logger.isDebugEnabled() == true) { - logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype); + logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty=" + + contentProperty.toString() + "; mimetype=" + mimetype); } - - // Check for duplicate names + checkThumbnailNameIsUnique(node, thumbnailName, contentProperty, mimetype); + return AuthenticationUtil.runAs( + new AuthenticationUtil.RunAsWork() + { + public NodeRef doWork() throws Exception + { + return createThumbnailNode(node, contentProperty, + mimetype, transformationOptions, thumbnailName, assocDetails); + } + }, AuthenticationUtil.getSystemUserName()); + } + + /** + * Throws a ThumbnailException if a thumbnail of this name already exists. + * @param node + * @param thumbnailName + * @param contentProperty + * @param mimetype + */ + private void checkThumbnailNameIsUnique(final NodeRef node, final String thumbnailName, + final QName contentProperty, final String mimetype) + { if (thumbnailName != null && getThumbnailByName(node, contentProperty, thumbnailName) != null) { if (logger.isDebugEnabled() == true) @@ -188,57 +169,20 @@ public class ThumbnailServiceImpl implements ThumbnailService // We can't continue because there is already a thumbnail with the given name for that content property throw new ThumbnailException(ERR_DUPLICATE_NAME); } - - ChildAssociationRef thumbnailRef = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public ChildAssociationRef doWork() throws Exception - { - // Need a variable scoped to this inner class in order to assign a new value to it. - String localThumbnailName = thumbnailName; - // Get the name of the thumbnail and add to properties map - if (localThumbnailName == null || localThumbnailName.length() == 0) - { - localThumbnailName = GUID.generate(); - } - - // We're prepending the cm namespace here. - QName thumbnailQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, localThumbnailName); - - // Convert the TransformationOptions and ThumbnailParentAssocDetails to - // rendition-style parameters - Map params = thumbnailRegistry.getThumbnailRenditionConvertor().convert(transformationOptions, assocDetails); - // Add the other parameters given in this method signature. - params.put(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, contentProperty); - params.put(AbstractRenderingEngine.PARAM_MIME_TYPE, mimetype); - - // Create the renditionDefinition - String renderingEngineName = getRenderingEngineNameFor(transformationOptions); - RenditionDefinition renderingAction = renditionService.createRenditionDefinition(thumbnailQName, renderingEngineName); - - // Set the parameters - for (String key : params.keySet()) - { - renderingAction.setParameterValue(key, params.get(key)); - } - - - ChildAssociationRef chAssRef = null; - try - { - chAssRef = renditionService.render(node, renderingAction); - } catch (RenditionServiceException rsx) - { - throw new ThumbnailException(rsx.getMessage(), rsx); - } - - return chAssRef; - } - }, AuthenticationUtil.getSystemUserName()); - - // Return the created thumbnail - return getThumbnailNode(thumbnailRef); } + private QName getThumbnailQName(String localThumbnailName) + { + if (localThumbnailName == null || localThumbnailName.length() == 0) + { + localThumbnailName = GUID.generate(); + } + + // We're prepending the cm namespace here. + QName thumbnailQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, localThumbnailName); + return thumbnailQName; + } + private String getRenderingEngineNameFor(TransformationOptions options) { if (options instanceof ImageTransformationOptions) @@ -449,4 +393,83 @@ public class ThumbnailServiceImpl implements ThumbnailService return result; } + + /** + * Creates a {@link RenditionDefinition} with no parameters set. + * @param thumbnailName + * @param transformationOptions + * @return + */ + private RenditionDefinition createRawRenditionDefinition(QName thumbnailQName, + final TransformationOptions transformationOptions) + { + // Create the renditionDefinition + String renderingEngineName = getRenderingEngineNameFor(transformationOptions); + RenditionDefinition definition = renditionService.createRenditionDefinition(thumbnailQName, renderingEngineName); + return definition; + } + + /** + * Creates a fully parameterized {@link RenditionDefinition}. + * @param contentProperty + * @param mimetype + * @param transformationOptions + * @param thumbnailName + * @param assocDetails + * @return + */ + private RenditionDefinition createRenditionDefinition(final QName contentProperty, final String mimetype, + final TransformationOptions transformationOptions, final QName thumbnailQName, + final ThumbnailParentAssociationDetails assocDetails) + { + RenditionDefinition definition = createRawRenditionDefinition(thumbnailQName, transformationOptions); + + // Convert the TransformationOptions and ThumbnailParentAssocDetails to + // rendition-style parameters + Map params = thumbnailRegistry.getThumbnailRenditionConvertor().convert(transformationOptions, assocDetails); + // Add the other parameters given in this method signature. + params.put(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, contentProperty); + params.put(AbstractRenderingEngine.PARAM_MIME_TYPE, mimetype); + params.put(RenditionService.PARAM_RENDITION_NODETYPE, ContentModel.TYPE_THUMBNAIL); + + // Set the parameters on the rendition definition. + definition.addParameterValues(params); + return definition; + } + + private NodeRef createThumbnailNode(final NodeRef node, final QName contentProperty, + final String mimetype, final TransformationOptions transformationOptions, final String thumbnailName, + final ThumbnailParentAssociationDetails assocDetails) + { + // Get the name of the thumbnail and add to properties map + QName thumbnailQName = getThumbnailQName(thumbnailName); + RenditionDefinition definition = createRenditionDefinition(contentProperty, mimetype, + transformationOptions, thumbnailQName, assocDetails); + try + { + ChildAssociationRef thumbnailAssoc = renditionService.render(node, definition); + NodeRef thumbnail = getThumbnailNode(thumbnailAssoc); + setThumbnailNameProperty(thumbnail, thumbnailName); + return thumbnail; + } catch (RenditionServiceException rsx) + { + throw new ThumbnailException(rsx.getMessage(), rsx); + } + } + + /** + * Sets the thumbnail name if the rendition is of type cm:thumbnail. + * @param thumbnailAssoc + * @param thumbnailName + */ + private void setThumbnailNameProperty(NodeRef thumbnail, String thumbnailName) + { + if (thumbnailName != null && thumbnailName.length() > 0) + { + if (ContentModel.TYPE_THUMBNAIL.equals(nodeService.getType(thumbnail))) + { + nodeService.setProperty(thumbnail, ContentModel.PROP_THUMBNAIL_NAME, thumbnailName); + } + } + } } diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplParameterTest.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplParameterTest.java index 1fb01d0158..e21006a2e7 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplParameterTest.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplParameterTest.java @@ -52,6 +52,7 @@ import org.alfresco.service.cmr.rendition.RenditionDefinition; import org.alfresco.service.cmr.rendition.RenditionService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.thumbnail.ThumbnailParentAssociationDetails; import org.alfresco.service.cmr.thumbnail.ThumbnailService; import org.alfresco.service.namespace.NamespaceService; @@ -121,6 +122,7 @@ public class ThumbnailServiceImplParameterTest return new ThumbnailRenditionConvertor(); } }); + thumbs.setNodeService(mock(NodeService.class)); thumbnailService = thumbs; } diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java index 1ff1a5bb87..3f4f6de73a 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java @@ -323,6 +323,13 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest // Check the content property value assertEquals(ContentModel.PROP_CONTENT, this.nodeService.getProperty(thumbnail, ContentModel.PROP_CONTENT_PROPERTY_NAME)); + + // Check the thumbnail is of type cm:thumbnail. + assertEquals("The thumbnail node should be of type cm:thumbnail!", + ContentModel.TYPE_THUMBNAIL, nodeService.getType(thumbnail)); + + // Check the thumbnail name property is correctly set on thumbnail. + assertEquals( thumbnailName, nodeService.getProperty(thumbnail, ContentModel.PROP_THUMBNAIL_NAME)); } private void outputThumbnailTempContentLocation(NodeRef thumbnail, String ext, String message) throws IOException diff --git a/source/java/org/alfresco/service/cmr/action/Action.java b/source/java/org/alfresco/service/cmr/action/Action.java index e8b26daad0..c6ce1cee95 100644 --- a/source/java/org/alfresco/service/cmr/action/Action.java +++ b/source/java/org/alfresco/service/cmr/action/Action.java @@ -18,8 +18,10 @@ */ package org.alfresco.service.cmr.action; +import java.io.Serializable; import java.util.Date; import java.util.List; +import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; @@ -200,4 +202,10 @@ public interface Action extends ParameterizedItem * Removes all action conditions */ void removeAllActionConditions(); + + /** + * Adds a {@link Map} of parameter values to the {@link Action} + * @param values A map of values to be added + */ + void addParameterValues(Map values); } diff --git a/source/java/org/alfresco/service/cmr/rendition/RenditionDefinition.java b/source/java/org/alfresco/service/cmr/rendition/RenditionDefinition.java index a0575dc8f0..06bde4c8de 100644 --- a/source/java/org/alfresco/service/cmr/rendition/RenditionDefinition.java +++ b/source/java/org/alfresco/service/cmr/rendition/RenditionDefinition.java @@ -41,7 +41,7 @@ public interface RenditionDefinition extends Action, Serializable /** * @return the name which uniquely identifies this rendering action. */ - public QName getRenditionName(); + QName getRenditionName(); /** * Returns the node to which the rendition is linked when it is first @@ -51,7 +51,7 @@ public interface RenditionDefinition extends Action, Serializable * * @return the renditionParent */ - public NodeRef getRenditionParent(); + NodeRef getRenditionParent(); /** * Sets the node to which the rendition is linked when it is first created. @@ -61,7 +61,7 @@ public interface RenditionDefinition extends Action, Serializable * * @param renditionParent the renditionParent to set */ - public void setRenditionParent(NodeRef renditionParent); + void setRenditionParent(NodeRef renditionParent); /** * Returns the association type used to link the rendition to its parent @@ -71,7 +71,7 @@ public interface RenditionDefinition extends Action, Serializable * * @return the renditionAssociationType */ - public QName getRenditionAssociationType(); + QName getRenditionAssociationType(); /** * Sets the association type used to link the rendition to its parent node @@ -81,7 +81,7 @@ public interface RenditionDefinition extends Action, Serializable * * @param renditionAssociationType the renditionAssociationType to set */ - public void setRenditionAssociationType(QName renditionAssociationType); + void setRenditionAssociationType(QName renditionAssociationType); /** * This method sets a callback object for use in asynchronous renditions. It is @@ -90,7 +90,7 @@ public interface RenditionDefinition extends Action, Serializable * * @param callback a callback object, which may be null. */ - public void setCallback(RenderCallback callback); + void setCallback(RenderCallback callback); /** * This method gets the registered callback object for use with asynchronous @@ -98,5 +98,5 @@ public interface RenditionDefinition extends Action, Serializable * * @return the callback object */ - public RenderCallback getCallback(); + RenderCallback getCallback(); }