In the HTML rendering engine, when extracting out images, don't include WCM specific associations. (We'll put back some more general ones once composite content hopefully offers a suitable one)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22737 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-09-28 10:46:20 +00:00
parent 778078e26c
commit 798e35c455
4 changed files with 27 additions and 46 deletions

View File

@@ -133,9 +133,7 @@
<bean id="htmlRenderingEngine" <bean id="htmlRenderingEngine"
class="org.alfresco.repo.rendition.executer.HTMLRenderingEngine" class="org.alfresco.repo.rendition.executer.HTMLRenderingEngine"
parent="baseRenderingAction"> parent="baseRenderingAction" />
<property name="dictionaryService" ref="DictionaryService" />
</bean>
<bean id="compositeRenderingEngine" <bean id="compositeRenderingEngine"
class="org.alfresco.repo.rendition.executer.CompositeRenderingEngine" class="org.alfresco.repo.rendition.executer.CompositeRenderingEngine"

View File

@@ -97,6 +97,7 @@ public abstract class TikaPoweredContentTransformer extends AbstractContentTrans
if(MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(targetMimetype) || if(MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(targetMimetype) ||
MimetypeMap.MIMETYPE_HTML.equals(targetMimetype) || MimetypeMap.MIMETYPE_HTML.equals(targetMimetype) ||
MimetypeMap.MIMETYPE_XHTML.equals(targetMimetype) ||
MimetypeMap.MIMETYPE_XML.equals(targetMimetype)) MimetypeMap.MIMETYPE_XML.equals(targetMimetype))
{ {
// We can output to this // We can output to this
@@ -134,7 +135,8 @@ public abstract class TikaPoweredContentTransformer extends AbstractContentTrans
{ {
handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "html"); handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "html");
} }
else if(MimetypeMap.MIMETYPE_XML.equals(targetMimeType)) else if(MimetypeMap.MIMETYPE_XHTML.equals(targetMimeType) ||
MimetypeMap.MIMETYPE_XML.equals(targetMimeType))
{ {
handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml"); handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
} }

View File

@@ -93,17 +93,6 @@ public class HTMLRenderingEngine extends AbstractRenderingEngine
*/ */
public static final String NAME = "htmlRenderingEngine"; public static final String NAME = "htmlRenderingEngine";
protected static final QName PRIMARY_IMAGE = QName.createQName(
"http://www.alfresco.org/model/website/1.0", "primaryImage");
protected static final QName SECONDARY_IMAGE = QName.createQName(
"http://www.alfresco.org/model/website/1.0", "secondaryImage");
private DictionaryService dictionaryService;
public void setDictionaryService(DictionaryService dictionaryService) {
this.dictionaryService = dictionaryService;
}
@Override @Override
protected Collection<ParameterDefinition> getParameterDefinitions() { protected Collection<ParameterDefinition> getParameterDefinitions() {
@@ -219,19 +208,9 @@ public class HTMLRenderingEngine extends AbstractRenderingEngine
).getChildRef(); ).getChildRef();
} }
// If we can, associate it with the rendered HTML, so // TODO Once composite content is properly supported,
// that they're properly linked // at this point we'll associate the new image with
QName assocType = SECONDARY_IMAGE; // the rendered HTML node so the dependency is tracked.
if(primary)
{
assocType = PRIMARY_IMAGE;
}
if(dictionaryService.getAssociation(assocType) != null)
{
nodeService.createAssociation(
context.getDestinationNode(), img, assocType
);
}
// Put the image into the node // Put the image into the node
ContentWriter writer = contentService.getWriter( ContentWriter writer = contentService.getWriter(

View File

@@ -284,10 +284,11 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest
// Check we didn't get any images // Check we didn't get any images
for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode)) for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode))
{ {
if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE)) // TODO Check against composite content associations when present
fail("Found unexpected primary image of rendered html"); // if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE))
if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE)) // fail("Found unexpected primary image of rendered html");
fail("Found unexpected secondary image of rendered html"); // if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE))
// fail("Found unexpected secondary image of rendered html");
} }
// All done // All done
@@ -376,21 +377,22 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest
assertEquals(1, nodeService.getChildAssocs(imgFolder).size()); assertEquals(1, nodeService.getChildAssocs(imgFolder).size());
// TODO Check against composite content associations when present
// Check the associations if supported // Check the associations if supported
if(dictionaryService.getAssociation(HTMLRenderingEngine.PRIMARY_IMAGE) != null) // if(dictionaryService.getAssociation(HTMLRenderingEngine.PRIMARY_IMAGE) != null)
{ // {
boolean hasPrimary = false; // boolean hasPrimary = false;
boolean hasSecondary = false; // boolean hasSecondary = false;
for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode)) // for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode))
{ // {
if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE)) // if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE))
hasPrimary = true; // hasPrimary = true;
if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE)) // if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE))
hasSecondary = true; // hasSecondary = true;
} // }
assertEquals(true, hasPrimary); // assertEquals(true, hasPrimary);
assertEquals(false, hasSecondary); // assertEquals(false, hasSecondary);
} // }
// All done // All done
tidyUpSourceDoc(); tidyUpSourceDoc();