mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
34321: Make CIFS virtual circuit per session limit configurable, return correct status code when virtual circuit limit is reached. Required by Terminal Server clients as they can use a single session for all connections. ALF-13156 34322: Services part of fix for ALF-13057 Nodes marked with rma:ghosted aspect (or other configurable aspects/types) should not be renditioned. 34323: Added configuration property for CIFS virtual circuits per session, required by Terminal Server clients. ALF-13156. 34332: Fix for ALF-8405 34336: Merged BRANCHES/V4.0 to BRANCHES/DEV/V4.0-BUG-FIX: 34335: Fixing a failing test as part of ALF-13057 34338: NodeDAO: re-parent "lost & found" orphan child nodes (see ALF-12358 & ALF-13066 / SYS-301) - test fix (follow-on to r34279) 34341: NodeDAO: re-parent "lost & found" orphan child nodes (see ALF-12358 & ALF-13066 / SYS-301) - ano test fix (once more with feeling) 34351: Merged V4.0 to V4.0-BUG-FIX 34335: (RECORD ONLY) Fixing a failing test as part of ALF-13057 34350: Merged V3.4 to V4.0 34327: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - TransformerOptions.sourceNodeRef now populated - Set average transformer time via global properties - TransformerDebug of active transformers added 34331: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - Fix test failures 34346: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - sourceNodeRef was not available to the first child transformer of a ComplexContentTransformer 34358: Merged V4.0 to V4.0-BUG-FIX (RECORD ONLY) 34324: Merged BRANCHES/DEV/V4.0-BUG-FIX to BRANCHES/V4.0: 34322: Services part of fix for ALF-13057 Nodes marked with rma:ghosted aspect (or other configurable aspects/types) should not be renditioned. 34360: Merged V3.4-BUG-FIX to V4.0-BUG-FIX (RECORD ONLY) 34349: Merged V3.4 to V3.4-BUG-FIX 34327: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - TransformerOptions.sourceNodeRef now populated - Set average transformer time via global properties - TransformerDebug of active transformers added 34331: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - Fix test failures 34346: ALF-13030 ALF-13041 Transformer Server needs filename and to make its transformer preferred over OpenOffice and JOD Relates to ALF-10976 and ALF-10412 set of changes - sourceNodeRef was not available to the first child transformer of a ComplexContentTransformer 34348: Merged PATCHES/V3.4.7 to V3.4 34347: ALF-12949: Merged V4.0-BUG-FIX to PATCHES/V3.4.7 33959: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 33950: Fix for ALF-12787: - Surf Memory usage optimizations and improvements to ModelObject and derived classes. - Reduced avg memory usage for a ModelObject in the Surf persister cache from 4.0K to 1.5K. - Related refactoring to support removal of in-memory XML DOM previously used to maintain ModelObject state. Now XML DOM only created as needed for set() operations and thrown away. - Improvements to Surf Persister cache strategy to support MRU style concurrent cache, now uses a LinkedConcurrentHashMap to provide a concurrent cache that also has a configurable maximum capacity - Added various improved spring config for persister caches and default sizes. Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 33956: Latest SpringSurf libs: Fixed issue with overly aggressive caching of missing page View objects. 34108: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 34107: Added missing jar lib to wcmquickstart and webeditor dependencies 34363: Merged V4.0 to V4.0-BUG-FIX 34362: Merged V3.4 to V4.0 (RECORD ONLY) 34282: ALF-13059: Windows 7 specific: It's impossible to add documents to DWS - Fix by Alex Malinovsky 34348: Merged PATCHES/V3.4.7 to V3.4 34347: ALF-12949: Merged V4.0-BUG-FIX to PATCHES/V3.4.7 33959: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 33950: Fix for ALF-12787: - Surf Memory usage optimizations and improvements to ModelObject and derived classes. - Reduced avg memory usage for a ModelObject in the Surf persister cache from 4.0K to 1.5K. - Related refactoring to support removal of in-memory XML DOM previously used to maintain ModelObject state. Now XML DOM only created as needed for set() operations and thrown away. - Improvements to Surf Persister cache strategy to support MRU style concurrent cache, now uses a LinkedConcurrentHashMap to provide a concurrent cache that also has a configurable maximum capacity - Added various improved spring config for persister caches and default sizes. Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 33956: Latest SpringSurf libs: Fixed issue with overly aggressive caching of missing page View objects. 34108: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX 34107: Added missing jar lib to wcmquickstart and webeditor dependencies git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34364 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
215 lines
9.0 KiB
Java
215 lines
9.0 KiB
Java
/*
|
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.repo.thumbnail;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import org.alfresco.error.AlfrescoRuntimeException;
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
|
import org.alfresco.service.cmr.action.Action;
|
|
import org.alfresco.service.cmr.action.ActionServiceTransientException;
|
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
import org.alfresco.service.cmr.repository.ContentData;
|
|
import org.alfresco.service.cmr.repository.ContentServiceTransientException;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
* Create thumbnail action executer.
|
|
*
|
|
* NOTE: This action is used to facilitate the async creation of thumbnails. It is not intended for genereral useage.
|
|
*
|
|
* @author Roy Wetherall
|
|
* @author Ph Dubois (optional thumbnail creation by mimetype and in general)
|
|
*/
|
|
public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|
{
|
|
private static Log logger = LogFactory.getLog(CreateThumbnailActionExecuter.class);
|
|
|
|
/** Thumbnail Service */
|
|
private ThumbnailService thumbnailService;
|
|
|
|
/** Node Service */
|
|
private NodeService nodeService;
|
|
|
|
/** Property turns on and off all thumbnail creation */
|
|
private boolean generateThumbnails = true;
|
|
|
|
// Size limitations (in KBytes) indexed by mimetype for thumbnail creation
|
|
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
|
|
|
|
/** Action name and parameters */
|
|
public static final String NAME = "create-thumbnail";
|
|
public static final String PARAM_CONTENT_PROPERTY = "content-property";
|
|
public static final String PARAM_THUMBANIL_NAME = "thumbnail-name";
|
|
|
|
/**
|
|
* Set the thumbnail service
|
|
*
|
|
* @param thumbnailService the thumbnail service
|
|
*/
|
|
public void setThumbnailService(ThumbnailService thumbnailService)
|
|
{
|
|
this.thumbnailService = thumbnailService;
|
|
}
|
|
|
|
/**
|
|
* Set the node service
|
|
*
|
|
* @param nodeService node service
|
|
*/
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.nodeService = nodeService;
|
|
}
|
|
|
|
/**
|
|
* Set the maximum size for each mimetype above which thumbnails are not created.
|
|
* @param mimetypeMaxSourceSizeKBytes map of mimetypes to max source sizes.
|
|
*/
|
|
public void setMimetypeMaxSourceSizeKBytes(HashMap<String, Long> mimetypeMaxSourceSizeKBytes)
|
|
{
|
|
this.mimetypeMaxSourceSizeKBytes = mimetypeMaxSourceSizeKBytes;
|
|
}
|
|
|
|
/**
|
|
* Enable thumbnail creation at all regardless of mimetype.
|
|
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
|
|
*/
|
|
public void setGenerateThumbnails(boolean generateThumbnails)
|
|
{
|
|
this.generateThumbnails = generateThumbnails;
|
|
}
|
|
|
|
/**
|
|
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
|
*/
|
|
@Override
|
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
|
{
|
|
// Check if thumbnailing is generally disabled
|
|
if (!generateThumbnails)
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug("Thumbnail transformations are not enabled");
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (this.nodeService.exists(actionedUponNodeRef) == true)
|
|
{
|
|
// Get the thumbnail Name
|
|
String thumbnailName = (String)action.getParameterValue(PARAM_THUMBANIL_NAME);
|
|
|
|
// Get the details of the thumbnail
|
|
ThumbnailRegistry registry = this.thumbnailService.getThumbnailRegistry();
|
|
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
|
|
if (details == null)
|
|
{
|
|
// Throw exception
|
|
throw new AlfrescoRuntimeException("The thumbnail name '" + thumbnailName + "' is not registered");
|
|
}
|
|
|
|
// Get the content property
|
|
QName contentProperty = (QName)action.getParameterValue(PARAM_CONTENT_PROPERTY);
|
|
if (contentProperty == null)
|
|
{
|
|
contentProperty = ContentModel.PROP_CONTENT;
|
|
}
|
|
|
|
// If there isn't a currently active transformer for this, log and skip
|
|
Serializable contentProp = nodeService.getProperty(actionedUponNodeRef, contentProperty);
|
|
if (contentProp == null)
|
|
{
|
|
logger.info("Creation of thumbnail, null content for " + details.getName());
|
|
return;
|
|
}
|
|
|
|
if(contentProp instanceof ContentData)
|
|
{
|
|
ContentData content = (ContentData)contentProp;
|
|
String mimetype = content.getMimetype();
|
|
if (!registry.isThumbnailDefinitionAvailable(content.getContentUrl(), mimetype, content.getSize(), actionedUponNodeRef, details))
|
|
{
|
|
logger.debug("Unable to create thumbnail '" + details.getName() + "' for " +
|
|
mimetype + " as no transformer is currently available");
|
|
return;
|
|
}
|
|
if (mimetypeMaxSourceSizeKBytes != null)
|
|
{
|
|
Long maxSourceSizeKBytes = mimetypeMaxSourceSizeKBytes.get(mimetype);
|
|
if (maxSourceSizeKBytes != null && maxSourceSizeKBytes >= 0 && maxSourceSizeKBytes < (content.getSize()/1024L))
|
|
{
|
|
logger.debug("Unable to create thumbnail '" + details.getName() + "' for " +
|
|
mimetype + " as content is too large ("+(content.getSize()/1024L)+"K > "+maxSourceSizeKBytes+"K)");
|
|
return; //avoid transform
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create the thumbnail
|
|
try
|
|
{
|
|
this.thumbnailService.createThumbnail(actionedUponNodeRef, contentProperty, details.getMimetype(), details.getTransformationOptions(), thumbnailName, null);
|
|
}
|
|
catch (ContentServiceTransientException cste)
|
|
{
|
|
// any transient failures in the thumbnail creation must be handled as transient failures of the action to execute.
|
|
StringBuilder msg = new StringBuilder();
|
|
msg.append("Creation of thumbnail '") .append(details.getName()) .append("' declined");
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
logger.debug(msg.toString());
|
|
}
|
|
|
|
throw new ActionServiceTransientException(msg.toString(), cste);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
final String msg = "Creation of thumbnail '" + details.getName() + "' failed";
|
|
logger.info(msg);
|
|
|
|
// We need to rethrow in order to trigger the compensating action.
|
|
// See AddFailedThumbnailActionExecuter
|
|
throw new AlfrescoRuntimeException(msg, exception);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
|
*/
|
|
@Override
|
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
|
{
|
|
paramList.add(new ParameterDefinitionImpl(PARAM_THUMBANIL_NAME, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_THUMBANIL_NAME)));
|
|
paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_CONTENT_PROPERTY)));
|
|
}
|
|
}
|