Search in sources :

Example 1 with SourceName

use of org.orcid.jaxb.model.message.SourceName in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorImpl method setSponsorFromAuthentication.

public void setSponsorFromAuthentication(OrcidProfile profile) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (profile.getOrcidHistory() == null) {
        OrcidHistory orcidHistory = new OrcidHistory();
        orcidHistory.setCreationMethod(CreationMethod.API);
        profile.setOrcidHistory(orcidHistory);
    }
    profile.getOrcidHistory().setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    if (OAuth2Authentication.class.isAssignableFrom(authentication.getClass())) {
        OAuth2Request authorizationRequest = ((OAuth2Authentication) authentication).getOAuth2Request();
        Source sponsor = new Source();
        String sponsorId = authorizationRequest.getClientId();
        ClientDetailsEntity clientDetails = clientDetailsManager.findByClientId(sponsorId);
        if (clientDetails != null) {
            sponsor.setSourceName(new SourceName(clientDetails.getClientName()));
            if (OrcidStringUtils.isClientId(sponsorId)) {
                sponsor.setSourceClientId(new SourceClientId(sponsorId));
            } else {
                sponsor.setSourceOrcid(new SourceOrcid(sponsorId));
            }
        }
        profile.getOrcidHistory().setSource(sponsor);
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) OAuth2Request(org.springframework.security.oauth2.provider.OAuth2Request) OAuth2Authentication(org.springframework.security.oauth2.provider.OAuth2Authentication) Authentication(org.springframework.security.core.Authentication) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) OAuth2Authentication(org.springframework.security.oauth2.provider.OAuth2Authentication) SourceClientId(org.orcid.jaxb.model.message.SourceClientId) SourceName(org.orcid.jaxb.model.message.SourceName) SourceOrcid(org.orcid.jaxb.model.message.SourceOrcid) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Source(org.orcid.jaxb.model.message.Source)

Example 2 with SourceName

use of org.orcid.jaxb.model.message.SourceName in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(ResearcherUrl element) {
    if (element.getSource() != null && element.getSource().retrieveSourcePath() != null) {
        SourceName sourceName = getSourceName(element.getSource().retrieveSourcePath());
        element.getSource().setSourceName(sourceName);
    }
}
Also used : SourceName(org.orcid.jaxb.model.message.SourceName)

Example 3 with SourceName

use of org.orcid.jaxb.model.message.SourceName in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(OrcidWork element) {
    if (element.getSource() != null && element.getSource().retrieveSourcePath() != null) {
        SourceName sourceName = getSourceName(element.getSource().retrieveSourcePath());
        element.getSource().setSourceName(sourceName);
    }
}
Also used : SourceName(org.orcid.jaxb.model.message.SourceName)

Example 4 with SourceName

use of org.orcid.jaxb.model.message.SourceName in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(Keyword element) {
    if (element.getSource() != null && element.getSource().retrieveSourcePath() != null) {
        SourceName sourceName = getSourceName(element.getSource().retrieveSourcePath());
        element.getSource().setSourceName(sourceName);
    }
}
Also used : SourceName(org.orcid.jaxb.model.message.SourceName)

Example 5 with SourceName

use of org.orcid.jaxb.model.message.SourceName in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(ExternalIdentifier element) {
    if (element.getSource() != null && element.getSource().retrieveSourcePath() != null) {
        SourceName sourceName = getSourceName(element.getSource().retrieveSourcePath());
        element.getSource().setSourceName(sourceName);
    }
}
Also used : SourceName(org.orcid.jaxb.model.message.SourceName)

Aggregations

SourceName (org.orcid.jaxb.model.message.SourceName)9 Date (java.util.Date)1 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)1 Source (org.orcid.jaxb.model.message.Source)1 SourceClientId (org.orcid.jaxb.model.message.SourceClientId)1 SourceOrcid (org.orcid.jaxb.model.message.SourceOrcid)1 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1 Authentication (org.springframework.security.core.Authentication)1 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)1 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)1