Merge V1.3 to HEAD (2976:3004)

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@2976 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3004 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3335 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-07-18 14:50:00 +00:00
parent d1acea9b24
commit d8b6213ee9
20 changed files with 2295 additions and 624 deletions

View File

@@ -18,7 +18,6 @@ package org.alfresco.repo.action.executer;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.Action;
@@ -212,58 +211,48 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
destinationAssocQName,
false);
newCopy = true;
}
}
// Get the content reader
ContentReader contentReader = this.contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
if (contentReader == null)
{
// for some reason, this action is premature
throw new AlfrescoRuntimeException(
"Attempting to execute content transformation rule " +
"but content has not finished writing, i.e. no URL is available.");
}
String originalMimetype = contentReader.getMimetype();
// get the writer and set it up
ContentWriter contentWriter = this.contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
contentWriter.setMimetype(mimeType); // new mimetype
contentWriter.setEncoding(contentReader.getEncoding()); // original encoding
if (newCopy == true)
{
// Adjust the name of the copy
String originalName = (String)nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
String newName = transformName(originalName, originalMimetype, mimeType);
String newName = transformName(originalName, mimeType);
nodeService.setProperty(copyNodeRef, ContentModel.PROP_NAME, newName);
String originalTitle = (String)nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_TITLE);
if (originalTitle != null && originalTitle.length() > 0)
{
String newTitle = transformName(originalTitle, originalMimetype, mimeType);
String newTitle = transformName(originalTitle, mimeType);
nodeService.setProperty(copyNodeRef, ContentModel.PROP_TITLE, newTitle);
}
}
// Try and transform the content
try
// Get the content reader
ContentReader contentReader = this.contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
// Only do the transformation if some content is available
if (contentReader != null)
{
doTransform(ruleAction, contentReader, contentWriter);
}
catch(NoTransformerException e)
{
if (logger.isDebugEnabled())
// get the writer and set it up
ContentWriter contentWriter = this.contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
contentWriter.setMimetype(mimeType); // new mimetype
contentWriter.setEncoding(contentReader.getEncoding()); // original encoding
// Try and transform the content
try
{
logger.debug("No transformer found to execute rule: \n" +
" reader: " + contentReader + "\n" +
" writer: " + contentWriter + "\n" +
" action: " + this);
doTransform(ruleAction, contentReader, contentWriter);
}
//if (newCopy == true)
//{
// TODO: Revisit this for alternative solutions
// nodeService.deleteNode(copyNodeRef);
// }
}
catch(NoTransformerException e)
{
if (logger.isDebugEnabled())
{
logger.debug("No transformer found to execute rule: \n" +
" reader: " + contentReader + "\n" +
" writer: " + contentWriter + "\n" +
" action: " + this);
}
}
}
}
protected void doTransform(Action ruleAction, ContentReader contentReader, ContentWriter contentWriter)
@@ -279,7 +268,7 @@ public class TransformActionExecuter extends ActionExecuterAbstractBase
* @param newMimetype
* @return
*/
private String transformName(String original, String originalMimetype, String newMimetype)
private String transformName(String original, String newMimetype)
{
// get the current extension
int dotIndex = original.lastIndexOf('.');