mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-21398 Unable to override standard rendition definitions (#913)
Relaxed the checks so that it is possible to override rendition definitions. DEBUG is logged in this case.
This commit is contained in:
@@ -252,8 +252,13 @@ public class RenditionDefinitionRegistry2Impl implements RenditionDefinitionRegi
|
|||||||
{
|
{
|
||||||
map.put(RenditionDefinition2.TIMEOUT, timeoutDefault);
|
map.put(RenditionDefinition2.TIMEOUT, timeoutDefault);
|
||||||
}
|
}
|
||||||
|
RenditionDefinition2 original = getRenditionDefinition(def.renditionName);
|
||||||
new RenditionDefinition2Impl(def.renditionName, def.targetMediaType, map, true,
|
new RenditionDefinition2Impl(def.renditionName, def.targetMediaType, map, true,
|
||||||
RenditionDefinitionRegistry2Impl.this);
|
RenditionDefinitionRegistry2Impl.this);
|
||||||
|
if (original != null)
|
||||||
|
{
|
||||||
|
log.debug(readFromMessage+" replaced the rendition "+def.renditionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,15 +319,13 @@ public class RenditionDefinitionRegistry2Impl implements RenditionDefinitionRegi
|
|||||||
public void register(RenditionDefinition2 renditionDefinition)
|
public void register(RenditionDefinition2 renditionDefinition)
|
||||||
{
|
{
|
||||||
String renditionName = renditionDefinition.getRenditionName();
|
String renditionName = renditionDefinition.getRenditionName();
|
||||||
RenditionDefinition2 original = getDefinition(renditionName);
|
|
||||||
if (original != null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("RenditionDefinition "+renditionName+" was already registered.");
|
|
||||||
}
|
|
||||||
Data data = getData();
|
Data data = getData();
|
||||||
|
// There may already be a rendition defined, but an extension may replace it.
|
||||||
|
// This is logged in a caller of this method were the file name is known.
|
||||||
data.renditionDefinitions.put(renditionName, renditionDefinition);
|
data.renditionDefinitions.put(renditionName, renditionDefinition);
|
||||||
|
|
||||||
if (renditionDefinition instanceof RenditionDefinition2Impl &&
|
if (renditionDefinition instanceof RenditionDefinition2Impl &&
|
||||||
!((RenditionDefinition2Impl)renditionDefinition).isDynamicallyLoaded())
|
!((RenditionDefinition2Impl)renditionDefinition).isDynamicallyLoaded())
|
||||||
{
|
{
|
||||||
log.debug("Adding static rendition "+renditionName+" into the registry");
|
log.debug("Adding static rendition "+renditionName+" into the registry");
|
||||||
data.staticCount++;
|
data.staticCount++;
|
||||||
|
@@ -56,6 +56,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static junit.framework.TestCase.assertTrue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
@@ -123,7 +124,6 @@ public class RenditionService2Test
|
|||||||
when(nodeService.exists(nodeRef)).thenReturn(true);
|
when(nodeService.exists(nodeRef)).thenReturn(true);
|
||||||
when(nodeService.exists(nodeRefMissing)).thenReturn(false);
|
when(nodeService.exists(nodeRefMissing)).thenReturn(false);
|
||||||
when(nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT)).thenReturn(contentData);
|
when(nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT)).thenReturn(contentData);
|
||||||
when(nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED)).thenReturn(new Date());
|
|
||||||
when(contentData.getContentUrl()).thenReturn(contentUrl);
|
when(contentData.getContentUrl()).thenReturn(contentUrl);
|
||||||
|
|
||||||
doAnswer(invocation ->
|
doAnswer(invocation ->
|
||||||
@@ -155,6 +155,7 @@ public class RenditionService2Test
|
|||||||
renditionService2.setEnabled(true);
|
renditionService2.setEnabled(true);
|
||||||
renditionService2.setThumbnailsEnabled(true);
|
renditionService2.setThumbnailsEnabled(true);
|
||||||
|
|
||||||
|
renditionDefinitionRegistry2.setRenditionConfigDir("alfresco/renditions/test");
|
||||||
renditionDefinitionRegistry2.afterPropertiesSet();
|
renditionDefinitionRegistry2.afterPropertiesSet();
|
||||||
renditionService2.afterPropertiesSet();
|
renditionService2.afterPropertiesSet();
|
||||||
|
|
||||||
@@ -273,4 +274,13 @@ public class RenditionService2Test
|
|||||||
assertTrue("Expected rendition "+name, renditionNames.contains(name));
|
assertTrue("Expected rendition "+name, renditionNames.contains(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test()
|
||||||
|
public void overriddenRendition()
|
||||||
|
{
|
||||||
|
// Check the standard rendition doclib has been overridden by one in alfresco/renditions/test/overrideRendition.json
|
||||||
|
RenditionDefinition2 doclib = renditionDefinitionRegistry2.getRenditionDefinition("doclib");
|
||||||
|
String resizeWidth = doclib.getTransformOptions().get("resizeWidth");
|
||||||
|
assertEquals("doclib has not been overridden", "180", resizeWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"renditions": [
|
||||||
|
{
|
||||||
|
"renditionName": "doclib",
|
||||||
|
"targetMediaType": "image/png",
|
||||||
|
"options": [
|
||||||
|
{"name": "resizeWidth", "value": 180},
|
||||||
|
{"name": "resizeHeight", "value": 180},
|
||||||
|
{"name": "allowEnlargement", "value": false},
|
||||||
|
{"name": "maintainAspectRatio", "value": true},
|
||||||
|
{"name": "autoOrient", "value": true},
|
||||||
|
{"name": "thumbnail", "value": true}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user