mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Mergeing form EC-MC: Completed. Removed intwined aspect deletion behaviour
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5745 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,11 +28,9 @@ package org.alfresco.repo.model.ml;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.ContentServicePolicies;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.PolicyScope;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -50,8 +48,6 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public class EmptyTranslationAspect implements
|
||||
CopyServicePolicies.OnCopyNodePolicy,
|
||||
// NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
// NodeServicePolicies.OnRemoveAspectPolicy,
|
||||
ContentServicePolicies.OnContentUpdatePolicy
|
||||
{
|
||||
|
||||
@@ -77,16 +73,6 @@ public class EmptyTranslationAspect implements
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION,
|
||||
new JavaBehaviour(this, "onContentUpdate"));
|
||||
//
|
||||
// this.policyComponent.bindClassBehaviour(
|
||||
// QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
// ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION,
|
||||
// new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
//
|
||||
// this.policyComponent.bindClassBehaviour(
|
||||
// QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
||||
// ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION,
|
||||
// new JavaBehaviour(this, "onRemoveAspect"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,32 +115,4 @@ public class EmptyTranslationAspect implements
|
||||
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * If a <b>cm:mlEmptyTranslation<b> is deleted, it can't be archived.
|
||||
// *
|
||||
// * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
// */
|
||||
// public void beforeDeleteNode(NodeRef nodeRef)
|
||||
// {
|
||||
// // add TEMPORARY ASPECT to force the deleteNode
|
||||
// nodeService.addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * If the aspect <b>cm:mlEmptyTranslation<b> is removed <b>and the content url property is null</b>, the node can be deleted.
|
||||
// * The other time the aspect is removed is when new content is added, in which case the node must be kept.
|
||||
// *
|
||||
// * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) *
|
||||
// */
|
||||
// public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||
// {
|
||||
// // Delete the node if the content is empty.
|
||||
// // Keep the node if it has content
|
||||
// ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
||||
// if(contentData.getContentUrl() == null)
|
||||
// {
|
||||
// nodeService.deleteNode(nodeRef);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@@ -49,7 +49,6 @@ import org.alfresco.service.namespace.QName;
|
||||
* @author yanipig
|
||||
*/
|
||||
public class MLContainerType implements
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy
|
||||
{
|
||||
/**
|
||||
@@ -76,11 +75,6 @@ public class MLContainerType implements
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
||||
ContentModel.TYPE_MULTILINGUAL_CONTAINER,
|
||||
new JavaBehaviour(this, "onUpdateProperties"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
ContentModel.TYPE_MULTILINGUAL_CONTAINER,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,27 +102,6 @@ public class MLContainerType implements
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a <b>cm:mlContainer<b> is deleted, it can't be archived.
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
Map<Locale, NodeRef> translations = multilingualContentService.getTranslations(nodeRef);
|
||||
|
||||
// add the DELETION_RUNNING property
|
||||
nodeService.setProperty(nodeRef, PROP_NAME_DELETION_RUNNING, Boolean.TRUE);
|
||||
|
||||
for(Map.Entry<Locale, NodeRef> entry : translations.entrySet())
|
||||
{
|
||||
nodeService.removeAspect(entry.getValue(), ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
}
|
||||
|
||||
// remove the DELETION_RUNNING property
|
||||
nodeService.removeProperty(nodeRef, PROP_NAME_DELETION_RUNNING);
|
||||
}
|
||||
|
||||
/**
|
||||
* The property <b>locale</b> of a <b>cm:mlContainer</b> represents the locale of the pivot translation.
|
||||
*
|
||||
@@ -139,6 +112,10 @@ public class MLContainerType implements
|
||||
*/
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
/*
|
||||
* TODO: Move into MultilingualContentService
|
||||
*/
|
||||
|
||||
Locale localeAfter = (Locale) after.get(ContentModel.PROP_LOCALE);
|
||||
Locale localeBefore = (Locale) before.get(ContentModel.PROP_LOCALE);
|
||||
|
||||
|
@@ -52,12 +52,26 @@ import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Multilingual support implementation
|
||||
* Multilingual support implementation.
|
||||
* <p>
|
||||
* The basic structure supported is that of a hidden container of type
|
||||
* <b>cm:mlContainer</b> containing one or more secondary children of
|
||||
* type <b>cm:mlDocument</b>. One of these will have a matching locale
|
||||
* and is referred to as the <i>pivot translation</i>. It is also possible
|
||||
* to have several transient <b>cm:emptyTranslation</b> instances that
|
||||
* live and die with the container until they get their own content.
|
||||
* <p>
|
||||
* It is not possible to guarantee that there is always a pivot translation
|
||||
* available in the set of sibling translations. The strategy is to hide
|
||||
* all translations when there isn't a pivot translation available. A
|
||||
* background task should be cleaning up the empty or invalid <b>cm:mlContainer</b>
|
||||
* instances.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @author Philippe Dubois
|
||||
@@ -244,6 +258,21 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
// done
|
||||
return mlContainerNodeRef;
|
||||
}
|
||||
|
||||
private boolean isPivotTranslation(NodeRef contentNodeRef)
|
||||
{
|
||||
Locale locale = (Locale) nodeService.getProperty(contentNodeRef, ContentModel.PROP_LOCALE);
|
||||
// Get the container
|
||||
NodeRef containerNodeRef = getOrCreateMLContainer(contentNodeRef, false);
|
||||
Locale containerLocale = (Locale) nodeService.getProperty(containerNodeRef, ContentModel.PROP_LOCALE);
|
||||
boolean isPivot = EqualsHelper.nullSafeEquals(locale, containerLocale);
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Node " + (isPivot ? "is" : "is not") + " pivot: " + contentNodeRef);
|
||||
}
|
||||
return isPivot;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public boolean isTranslation(NodeRef contentNodeRef)
|
||||
@@ -257,17 +286,13 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Is there a ML container
|
||||
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(
|
||||
contentNodeRef,
|
||||
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
if (parentAssocRefs.size() > 0)
|
||||
// Are there any associated translations
|
||||
Map<Locale, NodeRef> translations = getTranslations(contentNodeRef);
|
||||
if (translations.size() > 0)
|
||||
{
|
||||
// It has the parent required
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Document has ML container parent: " + contentNodeRef);
|
||||
logger.debug("Document is a translation: " + contentNodeRef);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -275,12 +300,12 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Document has no ML container parent: " + contentNodeRef);
|
||||
logger.debug("Document is not a translation: " + contentNodeRef);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @inheritDoc */
|
||||
public NodeRef makeTranslation(NodeRef contentNodeRef, Locale locale)
|
||||
{
|
||||
@@ -296,6 +321,52 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
return mlContainerNodeRef;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public void unmakeTranslation(NodeRef translationNodeRef)
|
||||
{
|
||||
boolean isPivot = isPivotTranslation(translationNodeRef);
|
||||
|
||||
if (isPivot)
|
||||
{
|
||||
// Get the container
|
||||
NodeRef containerNodeRef = getOrCreateMLContainer(translationNodeRef, false);
|
||||
// Get all translation child associations
|
||||
List<ChildAssociationRef> mlChildAssocs = nodeService.getChildAssocs(
|
||||
containerNodeRef,
|
||||
ContentModel.ASSOC_MULTILINGUAL_CHILD,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef mlChildAssoc : mlChildAssocs)
|
||||
{
|
||||
NodeRef mlChildNodeRef = mlChildAssoc.getChildRef();
|
||||
// Delete empty translations
|
||||
if (nodeService.hasAspect(mlChildNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
nodeService.deleteNode(mlChildNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeService.removeAspect(mlChildNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
}
|
||||
}
|
||||
// Now delete the container
|
||||
nodeService.deleteNode(containerNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
nodeService.deleteNode(translationNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the container and break the association to it
|
||||
NodeRef containerNodeRef = getOrCreateMLContainer(translationNodeRef, false);
|
||||
nodeService.removeChild(containerNodeRef, translationNodeRef);
|
||||
nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public NodeRef addTranslation(NodeRef newTranslationNodeRef, NodeRef translationOfNodeRef, Locale locale)
|
||||
{
|
||||
@@ -443,8 +514,6 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
/** @inheritDoc */
|
||||
public NodeRef getTranslationForLocale(NodeRef translationNodeRef, Locale locale)
|
||||
{
|
||||
// Get the container
|
||||
getOrCreateMLContainer(translationNodeRef, false);
|
||||
// Get all the translations
|
||||
Map<Locale, NodeRef> nodeRefsByLocale = getTranslations(translationNodeRef);
|
||||
// Get the closest matching locale
|
||||
@@ -529,8 +598,7 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
else if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(nodeRef)))
|
||||
{
|
||||
Locale containerLocale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
|
||||
|
||||
return getTranslationForLocale(getTranslations(nodeRef).get(containerLocale), containerLocale);
|
||||
return getTranslationForLocale(nodeRef, containerLocale);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -539,12 +607,9 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* TODO: This logic merely creates a file with a specific aspect and is designed to support
|
||||
* specific use-case in the UI. Examine if the logic should be here or in the UI.
|
||||
*/
|
||||
public NodeRef addEmptyTranslation(NodeRef translationOfNodeRef, String name, Locale locale)
|
||||
{
|
||||
|
@@ -55,8 +55,6 @@ public class MultilingualDocumentAspect implements
|
||||
CopyServicePolicies.OnCopyNodePolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.BeforeRemoveAspectPolicy,
|
||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy
|
||||
{
|
||||
|
||||
@@ -80,31 +78,20 @@ public class MultilingualDocumentAspect implements
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "onCopyNode"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRemoveAspect"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "beforeRemoveAspect"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "onUpdateProperties"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyComplete"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "onCopyComplete"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "onRemoveAspect"));
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
|
||||
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
|
||||
new JavaBehaviour(this, "onUpdateProperties"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,72 +140,19 @@ public class MultilingualDocumentAspect implements
|
||||
}
|
||||
|
||||
/**
|
||||
* If the node is multilingual and it is the pivot translation, then deletion is not allowed unless the
|
||||
* If this is not an empty translation, then ensure that the node is properly
|
||||
* unhooked from the translation mechanism first.
|
||||
*/
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
// checkRemoveParentMLContainer(nodeRef);
|
||||
// Remove the aspect
|
||||
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a pivot translation is deleted, it's <b>cm:mlContainer is deleted too.</b>
|
||||
*
|
||||
* <i>Note: When the pivot translation and the mlContainer are deleted, the mlDocument apsect is removed from
|
||||
* the other translations. It will be better to don't allow the deletion of the pivot if other translation is
|
||||
* available at the client side level.</i>
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeRemoveAspectPolicy#beforeRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public void beforeRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||
{
|
||||
checkRemoveParentMLContainer(nodeRef);
|
||||
}
|
||||
|
||||
private void checkRemoveParentMLContainer(NodeRef nodeRef)
|
||||
{
|
||||
// Avoid nodes that are no longer translations
|
||||
if (!multilingualContentService.isTranslation(nodeRef))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NodeRef mlContainer = multilingualContentService.getTranslationContainer(nodeRef);
|
||||
|
||||
// nothing to do if the mlContainer is in a deletion process
|
||||
Boolean inDeleteProcess = (Boolean) nodeService.getProperty(mlContainer, MLContainerType.PROP_NAME_DELETION_RUNNING);
|
||||
if(inDeleteProcess != null && inDeleteProcess == true)
|
||||
{
|
||||
// TODO: Is this still called? Can we get rid of the DELETION_RUNNING property?
|
||||
return;
|
||||
}
|
||||
|
||||
Locale mlContainerLocale = (Locale) nodeService.getProperty(mlContainer, ContentModel.PROP_LOCALE);
|
||||
Locale nodeRefLocale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
|
||||
|
||||
nodeService.removeChild(mlContainer, nodeRef);
|
||||
|
||||
// if last translation or if nodeRef is pivot translation
|
||||
if (multilingualContentService.getTranslations(mlContainer).size() == 0
|
||||
|| mlContainerLocale.equals(nodeRefLocale))
|
||||
{
|
||||
// delete the mlContainer
|
||||
nodeService.deleteNode(mlContainer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the document's locale and the <b>cm:mlEmptyTranslation</b> aspect,
|
||||
* if present.
|
||||
*/
|
||||
public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||
{
|
||||
nodeService.removeProperty(nodeRef, ContentModel.PROP_LOCALE);
|
||||
// Remove the empty translation aspect if it is present
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
||||
// We just let it get deleted
|
||||
}
|
||||
else
|
||||
{
|
||||
// First unhook it
|
||||
multilingualContentService.unmakeTranslation(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +166,10 @@ public class MultilingualDocumentAspect implements
|
||||
*/
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
/*
|
||||
* TODO: Move this into MultilingualContentService#setTranslationLocale
|
||||
*/
|
||||
|
||||
Locale localeBefore = (Locale) before.get(ContentModel.PROP_LOCALE);
|
||||
Locale localeAfter;
|
||||
|
||||
|
@@ -27,14 +27,12 @@ package org.alfresco.repo.model.ml;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.alfresco.repo.model.filefolder.FolderTypeTest;
|
||||
import org.alfresco.repo.model.ml.tools.ContentFilterLanguagesMapTest;
|
||||
import org.alfresco.repo.model.ml.tools.EmptyTranslationAspectTest;
|
||||
import org.alfresco.repo.model.ml.tools.MLContainerTypeTest;
|
||||
import org.alfresco.repo.model.ml.tools.MultilingualContentServiceImplTest;
|
||||
import org.alfresco.repo.model.ml.tools.MultilingualDocumentAspectTest;
|
||||
|
||||
|
||||
/**
|
||||
* Multilingual test suite
|
||||
*
|
||||
@@ -56,7 +54,6 @@ public class MultilingualTestSuite extends TestSuite
|
||||
suite.addTestSuite(MultilingualContentServiceImplTest.class);
|
||||
suite.addTestSuite(MultilingualDocumentAspectTest.class);
|
||||
suite.addTestSuite(MLContainerTypeTest.class);
|
||||
suite.addTestSuite(FolderTypeTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@@ -169,50 +169,4 @@ public class EmptyTranslationAspectTest extends AbstractMultilingualTestCases {
|
||||
fileFolderService.getReader(empty).getContentString(),
|
||||
fileFolderService.getReader(pivot).getContentString());
|
||||
}
|
||||
|
||||
public void testRemoveAspect() throws Exception
|
||||
{
|
||||
NodeRef pivot = createContent();
|
||||
NodeRef empty = null;
|
||||
|
||||
multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
|
||||
|
||||
// 1. remove mlEmptyTranslation aspect with empty content
|
||||
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
|
||||
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
||||
|
||||
// Ensure that the empty translation is deleted
|
||||
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with no content the node must be deleted",
|
||||
nodeService.exists(empty));
|
||||
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with no content the node must be deleted and can't be archived",
|
||||
nodeService.exists(nodeArchiveService.getArchivedNode(empty)));
|
||||
|
||||
// 2. remove mlDocument aspect with empty content
|
||||
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
|
||||
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
|
||||
// Ensure that the empty translation is deleted
|
||||
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " of an empty translation with no content the node must be deleted",
|
||||
nodeService.exists(empty));
|
||||
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " of an empty translation with no content the node must be deleted and can't be archived",
|
||||
nodeService.exists(nodeArchiveService.getArchivedNode(empty)));
|
||||
|
||||
// 3. remove mlEmptyTranslation aspect with not empty content
|
||||
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
|
||||
ContentWriter writer = contentService.getWriter(empty, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype("text/plain");
|
||||
writer.putContent("ANY_CONTENT");
|
||||
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
|
||||
|
||||
// Ensure that the empty translation is NOT deleted
|
||||
assertTrue("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content the node must NOT be deleted",
|
||||
nodeService.exists(empty));
|
||||
// Ensure that the mlEmptyTranslation aspect is removed
|
||||
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content this aspect must be removed",
|
||||
nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION));
|
||||
// Ensure that the mlEmptyDocument in NOT removed
|
||||
assertTrue("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " aspect must be keeped",
|
||||
nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,30 +39,8 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class MLContainerTypeTest extends AbstractMultilingualTestCases {
|
||||
|
||||
|
||||
public void testDeleteNode() throws Exception
|
||||
{
|
||||
NodeRef pivot = createContent();
|
||||
NodeRef empty;
|
||||
|
||||
NodeRef mlContainer = multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
|
||||
empty = multilingualContentService.addEmptyTranslation(pivot, "Empty_" + System.currentTimeMillis(), Locale.ENGLISH);
|
||||
|
||||
nodeService.deleteNode(mlContainer);
|
||||
|
||||
// Ensure that the mlContainer is deleted
|
||||
assertFalse("The mlContainer must be deleted", nodeService.exists(mlContainer));
|
||||
// Ensure that the empty translation is deleted
|
||||
assertFalse("The mlEmptyTranslation must be deleted", nodeService.exists(empty));
|
||||
// Ensure that the non-empty document is not deleted
|
||||
assertTrue("The mlDocument must not be deleted", nodeService.exists(pivot));
|
||||
// Ensure that the mlDocument property of the non-empty document is removed
|
||||
assertFalse("The " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " aspect of the mlDocument must be removed",
|
||||
nodeService.hasAspect(pivot, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
|
||||
}
|
||||
|
||||
public class MLContainerTypeTest extends AbstractMultilingualTestCases
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
public void testEditLocale() throws Exception
|
||||
{
|
||||
|
@@ -87,8 +87,11 @@ public class MultilingualDocumentAspectTest extends AbstractMultilingualTestCase
|
||||
assertEquals("The restored node would not be restaured to the mlContainer", 2, multilingualContentService.getTranslations(mlContainer).size());
|
||||
// Ensure that the restored node doesn't keep the mlDocument aspect
|
||||
assertFalse("The restored node can't keep the multilingual aspect", nodeService.hasAspect(restoredNode, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
|
||||
// Ensure that the restored node doesn't keep the locale property
|
||||
assertNull("The restaured node can't keep the locale property", nodeService.getProperty(restoredNode, ContentModel.PROP_LOCALE));
|
||||
// DH: The locale is stored on an aspect that is independent of the ML model.
|
||||
// It is therefore not possible to remove the locale just because the node
|
||||
// is being unhooked from the ML structures
|
||||
// // Ensure that the restored node doesn't keep the locale property
|
||||
// assertNull("The restaured node can't keep the locale property", nodeService.getProperty(restoredNode, ContentModel.PROP_LOCALE));
|
||||
}
|
||||
|
||||
public void testDeletePivot() throws Exception
|
||||
@@ -109,8 +112,10 @@ public class MultilingualDocumentAspectTest extends AbstractMultilingualTestCase
|
||||
assertTrue("The last translation would not be removed", nodeService.exists(trans1));
|
||||
// Ensure that trans1 has no mlDocument aspect
|
||||
assertFalse("The last translation can't keep the multilingual aspect", nodeService.hasAspect(trans1, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
|
||||
// Ensure that trans1 has no locale propety
|
||||
assertNull("The last translation can't keep the locale property", nodeService.getProperty(trans1, ContentModel.PROP_LOCALE));
|
||||
// DH: Here too, the sys:locale property must be left alone as it is independent of the
|
||||
// ML model
|
||||
// // Ensure that trans1 has no locale propety
|
||||
// assertNull("The last translation can't keep the locale property", nodeService.getProperty(trans1, ContentModel.PROP_LOCALE));
|
||||
}
|
||||
|
||||
public void testDeleteLastNode() throws Exception
|
||||
|
Reference in New Issue
Block a user