mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
MOB-1073: Fix build. Use dictionaryService.getAspect() rather than dictionaryService.getType() to look up aspects
- Also improved Boolean logic so that it's possible to switch on archiving via an aspect (as suggested by Derek) - M2ClassDefinition.getArchive() now returns true, false or null - false takes precedence and is the ultimate default - fixed JIBX classpath git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16022 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -307,20 +307,20 @@ public class DictionaryDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
QName testFileQName = QName.createQName(TEST_URL, "file");
|
QName testFileQName = QName.createQName(TEST_URL, "file");
|
||||||
ClassDefinition fileClassDef = service.getClass(testFileQName);
|
ClassDefinition fileClassDef = service.getClass(testFileQName);
|
||||||
assertTrue("File type should have the archive flag", fileClassDef.isArchive());
|
assertTrue("File type should have the archive flag", fileClassDef.getArchive());
|
||||||
|
|
||||||
QName testFileDerivedQName = QName.createQName(TEST_URL, "file-derived");
|
QName testFileDerivedQName = QName.createQName(TEST_URL, "file-derived");
|
||||||
ClassDefinition fileDerivedClassDef = service.getClass(testFileDerivedQName);
|
ClassDefinition fileDerivedClassDef = service.getClass(testFileDerivedQName);
|
||||||
assertTrue("Direct derived File type should have the archive flag", fileDerivedClassDef.isArchive());
|
assertTrue("Direct derived File type should have the archive flag", fileDerivedClassDef.getArchive());
|
||||||
|
|
||||||
QName testFileDerivedNoArchiveQName = QName.createQName(TEST_URL, "file-derived-no-archive");
|
QName testFileDerivedNoArchiveQName = QName.createQName(TEST_URL, "file-derived-no-archive");
|
||||||
ClassDefinition fileDerivedNoArchiveClassDef = service.getClass(testFileDerivedNoArchiveQName);
|
ClassDefinition fileDerivedNoArchiveClassDef = service.getClass(testFileDerivedNoArchiveQName);
|
||||||
assertFalse("Derived File with archive override type should NOT have the archive flag",
|
assertFalse("Derived File with archive override type should NOT have the archive flag",
|
||||||
fileDerivedNoArchiveClassDef.isArchive());
|
fileDerivedNoArchiveClassDef.getArchive());
|
||||||
|
|
||||||
QName testFolderQName = QName.createQName(TEST_URL, "folder");
|
QName testFolderQName = QName.createQName(TEST_URL, "folder");
|
||||||
ClassDefinition folderClassDef = service.getClass(testFolderQName);
|
ClassDefinition folderClassDef = service.getClass(testFolderQName);
|
||||||
assertFalse("Folder type should not have the archive flag", folderClassDef.isArchive());
|
assertNull("Folder type should not have the archive flag", folderClassDef.getArchive());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMandatoryEnforced()
|
public void testMandatoryEnforced()
|
||||||
|
@@ -154,9 +154,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
return type.isAspect();
|
return type.isAspect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isArchive()
|
public Boolean getArchive()
|
||||||
{
|
{
|
||||||
return type.isArchive();
|
return type.getArchive();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
* As a special exception to the terms and conditions of version 2.0 of
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
* FLOSS exception. You should have received a copy of the text describing
|
||||||
* the FLOSS exception, and it is also available here:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* http://www.alfresco.com/legal/licensing"
|
||||||
*/
|
*/
|
||||||
@@ -374,16 +374,10 @@ import org.alfresco.service.namespace.QName;
|
|||||||
return (m2Class instanceof M2Aspect);
|
return (m2Class instanceof M2Aspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* @return Returns the archive flag, which defaults to <tt>true</tt> for aspects and <tt>false</tt> for other classes
|
* @see org.alfresco.service.cmr.dictionary.ClassDefinition#getArchive()
|
||||||
*/
|
*/
|
||||||
public boolean isArchive()
|
public Boolean getArchive()
|
||||||
{
|
|
||||||
Boolean isArchive = getArchive();
|
|
||||||
return isArchive == null ? isAspect() : isArchive.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Boolean getArchive()
|
|
||||||
{
|
{
|
||||||
return archive == null ? inheritedArchive : archive;
|
return archive == null ? inheritedArchive : archive;
|
||||||
}
|
}
|
||||||
@@ -597,10 +591,21 @@ import org.alfresco.service.namespace.QName;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check archive/inheritedArchive
|
// check archive/inheritedArchive
|
||||||
if (isArchive() != classDef.isArchive())
|
if (archive == null)
|
||||||
|
{
|
||||||
|
if (classDef.getArchive() != null)
|
||||||
{
|
{
|
||||||
isUpdatedIncrementally = true;
|
isUpdatedIncrementally = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Boolean classArchive = classDef.getArchive();
|
||||||
|
if (classArchive == null || classArchive.booleanValue() != archive.booleanValue())
|
||||||
|
{
|
||||||
|
isUpdatedIncrementally = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String modelDiffType;
|
String modelDiffType;
|
||||||
if (isAspect())
|
if (isAspect())
|
||||||
|
@@ -730,7 +730,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
|
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
|
||||||
Long nodeId = nodePair.getFirst();
|
Long nodeId = nodePair.getFirst();
|
||||||
|
|
||||||
boolean requiresDelete = false;
|
Boolean requiresDelete = null;
|
||||||
|
|
||||||
// Invoke policy behaviours
|
// Invoke policy behaviours
|
||||||
invokeBeforeDeleteNode(nodeRef);
|
invokeBeforeDeleteNode(nodeRef);
|
||||||
@@ -754,27 +754,33 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
{
|
{
|
||||||
// get the type and check if we need archiving.
|
// get the type and check if we need archiving.
|
||||||
TypeDefinition typeDef = dictionaryService.getType(nodeTypeQName);
|
TypeDefinition typeDef = dictionaryService.getType(nodeTypeQName);
|
||||||
if (typeDef == null || !typeDef.isArchive())
|
if (typeDef != null)
|
||||||
{
|
{
|
||||||
requiresDelete = true;
|
Boolean requiresArchive = typeDef.getArchive();
|
||||||
|
if (requiresArchive != null)
|
||||||
|
{
|
||||||
|
requiresDelete = !requiresArchive;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
|
// If the type hasn't asked for deletion, check whether any applied aspects have
|
||||||
|
Iterator<QName> i = nodeAspectQNames.iterator();
|
||||||
|
while ((requiresDelete == null || !requiresDelete) && i.hasNext())
|
||||||
{
|
{
|
||||||
// If the type wants archiving, check whether any applied aspects have explicitly turned off the
|
QName nodeAspectQName = i.next();
|
||||||
// archive flag
|
AspectDefinition aspectDef = dictionaryService.getAspect(nodeAspectQName);
|
||||||
for (QName nodeAspectQName : nodeAspectQNames)
|
if (aspectDef != null)
|
||||||
{
|
{
|
||||||
typeDef = dictionaryService.getType(nodeAspectQName);
|
Boolean requiresArchive = aspectDef.getArchive();
|
||||||
if (typeDef != null && !typeDef.isArchive())
|
if (requiresArchive != null)
|
||||||
{
|
{
|
||||||
requiresDelete = true;
|
requiresDelete = !requiresArchive;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiresDelete)
|
if (requiresDelete == null || requiresDelete)
|
||||||
{
|
{
|
||||||
// Cascade as required
|
// Cascade as required
|
||||||
if (cascadeInTransaction)
|
if (cascadeInTransaction)
|
||||||
|
@@ -69,9 +69,10 @@ public interface ClassDefinition
|
|||||||
public boolean isAspect();
|
public boolean isAspect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Return true if the type should be archived on delete
|
* @return Return <code>true</code> if the type should be archived on delete, <code>false</code> if it should be
|
||||||
|
* deleted or <code>null</code> if not defined.
|
||||||
*/
|
*/
|
||||||
public boolean isArchive();
|
public Boolean getArchive();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the properties of the class, including inherited properties
|
* @return the properties of the class, including inherited properties
|
||||||
|
Reference in New Issue
Block a user