Search in sources :

Example 16 with EntityNotFoundException

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);
}
Also used : AuthorityType(org.alfresco.service.cmr.security.AuthorityType) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) ConstraintViolatedException(org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)

Example 17 with EntityNotFoundException

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;
}
Also used : Network(org.alfresco.rest.api.model.Network) PersonNetwork(org.alfresco.rest.api.model.PersonNetwork) NetworkImpl(org.alfresco.rest.api.model.NetworkImpl) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)

Example 18 with EntityNotFoundException

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();
}
Also used : AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) FileInfo(org.alfresco.service.cmr.model.FileInfo) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) NotFoundException(org.alfresco.rest.framework.core.exceptions.NotFoundException) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)

Example 19 with EntityNotFoundException

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;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) PermissionDeniedException(org.alfresco.rest.framework.core.exceptions.PermissionDeniedException) ResetPasswordWorkflowInvalidUserException(org.alfresco.repo.security.authentication.ResetPasswordServiceImpl.ResetPasswordWorkflowInvalidUserException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) ConstraintViolatedException(org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException) AuthenticationException(org.alfresco.repo.security.authentication.AuthenticationException) DisabledServiceException(org.alfresco.rest.framework.core.exceptions.DisabledServiceException) ResetPasswordWorkflowException(org.alfresco.repo.security.authentication.ResetPasswordServiceImpl.ResetPasswordWorkflowException) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Person(org.alfresco.rest.api.model.Person)

Example 20 with EntityNotFoundException

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;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)

Aggregations

EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)66 NodeRef (org.alfresco.service.cmr.repository.NodeRef)28 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)24 PermissionDeniedException (org.alfresco.rest.framework.core.exceptions.PermissionDeniedException)16 QName (org.alfresco.service.namespace.QName)15 ConstraintViolatedException (org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)12 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)12 HashMap (java.util.HashMap)11 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)11 ArrayList (java.util.ArrayList)9 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)8 InvalidSharedIdException (org.alfresco.service.cmr.quickshare.InvalidSharedIdException)7 Serializable (java.io.Serializable)6 FileInfo (org.alfresco.service.cmr.model.FileInfo)6 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 ActivitiScriptNode (org.alfresco.repo.workflow.activiti.ActivitiScriptNode)5 ApiException (org.alfresco.rest.framework.core.exceptions.ApiException)5 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)4 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)4