alfresco-community-repo/source/java/org/alfresco/repo/rule/ruletrigger/SingleAssocRefPolicyRuleTrigger.java
Dave Ward 193546cc47 Merged V4.0-BUG-FIX to HEAD
37502: Merged V3.4-BUG-FIX to V4.0-BUG-FIX (RECORD ONLY)
      37159: ALF-12541: Fix EOL.
      37172: Merged HEAD to V3.4-BUG-FIX:
         33880: ALF-12777 / ALF-14259: MMT should not install AMPs which override pre-existing files in the war file, unless -force is provided. The MMT is moving toward more of a validation phase (checks things, calculate changes) then an execution phase (makes the changes).
   37526: ALF-11027: update URLs to our Maven repos
   37554: Follow-on fix to ALF-9661 - do not fire update rule (onDeleteAssociation) if node also no longer exists
   - will fail with concurrency/retry error (=> "Attempt to follow reference ... to deleted node")
   - fix targeted for 4.0.3 (requires merge from V4.0-BUG-FIX to V4.0)
   - required by CloudSync (ALF-13941) - eg. last target( SSMN) also deletes source (SSD)
   37564: Pull out some bits to constants, so downstream classes can more easily configure themselves
   37571: ALF-14055: Merged V3.4-BUG-FIX to V4.0-BUG-FIX
      37570: ALF-13751: Catastrophic indexing performance when a repository containing 60,000 sites, all containing the admin user is synced with an LDAP server containing an admin user
         - made LDAP sync only apply incremental changes to zones (rather than removing all and adding all) and made it preserve the AUTH.ALF zone if it is already there, as that contains all the site group paths


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37572 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-06-08 17:17:36 +00:00

84 lines
3.0 KiB
Java

/*
* Copyright (C) 2005-2012 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.rule.ruletrigger;
import java.util.List;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.PropertyCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SingleAssocRefPolicyRuleTrigger extends RuleTriggerAbstractBase
{
private static Log logger = LogFactory.getLog(OnPropertyUpdateRuleTrigger.class);
private String policyNamespace = NamespaceService.ALFRESCO_URI;
private String policyName;
public void setPolicyNamespace(String policyNamespace)
{
this.policyNamespace = policyNamespace;
}
public void setPolicyName(String policyName)
{
this.policyName = policyName;
}
/**
* @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger()
*/
public void registerRuleTrigger()
{
PropertyCheck.mandatory(this, "policyNamespace", policyNamespace);
PropertyCheck.mandatory(this, "policyName", policyName);
this.policyComponent.bindAssociationBehaviour(
QName.createQName(this.policyNamespace, this.policyName),
this,
new JavaBehaviour(this, "policyBehaviour"));
}
public void policyBehaviour(AssociationRef assocRef)
{
NodeRef nodeRef = assocRef.getSourceRef();
if (nodeService.exists(nodeRef))
{
List<ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef parentAssocRef : parentsAssocRefs)
{
triggerRules(parentAssocRef.getParentRef(), nodeRef);
if (logger.isDebugEnabled() == true)
{
logger.debug(
"OnUpdateAssoc rule triggered (parent); " +
"nodeRef=" + parentAssocRef.getParentRef());
}
}
}
}
}