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:
Dave Ward
2009-09-01 16:10:49 +00:00
parent a949dcad97
commit 415c90c971
5 changed files with 50 additions and 38 deletions

View File

@@ -307,20 +307,20 @@ public class DictionaryDAOTest extends TestCase
{
QName testFileQName = QName.createQName(TEST_URL, "file");
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");
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");
ClassDefinition fileDerivedNoArchiveClassDef = service.getClass(testFileDerivedNoArchiveQName);
assertFalse("Derived File with archive override type should NOT have the archive flag",
fileDerivedNoArchiveClassDef.isArchive());
fileDerivedNoArchiveClassDef.getArchive());
QName testFolderQName = QName.createQName(TEST_URL, "folder");
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()

View File

@@ -154,9 +154,9 @@ import org.alfresco.service.namespace.QName;
return type.isAspect();
}
public boolean isArchive()
public Boolean getArchive()
{
return type.isArchive();
return type.getArchive();
}
/* (non-Javadoc)

View File

@@ -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
* 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
* the GPL, you may redistribute this Program in connection with Free/Libre
* 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:
* http://www.alfresco.com/legal/licensing"
*/
@@ -374,16 +374,10 @@ import org.alfresco.service.namespace.QName;
return (m2Class instanceof M2Aspect);
}
/**
* @return Returns the archive flag, which defaults to <tt>true</tt> for aspects and <tt>false</tt> for other classes
/* (non-Javadoc)
* @see org.alfresco.service.cmr.dictionary.ClassDefinition#getArchive()
*/
public boolean isArchive()
{
Boolean isArchive = getArchive();
return isArchive == null ? isAspect() : isArchive.booleanValue();
}
protected Boolean getArchive()
public Boolean getArchive()
{
return archive == null ? inheritedArchive : archive;
}
@@ -597,9 +591,20 @@ import org.alfresco.service.namespace.QName;
}
// check archive/inheritedArchive
if (isArchive() != classDef.isArchive())
if (archive == null)
{
isUpdatedIncrementally = true;
if (classDef.getArchive() != null)
{
isUpdatedIncrementally = true;
}
}
else
{
Boolean classArchive = classDef.getArchive();
if (classArchive == null || classArchive.booleanValue() != archive.booleanValue())
{
isUpdatedIncrementally = true;
}
}
String modelDiffType;

View File

@@ -730,11 +730,11 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
Long nodeId = nodePair.getFirst();
boolean requiresDelete = false;
Boolean requiresDelete = null;
// Invoke policy behaviours
invokeBeforeDeleteNode(nodeRef);
// get the primary parent-child relationship before it is gone
Pair<Long, ChildAssociationRef> childAssocPair = nodeDaoService.getPrimaryParentAssoc(nodeId);
ChildAssociationRef childAssocRef = childAssocPair.getSecond();
@@ -754,27 +754,33 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
{
// get the type and check if we need archiving.
TypeDefinition typeDef = dictionaryService.getType(nodeTypeQName);
if (typeDef == null || !typeDef.isArchive())
if (typeDef != null)
{
requiresDelete = true;
}
else
{
// If the type wants archiving, check whether any applied aspects have explicitly turned off the
// archive flag
for (QName nodeAspectQName : nodeAspectQNames)
Boolean requiresArchive = typeDef.getArchive();
if (requiresArchive != null)
{
typeDef = dictionaryService.getType(nodeAspectQName);
if (typeDef != null && !typeDef.isArchive())
requiresDelete = !requiresArchive;
}
}
// 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())
{
QName nodeAspectQName = i.next();
AspectDefinition aspectDef = dictionaryService.getAspect(nodeAspectQName);
if (aspectDef != null)
{
Boolean requiresArchive = aspectDef.getArchive();
if (requiresArchive != null)
{
requiresDelete = true;
break;
requiresDelete = !requiresArchive;
}
}
}
}
if (requiresDelete)
if (requiresDelete == null || requiresDelete)
{
// Cascade as required
if (cascadeInTransaction)

View File

@@ -69,9 +69,10 @@ public interface ClassDefinition
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