Search in sources :

Example 31 with RenditionDefinition

use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.

the class PerformRenditionActionExecuter method executeImpl.

@Override
protected void executeImpl(final Action containingAction, final NodeRef actionedUponNodeRef) {
    final RenditionDefinition renditionDefinition = getRenditionDefinition(containingAction);
    if (log.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Rendering node ").append(actionedUponNodeRef).append(" with rendition definition ").append(renditionDefinition.getRenditionName());
        msg.append("\n").append("  parameters:").append("\n");
        if (renditionDefinition.getParameterValues().isEmpty() == false) {
            for (String paramKey : renditionDefinition.getParameterValues().keySet()) {
                msg.append("    ").append(paramKey).append("=").append(renditionDefinition.getParameterValue(paramKey)).append("\n");
            }
        } else {
            msg.append("    [None]");
        }
        log.debug(msg.toString());
    }
    ChildAssociationRef result = executeRendition(actionedUponNodeRef, renditionDefinition);
    containingAction.setParameterValue(PARAM_RESULT, result);
}
Also used : RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 32 with RenditionDefinition

use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.

the class PerformRenditionActionExecuter method getRenditionDefinition.

/**
 * This method gets the (mandatory) rendition definition parameter from the containing action.
 * @param containingAction the containing action.
 * @return the rendition definition.
 * @throws IllegalArgumentException if the rendition definition is missing.
 */
private RenditionDefinition getRenditionDefinition(final Action containingAction) {
    Serializable rendDefObj = containingAction.getParameterValue(PARAM_RENDITION_DEFINITION);
    ParameterCheck.mandatory(PARAM_RENDITION_DEFINITION, rendDefObj);
    return (RenditionDefinition) rendDefObj;
}
Also used : Serializable(java.io.Serializable) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition)

Example 33 with RenditionDefinition

use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.

the class RenditionDefinitionPersisterImpl method loadRenditionDefinitions.

public List<RenditionDefinition> loadRenditionDefinitions() {
    checkRenderingActionRootNodeExists();
    // Note that in the call to getChildAssocs below, only the specified
    // types are included.
    // Subtypes of the type action:action will not be returned.
    Set<QName> actionTypes = new HashSet<QName>();
    actionTypes.add(ActionModel.TYPE_ACTION);
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(RENDERING_ACTION_ROOT_NODE_REF, actionTypes);
    List<RenditionDefinition> renderingActions = new ArrayList<RenditionDefinition>(childAssocs.size());
    for (ChildAssociationRef actionAssoc : childAssocs) {
        Action nextAction = runtimeActionService.createAction(actionAssoc.getChildRef());
        renderingActions.add(new RenditionDefinitionImpl(nextAction));
    }
    return renderingActions;
}
Also used : Action(org.alfresco.service.cmr.action.Action) CompositeAction(org.alfresco.service.cmr.action.CompositeAction) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition) HashSet(java.util.HashSet)

Example 34 with RenditionDefinition

use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.

the class RenditionDefinitionPersisterImpl method loadRenditionDefinitions.

public List<RenditionDefinition> loadRenditionDefinitions(String renditionEngineName) {
    if (renditionEngineName == null) {
        throw new NullPointerException("Unexpected null renditionEngineName");
    }
    List<RenditionDefinition> allRenditionDefinitions = this.loadRenditionDefinitions();
    List<RenditionDefinition> filteredRenditionDefinitions = new ArrayList<RenditionDefinition>();
    for (RenditionDefinition renderAction : allRenditionDefinitions) {
        if (renditionEngineName.equals(renderAction.getActionDefinitionName())) {
            filteredRenditionDefinitions.add(renderAction);
        }
    }
    return filteredRenditionDefinitions;
}
Also used : ArrayList(java.util.ArrayList) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition)

Example 35 with RenditionDefinition

use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.

the class RenditionDefinitionTest method testGetRenderingEngineDefinition.

@Test
public void testGetRenderingEngineDefinition() throws Exception {
    ThumbnailRenditionConvertor converter = new ThumbnailRenditionConvertor();
    List<RenditionDefinition> renditionDefinitions = new ArrayList(renditionService.loadRenditionDefinitions());
    Set<String> renditionNames = renditionDefinitionRegistry2.getRenditionNames();
    for (String renditionName : renditionNames) {
        System.out.println("renditionName=" + renditionName);
        RenditionDefinition definition = getRenditionDefinition(renditionDefinitions, renditionName);
        assertNotNull("There is no RenditionDefinition for " + renditionName, definition);
        renditionDefinitions.remove(definition);
        ThumbnailDefinition thumbnailDefinition = converter.convert(definition);
        TransformationOptions transformationOptions = thumbnailDefinition.getTransformationOptions();
        RenditionDefinition2 definition2 = renditionDefinitionRegistry2.getRenditionDefinition(renditionName);
        Map<String, String> options = definition2.getTransformOptions();
        TransformationOptions transformationOptions2 = transformationOptionsConverter.getTransformationOptions(renditionName, options);
        Map<String, String> options2 = transformationOptionsConverter.getOptions(transformationOptions2, null, null);
        // The use is not set in the original until much later
        transformationOptions2.setUse(null);
        // than checking transformationOptions is equal to transformationOptions2.
        if (!renditionName.equals("pdf") && !renditionName.equals("webpreview")) {
            assertEquals("The TransformationOptions used in transforms for " + renditionName + " should be the same", transformationOptions.toStringAll(), transformationOptions2.toStringAll());
            assertEquals("The transformationOptionsConverter back to the newer format was not the same for " + renditionName, options, options2);
        } else {
            assertEquals("The converted class for " + renditionName + " should be the same as before", transformationOptions.getClass(), transformationOptions2.getClass());
            assertEquals("The converted class for " + renditionName + " should be SWFTransformationOptions", SWFTransformationOptions.class, transformationOptions2.getClass());
        }
    }
    if (!renditionDefinitions.isEmpty()) {
        StringJoiner sj = new StringJoiner(", ");
        for (RenditionDefinition renditionDefinition : renditionDefinitions) {
            String name = renditionDefinition.getRenditionName().getLocalName();
            sj.add(name);
        }
        fail("There is no RenditionDefinition2 for existing RenditionDefinitions " + sj);
    }
}
Also used : ThumbnailDefinition(org.alfresco.repo.thumbnail.ThumbnailDefinition) ArrayList(java.util.ArrayList) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition) StringJoiner(java.util.StringJoiner) ThumbnailRenditionConvertor(org.alfresco.repo.thumbnail.ThumbnailRenditionConvertor) SWFTransformationOptions(org.alfresco.repo.content.transform.swf.SWFTransformationOptions) TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

RenditionDefinition (org.alfresco.service.cmr.rendition.RenditionDefinition)58 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)32 QName (org.alfresco.service.namespace.QName)28 Test (org.junit.Test)25 CompositeRenditionDefinition (org.alfresco.service.cmr.rendition.CompositeRenditionDefinition)22 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)21 AbstractContentTransformerTest (org.alfresco.repo.content.transform.AbstractContentTransformerTest)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 Serializable (java.io.Serializable)11 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)11 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)9 RenditionServiceException (org.alfresco.service.cmr.rendition.RenditionServiceException)9 ArrayList (java.util.ArrayList)6 ContentReader (org.alfresco.service.cmr.repository.ContentReader)6 AuthenticationUtil (org.alfresco.repo.security.authentication.AuthenticationUtil)5 FileInfo (org.alfresco.service.cmr.model.FileInfo)5 HashMap (java.util.HashMap)3 RenderingContext (org.alfresco.repo.rendition.executer.AbstractRenderingEngine.RenderingContext)3 List (java.util.List)2 ImageTransformationOptions (org.alfresco.repo.content.transform.magick.ImageTransformationOptions)2