use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.
the class ThumbnailServiceImplParameterTest method initMockObjects.
@Before
public void initMockObjects() {
renditionService = new RenditionServiceImpl() {
@Override
public RenditionDefinition loadRenditionDefinition(QName renditionDefinitionName) {
// We're intentionally returning null for this test.
return null;
}
};
renditionService.setActionService(mockActionService);
renditionService.setServiceRegistry(new MockedTestServiceRegistry());
renditionService.setRenditionService2(mockRenditionService2);
when(mockRenditionService2.isCreatedByRenditionService2(any(), any())).thenReturn(false);
ThumbnailServiceImpl thumbs = new ThumbnailServiceImpl() {
@Override
public NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName) {
return null;
}
/**
* In this test the thumbnailRef will be null, so we need to ensure
* it is not dereferenced here.
*/
@Override
public NodeRef getThumbnailNode(ChildAssociationRef thumbnailRef) {
return null;
}
};
thumbs.setRenditionService(renditionService);
thumbs.setThumbnailRegistry(new ThumbnailRegistry() {
@Override
public ThumbnailRenditionConvertor getThumbnailRenditionConvertor() {
return new ThumbnailRenditionConvertor();
}
});
thumbs.setNodeService(mock(NodeService.class));
TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl() {
@Override
public boolean getAllowWrite() {
return true;
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public RetryingTransactionHelper getRetryingTransactionHelper() {
RetryingTransactionHelper rth = new RetryingTransactionHelper() {
@Override
public <R> R doInTransaction(RetryingTransactionCallback<R> cb, boolean readOnly, boolean requiresNew) {
try {
return cb.execute();
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
};
return rth;
}
};
thumbs.setTransactionService(transactionServiceImpl);
thumbnailService = thumbs;
}
use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.
the class ScriptRenditionService method createRenditionDefinition.
/**
* Creates a new {@link ScriptRenditionDefinition} and sets the rendition name and
* the rendering engine name to the specified values.
*
* @param renditionName A unique identifier used to specify the created
* {@link ScriptRenditionDefinition}.
* @param renderingEngineName The name of the rendering engine associated
* with this {@link ScriptRenditionDefinition}.
* @return the created {@link ScriptRenditionDefinition}.
* @see org.alfresco.service.cmr.rendition.RenditionService#createRenditionDefinition(QName, String)
*/
public ScriptRenditionDefinition createRenditionDefinition(String renditionName, String renderingEngineName) {
QName renditionQName = createQName(renditionName);
if (logger.isDebugEnabled()) {
StringBuilder msg = new StringBuilder();
msg.append("Creating ScriptRenditionDefinition [").append(renditionName).append(", ").append(renderingEngineName).append("]");
logger.debug(msg.toString());
}
RenderingEngineDefinition engineDefinition = renditionService.getRenderingEngineDefinition(renderingEngineName);
RenditionDefinition rendDef = renditionService.createRenditionDefinition(renditionQName, renderingEngineName);
return new ScriptRenditionDefinition(serviceRegistry, this.getScope(), engineDefinition, rendDef);
}
use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.
the class ScriptRenditionService method render.
/**
* This method renders the specified source node using the specified saved
* rendition definition.
* @param sourceNode the source node to be rendered.
* @param renditionDefQName the rendition definition to be used e.g. "cm:doclib" or
* "{http://www.alfresco.org/model/content/1.0}imgpreview"
* @return the rendition scriptnode.
* @see org.alfresco.service.cmr.rendition.RenditionService#render(org.alfresco.service.cmr.repository.NodeRef, RenditionDefinition)
*/
public ScriptNode render(ScriptNode sourceNode, String renditionDefQName) {
if (logger.isDebugEnabled()) {
StringBuilder msg = new StringBuilder();
msg.append("Rendering source node '").append(sourceNode).append("' with renditionDef '").append(renditionDefQName).append("'");
logger.debug(msg.toString());
}
RenditionDefinition rendDef = loadRenditionDefinitionImpl(renditionDefQName);
ChildAssociationRef result = this.renditionService.render(sourceNode.getNodeRef(), rendDef);
NodeRef renditionNode = result.getChildRef();
if (logger.isDebugEnabled()) {
StringBuilder msg = new StringBuilder();
msg.append("Rendition: ").append(renditionNode);
logger.debug(msg.toString());
}
return new ScriptNode(renditionNode, serviceRegistry);
}
use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.
the class ScriptRenditionService method loadRenditionDefinitionImpl.
private RenditionDefinition loadRenditionDefinitionImpl(String shortOrLongFormQName) {
final QName renditionName = createQName(shortOrLongFormQName);
// Rendition Definitions are persisted underneath the Data Dictionary for which Group ALL
// has Consumer access by default. However, we cannot assume that that access level applies for all deployments. See ALF-7334.
RenditionDefinition rendDefn = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<RenditionDefinition>() {
@Override
public RenditionDefinition doWork() throws Exception {
return renditionService.loadRenditionDefinition(renditionName);
}
}, AuthenticationUtil.getSystemUserName());
return rendDefn;
}
use of org.alfresco.service.cmr.rendition.RenditionDefinition in project alfresco-repository by Alfresco.
the class ScriptRenditionDefinition method executeImpl.
@Override
protected void executeImpl(ScriptNode node) {
RenditionDefinition renditionDefinition = getRenditionDefinition();
this.services.getRenditionService().render(node.getNodeRef(), renditionDefinition);
}
Aggregations