use of org.jboss.errai.security.shared.exception.UnauthorizedException in project kie-wb-common by kiegroup.
the class LibraryServiceImpl method createDefaultOrganizationalUnit.
private OrganizationalUnit createDefaultOrganizationalUnit() {
if (!authorizationManager.authorize(OrganizationalUnit.RESOURCE_TYPE, OrganizationalUnitAction.CREATE, sessionInfo.getIdentity())) {
throw new UnauthorizedException("User :user has no permissions to :type -> :action".replace(":user", sessionInfo.getIdentity().getIdentifier()).replace(":type", OrganizationalUnit.RESOURCE_TYPE.getName()).replace(":action", OrganizationalUnitAction.CREATE.getName()));
}
final LibraryPreferences preferences = getPreferences();
final List<Contributor> contributors = new ArrayList<>();
contributors.add(new Contributor(preferences.getOrganizationalUnitPreferences().getOwner(), ContributorType.OWNER));
return ouService.createOrganizationalUnit(preferences.getOrganizationalUnitPreferences().getName(), preferences.getOrganizationalUnitPreferences().getGroupId(), Collections.emptyList(), contributors);
}
use of org.jboss.errai.security.shared.exception.UnauthorizedException in project kie-wb-common by kiegroup.
the class LibraryPlacesTest method goToLibraryWhenUserIsNotAuthorizedToCreateProjectsTest.
@Test
public void goToLibraryWhenUserIsNotAuthorizedToCreateProjectsTest() {
doReturn(Optional.ofNullable(null)).when(projectContext).getActiveOrganizationalUnit();
when(libraryService.getDefaultOrganizationalUnit()).thenThrow(new UnauthorizedException());
libraryPlaces.goToLibrary();
verify(libraryPlaces).goToOrganizationalUnits();
}
Aggregations