use of com.enonic.xp.node.NodeAccessException in project xp by enonic.
the class SetRootPermissionsCommand method execute.
public Node execute() {
final Node rootNode = doGetById(Node.ROOT_UUID);
if (rootNode == null) {
throw new NodeAccessException(ContextAccessor.current().getAuthInfo().getUser(), NodePath.ROOT, Permission.READ);
}
requireContextUserPermissionOrAdmin(Permission.WRITE_PERMISSIONS, rootNode);
return StoreNodeCommand.create(this).node(Node.create(rootNode).permissions(this.permissions).inheritPermissions(this.inheritPermissions).timestamp(Instant.now(CLOCK)).build()).build().execute();
}
use of com.enonic.xp.node.NodeAccessException in project xp by enonic.
the class SetNodeChildOrderCommandTest method order_without_permission.
@Test
public void order_without_permission() throws Exception {
final Node createUngrantedNode = createNode(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).permissions(AccessControlList.of(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.CREATE).build())).build());
final Node createGrantedNode = createNode(CreateNodeParams.create().name("my-node2").parent(NodePath.ROOT).permissions(AccessControlList.of(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().build())).build());
// Tests the check of the DELETE right on the moved node
boolean createRightChecked = false;
try {
setChildOrder(createUngrantedNode, ChildOrder.create().add(FieldOrderExpr.create(NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.ASC)).build());
} catch (NodeAccessException e) {
createRightChecked = true;
}
assertTrue(createRightChecked);
// Tests the correct behaviour if the right is granted
setChildOrder(createGrantedNode, ChildOrder.create().add(FieldOrderExpr.create(NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.ASC)).build());
}
use of com.enonic.xp.node.NodeAccessException in project xp by enonic.
the class DeleteContentCommand method execute.
DeleteContentsResult execute() {
params.validate();
try {
final DeleteContentsResult deletedContents = doExecute();
nodeService.refresh(RefreshMode.SEARCH);
return deletedContents;
} catch (NodeAccessException e) {
throw new ContentAccessException(e);
}
}
use of com.enonic.xp.node.NodeAccessException in project xp by enonic.
the class CreateContentCommand method doExecute.
private Content doExecute() {
final ContentType contentType = contentTypeService.getByName(new GetContentTypeParams().contentTypeName(params.getType()));
validateContentType(contentType);
formDefaultValuesProcessor.setDefaultValues(contentType.getForm(), params.getData());
// TODO apply default values to xData
CreateContentParams processedParams = runContentProcessors(this.params, contentType);
validateBlockingChecks(processedParams);
final CreateContentTranslatorParams createContentTranslatorParams = createContentTranslatorParams(processedParams);
final CreateNodeParams createNodeParams = CreateNodeParamsFactory.create(createContentTranslatorParams).contentTypeService(this.contentTypeService).pageDescriptorService(this.pageDescriptorService).xDataService(this.xDataService).partDescriptorService(this.partDescriptorService).layoutDescriptorService(this.layoutDescriptorService).contentDataSerializer(this.contentDataSerializer).siteService(this.siteService).build().produce();
try {
final Node createdNode = nodeService.create(createNodeParams);
if (params.isRefresh()) {
nodeService.refresh(RefreshMode.SEARCH);
}
return translator.fromNode(createdNode, false);
} catch (NodeAlreadyExistAtPathException e) {
throw new ContentAlreadyExistsException(ContentPath.from(createContentTranslatorParams.getParent(), createContentTranslatorParams.getName().toString()), e.getRepositoryId(), e.getBranch());
} catch (NodeAccessException e) {
throw new ContentAccessException(e);
}
}
use of com.enonic.xp.node.NodeAccessException in project xp by enonic.
the class RestoreContentCommand method execute.
RestoreContentsResult execute() {
params.validate();
try {
final RestoreContentsResult restoredContents = doExecute();
this.nodeService.refresh(RefreshMode.ALL);
return restoredContents;
} catch (MoveNodeException e) {
throw new RestoreContentException(e.getMessage(), ContentNodeHelper.translateNodePathToContentPath(e.getPath()));
} catch (NodeAccessException e) {
throw new ContentAccessException(e);
}
}
Aggregations