Search in sources :

Example 6 with MismatchedPutCodeException

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

the class MemberV2ApiServiceDelegatorImpl method updateResearcherUrl.

@Override
public Response updateResearcherUrl(String orcid, Long putCode, ResearcherUrl researcherUrl) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_BIO_UPDATE);
    if (!putCode.equals(researcherUrl.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(researcherUrl.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(researcherUrl);
    ResearcherUrl updatedResearcherUrl = researcherUrlManager.updateResearcherUrl(orcid, researcherUrl, true);
    ElementUtils.setPathToResearcherUrl(updatedResearcherUrl, orcid);
    sourceUtils.setSourceName(updatedResearcherUrl);
    return Response.ok(updatedResearcherUrl).build();
}
Also used : HashMap(java.util.HashMap) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 7 with MismatchedPutCodeException

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

the class MemberV2ApiServiceDelegatorImpl method updateOtherName.

@Override
public Response updateOtherName(String orcid, Long putCode, OtherName otherName) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_BIO_UPDATE);
    if (!putCode.equals(otherName.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(otherName.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(otherName);
    OtherName updatedOtherName = otherNameManager.updateOtherName(orcid, putCode, otherName, true);
    ElementUtils.setPathToOtherName(updatedOtherName, orcid);
    sourceUtils.setSourceName(updatedOtherName);
    return Response.ok(updatedOtherName).build();
}
Also used : HashMap(java.util.HashMap) OtherName(org.orcid.jaxb.model.record_v2.OtherName) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 8 with MismatchedPutCodeException

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

the class MemberV2ApiServiceDelegatorImpl method updateExternalIdentifier.

@Override
public Response updateExternalIdentifier(String orcid, Long putCode, PersonExternalIdentifier externalIdentifier) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_BIO_EXTERNAL_IDENTIFIERS_CREATE);
    if (!putCode.equals(externalIdentifier.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(externalIdentifier.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(externalIdentifier);
    PersonExternalIdentifier extId = externalIdentifierManager.updateExternalIdentifier(orcid, externalIdentifier, true);
    ElementUtils.setPathToExternalIdentifier(extId, orcid);
    sourceUtils.setSourceName(extId);
    return Response.ok(extId).build();
}
Also used : HashMap(java.util.HashMap) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 9 with MismatchedPutCodeException

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

the class MemberV2ApiServiceDelegatorImpl method updateEmployment.

@Override
public Response updateEmployment(String orcid, Long putCode, Employment employment) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_UPDATE);
    if (!putCode.equals(employment.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(employment.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(employment);
    Employment e = affiliationsManager.updateEmploymentAffiliation(orcid, employment, true);
    sourceUtils.setSourceName(e);
    return Response.ok(e).build();
}
Also used : HashMap(java.util.HashMap) Employment(org.orcid.jaxb.model.record_v2.Employment) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Aggregations

HashMap (java.util.HashMap)9 MismatchedPutCodeException (org.orcid.core.exception.MismatchedPutCodeException)9 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)1 Education (org.orcid.jaxb.model.record_v2.Education)1 Employment (org.orcid.jaxb.model.record_v2.Employment)1 Funding (org.orcid.jaxb.model.record_v2.Funding)1 OtherName (org.orcid.jaxb.model.record_v2.OtherName)1 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)1 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)1 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)1 Work (org.orcid.jaxb.model.record_v2.Work)1