Merge pull request #139 from Alfresco/feature/SEARCH-2532_PermissionEvents

SEARCH-2532: Add Permission Update events to be generated from alfres…
This commit is contained in:
Angel Borroy
2020-11-11 12:06:22 +01:00
committed by GitHub
6 changed files with 39 additions and 18 deletions

View File

@@ -58,7 +58,7 @@ import org.alfresco.service.namespace.QName;
public class EventConsolidator implements EventSupportedPolicies
{
private final NodeResourceHelper helper;
private final Deque<EventType> eventTypes;
protected final Deque<EventType> eventTypes;
private final List<QName> aspectsAdded;
private final List<QName> aspectsRemoved;
@@ -125,7 +125,7 @@ public class EventConsolidator implements EventSupportedPolicies
* @param forceUpdate if {@code true}, will get the latest node info and ignores
* the existing builder object.
*/
private void createBuilderIfAbsent(NodeRef nodeRef, boolean forceUpdate)
protected void createBuilderIfAbsent(NodeRef nodeRef, boolean forceUpdate)
{
if (resourceBuilder == null || forceUpdate)
{
@@ -140,7 +140,7 @@ public class EventConsolidator implements EventSupportedPolicies
*
* @param nodeRef the nodeRef in the txn
*/
private void createBuilderIfAbsent(NodeRef nodeRef)
protected void createBuilderIfAbsent(NodeRef nodeRef)
{
createBuilderIfAbsent(nodeRef, false);
}
@@ -491,4 +491,9 @@ public class EventConsolidator implements EventSupportedPolicies
{
return resourceBeforeAllFieldsNull;
}
protected void setResourceBeforeAllFieldsNull(boolean resourceBeforeAllFieldsNull){
this.resourceBeforeAllFieldsNull = resourceBeforeAllFieldsNull;
}
}

View File

@@ -83,21 +83,21 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
{
private static final Log LOGGER = LogFactory.getLog(EventGenerator.class);
private PolicyComponent policyComponent;
private NodeService nodeService;
protected PolicyComponent policyComponent;
protected NodeService nodeService;
private NamespaceService namespaceService;
private DictionaryService dictionaryService;
protected DictionaryService dictionaryService;
private DescriptorService descriptorService;
private EventFilterRegistry eventFilterRegistry;
private Event2MessageProducer event2MessageProducer;
private TransactionService transactionService;
private PersonService personService;
private NodeResourceHelper nodeResourceHelper;
protected NodeResourceHelper nodeResourceHelper;
private NodeTypeFilter nodeTypeFilter;
private ChildAssociationTypeFilter childAssociationTypeFilter;
private EventUserFilter userFilter;
private final EventTransactionListener transactionListener = new EventTransactionListener();
protected final EventTransactionListener transactionListener = new EventTransactionListener();
@Override
public void afterPropertiesSet()
@@ -283,7 +283,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
* @return the {@link EventConsolidator} for the supplied {@code nodeRef} from
* the current transaction context.
*/
private EventConsolidator getEventConsolidator(NodeRef nodeRef)
protected EventConsolidator getEventConsolidator(NodeRef nodeRef)
{
Consolidators consolidators = getTxnConsolidators(transactionListener);
Map<NodeRef, EventConsolidator> nodeEvents = consolidators.getNodes();
@@ -302,7 +302,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
}
private Consolidators getTxnConsolidators(Object resourceKey)
protected Consolidators getTxnConsolidators(Object resourceKey)
{
Consolidators consolidators = AlfrescoTransactionSupport.getResource(resourceKey);
if (consolidators == null)
@@ -388,7 +388,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
//NOOP
}
private class EventTransactionListener extends TransactionListenerAdapter
protected class EventTransactionListener extends TransactionListenerAdapter
{
@Override
public void afterCommit()
@@ -425,7 +425,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
}
}
private void sendEvent(NodeRef nodeRef, EventConsolidator consolidator)
protected void sendEvent(NodeRef nodeRef, EventConsolidator consolidator)
{
if (consolidator.isTemporaryNode())
{
@@ -466,7 +466,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
logAndSendEvent(event, consolidator.getEventTypes());
}
private void sendEvent(ChildAssociationRef childAssociationRef, ChildAssociationEventConsolidator consolidator)
protected void sendEvent(ChildAssociationRef childAssociationRef, ChildAssociationEventConsolidator consolidator)
{
if (consolidator.isTemporaryChildAssociation())
{
@@ -506,7 +506,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
logAndSendEvent(event, consolidator.getEventTypes());
}
private void sendEvent(AssociationRef peerAssociationRef, PeerAssociationEventConsolidator consolidator)
protected void sendEvent(AssociationRef peerAssociationRef, PeerAssociationEventConsolidator consolidator)
{
if (consolidator.isTemporaryPeerAssociation())
{
@@ -525,7 +525,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
logAndSendEvent(event, consolidator.getEventTypes());
}
private void logAndSendEvent(RepoEvent<?> event, Deque<EventType> listOfEvents)
protected void logAndSendEvent(RepoEvent<?> event, Deque<EventType> listOfEvents)
{
if (LOGGER.isTraceEnabled())
{
@@ -542,7 +542,7 @@ public class EventGenerator extends AbstractLifecycleBean implements Initializin
}
private static class Consolidators
protected static class Consolidators
{
private Map<NodeRef, EventConsolidator> nodes;
private Map<ChildAssociationRef, ChildAssociationEventConsolidator> childAssocs;

View File

@@ -43,7 +43,8 @@ public enum EventJSONSchema
CHILD_ASSOC_CREATED_V1("childAssocCreated", 1, EventType.CHILD_ASSOC_CREATED),
CHILD_ASSOC_DELETED_V1("childAssocDeleted", 1, EventType.CHILD_ASSOC_DELETED),
PEER_ASSOC_CREATED_V1("peerAssocCreated", 1 , EventType.PEER_ASSOC_CREATED),
PEER_ASSOC_DELETED_V1("peerAssocDeleted", 1 , EventType.PEER_ASSOC_DELETED);
PEER_ASSOC_DELETED_V1("peerAssocDeleted", 1 , EventType.PEER_ASSOC_DELETED),
PERMISSION_UPDATED_V1("permissionUpdated", 1, EventType.PERMISSION_UPDATED);
private static final String PREFIX = "https://api.alfresco.com/schema/event/repo/v";

View File

@@ -34,7 +34,8 @@ public enum EventType
{
NODE_CREATED(EventTypeConst.CREATED, ContextType.NODE), NODE_UPDATED(EventTypeConst.UPDATED, ContextType.NODE), NODE_DELETED(EventTypeConst.DELETED, ContextType.NODE),
CHILD_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.CHILD_ASSOC), CHILD_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.CHILD_ASSOC),
PEER_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.PEER_ASSOC), PEER_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.PEER_ASSOC);
PEER_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.PEER_ASSOC), PEER_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.PEER_ASSOC),
PERMISSION_UPDATED(EventTypeConst.UPDATED, ContextType.NODE);
private static final String PREFIX = "org.alfresco.event.";
private final String type;

View File

@@ -52,6 +52,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.security.NoSuchPersonException;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceException;
import org.alfresco.service.namespace.NamespaceService;
@@ -76,6 +77,7 @@ public class NodeResourceHelper implements InitializingBean
protected PersonService personService;
protected EventFilterRegistry eventFilterRegistry;
protected NamespaceService namespaceService;
protected PermissionService permissionService;
private NodeAspectFilter nodeAspectFilter;
private NodePropertyFilter nodePropertyFilter;
@@ -88,6 +90,7 @@ public class NodeResourceHelper implements InitializingBean
PropertyCheck.mandatory(this, "personService", personService);
PropertyCheck.mandatory(this, "eventFilterRegistry", eventFilterRegistry);
PropertyCheck.mandatory(this, "namespaceService", namespaceService);
PropertyCheck.mandatory(this, "permissionService", permissionService);
this.nodeAspectFilter = eventFilterRegistry.getNodeAspectFilter();
this.nodePropertyFilter = eventFilterRegistry.getNodePropertyFilter();
@@ -108,6 +111,11 @@ public class NodeResourceHelper implements InitializingBean
this.personService = personService;
}
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
// To make IntelliJ stop complaining about unused method!
@SuppressWarnings("unused")
public void setEventFilterRegistry(EventFilterRegistry eventFilterRegistry)
@@ -316,4 +324,9 @@ public class NodeResourceHelper implements InitializingBean
final Path path = nodeService.getPath(nodeRef);
return PathUtil.getNodeIdsInReverse(path, showLeaf);
}
public PermissionService getPermissionService()
{
return permissionService;
}
}

View File

@@ -49,6 +49,7 @@
<property name="personService" ref="personService"/>
<property name="eventFilterRegistry" ref="event2FilterRegistry"/>
<property name="namespaceService" ref="namespaceService"/>
<property name="permissionService" ref="permissionService"/>
</bean>
<bean id="nodeResourceHelper" class="org.alfresco.repo.event2.NodeResourceHelper" parent="baseNodeResourceHelper"/>