Search in sources :

Example 31 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    Emails emails = null;
    try {
        // return all emails if client has /email/read-private scope
        orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE);
        emails = emailManagerReadOnly.getEmails(orcid);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
    } catch (OrcidAccessControlException e) {
        emails = emailManagerReadOnly.getEmails(orcid);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
        // Filter just in case client doesn't have the /email/read-private
        // scope
        orcidSecurityManager.checkAndFilter(orcid, emails.getEmails(), ScopePathType.ORCID_BIO_READ_LIMITED);
    }
    ElementUtils.setPathToEmail(emails, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtils.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException)

Aggregations

OrcidAccessControlException (org.orcid.core.exception.OrcidAccessControlException)31 NoResultException (javax.persistence.NoResultException)25 Response (javax.ws.rs.core.Response)25 Test (org.junit.Test)25 OrcidUnauthorizedException (org.orcid.core.exception.OrcidUnauthorizedException)25 OrcidVisibilityException (org.orcid.core.exception.OrcidVisibilityException)25 VisibilityMismatchException (org.orcid.core.exception.VisibilityMismatchException)25 WrongSourceException (org.orcid.core.exception.WrongSourceException)25 DBUnitTest (org.orcid.test.DBUnitTest)25 OrcidDuplicatedActivityException (org.orcid.core.exception.OrcidDuplicatedActivityException)9 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)7 ActivityIdentifierValidationException (org.orcid.core.exception.ActivityIdentifierValidationException)6 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)4 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ExceedMaxNumberOfPutCodesException (org.orcid.core.exception.ExceedMaxNumberOfPutCodesException)2 OrcidNoResultException (org.orcid.core.exception.OrcidNoResultException)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2 Filterable (org.orcid.jaxb.model.common_v2.Filterable)1