Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
Revert "simplified job fix and corrected formatting"
Browse files Browse the repository at this point in the history
This reverts commit 9329453.
  • Loading branch information
evasques committed May 5, 2020
1 parent 9329453 commit 77f3602
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@
*/
package org.alfresco.repo.domain.permissions;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeIdAndAclId;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.permissions.ACLType;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.security.permissions.AccessControlListProperties;
import org.alfresco.repo.security.permissions.SimpleAccessControlListProperties;
import org.alfresco.repo.security.permissions.impl.AclChange;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeIdAndAclId;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.permissions.ACLType;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.security.permissions.AccessControlListProperties;
import org.alfresco.repo.security.permissions.SimpleAccessControlListProperties;
import org.alfresco.repo.security.permissions.impl.AclChange;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.ConcurrencyFailureException;

/**
Expand Down Expand Up @@ -101,23 +101,23 @@ public void setBehaviourFilter(BehaviourFilter behaviourFilter)
public void setPreserveAuditableData(boolean preserveAuditableData)
{
this.preserveAuditableData = preserveAuditableData;
}
}

public void setForceAsyncAclCreation(boolean forceAsyncAclCreation)
{
this.forceAsyncAclCreation = forceAsyncAclCreation;
}
}

public boolean isPreserveAuditableData()
{
return preserveAuditableData;
}
}

public boolean isForceAsyncAclCreation()
{
return forceAsyncAclCreation;
}
}

public void forceCopy(NodeRef nodeRef)
{
// Nothing to do
Expand Down Expand Up @@ -478,8 +478,9 @@ else if (dbAcl.getAclType() == ACLType.SHARED)
*/
private boolean setFixAclPending(Long nodeId, Long inheritFrom, Long mergeFrom, Long sharedAclToReplace, List<AclChange> changes,
boolean set, boolean asyncCall, boolean propagateOnChildren)
{
// If we exceeded the transaction time and either call is async or system set to force acl async creation, delegate to job
{

// If we exceeded the transaction time and either call is async or system set to force acl async creation, delegate to job
if(isSubjectToAsyncAclCreation(nodeId,asyncCall)) {
// set ASPECT_PENDING_FIX_ACL aspect on node to be later on processed with FixedAclUpdater
addFixedAclPendingAspect(nodeId, sharedAclToReplace, inheritFrom);
Expand All @@ -489,16 +490,19 @@ private boolean setFixAclPending(Long nodeId, Long inheritFrom, Long mergeFrom,
Long setSharedAclToReplace = (Long) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_SHARED_ACL_TO_REPLACE);
return false;
}


// make regular method call
setFixedAcls(nodeId, inheritFrom, mergeFrom, sharedAclToReplace, changes, set, asyncCall, propagateOnChildren);
return true;
}
}

/**
* MNT-18308 - Verify if we turn this ACL creation to an asynchronous process based on three parameters: if the call is already async and
* transaction time was exceeded OR if system is set to force async ACL creation when max transaction time allowed is exceeded
* even on asynchronous calls
* @param nodeId
* @param asyncCall
* @return
*/
private boolean isSubjectToAsyncAclCreation(Long nodeId, boolean asyncCall) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
private PolicyComponent policyComponent;
private PolicyIgnoreUtil policyIgnoreUtil;

private List<NodeRef> currentlyProcessingNodes = new ArrayList<NodeRef>();

public void setNumThreads(int numThreads)
{
this.numThreads = numThreads;
Expand Down Expand Up @@ -183,7 +185,16 @@ public List<NodeRef> execute() throws Throwable
nodeDAO.getNodesWithAspects(aspects, getNodesCallback.getMinNodeId(), null, getNodesCallback);
getNodesCallback.done();

return getNodesCallback.getNodes();
List<NodeRef> nodesWithAspects = new ArrayList<NodeRef>();

getNodesCallback.getNodes().forEach(el -> {
if(!currentlyProcessingNodes.contains(el)) {
nodesWithAspects.add(el);
currentlyProcessingNodes.add(el);
}
});

return nodesWithAspects;
}
}, false, true);
return nodes;
Expand Down Expand Up @@ -276,7 +287,8 @@ public Void doWork() throws Exception

nodeDAO.removeNodeAspects(nodeId, aspects);
nodeDAO.removeNodeProperties(nodeId, PENDING_FIX_ACL_ASPECT_PROPS);

currentlyProcessingNodes.remove(nodeRef);

if (!policyIgnoreUtil.ignorePolicy(nodeRef))
{
boolean transformedToAsyncOperation = toBoolean((Boolean) AlfrescoTransactionSupport.getResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY));
Expand Down Expand Up @@ -321,9 +333,7 @@ public boolean handle(Pair<Long, NodeRef> nodePair)
if (nodes.size() < maxItemBatchSize)
{
nodes.add(nodePair.getSecond());
if (nodePair.getFirst() > maxNodeId) {
maxNodeId = nodePair.getFirst();
}
maxNodeId = nodePair.getFirst();
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ cm_contentmodel.property.cm_originator.title=From
cm_contentmodel.property.cm_originator.description=From
cm_contentmodel.property.cm_addressee.title=To
cm_contentmodel.property.cm_addressee.description=To
cm_contentmodel.property.cm_addressees.title=All Recipients
cm_contentmodel.property.cm_addressees.title=CC
cm_contentmodel.property.cm_addressees.description=CC
cm_contentmodel.property.cm_subjectline.title=Subject
cm_contentmodel.property.cm_subjectline.description=Subject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
private static String LABEL_SIZE = "Size";
private static String LABEL_ORIGINATOR = "From";
private static String LABEL_ADDRESSEE = "To";
private static String LABEL_ADDRESSEES = "All Recipients";
private static String LABEL_ADDRESSEES = "CC";
private static String LABEL_SUBJECT = "Subject";
private static String LABEL_SENT_DATE = "Sent Date";
private static String LABEL_REFERENCES = "References";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function testGetFormForContentNode()
test.assertEquals("Description", descField.label);
test.assertEquals("From", originatorField.label);
test.assertEquals("To", addresseeField.label);
test.assertEquals("All Recipients", addresseesField.label);
test.assertEquals("CC", addresseesField.label);
test.assertEquals("Subject", subjectField.label);
test.assertEquals("Sent Date", sentDateField.label);
test.assertEquals("References", referencesField.label);
Expand Down

0 comments on commit 77f3602

Please sign in to comment.