Merged V3.0 to HEAD

12003: ETHREEOH-535: User with Editor role can't edit content
   12016: ETHREEOH-864
   12018: Fixed NullPointerException during NFS mount. JLAN-51.
   12019: Fixed problems in mounting the Alfresco filesystems with NFS. ETHREEOH-913.
   12020: Use a default RPC authenticator if not specified in the xml configuration. JLAN-51.
   12021: Fixed typo in Portmapper server class name that is loader dynamically. JLAN-52.
   12025: MT - fix export/import tenant (ensure tenant admin ops run in tx)
   12026: Site service now returns information about the site managers. First part of fix for ETHREEOH-547
   12027: Fix for ETHREEOH-664 and ETHREEOH-789. RSS feed issues and authentication errors when trying to retrieve user details via feed service endpoint.
   12029: Fix for some wiki page links being highlighted as "missing page" when they're not
   12030: ETHREEOH-916 - Unable to "Publish Internally" a newly created blog post
   12031: Added logging to thumbnail service to help diagnose ETHREEOH-910 should it occur again
   12032: Removed out of date comment on mysql driver
   12034: Suppress freemarker.runtime ERROR log messages. These may correspond to exceptions that get handled by Alfresco's retrying transaction handler (e.g. optimistic locking failures) and are only passed on and logged if the retry threshold is exceeded.
   12037: Fix for ETHREEOH-901: Radio buttons using a enumeration can not be selected in internet explorer and selecting an option in a drop down menu causes a script error in Internet Explorer
   12038: Merged 2.2 to 3.0
      12017: Integrated ETWOTWO-926: Inline callouts should be able to reference a web script maintained in the Data Dictionary
   12042: Build fix
   12043: Fix for ETHREEOH-472 & ETHREEOH-473: File picker restrictions (folder and search) do not work.
   12065: New class Alfresco.service.Preferences that makes it easy to add and remove user preferences.
   12069: Fix for ETHREEOH-926. Fixed bug webscript matching code when url element containing a dot is followed by further url elements.
   12071: Added support to Alfresco.service.Preferences so it can handle hirerchial properties, ie "org.alfresco.share.sites.favourites"
   12074: Fix for ETHREEOH-896: XML Form layout is incorrect on Firefox 3
   12075: Fix for ETHREEOH-917 - help text for Create Site changed as requested.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12497 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-12-18 15:49:55 +00:00
parent 6b3d327f64
commit 9f42bfac4c
9 changed files with 571 additions and 385 deletions

View File

@@ -49,17 +49,21 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.GUID;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Roy Wetherall
*/
public class ThumbnailServiceImpl implements ThumbnailService
{
/** Logger */
private static Log logger = LogFactory.getLog(ThumbnailServiceImpl.class);
/** Error messages */
private static final String ERR_NO_CREATE = "Thumbnail could not be created as required transformation is not supported from {0} to {1}";
private static final String ERR_DUPLICATE_NAME = "Thumbnail could not be created because of a duplicate name";
private static final String ERR_NO_PARENT = "Thumbnail has no parent so update cannot take place.";
private static final String ERR_TOO_PARENT = "Thumbnail has more than one source content node. This is invalid so update cannot take place.";
/** Node service */
private NodeService nodeService;
@@ -140,11 +144,21 @@ public class ThumbnailServiceImpl implements ThumbnailService
ParameterCheck.mandatoryString( "mimetype", mimetype);
ParameterCheck.mandatory("transformationOptions", transformationOptions);
if (logger.isDebugEnabled() == true)
{
logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype);
}
NodeRef thumbnail = null;
// Check for duplicate names
if (thumbnailName != null && getThumbnailByName(node, contentProperty, thumbnailName) != null)
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Creating thumbnail: There is already a thumbnail with the name '" + thumbnail + "' (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype);
}
// We can't continue because there is already an thumnail with the given name for that content property
throw new ThumbnailException(ERR_DUPLICATE_NAME);
}
@@ -209,6 +223,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// Catch the failure to create the thumbnail
if (this.contentService.isTransformable(reader, writer, transformationOptions) == false)
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Creating thumbnail: There is no transformer to generate the thumbnail required (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype + ")");
}
// Throw exception indicating that the thumbnail could not be created
throw new ThumbnailException(MessageFormat.format(ERR_NO_CREATE, reader.getMimetype(), writer.getMimetype()));
}
@@ -239,6 +258,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
*/
public void updateThumbnail(NodeRef thumbnail, TransformationOptions transformationOptions)
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Updating thumbnail (thumbnail=" + thumbnail.toString() + ")");
}
// First check that we are dealing with a thumbnail
if (ContentModel.TYPE_THUMBNAIL.equals(this.nodeService.getType(thumbnail)) == true)
{
@@ -247,16 +271,13 @@ public class ThumbnailServiceImpl implements ThumbnailService
List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(thumbnail, ContentModel.ASSOC_THUMBNAILS, RegexQNamePattern.MATCH_ALL);
if (parents.size() == 0)
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Updating thumbnail: The thumbnails parent cannot be found (thumbnail=" + thumbnail.toString() + ")");
}
throw new ThumbnailException(ERR_NO_PARENT);
}
// TODO
// When a node with thumbnails is checked in the assoc's get doubled up. This means we get more than one parent.
// As a work around simply take the first parent retrieved
//
//else if (parents.size() != 1)
//{
// throw new ThumbnailException(ERR_TOO_PARENT);
//}
else
{
node = parents.get(0).getParentRef();
@@ -278,6 +299,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// Catch the failure to create the thumbnail
if (this.contentService.isTransformable(reader, writer, transformationOptions) == false)
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Updating thumbnail: there is not transformer to update the thumbnail with (thumbnail=" + thumbnail.toString() + ")");
}
// Throw exception indicating that the thumbnail could not be created
throw new ThumbnailException(MessageFormat.format(ERR_NO_CREATE, reader.getMimetype(), writer.getMimetype()));
}
@@ -287,7 +313,13 @@ public class ThumbnailServiceImpl implements ThumbnailService
this.contentService.transform(reader, writer, transformationOptions);
}
}
// TODO else should we throw an exception?
else
{
if (logger.isDebugEnabled() == true)
{
logger.debug("Updating thumbnail: cannot update a thumbnail node that isn't the correct thumbnail type (thumbnail=" + thumbnail.toString() + ")");
}
}
}
/**
@@ -304,6 +336,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// If retrieval performance becomes an issue then this code can be replaced
//
if (logger.isDebugEnabled() == true)
{
logger.debug("Getting thumbnail by name (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; thumbnailName=" + thumbnailName + ")");
}
// Check that the node has the thumbnailed aspect applied
if (nodeService.hasAspect(node, ContentModel.ASPECT_THUMBNAILED) == true)
{
@@ -339,6 +376,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// If retrieval performance becomes an issue then this code can be replaced
//
if (logger.isDebugEnabled() == true)
{
logger.debug("Getting thumbnails (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype + ")");
}
// Check that the node has the thumbnailed aspect applied
if (nodeService.hasAspect(node, ContentModel.ASPECT_THUMBNAILED) == true)
{