Search in sources :

Example 6 with RedirectUris

use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.

the class ThirdPartyLinkManagerImpl method getClients.

private List<OrcidClient> getClients(RedirectUriType rut) {
    List<OrcidClient> orcidClients = new ArrayList<OrcidClient>();
    List<ClientRedirectUriEntity> entitiesWithPredefinedScopes = clientRedirectDao.findClientDetailsWithRedirectScope();
    for (ClientRedirectUriEntity entity : entitiesWithPredefinedScopes) {
        if (rut.value().equals(entity.getRedirectUriType())) {
            ClientDetailsEntity clientDetails = entity.getClientDetailsEntity();
            RedirectUri redirectUri = new RedirectUri(entity.getRedirectUri());
            String prefefinedScopes = entity.getPredefinedClientScope();
            redirectUri.setScope(new ArrayList<ScopePathType>(ScopePathType.getScopesFromSpaceSeparatedString(prefefinedScopes)));
            redirectUri.setType(RedirectUriType.fromValue(entity.getRedirectUriType()));
            redirectUri.setActType(entity.getUriActType());
            redirectUri.setGeoArea(entity.getUriGeoArea());
            RedirectUris redirectUris = new RedirectUris();
            redirectUris.getRedirectUri().add(redirectUri);
            OrcidClient minimalClientDetails = new OrcidClient();
            minimalClientDetails.setDisplayName(clientDetails.getClientName());
            minimalClientDetails.setShortDescription(clientDetails.getClientDescription());
            minimalClientDetails.setClientId(clientDetails.getClientId());
            minimalClientDetails.setRedirectUris(redirectUris);
            orcidClients.add(minimalClientDetails);
        }
    }
    return orcidClients;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ScopePathType(org.orcid.jaxb.model.message.ScopePathType) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ArrayList(java.util.ArrayList) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) ClientRedirectUriEntity(org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)

Example 7 with RedirectUris

use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.

the class OrcidClientGroupManagerTest method testAddUpdaterToBasicInstitutionGroup.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddUpdaterToBasicInstitutionGroup() {
    final OrcidClientGroup group = new OrcidClientGroup();
    group.setGroupName("Elsevier");
    group.setEmail("basic-institution-member@elsevier.com" + System.currentTimeMillis());
    group.setType(MemberType.BASIC_INSTITUTION);
    OrcidClientGroup createdGroup = transactionTemplate.execute(new TransactionCallback<OrcidClientGroup>() {

        public OrcidClientGroup doInTransaction(TransactionStatus status) {
            return orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
        }
    });
    RedirectUris redirectUris = new RedirectUris();
    RedirectUri redirectUri = new RedirectUri("http://uri.com");
    redirectUris.getRedirectUri().add(redirectUri);
    OrcidClient client1 = new OrcidClient();
    client1.setDisplayName("Name");
    client1.setRedirectUris(redirectUris);
    client1.setShortDescription("Description");
    client1.setType(ClientType.UPDATER);
    client1.setWebsite("http://site.com");
    // Add one creator client to a basic group should fail
    try {
        OrcidClient orcidClient = orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
        assertEquals(orcidClient.getType(), ClientType.CREATOR);
    } catch (OrcidClientGroupManagementException e) {
    }
}
Also used : OrcidClientGroup(org.orcid.jaxb.model.clientgroup.OrcidClientGroup) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) TransactionStatus(org.springframework.transaction.TransactionStatus) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with RedirectUris

use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.

the class OrcidClientGroupManagerTest method testAddMoreThanOneClientToBasicGroup.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddMoreThanOneClientToBasicGroup() {
    final OrcidClientGroup group = new OrcidClientGroup();
    group.setGroupName("Elsevier");
    group.setEmail("basic-member@elsevier.com" + System.currentTimeMillis());
    group.setType(MemberType.BASIC);
    OrcidClientGroup createdGroup = transactionTemplate.execute(new TransactionCallback<OrcidClientGroup>() {

        public OrcidClientGroup doInTransaction(TransactionStatus status) {
            return orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
        }
    });
    RedirectUris redirectUris = new RedirectUris();
    RedirectUri redirectUri = new RedirectUri("http://uri.com");
    redirectUris.getRedirectUri().add(redirectUri);
    OrcidClient client1 = new OrcidClient();
    client1.setDisplayName("Name");
    client1.setRedirectUris(redirectUris);
    client1.setShortDescription("Description");
    client1.setType(ClientType.UPDATER);
    client1.setWebsite("http://site.com");
    // Add one client
    try {
        orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
    } catch (OrcidClientGroupManagementException e) {
        fail();
    }
    OrcidClient client2 = new OrcidClient();
    client2.setDisplayName("Name");
    client2.setRedirectUris(redirectUris);
    client2.setShortDescription("Description");
    client2.setType(ClientType.UPDATER);
    client2.setWebsite("http://site.com");
    // Add other client should fail
    try {
        orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client2);
        fail();
    } catch (OrcidClientGroupManagementException e) {
    }
}
Also used : OrcidClientGroup(org.orcid.jaxb.model.clientgroup.OrcidClientGroup) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) TransactionStatus(org.springframework.transaction.TransactionStatus) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with RedirectUris

use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.

the class OrcidClientGroupManagerTest method testAddCreatorToBasicGroup.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddCreatorToBasicGroup() {
    final OrcidClientGroup group = new OrcidClientGroup();
    group.setGroupName("Elsevier");
    group.setEmail("basic-member@elsevier.com" + System.currentTimeMillis());
    group.setType(MemberType.PREMIUM);
    OrcidClientGroup createdGroup = transactionTemplate.execute(new TransactionCallback<OrcidClientGroup>() {

        public OrcidClientGroup doInTransaction(TransactionStatus status) {
            return orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
        }
    });
    RedirectUris redirectUris = new RedirectUris();
    RedirectUri redirectUri = new RedirectUri("http://uri.com");
    redirectUris.getRedirectUri().add(redirectUri);
    OrcidClient client1 = new OrcidClient();
    client1.setDisplayName("Name");
    client1.setRedirectUris(redirectUris);
    client1.setShortDescription("Description");
    client1.setType(ClientType.CREATOR);
    client1.setWebsite("http://site.com");
    // Add one creator client to a basic group should fail
    try {
        OrcidClient orcidClient = orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
        assertEquals(ClientType.UPDATER, orcidClient.getType());
    } catch (OrcidClientGroupManagementException e) {
    }
}
Also used : OrcidClientGroup(org.orcid.jaxb.model.clientgroup.OrcidClientGroup) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) TransactionStatus(org.springframework.transaction.TransactionStatus) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with RedirectUris

use of org.orcid.jaxb.model.clientgroup.RedirectUris in project ORCID-Source by ORCID.

the class OrcidClientGroupManagerTest method testAddUpdaterToPremiumInstitutionGroup.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddUpdaterToPremiumInstitutionGroup() {
    final OrcidClientGroup group = new OrcidClientGroup();
    group.setGroupName("Elsevier");
    group.setEmail("premium-institution-member@elsevier.com" + System.currentTimeMillis());
    group.setType(MemberType.PREMIUM_INSTITUTION);
    OrcidClientGroup createdGroup = transactionTemplate.execute(new TransactionCallback<OrcidClientGroup>() {

        public OrcidClientGroup doInTransaction(TransactionStatus status) {
            return orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
        }
    });
    RedirectUris redirectUris = new RedirectUris();
    RedirectUri redirectUri = new RedirectUri("http://uri.com");
    redirectUris.getRedirectUri().add(redirectUri);
    OrcidClient client1 = new OrcidClient();
    client1.setDisplayName("Name");
    client1.setRedirectUris(redirectUris);
    client1.setShortDescription("Description");
    client1.setType(ClientType.UPDATER);
    client1.setWebsite("http://site.com");
    // Add one creator client to a premium group should fail
    try {
        OrcidClient orcidClient = orcidClientGroupManager.createAndPersistClientProfile(createdGroup.getGroupOrcid(), client1);
        assertEquals(orcidClient.getType(), ClientType.PREMIUM_CREATOR);
    } catch (OrcidClientGroupManagementException e) {
    }
}
Also used : OrcidClientGroup(org.orcid.jaxb.model.clientgroup.OrcidClientGroup) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) TransactionStatus(org.springframework.transaction.TransactionStatus) RedirectUris(org.orcid.jaxb.model.clientgroup.RedirectUris) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)10 RedirectUris (org.orcid.jaxb.model.clientgroup.RedirectUris)10 RedirectUri (org.orcid.jaxb.model.clientgroup.RedirectUri)8 Test (org.junit.Test)6 BaseTest (org.orcid.core.BaseTest)6 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)6 OrcidClientGroup (org.orcid.jaxb.model.clientgroup.OrcidClientGroup)6 TransactionStatus (org.springframework.transaction.TransactionStatus)6 Transactional (org.springframework.transaction.annotation.Transactional)6 ArrayList (java.util.ArrayList)3 ClientRedirectUriEntity (org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1