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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations