Search in sources :

Example 1 with ThirdPartyRedirect

use of org.orcid.pojo.ThirdPartyRedirect in project ORCID-Source by ORCID.

the class WorkspaceController method getSourceGrantReadWizard.

@RequestMapping(value = "/my-orcid/sourceGrantReadWizard.json", method = RequestMethod.GET)
@ResponseBody
public ThirdPartyRedirect getSourceGrantReadWizard() {
    ThirdPartyRedirect tpr = new ThirdPartyRedirect();
    ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
    if (profile.getSource() == null || profile.getSource().getSourceId() == null) {
        return tpr;
    }
    String sourcStr = profile.getSource().getSourceId();
    // Check that the cache is up to date
    evictThirdPartyLinkManagerCacheIfNeeded();
    // Get list of clients
    List<OrcidClient> orcidClients = thirdPartyLinkManager.findOrcidClientsWithPredefinedOauthScopeReadAccess();
    for (OrcidClient orcidClient : orcidClients) {
        if (sourcStr.equals(orcidClient.getClientId())) {
            RedirectUri ru = orcidClient.getRedirectUris().getRedirectUri().get(0);
            String redirect = getBaseUri() + "/oauth/authorize?client_id=" + orcidClient.getClientId() + "&response_type=code&scope=" + ru.getScopeAsSingleString() + "&redirect_uri=" + ru.getValue();
            tpr.setUrl(redirect);
            tpr.setDisplayName(orcidClient.getDisplayName());
            tpr.setShortDescription(orcidClient.getShortDescription());
            return tpr;
        }
    }
    return tpr;
}
Also used : OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ThirdPartyRedirect(org.orcid.pojo.ThirdPartyRedirect) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)1 RedirectUri (org.orcid.jaxb.model.clientgroup.RedirectUri)1 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)1 ThirdPartyRedirect (org.orcid.pojo.ThirdPartyRedirect)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1