Search in sources :

Example 1 with NodeRenamedEvent

use of org.alfresco.sync.events.types.NodeRenamedEvent in project alfresco-repository by Alfresco.

the class EventsServiceImpl method nodeRenamed.

@Override
public void nodeRenamed(NodeRef nodeRef, String oldName, String newName) {
    NodeInfo nodeInfo = getNodeInfo(nodeRef, NodeRenamedEvent.EVENT_TYPE);
    if (nodeInfo.checkNodeInfo()) {
        NodeRenamedEvent nodeRenamedEvent = nodeRenamedEvent(nodeInfo, oldName, newName);
        sendEvent(nodeRenamedEvent);
    }
}
Also used : NodeRenamedEvent(org.alfresco.sync.events.types.NodeRenamedEvent)

Example 2 with NodeRenamedEvent

use of org.alfresco.sync.events.types.NodeRenamedEvent in project alfresco-repository by Alfresco.

the class EventsServiceImpl method nodeRenamedEvent.

private NodeRenamedEvent nodeRenamedEvent(NodeInfo nodeInfo, String oldName, String newName) {
    String username = AuthenticationUtil.getFullyAuthenticatedUser();
    String networkId = TenantUtil.getCurrentDomain();
    String objectId = nodeInfo.getNodeId();
    String siteId = nodeInfo.getSiteId();
    String txnId = AlfrescoTransactionSupport.getTransactionId();
    long timestamp = System.currentTimeMillis();
    Long modificationTime = nodeInfo.getModificationTimestamp();
    QName nodeTypeQName = nodeInfo.getType();
    String nodeType = nodeTypeQName.toPrefixString(namespaceService);
    List<List<String>> parentNodeIds = nodeInfo.getParentNodeIds();
    List<String> newPaths = nodeInfo.getPaths();
    List<String> paths = null;
    // For site display name (title) rename events we don't want the path to be changed to the display name (title); leave it to name (id)
    if (nodeTypeQName.equals(SiteModel.TYPE_SITE)) {
        paths = newPaths;
    } else {
        nodeInfo.updateName(oldName);
        paths = nodeInfo.getPaths();
    }
    Set<String> aspects = nodeInfo.getAspectsAsStrings();
    Map<String, Serializable> properties = nodeInfo.getProperties();
    Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());
    NodeRenamedEvent event = new NodeRenamedEvent(nextSequenceNumber(), oldName, newName, txnId, timestamp, networkId, siteId, objectId, nodeType, paths, parentNodeIds, username, modificationTime, newPaths, alfrescoClient, aspects, properties);
    return event;
}
Also used : Serializable(java.io.Serializable) NodeRenamedEvent(org.alfresco.sync.events.types.NodeRenamedEvent) QName(org.alfresco.service.namespace.QName) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Client(org.alfresco.sync.repo.Client)

Aggregations

NodeRenamedEvent (org.alfresco.sync.events.types.NodeRenamedEvent)2 Serializable (java.io.Serializable)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 QName (org.alfresco.service.namespace.QName)1 Client (org.alfresco.sync.repo.Client)1