use of com.enonic.xp.node.NodeAlreadyExistAtPathException in project xp by enonic.
the class MoveContentCommand method execute.
MoveContentsResult execute() {
params.validate();
try {
final MoveContentsResult movedContents = doExecute();
this.nodeService.refresh(RefreshMode.ALL);
return movedContents;
} catch (MoveNodeException e) {
throw new MoveContentException(e.getMessage(), ContentPath.from(e.getPath().toString()));
} catch (NodeAlreadyExistAtPathException e) {
throw new ContentAlreadyExistsException(ContentPath.from(e.getNode().toString()), e.getRepositoryId(), e.getBranch());
} catch (NodeAccessException e) {
throw new ContentAccessException(e);
}
}
use of com.enonic.xp.node.NodeAlreadyExistAtPathException in project xp by enonic.
the class CheckNodeExistsCommand method execute.
public boolean execute() {
final InternalContext context = InternalContext.create(ContextAccessor.current()).searchPreference(Mode.ACCURACY.equals(mode) ? SearchPreference.PRIMARY : SearchPreference.LOCAL).build();
if (Mode.ACCURACY.equals(mode)) {
RefreshCommand.create().indexServiceInternal(this.indexServiceInternal).refreshMode(RefreshMode.STORAGE).build().execute();
}
final NodeId found = nodeStorageService.getIdForPath(nodePath, context);
if (found != null && throwIfExists) {
throw new NodeAlreadyExistAtPathException(nodePath, context.getRepositoryId(), context.getBranch());
}
return found != null;
}
use of com.enonic.xp.node.NodeAlreadyExistAtPathException in project xp by enonic.
the class SecurityServiceImpl method doCreateUser.
private User doCreateUser(final CreateUserParams createUser) {
final User user = User.create().key(createUser.getKey()).login(createUser.getLogin()).email(createUser.getEmail()).displayName(createUser.getDisplayName()).modifiedTime(Instant.now(clock)).build();
final CreateNodeParams createNodeParams = PrincipalNodeTranslator.toCreateNodeParams(user);
try {
final Node node = callWithContext(() -> {
final Node createdNode = nodeService.create(createNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return createdNode;
});
if (createUser.getPassword() != null) {
return setPassword(user.getKey(), createUser.getPassword());
}
return PrincipalNodeTranslator.userFromNode(node);
} catch (NodeIdExistsException | NodeAlreadyExistAtPathException e) {
throw new PrincipalAlreadyExistsException(createUser.getKey());
}
}
use of com.enonic.xp.node.NodeAlreadyExistAtPathException in project xp by enonic.
the class SecurityServiceImpl method createGroup.
@Override
public Group createGroup(final CreateGroupParams createGroup) {
final Group group = Group.create().key(createGroup.getKey()).displayName(createGroup.getDisplayName()).modifiedTime(Instant.now(clock)).description(createGroup.getDescription()).build();
final CreateNodeParams createGroupParams = PrincipalNodeTranslator.toCreateNodeParams(group);
try {
final Node node = callWithContext(() -> {
final Node createdNode = this.nodeService.create(createGroupParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return createdNode;
});
return PrincipalNodeTranslator.groupFromNode(node);
} catch (NodeIdExistsException | NodeAlreadyExistAtPathException e) {
throw new PrincipalAlreadyExistsException(createGroup.getKey());
}
}
use of com.enonic.xp.node.NodeAlreadyExistAtPathException in project xp by enonic.
the class SecurityServiceImpl method createRole.
@Override
public Role createRole(final CreateRoleParams createRole) {
final Role role = Role.create().key(createRole.getKey()).displayName(createRole.getDisplayName()).modifiedTime(Instant.now(clock)).description(createRole.getDescription()).build();
final CreateNodeParams createNodeParams = PrincipalNodeTranslator.toCreateNodeParams(role);
try {
final Node node = callWithContext(() -> {
final Node createdNode = this.nodeService.create(createNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return createdNode;
});
return PrincipalNodeTranslator.roleFromNode(node);
} catch (NodeIdExistsException | NodeAlreadyExistAtPathException e) {
throw new PrincipalAlreadyExistsException(createRole.getKey());
}
}
Aggregations