protected final RecordingChanges changesFor( String workspaceName ) { RecordingChanges changes = changesByWorkspace.get(workspaceName); if (changes == null) { changes = new RecordingChanges(sessionId, processId, repositoryKey, workspaceName, journalId); changesByWorkspace.put(workspaceName, changes); } return changes; }
@Override public void nodeRenamed( NodeKey key, Path newPath, Segment oldName, Name primaryType, Set<Name> mixinTypes ) { events.add(new NodeRenamed(key, newPath, oldName, filterName(primaryType), filterNameSet(mixinTypes))); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Save by '").append(getUserId()).append("' at ").append(getTimestamp()).append(" with user data = ") .append(userData).append(" in repository with key '").append(repositoryKey).append("' and workspace '") .append(workspaceName); if (journalId != null) { sb.append(". Journal id=").append(journalId); } sb.append("'\n"); for (Change change : this) { sb.append(" ").append(change).append("\n"); } sb.append("changed ").append(nodeKeys.size()).append(" nodes:\n"); for (NodeKey key : nodeKeys) { sb.append(" ").append(key).append("\n"); } return sb.toString(); }
String workspaceName = persistedCache.getWorkspaceName(); String repositoryKey = persistedCache.getRepositoryKey(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), repositoryKey, workspaceName, repositoryEnvironment.journalId()); changes.nodeRemoved(key, parentKey, path, primaryType, mixinTypes, parentPrimaryType, parentMixinTypes); removedNodes.add(key); if (isUnorderedCollection) { changes.nodeCreated(key, newParent, newPath, primaryType, mixinTypes, node.changedProperties()); } else { doc = documentStore.edit(keyStr, true); boolean isSameWorkspace = persistedCache.getWorkspaceKey().equalsIgnoreCase(workspaceKey); if (isSameWorkspace) { changes.nodeMoved(key, primaryType, mixinTypes, newParent, oldParentKey, newPath, oldPath); changes.propertyAdded(key, primaryType, mixinTypes, newPath, newProperty); } else if (newProperty == null) { changes.propertyRemoved(key, primaryType, mixinTypes, newPath, oldProperty); } else { changes.propertyChanged(key, primaryType, mixinTypes, newPath, newProperty, oldProperty); changes.propertyRemoved(key, primaryType, mixinTypes, newPath, oldProperty); changes.propertyAdded(key, primaryType, mixinTypes, newPath, prop); changes.propertyChanged(key, primaryType, mixinTypes, newPath, prop, oldProperty); hasPropertyChanges = true;
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceAdded(name); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes);
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceRemoved(name); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); return true;
changesFor(wsAndOldPath.getWorkspaceName()).nodeRemoved(key, oldParentKey, wsAndOldPath.getPath(), primaryType, mixinTypes, null, null); changesFor(wsAndNewPath.getWorkspaceName()).nodeCreated(key, newParentKey, wsAndNewPath.getPath(), primaryType, mixinTypes, properties); changesFor(newWorkspace).nodeMoved(key, primaryType, mixinTypes, newParentKey, oldParentKey, newWsAndPath.getPath(), oldWsAndPath.getPath()); return; changesFor(oldWsAndPath.getWorkspaceName()).nodeRemoved(key, oldParentKey, oldWsAndPath.getPath(), primaryType, mixinTypes, null, null); changesFor(newWsAndPath.getWorkspaceName()).nodeCreated(key, newParentKey, newWsAndPath.getPath(), primaryType, mixinTypes, properties); return; if (newWorkspace.equals(oldWorkspace)) { found = true; changesFor(newWorkspace).nodeMoved(key, primaryType, mixinTypes, newParentKey, oldParentKey, wsAndNewPath.getPath(), wsAndOldPath.getPath()); changesFor(wsAndNewPath).nodeCreated(key, newParentKey, wsAndNewPath.getPath(), primaryType, mixinTypes, properties); changesFor(oldWsAndPath).nodeRemoved(key, oldParentKey, oldWsAndPath.getPath(), primaryType, mixinTypes, null, null);
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }
@Override public void publish( Map<String, String> data ) { DateTime now = timeFactory.create(); if (data == null) data = Collections.emptyMap(); // Freeze and then notify the bus of each change set of a given workspace ... for (RecordingChanges changes : changesByWorkspace.values()) { changes.freeze(connectorSourceName, data, now); bus.notify(changes); } changesByWorkspace.clear(); }
private Set<Name> filterNameSet( Set<Name> input ) { Set<Name> result = new HashSet<Name>(input.size()); for (Name name : input) { result.add(filterName(name)); } return result; } }
@Override public void nodeCreated( String docId, String parentDocId, String path, Name primaryType, Set<Name> mixinTypes, Map<Name, Property> properties ) { NodeKey key = nodeKey(docId); NodeKey parentKey = nodeKey(parentDocId); Path externalPath = pathMappings.getPathFactory().create(path); // This external path in the connector may be projected into *multiple* nodes in the same or different workspaces ... for (WorkspaceAndPath wsAndPath : pathMappings.resolveExternalPathToInternal(externalPath)) { changesFor(wsAndPath).nodeCreated(key, parentKey, wsAndPath.getPath(), primaryType, mixinTypes, properties); } }
String workspaceName = persistedCache.getWorkspaceName(); String repositoryKey = persistedCache.getRepositoryKey(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), repositoryKey, workspaceName, repositoryEnvironment.journalId()); changes.nodeRemoved(key, parentKey, path, primaryType, mixinTypes, parentPrimaryType, parentMixinTypes); removedNodes.add(key); if (isUnorderedCollection) { changes.nodeCreated(key, newParent, newPath, primaryType, mixinTypes, node.changedProperties()); } else { doc = documentStore.edit(keyStr, true); boolean isSameWorkspace = persistedCache.getWorkspaceKey().equalsIgnoreCase(workspaceKey); if (isSameWorkspace) { changes.nodeMoved(key, primaryType, mixinTypes, newParent, oldParentKey, newPath, oldPath); changes.propertyAdded(key, primaryType, mixinTypes, newPath, newProperty); } else if (newProperty == null) { changes.propertyRemoved(key, primaryType, mixinTypes, newPath, oldProperty); } else { changes.propertyChanged(key, primaryType, mixinTypes, newPath, newProperty, oldProperty); changes.propertyRemoved(key, primaryType, mixinTypes, newPath, oldProperty); changes.propertyAdded(key, primaryType, mixinTypes, newPath, prop); changes.propertyChanged(key, primaryType, mixinTypes, newPath, prop, oldProperty); hasPropertyChanges = true;
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceAdded(name); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes);
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceRemoved(name); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); return true;
changesFor(wsAndOldPath.getWorkspaceName()).nodeRemoved(key, oldParentKey, wsAndOldPath.getPath(), primaryType, mixinTypes, null, null); changesFor(wsAndNewPath.getWorkspaceName()).nodeCreated(key, newParentKey, wsAndNewPath.getPath(), primaryType, mixinTypes, properties); changesFor(newWorkspace).nodeMoved(key, primaryType, mixinTypes, newParentKey, oldParentKey, newWsAndPath.getPath(), oldWsAndPath.getPath()); return; changesFor(oldWsAndPath.getWorkspaceName()).nodeRemoved(key, oldParentKey, oldWsAndPath.getPath(), primaryType, mixinTypes, null, null); changesFor(newWsAndPath.getWorkspaceName()).nodeCreated(key, newParentKey, newWsAndPath.getPath(), primaryType, mixinTypes, properties); return; if (newWorkspace.equals(oldWorkspace)) { found = true; changesFor(newWorkspace).nodeMoved(key, primaryType, mixinTypes, newParentKey, oldParentKey, wsAndNewPath.getPath(), wsAndOldPath.getPath()); changesFor(wsAndNewPath).nodeCreated(key, newParentKey, wsAndNewPath.getPath(), primaryType, mixinTypes, properties); changesFor(oldWsAndPath).nodeRemoved(key, oldParentKey, oldWsAndPath.getPath(), primaryType, mixinTypes, null, null);
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }