Search in sources :

Example 6 with RedirectUri

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

the class GroupAdministratorController method getEmptyRedirectUri.

@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
    RedirectUri result = new RedirectUri();
    result.setValue(new Text());
    result.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
    result.setActType(Text.valueOf(""));
    result.setGeoArea(Text.valueOf(""));
    return result;
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with RedirectUri

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

the class DeveloperToolsController method getEmptyRedirectUri.

@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
    RedirectUri result = new RedirectUri();
    result.setValue(new Text());
    result.setActType(Text.valueOf(""));
    result.setGeoArea(Text.valueOf(""));
    result.setType(Text.valueOf(RedirectUriType.DEFAULT.name()));
    return result;
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with RedirectUri

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

the class GroupAdministratorController method getClient.

@RequestMapping(value = "/client.json", method = RequestMethod.GET)
@ResponseBody
public Client getClient() {
    Client emptyClient = new Client();
    emptyClient.setDisplayName(new Text());
    emptyClient.setWebsite(new Text());
    emptyClient.setShortDescription(new Text());
    emptyClient.setClientId(new Text());
    emptyClient.setClientSecret(new Text());
    emptyClient.setType(new Text());
    emptyClient.setAllowAutoDeprecate(Checkbox.valueOf(false));
    ArrayList<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
    RedirectUri emptyRedirectUri = new RedirectUri();
    emptyRedirectUri.setValue(new Text());
    emptyRedirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
    emptyRedirectUri.setActType(Text.valueOf(""));
    emptyRedirectUri.setGeoArea(Text.valueOf(""));
    redirectUris.add(emptyRedirectUri);
    emptyClient.setRedirectUris(redirectUris);
    return emptyClient;
}
Also used : ArrayList(java.util.ArrayList) Text(org.orcid.pojo.ajaxForm.Text) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) Client(org.orcid.pojo.ajaxForm.Client) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with RedirectUri

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

the class GroupAdministratorController method createClient.

@RequestMapping(value = "/add-client.json", method = RequestMethod.POST)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public Client createClient(@RequestBody Client client) {
    // Clean the error list
    client.setErrors(new ArrayList<String>());
    // Validate fields
    validateDisplayName(client);
    validateWebsite(client);
    validateShortDescription(client);
    validateRedirectUris(client);
    copyErrors(client.getDisplayName(), client);
    copyErrors(client.getWebsite(), client);
    copyErrors(client.getShortDescription(), client);
    for (RedirectUri redirectUri : client.getRedirectUris()) {
        copyErrors(redirectUri, client);
    }
    if (client.getErrors().size() == 0) {
        OrcidProfile profile = getEffectiveProfile();
        String groupOrcid = profile.getOrcidIdentifier().getPath();
        if (profile.getType() == null || !profile.getType().equals(OrcidType.GROUP)) {
            LOGGER.warn("Trying to create client with non group user {}", profile.getOrcidIdentifier().getPath());
            throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
        }
        OrcidClient result = null;
        try {
            result = orcidClientGroupManager.createAndPersistClientProfile(groupOrcid, client.toOrcidClient());
        } catch (OrcidClientGroupManagementException e) {
            LOGGER.error(e.getMessage());
            result = new OrcidClient();
            result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.cannot_create_client")));
        }
        client = Client.valueOf(result);
    }
    return client;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Produces(javax.ws.rs.Produces) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with RedirectUri

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

the class ResultContainer method getEmptyRedirectUri.

@RequestMapping(value = "/empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri() {
    RedirectUri rUri = new RedirectUri();
    rUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
    rUri.setValue(Text.valueOf(""));
    rUri.setActType(Text.valueOf(""));
    rUri.setGeoArea(Text.valueOf(""));
    return rUri;
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RedirectUri (org.orcid.pojo.ajaxForm.RedirectUri)24 Test (org.junit.Test)12 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)10 HashSet (java.util.HashSet)9 Text (org.orcid.pojo.ajaxForm.Text)8 Client (org.orcid.pojo.ajaxForm.Client)7 SSOCredentials (org.orcid.pojo.ajaxForm.SSOCredentials)7 Transactional (org.springframework.transaction.annotation.Transactional)6 ArrayList (java.util.ArrayList)5 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)4 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 Produces (javax.ws.rs.Produces)2 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)2 ErrorDesc (org.orcid.jaxb.model.message.ErrorDesc)2 DBUnitTest (org.orcid.test.DBUnitTest)2 UrlValidator (org.apache.commons.validator.routines.UrlValidator)1 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)1