Merged DEV to HEAD

- ALF-8806 RINF 41: Lucene Removal: Fix CopyService
     - ALF-9028: RINF 41: Fix Aspect cm:copiedFrom
   - ALF-9029 RINF 49: Lucene Removal: CheckOutCheckInService API
     - ALF-9032: RINF 49: fixes to cm:workingcopy aspect

   28996: Dev branch for De-Lucene work pending patches
   29004: Evaluator runs in read-only txn
   29006: Additional PermissionCheckedCollection.create method
          - Use an existing collection's permission check data (cut-off, etc) to wrap a new collection
   29007:
          CopyService and CheckOutCheckInService refactors to remove Lucene
          
          CopyService:
          
          Removed cm:source property from cm:copiedfrom aspect and replaced with a cm:original association.
          Added CQ-based APIs to query for copies
          Added APIs to support bi-directional walking of copy association
          Fixed sundry uses of cm:copiedfrom esp. all uses related to cm:workingcopy
          
          CheckOutCheckInService:
          
          Check-out now creates a source aspect cm:checkedOut with 1:1 relationship to cm:workingcopy via cm:workingcopylink
          Removed explicit use of cm:workingcopy aspect and replaced it with calls to COCI API
          
   29083: Audit tests fail when indexing is turned off.
          Also removed a getReader() call during rule evaluation, leading to a 'sub-action' read being recorded.
   29113: NodeDAO.getNodesWithAspects supports paging
   29135: Removed unused patch queries
   29139: Basic patch (still terminates with error) to upgrade cm:copiedfrom and cm:workingcopy
   29157: Tested patch for cm:copiedfrom and cm:workingcopy aspects


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29159 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-07-19 03:22:11 +00:00
parent 8a561b38ca
commit 6ec3f44c29
58 changed files with 2277 additions and 1845 deletions

View File

@@ -902,6 +902,8 @@ public class RuleServiceCoverageTest extends TestCase
*/
public void testCopyAction()
{
String localName = getName() + System.currentTimeMillis();
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, this.rootNodeRef);
@@ -917,7 +919,7 @@ public class RuleServiceCoverageTest extends TestCase
NodeRef newNodeRef = this.nodeService.createNode(
this.nodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(TEST_NAMESPACE, "origional"),
QName.createQName(TEST_NAMESPACE, localName),
ContentModel.TYPE_CONTENT,
getContentProperties()).getChildRef();
addContentToNode(newNodeRef);
@@ -928,7 +930,7 @@ public class RuleServiceCoverageTest extends TestCase
List<ChildAssociationRef> origRefs = this.nodeService.getChildAssocs(
this.nodeRef,
RegexQNamePattern.MATCH_ALL,
QName.createQName(TEST_NAMESPACE, "origional"));
QName.createQName(TEST_NAMESPACE, localName));
assertNotNull(origRefs);
assertEquals(1, origRefs.size());
NodeRef origNodeRef = origRefs.get(0).getChildRef();
@@ -937,7 +939,7 @@ public class RuleServiceCoverageTest extends TestCase
// Check that the created node has been copied
List<ChildAssociationRef> copyChildAssocRefs = this.nodeService.getChildAssocs(
this.rootNodeRef,
RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, "origional"));
RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, localName));
assertNotNull(copyChildAssocRefs);
// **********************************
@@ -947,7 +949,7 @@ public class RuleServiceCoverageTest extends TestCase
NodeRef copyNodeRef = copyChildAssocRefs.get(0).getChildRef();
assertTrue(this.nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
NodeRef source = (NodeRef)this.nodeService.getProperty(copyNodeRef, ContentModel.PROP_COPY_REFERENCE);
NodeRef source = copyService.getOriginal(copyNodeRef);
assertEquals(newNodeRef, source);
// TODO test deep copy !!
@@ -1028,7 +1030,7 @@ public class RuleServiceCoverageTest extends TestCase
assertEquals(1, copyChildAssocRefs.size());
NodeRef copyNodeRef = copyChildAssocRefs.get(0).getChildRef();
assertTrue(this.nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
NodeRef source = (NodeRef)this.nodeService.getProperty(copyNodeRef, ContentModel.PROP_COPY_REFERENCE);
NodeRef source = copyService.getOriginal(copyNodeRef);
assertEquals(newNodeRef, source);
// Check the transformed content
@@ -1107,7 +1109,7 @@ public class RuleServiceCoverageTest extends TestCase
assertEquals(1, copyChildAssocRefs.size());
NodeRef copyNodeRef = copyChildAssocRefs.get(0).getChildRef();
assertTrue(this.nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
NodeRef source = (NodeRef)this.nodeService.getProperty(copyNodeRef, ContentModel.PROP_COPY_REFERENCE);
NodeRef source = copyService.getOriginal(copyNodeRef);
assertEquals(newNodeRef, source);
}
@@ -1215,7 +1217,7 @@ public class RuleServiceCoverageTest extends TestCase
else if (this.nodeService.hasAspect(childNodeRef, ContentModel.ASPECT_WORKING_COPY) == true)
{
// assert that it is the working copy that relates to the origional node
NodeRef copiedFromNodeRef = (NodeRef)this.nodeService.getProperty(childNodeRef, ContentModel.PROP_COPY_REFERENCE);
NodeRef copiedFromNodeRef = copyService.getOriginal(childNodeRef);
assertEquals(newNodeRef, copiedFromNodeRef);
}
}

View File

@@ -43,6 +43,7 @@ import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ActionServiceException;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
@@ -89,6 +90,7 @@ public class RuleServiceImpl
private NodeService nodeService;
private NodeService runtimeNodeService;
private CopyService copyService;
private ActionService actionService;
private DictionaryService dictionaryService;
private PolicyComponent policyComponent;
@@ -156,7 +158,15 @@ public class RuleServiceImpl
{
this.runtimeNodeService = runtimeNodeService;
}
/**
* Set the service for locating copied nodes' originals
*/
public void setCopyService(CopyService copyService)
{
this.copyService = copyService;
}
/**
* Set the action service
*/
@@ -335,107 +345,81 @@ public class RuleServiceImpl
return result;
}
/**
* @see org.alfresco.repo.rule.RuleService#getRuleTypes()
*/
@Override
public List<RuleType> getRuleTypes()
{
return new ArrayList<RuleType>(this.ruleTypes.values());
}
/**
* @see org.alfresco.repo.rule.RuleService#getRuleType(java.lang.String)
*/
@Override
public RuleType getRuleType(String name)
{
return this.ruleTypes.get(name);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#enableRules()
*/
@Override
public void enableRules()
{
this.rulesDisabled.remove();
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#disableRules()
*/
@Override
public void disableRules()
{
this.rulesDisabled.set(Boolean.TRUE);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#isEnabled()
*/
@Override
public boolean isEnabled()
{
return (this.globalRulesDisabled == false && this.rulesDisabled.get() == null);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#rulesEnabled(NodeRef)
*/
@Override
public boolean rulesEnabled(NodeRef nodeRef)
{
return (this.disabledNodeRefs.contains(nodeRef) == false);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#disableRules(NodeRef)
*/
@Override
public void disableRules(NodeRef nodeRef)
{
// Add the node to the set of disabled nodes
this.disabledNodeRefs.add(nodeRef);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#enableRules(NodeRef)
*/
@Override
public void enableRules(NodeRef nodeRef)
{
// Remove the node from the set of disabled nodes
this.disabledNodeRefs.remove(nodeRef);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#disableRule(org.alfresco.service.cmr.rule.Rule)
*/
@Override
public void disableRule(Rule rule)
{
this.disabledRules.add(rule);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#enableRule(org.alfresco.service.cmr.rule.Rule)
*/
@Override
public void enableRule(Rule rule)
{
this.disabledRules.remove(rule);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#disableRuleType(org.alfresco.service.cmr.rule.RuleType)
*/
@Override
public void disableRuleType(String ruleType)
{
disabledRuleTypes.add(ruleType);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#enableRuleType(org.alfresco.service.cmr.rule.RuleType)
*/
@Override
public void enableRuleType(String ruleType)
{
disabledRuleTypes.remove(ruleType);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#isRuleTypeEnabled(org.alfresco.service.cmr.rule.RuleType)
*/
@Override
public boolean isRuleTypeEnabled(String ruleType)
{
boolean result = true;
@@ -446,33 +430,25 @@ public class RuleServiceImpl
return result;
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#hasRules(org.alfresco.repo.ref.NodeRef)
*/
@Override
public boolean hasRules(NodeRef nodeRef)
{
return getRules(nodeRef).size() != 0;
}
/**
* @see org.alfresco.repo.rule.RuleService#getRules(org.alfresco.repo.ref.NodeRef)
*/
@Override
public List<Rule> getRules(NodeRef nodeRef)
{
return getRules(nodeRef, true, null);
}
/**
* @see org.alfresco.repo.rule.RuleService#getRules(org.alfresco.repo.ref.NodeRef, boolean)
*/
@Override
public List<Rule> getRules(NodeRef nodeRef, boolean includeInherited)
{
return getRules(nodeRef, includeInherited, null);
}
/**
* @see org.alfresco.repo.rule.RuleService#getRulesByRuleType(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.rule.RuleType)
*/
@Override
public List<Rule> getRules(final NodeRef nodeRef, final boolean includeInherited, final String ruleTypeName)
{
//Run from system user: https://issues.alfresco.com/jira/browse/ALF-607
@@ -556,9 +532,7 @@ public class RuleServiceImpl
return nodeRules;
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#countRules(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public int countRules(NodeRef nodeRef)
{
int ruleCount = 0;
@@ -749,9 +723,7 @@ public class RuleServiceImpl
return rule;
}
/**
* @see org.alfresco.repo.rule.RuleService#saveRule(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.rule.Rule)
*/
@Override
public void saveRule(NodeRef nodeRef, Rule rule)
{
checkForLinkedRules(nodeRef);
@@ -810,18 +782,14 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#saveRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule, int)
*/
@Override
public void saveRule(NodeRef nodeRef, Rule rule, int index)
{
saveRule(nodeRef, rule);
setRulePosition(nodeRef, rule.getNodeRef(), index);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#setRulePosition(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, int)
*/
@Override
public void setRulePosition(NodeRef nodeRef, NodeRef ruleNodeRef, int index)
{
NodeRef ruleFolder = getSavedRuleFolderRef(nodeRef);
@@ -856,9 +824,7 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#setRulePosition(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule, int)
*/
@Override
public void setRulePosition(NodeRef nodeRef, Rule rule, int index)
{
setRulePosition(nodeRef, rule.getNodeRef(), index);
@@ -909,9 +875,7 @@ public class RuleServiceImpl
}
/**
* @see org.alfresco.repo.rule.RuleService#removeRule(org.alfresco.repo.ref.NodeRef, org.alfresco.service.cmr.rule.Rule)
*/
@Override
public void removeRule(NodeRef nodeRef, Rule rule)
{
checkForLinkedRules(nodeRef);
@@ -962,10 +926,8 @@ public class RuleServiceImpl
throw new RuleServiceException("Can not edit rules as they are linked to another rule set.");
}
}
/**
* @see org.alfresco.repo.rule.RuleService#removeAllRules(NodeRef)
*/
@Override
public void removeAllRules(NodeRef nodeRef)
{
checkForLinkedRules(nodeRef);
@@ -999,14 +961,13 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule)
*/
@Override
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule)
{
addRulePendingExecution(actionableNodeRef, actionedUponNodeRef, rule, false);
}
@Override
@SuppressWarnings("unchecked")
public void removeRulePendingExecution(NodeRef actionedUponNodeRef)
{
@@ -1035,9 +996,7 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule, boolean)
*/
@Override
@SuppressWarnings("unchecked")
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
{
@@ -1082,11 +1041,7 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.repo.rule.RuleService#executePendingRules()
*/
@Override
public void executePendingRules()
{
if (AlfrescoTransactionSupport.getResource(KEY_RULES_EXECUTED) == null)
@@ -1186,9 +1141,7 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.repo.rule.RuntimeRuleService#executeRule(org.alfresco.service.cmr.rule.Rule, org.alfresco.service.cmr.repository.NodeRef, java.util.Set)
*/
@Override
public void executeRule(Rule rule, NodeRef actionedUponNodeRef, Set<ExecutedRuleData> executedRules)
{
// Get the action associated with the rule
@@ -1220,11 +1173,6 @@ public class RuleServiceImpl
/**
* Determines whether the rule can be executed
*
* @param executedRules
* @param actionedUponNodeRef
* @param rule
* @return
*/
private boolean canExecuteRule(Set<ExecutedRuleData> executedRules, NodeRef actionedUponNodeRef, Rule rule)
{
@@ -1263,26 +1211,18 @@ public class RuleServiceImpl
/**
* Checks to see if a copy exists in the executed rules list
*
* @param executedRules
* @param actionedUponNodeRef
* @param rule
* @return
*/
private boolean checkForCopy(Set<ExecutedRuleData> executedRules, NodeRef actionedUponNodeRef, Rule rule)
{
boolean result = true;
if (this.nodeService.exists(actionedUponNodeRef)
&& this.permissionService.hasPermission(actionedUponNodeRef, PermissionService.READ).equals(AccessStatus.ALLOWED)
&& this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
&& this.permissionService.hasPermission(actionedUponNodeRef, PermissionService.READ).equals(AccessStatus.ALLOWED))
{
NodeRef copiedFrom = copyService.getOriginal(actionedUponNodeRef);
if (logger.isDebugEnabled() == true)
{
logger.debug(" >> Has the copied from aspect (" + actionedUponNodeRef.getId() + ")");
logger.debug(" >> Got the copiedFrom nodeRef (" + copiedFrom + ")");
}
NodeRef copiedFrom = (NodeRef)this.nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_COPY_REFERENCE);
if (logger.isDebugEnabled() == true && copiedFrom != null) {logger.debug(" >> Got the copedFrom nodeRef (" + copiedFrom.getId() + ")");};
if (copiedFrom != null)
{
@@ -1436,18 +1376,14 @@ public class RuleServiceImpl
}
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#getOwningNodeRef(org.alfresco.service.cmr.rule.Rule)
*/
@Override
public NodeRef getOwningNodeRef(final Rule rule)
{
// Run from system user: https://issues.alfresco.com/jira/browse/ALF-607
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
NodeRef result = null;
NodeRef ruleNodeRef = rule.getNodeRef();
@@ -1461,10 +1397,6 @@ public class RuleServiceImpl
}, AuthenticationUtil.getSystemUserName());
}
/**
* @param ruleNodeRef
* @return
*/
private NodeRef getOwningNodeRefRuleImpl(NodeRef ruleNodeRef)
{
// Get the system folder parent
@@ -1474,9 +1406,7 @@ public class RuleServiceImpl
return this.nodeService.getPrimaryParent(systemFolder).getParentRef();
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#getOwningNodeRef(org.alfresco.service.cmr.action.Action)
*/
@Override
public NodeRef getOwningNodeRef(final Action action)
{
// Run from system user: https://issues.alfresco.com/jira/browse/ALF-607
@@ -1498,9 +1428,6 @@ public class RuleServiceImpl
}, AuthenticationUtil.getSystemUserName());
}
/**
* @param actionNodeRef
*/
private NodeRef getOwningNodeRefActionImpl(NodeRef actionNodeRef)
{
NodeRef result = null;
@@ -1520,17 +1447,13 @@ public class RuleServiceImpl
return result;
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#isLinkedToRuleNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public boolean isLinkedToRuleNode(NodeRef nodeRef)
{
return (getLinkedToRuleNode(nodeRef) != null);
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#getLinkedToRuleNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public NodeRef getLinkedToRuleNode(NodeRef nodeRef)
{
NodeRef result = null;
@@ -1548,9 +1471,7 @@ public class RuleServiceImpl
return result;
}
/**
* @see org.alfresco.service.cmr.rule.RuleService#getLinkedFromRuleNodes(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<NodeRef> getLinkedFromRuleNodes(NodeRef nodeRef)
{
List<NodeRef> result = new ArrayList<NodeRef>();
@@ -1570,8 +1491,6 @@ public class RuleServiceImpl
}
}
}
return result;
}
}

View File

@@ -27,7 +27,7 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.transaction.TransactionalResourceHelper;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -88,12 +88,12 @@ public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase
*/
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
{
// Check the new content and make sure that we do indeed want to trigger the rule
boolean fail = false;
if (newContent == true)
{
Boolean value = (Boolean)nodeService.getProperty(nodeRef, QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "editInline"));
// Check the new content and make sure that we do indeed want to trigger the rule
boolean fail = false;
if (newContent == true)
{
Boolean value = (Boolean)nodeService.getProperty(nodeRef, QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "editInline"));
if (value != null)
{
boolean editInline = value.booleanValue();
@@ -102,18 +102,17 @@ public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase
fail = true;
}
}
if (fail == false)
{
ContentReader contentReader = this.contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
if (contentReader == null ||
contentReader.exists() == false ||
isZeroLengthOfficeDoc(contentReader) == true)
{
fail = true;
}
// Note: Don't use the ContentService.getReader() because we don't need access to the content
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
if (contentData == null || isZeroLengthOfficeDoc(contentData))
{
fail = true;
}
}
}
}
// Double check for content created in this transaction
if (fail == false && !newContent)
@@ -126,11 +125,11 @@ public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase
}
fail = wasCreatedInTxn;
}
// Trigger the rules in the appropriate way
// Trigger the rules in the appropriate way
if (fail == false && newContent == this.onNewContent)
{
if (triggerParentRules == true)
if (triggerParentRules == true)
{
if (logger.isDebugEnabled() == true)
{
@@ -153,20 +152,20 @@ public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase
/**
* Indicates whether we are dealing with a zero length office document or not
*
* @param contentReader the content reader
* @return boolean true if zero length office document, false otherwise
* @param contentData the content details
* @return boolean true if zero length office document, false otherwise
*/
private boolean isZeroLengthOfficeDoc(ContentReader contentReader)
private boolean isZeroLengthOfficeDoc(ContentData contentData)
{
boolean result = false;
if (contentReader.getSize() == 0 &&
(MimetypeMap.MIMETYPE_WORD.equals(contentReader.getMimetype()) == true ||
MimetypeMap.MIMETYPE_EXCEL.equals(contentReader.getMimetype()) == true ||
MimetypeMap.MIMETYPE_PPT.equals(contentReader.getMimetype()) == true))
{
result = true;
}
return result;
boolean result = false;
if (contentData.getSize() == 0 &&
(MimetypeMap.MIMETYPE_WORD.equals(contentData.getMimetype()) == true ||
MimetypeMap.MIMETYPE_EXCEL.equals(contentData.getMimetype()) == true ||
MimetypeMap.MIMETYPE_PPT.equals(contentData.getMimetype()) == true))
{
result = true;
}
return result;
}
}