use of com.enonic.xp.security.PrincipalNotFoundException in project xp by enonic.
the class SecurityServiceImpl method updateGroup.
@Override
public Group updateGroup(final UpdateGroupParams updateGroupParams) {
return callWithContext(() -> {
final Node node = this.nodeService.getByPath(updateGroupParams.getKey().toPath());
if (node == null) {
throw new PrincipalNotFoundException(updateGroupParams.getKey());
}
final Group existingGroup = PrincipalNodeTranslator.groupFromNode(node);
final Group groupToUpdate = updateGroupParams.update(existingGroup);
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.toUpdateNodeParams(groupToUpdate);
final Node updatedNode = nodeService.update(updateNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return PrincipalNodeTranslator.groupFromNode(updatedNode);
});
}
use of com.enonic.xp.security.PrincipalNotFoundException in project xp by enonic.
the class SecurityServiceImpl method doUpdateUser.
private User doUpdateUser(final UpdateUserParams updateUserParams) {
return callWithContext(() -> {
final Node node = this.nodeService.getByPath(updateUserParams.getKey().toPath());
if (node == null) {
throw new PrincipalNotFoundException(updateUserParams.getKey());
}
final User existingUser = PrincipalNodeTranslator.userFromNode(node);
final User userToUpdate = updateUserParams.update(existingUser);
duplicateEmailValidation(userToUpdate.getKey(), userToUpdate.getEmail());
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.toUpdateNodeParams(userToUpdate);
final Node updatedNode = nodeService.update(updateNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return PrincipalNodeTranslator.userFromNode(updatedNode);
});
}
use of com.enonic.xp.security.PrincipalNotFoundException in project xp by enonic.
the class SecurityServiceImpl method updateRole.
@Override
public Role updateRole(final UpdateRoleParams updateRoleParams) {
return callWithContext(() -> {
final Node node = this.nodeService.getByPath(updateRoleParams.getKey().toPath());
if (node == null) {
throw new PrincipalNotFoundException(updateRoleParams.getKey());
}
final Role existingRole = PrincipalNodeTranslator.roleFromNode(node);
final Role roleToUpdate = updateRoleParams.update(existingRole);
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.toUpdateNodeParams(roleToUpdate);
final Node updatedNode = nodeService.update(updateNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return PrincipalNodeTranslator.roleFromNode(updatedNode);
});
}
use of com.enonic.xp.security.PrincipalNotFoundException in project xp by enonic.
the class DeletePrincipalHandlerTest method testDeleteNonExistingUser.
@Test
public void testDeleteNonExistingUser() {
final PrincipalKey principalKey = PrincipalKey.from("user:myIdProvider:XXX");
Mockito.doThrow(new PrincipalNotFoundException(principalKey)).when(securityService).deletePrincipal(principalKey);
runFunction("/test/deletePrincipal-test.js", "deleteNonExistingUser");
}
Aggregations