use of com.enonic.xp.node.Node in project xp by enonic.
the class UpdateNodeCommand method doExecute.
private Node doExecute() {
final Node persistedNode = getPersistedNode();
requireContextUserPermissionOrAdmin(Permission.MODIFY, persistedNode);
final EditableNode editableNode = new EditableNode(persistedNode);
params.getEditor().edit(editableNode);
if (editableNode.inheritPermissions != persistedNode.inheritsPermissions() || !persistedNode.getPermissions().equals(editableNode.permissions)) {
requireContextUserPermissionOrAdmin(Permission.WRITE_PERMISSIONS, persistedNode);
}
final AttachedBinaries updatedBinaries = UpdatedAttachedBinariesResolver.create().editableNode(editableNode).persistedNode(persistedNode).binaryAttachments(this.params.getBinaryAttachments()).binaryService(this.binaryService).build().resolve();
final Node editedNode = editableNode.build();
if (editedNode.equals(persistedNode) && updatedBinaries.equals(persistedNode.getAttachedBinaries())) {
return persistedNode;
}
final Node updatedNode = createUpdatedNode(Node.create(editedNode).timestamp(Instant.now(CLOCK)).attachedBinaries(updatedBinaries).build());
if (!this.params.isDryRun()) {
StoreNodeCommand.create(this).node(updatedNode).build().execute();
}
return updatedNode;
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class UpdateNodeCommand method createUpdatedNode.
private Node createUpdatedNode(final Node editedNode) {
final NodePath parentPath = editedNode.path().getParentPath();
final AccessControlList permissions = evaluatePermissions(parentPath, editedNode.inheritsPermissions(), editedNode.getPermissions());
final Node.Builder updateNodeBuilder = Node.create(editedNode).permissions(permissions);
return updateNodeBuilder.build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class SetActiveVersionCommand method execute.
public NodeVersionId execute() {
final InternalContext context = InternalContext.from(ContextAccessor.current());
final Node node = this.nodeStorageService.get(nodeId, nodeVersionId, context);
if (node == null) {
throw new NodeNotFoundException("Cannot find nodeVersion [" + this.nodeVersionId + "] in branch " + context.getBranch().getValue());
}
if (!node.id().equals(nodeId)) {
throw new NodeNotFoundException("NodeVersionId [" + nodeVersionId + "] not a version of Node with id [" + nodeId + "]");
}
NodePermissionsResolver.requireContextUserPermissionOrAdmin(REQUIRED_PERMISSION, node);
this.nodeStorageService.updateVersion(node, nodeVersionId, context);
return nodeVersionId;
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class SetNodeStateCommand method execute.
public SetNodeStateResult execute() {
final Node node = doGetById(this.params.getNodeId());
final SetNodeStateResult.Builder setNodeStateResultBuilder = SetNodeStateResult.create();
if (this.params.isRecursive()) {
setNodeStateWithChildren(node, setNodeStateResultBuilder);
} else {
setNodeState(node, setNodeStateResultBuilder);
}
return setNodeStateResultBuilder.build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class RepositoryEntryServiceImpl method updateRepositoryNode.
private Repository updateRepositoryNode(final UpdateNodeParams updateNodeParams) {
final Node updatedNode = createContext().callWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).binaryService(this.binaryService).build().execute());
eventPublisher.publish(NodeEvents.updated(updatedNode));
refresh();
Repository repository = RepositoryNodeTranslator.toRepository(updatedNode);
eventPublisher.publish(RepositoryEvents.updated(repository.getId()));
return repository;
}
Aggregations