Dave Ward 90a78359bd Merged V3.4-BUG-FIX to HEAD
31682: Fix for ALF-9504 - Upload non-flash fallback fails
      Merged HEAD to V3.4-BUG-FIX
         31065: Fixed ALF-10407 "Share HTML uploader broken in Swift"
   31738: merged DEV to V3.4_BUG_FIX
     31681 : ALF-7859 - Deployment fails for *.xml content with wcm-xml-metadata-extracter-context.xml enabled
   31755: Fix for ALF-9257: merged in and optimised Belarus fix.
   31775: Fixed ALF-10667: WCM - Validation issue with xf:switch web forms
   31817: Spanish: Updates translations (based on: r31738) & adds new WCM translations.
   31840: Fix for ALF-10282 - Web Browser freezes with large xml files Web form transformation
   31843: ALF-9208 Performance issue, during load tests /share/page/user/user-sites is showing to be the most expensive.
      Modification to AuthorityDAOImpl.findAuthorities(...) to use childAuthorityCache when possible
      Big improvement to 'My Sites'
   31850: Italian: Translation updates, inc. fix for: ALF-11293.
   31867: Merged DEV/TEMPORARY to V3.4-BUG-FIX
      31400: ALF-10764: PDF vs 1.5 cause crash jvm
         - PDFRenderer library has been updated from 2009-09-27 to 0.9.1 version to support PDF documents of 1.5 version
   31906: ALF-9545: Adjust date picker for IE
   31911: Merge PATCHES/V3.3.3 to V3.4-BUG-FIX (3.4.7)
      31905: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content
         - Run Timer as the original user
         - Run timer if there is a LOCK timeout (not run if not so not to break standard. MS Office uses a 3 minute timeout)
         - PUT method clears aspect BEFORE it starts processing the content, so that the Timer does not remove the node if the content is very large
         - Delete node faster (than the Timer) if the client issues an UNLOCK, having locked the node but not issued a PUT. 
         - Lots of debug
      31708: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content
          'runAsSystem' the 5 minute timer to remove LOCKED but not PUT WebDAV files 
      31698: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content
          Added 5 minute timer to remove LOCKED but not PUT WebDAV files 
      31687: ALF-10309 CLONE -WebDAV - Cancelling "save as" upload will create 0 byte content
          Added missing sys:webdavNoContent aspect to system model.
   31913: Merge PATCHES/V3.4.1 (3.4.1.22) to V3.4-BUG-FIX (3.4.7)
      31876: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Use a retrying non-propagating (new) transaction to get the licence key in order to avoid intermittent issues.
   31929: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_11_09 to BRANCHES/DEV/V3.4-BUG-FIX
       31903: ALF-9971: RM search doesn't work with NAME:any_text: Check for dublicate template of properties was added. Throws an exception if there is already an entry in the map entry.
   31931: ALF_9678 Fixed null pointer issues in WorkflowManager methods
   31938: Merged DEV to V3.4-BUG-FIX
      31932: ALF-9566: hasMoreItems always false in CMIS query (Web Service binding)
             1. PropertyFilter was fixed to be able to handle OpenCMIS Workbench. Unit test was updated.
             2. hasMoreItems was adopted to indicate whether more itemsa are avliable in the repo based on maxItems and skipCount. Unit test was added.
             3. CMISFolderTypeDefinition was fixed to be fileable according to 2.1.5.1 File-able Objects.
   31965: German: Translation updates and additions based on EN r31738
   31967: French: Translation updates and additions based on EN r31738
   31969: Spanish: : Translation updates and additions based on EN r31738
   31971: Italian: Translation updates and additions based on EN r31738
   31972: Fix for patch 'alternatives': Alternative patch must have executed and not just been marked as successful
   31973: Fixed ALF-11489: 'patch.sitesSpacePermissions' failed on upgrade 2.2.8 -> 3.4.6
    - 'patch.sitesFolder' is an alternative to 'patch.sitesSpacePermissions'
    - Note: Requires rev 31972 for fix to PatchService use of alternatives
   31994: ALF-11495 CLONE - Enterprise unlimited licenses still get invalidated turning the system into read-only mode
      - Replaced DescriptorDAORetryingInterceptor (add in the hotfix) with a RetryingTransactionInterceptor 
   31999: Change the low level CIFS packet reading code to read/process up to 4 requests per thread run. ALF-9540
   Reduces thread blocking when the CIFS client uses overlapped I/O, and also keeps writes in their original sequence.
   32037: Japanese: Translation update, new and modified strings based on EN r31738
   32061: ALF-11376 Requesting PDFBox 1.6 be included in future service pack release. 
      Upgrading pdfbox,fontbox,jempbox from 1.5.0 to 1.6.0
   32074: ALF-11522 IMAP: Generic AlfrescoImapFolderException error is a bit misleading
      "Can't create folder - Permission denied" --> "Cannot perform action - permission denied"
   32086: ALF-9971 RM search doesn't work with NAME:any_text
      - fix to test failure to do with upper case defaultFieldName finding nothing
   32093: Merged BELARUS/V3.4-BUG-FIX-2011_10_13 to V3.4-BUG-FIX (3.4.7)
      Plus a little bit of refactoring to remove duplicate code
      31490: ALF-9817: IE strips exe extension on download file when using download url with ticket parameter in code  
         The "filename" part for "Content-Disposition" header in case of "attachment" for IE
   32115: ALF-11569: Merged V3.3 to V3.4-BUG-FIX
      32108: ALF-11571: Fix new deadlock in NIO CIFSRequestHandler
         - Needed to be able to get a thread safe estimate of the number of registered sessions without synchronizing on m_selector.keys() because a lock is held by the selector whilst waiting
         - Now the session count is maintained by the main thread, which is woken by anything wanting a session count.
   32136: ALF-10412 Nonreducing 100% CPU Uploading Large Files to Share Site Document Library
      Reducing the priority of the async thread pool that is used to perform the transformations so that normal activity (and even garbage collection) is not interrupted by transformations. 
   32143: MERGED 2011_11_09 to V3.4-BUG-FIX
     32133 - ALF-11193 Consumer role cannot Unscribe/subscribe the IMAP folders.
     32137
   32152: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_10_13 to BRANCHES/DEV/V3.4-BUG-FIX:
      31731: ALF-6275: Discrepancy detected on archived pivot language with EditionService
   32171: ALF-9638: Version2ServiceImpl now freezes aspect specific associations, in line with VersionServiceImpl
   32191: Merged DEV to V3.4-BUG-FIX
      32187: ALF-10884: A file renamed using the web UI still appears in a NFS mount but with NULL stats
             - Timestamp propogation in case of move
             - getPaths() call removed from the NodeMonitor
   32192: Reversed out rev 32143: ALF-11193: Consumer role cannot Unscribe/subscribe the IMAP folders. 
    - Patch is using SearchService
    - Patch doesn't transfer IMAP 'unsubscriptions'
    - Patch will not scale
   32211: Merged V3.4 to V3.4-BUG-FIX
      31914: ALF-10619: Not all container deletions were being honoured during indexing due to deletionsSinceFlushed processing
         - If container B is under container A with a secondary association, and A then B were deleted, then not all of Bs containers were getting masked out - only those in a subtree of A!
         - Now that delete events are fired on every affected node in a cascading delete, we can handle the nodes and containers on an individual basis
      31915: ALF-10619: Prevent possible InvalidNodeRefException during reindexing
         - Handle in childRelationshipEvent() when comparing with 'path generation factor'
   32322: Possible fix for: (ALF-11344) SORT clause in CMIS query (ORDER BY) drastically affects performance of search.
   - English based locales will sort as Java String comparison.
   32327: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8)
      32326: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         MaxUserLicenseException class was not added to SVN in previous commit
      32325: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Remove RetryingTransactionInterceptor from around RepositoryDescriptorDAOImpl - not needed any more and caused extra exception if repo was r/o on boot
      32324: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Addition of message to say temporary problem has gone away
      32323: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Think I have found the reason for the vanishing licenses.
         License Descriptor can be accessed but the file in the content store cannot be read.
         Tidy up of code to remove TODO messages
         Addition of MaxUserLicenseException
         Additional code to handle possible temporary license outages and recovery
         Addition of more specific exception of invalid content store issue
      32326: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         MaxUserLicenseException class was not added to SVN in previous commit
      32288: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Fix tests by still failing if we have not loaded a license yet
      32259: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Ignore exceptions from debug after RepositoryDescriptorDAOImpl Throwable
      32252: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Addition of logging and keep license live after error
   32343: FIXED - issue ALF-11617: wma file type is mapped to 'video/x-ms-wma' mimetype instead of audio/x-ms-wma'
   Changed the type audio/x-ms-wma
   32346: Fixed query use-case lookup of assoc namespace entity (i.e. should not lazily create)
    - Does not need merging to 4.0, which contains the fixes already
   32349: Merged V3.3 to V3.4-BUG-FIX
      32347: Prevent possible deadlock during subsystem syncing in a cluster
   32352: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8)
      PLEASE NOTE that ALF-11381 was also merged into V3.4-BUG-FIX in r32327 
      32350: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Patched version of true license to log RunTimeExceptions and Errors from both ftp and non-ftp LicenseManager verify methods
      32332: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         Cannot throw specific Exception for the file reader issue as returning null is required for FTL
   32356: ALF-11495: Merge V3.4.1 (3.4.1.23) to V3.4-BUG-FIX (3.4.8)
      32355: ALF-11381 Enterprise unlimited licenses still get invalidated turning the system into read-only mode
         TrueLicense missing from classpath.unit.test.extension
   32387: ALF-11617 Correct mimetype for WMA audio (with patch)
   32395: ALF-11004 Workflow Interpreter can now handle transitions with spaces in the name when 'signal' is called.
   32398: ALF-11078: Reinstate maxPermissionChecks logging from ALF-7237
   32411: Fix for ALF-11344 SORT clause in CMIS query (ORDER BY) drastically affects performance of search.
   - use in memory sort rather than relying on the lucene field cache for result sets up to 1000 by default 
   - this is configurable across all query languages (and per query via SearchParameters and QueryOptions)
           lucene.indexer.useInMemorySort=true
           lucene.indexer.maxRawResultSetSizeForInMemorySort=1000
   32425: Fix for ALF-11344 SORT clause in CMIS query (ORDER BY) drastically affects performance of search.
   - fix for score sorting
   32433: Merged V3.4 to V3.4-BUG-FIX
      32432: ALF-11743: When RM is installed, admin does not have the appropriate permissions to perform any operations in Alfresco Explorer


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32477 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2011-12-02 14:25:48 +00:00

476 lines
19 KiB
Java

/*
* Copyright (C) 2005-2010 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.model.ml;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.version.Version2Model;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.repo.version.common.VersionUtil;
import org.alfresco.service.cmr.ml.EditionService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Edition support implementation
*
* @author Yannick Pignot
*/
public class EditionServiceImpl implements EditionService
{
private static Log logger = LogFactory.getLog(EditionServiceImpl.class);
private VersionService versionService;
private NodeService nodeService;
private BehaviourFilter policyBehaviourFilter;
private MultilingualContentService multilingualContentService;
private NodeArchiveService nodeArchiveService;
private NodeService versionNodeService;
private FileFolderService fileFolderService;
/**
* List of properties to set persistent when an edition of the mlContainer is created
*/
public static final QName[] ML_CONTAINER_PROPERTIES_TO_VERSION = {
ContentModel.PROP_AUTHOR,
ContentModel.PROP_LOCALE
};
/** {@inheritDoc} */
public NodeRef createEdition(NodeRef startingTranslationNodeRef, Map<String, Serializable> versionProperties)
{
if (nodeService.hasAspect(startingTranslationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
{
return createEditionImpl(
startingTranslationNodeRef,
versionProperties
);
}
else
{
throw new IllegalArgumentException("The node " + startingTranslationNodeRef + " is not multilingual.");
}
}
private NodeRef createEditionImpl(NodeRef startingTranslationNodeRef, Map<String, Serializable> versionProperties)
{
// 1. First step: prepare and version the mlContainer
// Get the ml container to version
NodeRef mlContainerToVersion = multilingualContentService.getTranslationContainer(startingTranslationNodeRef);
// Get all the container's children
List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(
mlContainerToVersion, ContentModel.ASSOC_MULTILINGUAL_CHILD,
RegexQNamePattern.MATCH_ALL);
// get the last edition and add it the Version Histories property to the version
Version currentEdition = versionService.getCurrentVersion(mlContainerToVersion);
addVersionHistoryProperty(currentEdition, childAssocRefs);
if(versionProperties == null)
{
versionProperties = new HashMap<String, Serializable>();
}
// get the properties to add to the edition history
addPropertiesToVersion(versionProperties, startingTranslationNodeRef);
// Version the container and its translations
versionService.createVersion(mlContainerToVersion, versionProperties, true);
// 2. second step: prepare the current edition of the mlContainer
// Get the new starting point node, it will be returned
NodeRef startNode;
// copy the translation before its deletion and get usefull properties
NodeRef space = nodeService.getPrimaryParent(startingTranslationNodeRef).getParentRef();
String name = (String) nodeService.getProperty(startingTranslationNodeRef, ContentModel.PROP_NAME);
Locale locale = (Locale) nodeService.getProperty(startingTranslationNodeRef, ContentModel.PROP_LOCALE);
String author = (String) nodeService.getProperty(startingTranslationNodeRef, ContentModel.PROP_AUTHOR);
for (int count = 0;; count++)
{
try
{
// genererate a temporary name.
String tempName = "TEMP_NAME" + System.currentTimeMillis() + "_" + count;
// try to copy the node
startNode = fileFolderService.copy(startingTranslationNodeRef, space, tempName).getNodeRef();
// copy completed without exception
break;
}
catch (FileExistsException e)
{
// try again with a new name
}
catch (FileNotFoundException e)
{
throw new IllegalStateException(e);
}
}
// remove the current translations of the mlContainer
removeTranslations(childAssocRefs);
// restore the original name of the node
nodeService.setProperty(startNode, ContentModel.PROP_NAME, name);
// add the starting node to the mlContainer, and set the author
multilingualContentService.addTranslation(startNode, mlContainerToVersion, locale);
nodeService.setProperty(startNode, ContentModel.PROP_AUTHOR, author);
// set the starting translation become the pivot.
nodeService.setProperty(mlContainerToVersion, ContentModel.PROP_LOCALE, locale);
nodeService.setProperty(mlContainerToVersion, ContentModel.PROP_AUTHOR, author);
nodeService.setProperty(mlContainerToVersion, ContentModel.PROP_NAME, name);
// Done
if (logger.isDebugEnabled())
{
// Get the version information
Version mlContainerVersion = versionService.getCurrentVersion(mlContainerToVersion);
String mlContainerVersionLabel = mlContainerVersion.getVersionLabel();
logger.debug("Versioned multilingual container: \n"
+ " Container: " + mlContainerToVersion + "\n"
+ " Current Version: " + mlContainerVersionLabel);
}
return startNode;
}
/** {@inheritDoc} */
public VersionHistory getEditions(NodeRef mlContainer)
{
VersionHistory editionHistory = null;
// Only the mlContainer can have editions
if (nodeService.getType(mlContainer).equals(
ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
// get the editions of the mlContainer
editionHistory = versionService.getVersionHistory(mlContainer);
}
else
{
throw new IllegalArgumentException("The type of the node must be "
+ ContentModel.TYPE_CONTAINER);
}
if (logger.isDebugEnabled())
{
logger.debug("Found all editions: \n" + " Node: "
+ mlContainer + " (type "
+ ContentModel.TYPE_MULTILINGUAL_CONTAINER + ")\n"
+ " Editions: " + editionHistory);
}
return editionHistory;
}
/** {@inheritDoc} */
public Map<QName, Serializable> getVersionedMetadatas(Version version)
{
NodeRef frozenNodeRef = version.getFrozenStateNodeRef();
if (frozenNodeRef.getStoreRef().getIdentifier().equals("lightWeightVersionStore"))
{
// The data stored belonged to the old version store
Map<String, Serializable> versionProps = version.getVersionProperties();
}
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(frozenNodeRef)))
{
// for the mlContainer, the properties are set as a version properties
Map<String, Serializable> properties = version.getVersionProperties();
// The returned map of this method need a QName type key, not a String.
Map<QName, Serializable> convertedProperties = new HashMap<QName, Serializable>(properties.size());
// perform the convertion
for(Map.Entry<String, Serializable> entry : properties.entrySet())
{
convertedProperties.put(
QName.createQName(entry.getKey()),
entry.getValue());
}
return convertedProperties;
}
else
{
// for any other type of node, the properties are set as versioned metadata
return versionNodeService.getProperties(frozenNodeRef);
}
}
/** {@inheritDoc} */
public List<VersionHistory> getVersionedTranslations(Version mlContainerEdition)
{
// Ensure that the given version is an Edition of an mlContainer
if(!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerEdition.getVersionedNodeRef())))
{
throw new IllegalArgumentException("The type of the node must be " + ContentModel.TYPE_CONTAINER);
}
Map<QName, Serializable> properties = versionNodeService.getProperties(mlContainerEdition.getFrozenStateNodeRef());
List<VersionHistory> versionHistories = null;
// Switch VersionStore depending on configured impl
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
{
// V2 version store (eg. workspace://version2Store)
// get the serialisation of the version histories in the version properties
Object histories = properties.get(Version2Model.PROP_QNAME_TRANSLATION_VERSIONS);
if (histories instanceof List)
{
versionHistories = (List<VersionHistory>)histories;
}
else if (histories instanceof VersionHistory)
{
versionHistories = new ArrayList<VersionHistory>(1);
versionHistories.add((VersionHistory)histories);
}
}
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
{
// Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
// get the serialisation of the version histories in the version properties
Object histories = properties.get(VersionModel.PROP_QNAME_TRANSLATION_VERSIONS);
if (histories instanceof List)
{
versionHistories = (List<VersionHistory>)histories;
}
else if (histories instanceof VersionHistory)
{
versionHistories = new ArrayList<VersionHistory>(1);
versionHistories.add((VersionHistory)histories);
}
}
else
{
throw new AlfrescoRuntimeException("Unexpected versionstore: " + versionService.getVersionStoreReference().getIdentifier());
}
if (versionHistories == null)
{
// the initial edition doesn't content translations (at the creation time of the mlContainer).
versionHistories = new ArrayList<VersionHistory>();
}
if (logger.isDebugEnabled())
{
logger.debug("Found all translations : \n"
+ " Versioned mlContainer: " + mlContainerEdition.getVersionedNodeRef() + "\n"
+ " Edition: " + mlContainerEdition
+ " Translations: " + versionHistories);
}
return versionHistories;
}
/**
* Util method to add the version histories of translations as a property of the frozen mlContainer
*/
private void addVersionHistoryProperty(Version edition, List<ChildAssociationRef> childAssocRefs)
{
List<VersionHistory> translationVersionHistories = new ArrayList<VersionHistory>(childAssocRefs.size());
for (ChildAssociationRef ref : childAssocRefs)
{
NodeRef translation = ref.getChildRef();
translationVersionHistories.add(versionService.getVersionHistory(translation));
}
// properties in which the version histories will be stored
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
// Switch VersionStore depending on configured impl
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
{
// V2 version store (eg. workspace://version2Store)
// add the version history of the translation as property of the Edition
NodeRef versionNodeRef = VersionUtil.convertNodeRef(edition.getFrozenStateNodeRef());
this.nodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_TRANSLATION_VERSIONS, (Serializable) translationVersionHistories);
}
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
{
// Deprecated V1 version store (eg. workspace://lightWeightVersionStore)
// add the version history of the translation as property of the Edition
properties.put(VersionModel.PROP_QNAME_QNAME, VersionModel.PROP_QNAME_TRANSLATION_VERSIONS);
properties.put(VersionModel.PROP_QNAME_IS_MULTI_VALUE, true);
properties.put(VersionModel.PROP_QNAME_MULTI_VALUE, (Serializable) translationVersionHistories);
// create the versioned property node
this.nodeService.createNode(
VersionUtil.convertNodeRef(edition.getFrozenStateNodeRef()),
VersionModel.CHILD_QNAME_VERSIONED_ATTRIBUTES,
VersionModel.CHILD_QNAME_VERSIONED_ATTRIBUTES,
VersionModel.TYPE_QNAME_VERSIONED_PROPERTY,
properties);
}
else
{
throw new AlfrescoRuntimeException("Unexpected versionstore: " + versionService.getVersionStoreReference().getIdentifier());
}
}
/**
* Util method to add the usefull properties to the existing properties of the given, mlContainer
*
* @link {@link EditionServiceImpl#ML_CONTAINER_PROPERTIES_TO_VERSION}
*/
private void addPropertiesToVersion(Map<String, Serializable> versionProperties, NodeRef mlContainerToVersion)
{
// add useful properties
for(QName prop : ML_CONTAINER_PROPERTIES_TO_VERSION)
{
versionProperties.put(prop.toString(), nodeService.getProperty(mlContainerToVersion, prop));
}
}
/**
* Util method to remove the given translations after making a new edition
*/
private void removeTranslations(List<ChildAssociationRef> childAssocRefs)
{
// Turn off any auto-version policy behaviours. Without that,
// the version history of the translations will be deleted.
this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
// Turn off any multilingual document policy behaviours. Without that,
// the mlcontainer of the translations will be deleted.
this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
try
{
for (ChildAssociationRef childAssoc : childAssocRefs)
{
NodeRef documentNodeRef = childAssoc.getChildRef();
// Permanently delete it
nodeService.deleteNode(documentNodeRef);
if(nodeService.exists(nodeArchiveService.getArchivedNode(documentNodeRef)))
{
nodeService.deleteNode(nodeArchiveService.getArchivedNode(documentNodeRef));
}
}
}
finally
{
// Turn auto-version and multinlingual document policies back on
this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
}
}
/**
* @param nodeService
* the Node Service to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param versionService
* the Version Service to set
*/
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
/**
* @param multilingualContentService
* the Multilingual Content Service to set
*/
public void setMultilingualContentService(MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
/**
* @param versionNodeService
* the Version Store Node Service to set
*/
public void setVersionNodeService(NodeService versionNodeService)
{
this.versionNodeService = versionNodeService;
}
/**
* @param policyBehaviourFilter the Behaviour Filter to set
*/
public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
{
this.policyBehaviourFilter = policyBehaviourFilter;
}
/**
* @param nodeArchiveService the node Archive Service to set
*/
public void setNodeArchiveService(NodeArchiveService nodeArchiveService)
{
this.nodeArchiveService = nodeArchiveService;
}
/**
* @param fileFolderService the fileFolder Service to set
*/
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
}