use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class GroupsImpl method createGroupMember.
@Override
public GroupMember createGroupMember(String groupId, GroupMember groupMember) {
validateGroupId(groupId, false);
// Not allowed to modify a GROUP_EVERYONE member.
if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
throw new ConstraintViolatedException(ERR_MSG_MODIFY_FIXED_AUTHORITY);
}
validateGroupMember(groupMember);
AuthorityType authorityType = getAuthorityType(groupMember.getMemberType());
if (!authorityService.authorityExists(groupMember.getId())) {
throw new EntityNotFoundException(groupMember.getId());
}
AuthorityType existingAuthorityType = AuthorityType.getAuthorityType(groupMember.getId());
if (existingAuthorityType != authorityType) {
throw new IllegalArgumentException("Incorrect group member type, " + (AuthorityType.USER.equals(existingAuthorityType) ? Groups.PARAM_MEMBER_TYPE_PERSON : existingAuthorityType) + " exists with the given id");
}
authorityService.addAuthority(groupId, groupMember.getId());
String authority = authorityService.getName(authorityType, groupMember.getId());
return getGroupMember(authority);
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class NetworksImpl method validateNetwork.
public Network validateNetwork(String networkId) {
org.alfresco.repo.tenant.Network network = networksService.getNetwork(networkId);
if (network == null) {
throw new EntityNotFoundException(networkId);
}
Network restNetwork = new NetworkImpl(network);
return restNetwork;
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class NodesImpl method resolveNodeByPath.
protected NodeRef resolveNodeByPath(final NodeRef parentNodeRef, String path, boolean checkForCompanyHome) {
final List<String> pathElements = getPathElements(path);
if (!pathElements.isEmpty() && checkForCompanyHome) {
/*
if (nodeService.getRootNode(parentNodeRef.getStoreRef()).equals(parentNodeRef))
{
// special case
NodeRef chNodeRef = repositoryHelper.getCompanyHome();
String chName = (String) nodeService.getProperty(chNodeRef, ContentModel.PROP_NAME);
if (chName.equals(pathElements.get(0)))
{
pathElements = pathElements.subList(1, pathElements.size());
parentNodeRef = chNodeRef;
}
}
*/
}
FileInfo fileInfo = null;
try {
if (!pathElements.isEmpty()) {
fileInfo = fileFolderService.resolveNamePath(parentNodeRef, pathElements);
} else {
fileInfo = fileFolderService.getFileInfo(parentNodeRef);
if (fileInfo == null) {
throw new EntityNotFoundException(parentNodeRef.getId());
}
}
} catch (FileNotFoundException fnfe) {
// convert checked exception
throw new NotFoundException("The entity with relativePath: " + path + " was not found.");
} catch (AccessDeniedException ade) {
// return 404 instead of 403 (as per security review - uuid vs path)
throw new NotFoundException("The entity with relativePath: " + path + " was not found.");
}
return fileInfo.getNodeRef();
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class PeopleImpl method getPersonWithProperties.
private Person getPersonWithProperties(String personId, List<String> include) {
Person person = null;
NodeRef personNode = personService.getPerson(personId, false);
if (personNode != null) {
Map<QName, Serializable> nodeProps = nodeService.getProperties(personNode);
processPersonProperties(personId, nodeProps);
// TODO this needs to be run as admin but should we do this here?
final String pId = personId;
Boolean enabled = AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>() {
public Boolean doWork() throws Exception {
return authenticationService.getAuthenticationEnabled(pId);
}
});
person = new Person(personNode, nodeProps, enabled);
// Remove the temporary property used to help inline the person description content property.
// It may be accessed from the person object (person.getDescription()).
nodeProps.remove(Person.PROP_PERSON_DESCRIPTION);
// Expose properties
if (include.contains(PARAM_INCLUDE_PROPERTIES)) {
// Note that custProps may be null.
Map<String, Object> custProps = nodes.mapFromNodeProperties(nodeProps, new ArrayList<>(), new HashMap<>(), EXCLUDED_NS, EXCLUDED_PROPS);
person.setProperties(custProps);
}
if (include.contains(PARAM_INCLUDE_ASPECTNAMES)) {
// Expose aspect names
Set<QName> aspects = nodeService.getAspects(personNode);
person.setAspectNames(nodes.mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS));
}
if (include.contains(PARAM_INCLUDE_CAPABILITIES)) {
// Expose capabilities
Map<String, Boolean> capabilities = new HashMap<>(3);
capabilities.put("isAdmin", isAdminAuthority(personId));
capabilities.put("isGuest", isGuestAuthority(personId));
capabilities.put("isMutable", isMutableAuthority(personId));
person.setCapabilities(capabilities);
}
// get avatar information
if (hasAvatar(personNode)) {
try {
NodeRef avatar = getAvatar(personId);
person.setAvatarId(avatar);
} catch (EntityNotFoundException e) {
// shouldn't happen, but ok
}
}
} else {
throw new EntityNotFoundException(personId);
}
return person;
}
use of org.alfresco.rest.framework.core.exceptions.EntityNotFoundException in project alfresco-remote-api by Alfresco.
the class PeopleImpl method getAvatar.
@Override
public NodeRef getAvatar(String personId) {
NodeRef avatar = null;
personId = validatePerson(personId);
NodeRef personNode = personService.getPerson(personId);
if (personNode != null) {
NodeRef avatarOrig = getAvatarOriginal(personNode);
avatar = thumbnailService.getThumbnailByName(avatarOrig, ContentModel.PROP_CONTENT, "avatar");
}
if (avatar == null) {
throw new EntityNotFoundException(personId);
}
return avatar;
}
Aggregations