Search in sources :

Example 46 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.

the class GroupAdministratorController method editClient.

@RequestMapping(value = "/edit-client.json", method = RequestMethod.POST)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public Client editClient(@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 edit client with non group user {}", profile.getOrcidIdentifier().getPath());
            throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
        }
        OrcidClient result = null;
        try {
            result = orcidClientGroupManager.updateClient(groupOrcid, client.toOrcidClient());
            clearCache();
        } catch (OrcidClientGroupManagementException e) {
            LOGGER.error(e.getMessage());
            result = new OrcidClient();
            result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.unable_to_update")));
        }
        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 47 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.

the class ManageConsortiumController method getConsortium.

@RequestMapping(value = "/get-consortium.json", method = RequestMethod.GET)
@ResponseBody
public ConsortiumForm getConsortium() {
    String accountId = salesForceManager.retrieveAccountIdByOrcid(getCurrentUserOrcid());
    MemberDetails memberDetails = salesForceManager.retrieveDetails(accountId);
    ConsortiumForm consortiumForm = ConsortiumForm.fromMemberDetails(memberDetails);
    return consortiumForm;
}
Also used : ConsortiumForm(org.orcid.pojo.ajaxForm.ConsortiumForm) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 48 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.

the class ManageConsortiumController method addContactByEmail.

@RequestMapping(value = "/add-contact-by-email.json")
@ResponseBody
public Contact addContactByEmail(@RequestBody Contact contact) {
    EmailEntity emailEntity = emailManager.findCaseInsensitive(contact.getEmail());
    contact.setOrcid(emailEntity.getProfile().getId());
    RecordNameEntity recordNameEntity = emailEntity.getProfile().getRecordNameEntity();
    if (Visibility.PUBLIC.equals(recordNameEntity.getVisibility())) {
        contact.setFirstName(recordNameEntity.getGivenNames());
        contact.setLastName(recordNameEntity.getFamilyName());
    } else {
        contact.setFirstName(NOT_PUBLIC);
        contact.setLastName(NOT_PUBLIC);
    }
    salesForceManager.createContact(contact);
    return contact;
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 49 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.

the class NotificationController method setPreference.

@RequestMapping(value = "/frequencies/{encryptedEmail}/email-frequencies.json", method = RequestMethod.POST)
@ResponseBody
public Preferences setPreference(HttpServletRequest request, HttpServletResponse response, @RequestBody Preferences preferences, @PathVariable("encryptedEmail") String encryptedEmail) throws UnsupportedEncodingException {
    String decryptedEmail = encryptionManager.decryptForExternalUse(new String(Base64.decodeBase64(encryptedEmail), "UTF-8"));
    OrcidProfile profile = orcidProfileManager.retrieveOrcidProfileByEmail(decryptedEmail);
    orcidProfileManager.updatePreferences(profile.getOrcidIdentifier().getPath(), preferences);
    response.addHeader("X-Robots-Tag", "noindex");
    return preferences;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 50 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.

the class ManageProfileController method addDelegateByEmail.

@RequestMapping(value = "/addDelegateByEmail.json")
@ResponseBody
public ManageDelegate addDelegateByEmail(@RequestBody ManageDelegate addDelegate) {
    EmailEntity emailEntity = emailManager.findCaseInsensitive(addDelegate.getDelegateEmail());
    addDelegate.setDelegateToManage(emailEntity.getProfile().getId());
    return addDelegate(addDelegate);
}
Also used : EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1991 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1700 HashMap (java.util.HashMap)458 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)212 IOException (java.io.IOException)207 JSONObject (com.alibaba.fastjson.JSONObject)200 Map (java.util.Map)172 ApiOperation (io.swagger.annotations.ApiOperation)170 ArrayList (java.util.ArrayList)169 GetMapping (org.springframework.web.bind.annotation.GetMapping)112 ResponseEntity (org.springframework.http.ResponseEntity)102 ApiRest (build.dream.common.api.ApiRest)101 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)101 AuthPassport (com.ngtesting.platform.util.AuthPassport)99 PostMapping (org.springframework.web.bind.annotation.PostMapping)94 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)87 Date (java.util.Date)81 UserVo (com.ngtesting.platform.vo.UserVo)78 LogDetail (com.bc.pmpheep.annotation.LogDetail)71 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)65