Search in sources :

Example 1 with OtherNameForm

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

the class WorkspaceController method setOtherNamesFormJson.

@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.POST)
@ResponseBody
public OtherNamesForm setOtherNamesFormJson(@RequestBody OtherNamesForm onf) throws NoSuchRequestHandlingMethodException {
    onf.setErrors(new ArrayList<String>());
    if (onf != null) {
        Iterator<OtherNameForm> it = onf.getOtherNames().iterator();
        while (it.hasNext()) {
            OtherNameForm form = it.next();
            if (PojoUtil.isEmpty(form.getContent())) {
                it.remove();
                continue;
            }
            if (form.getContent().length() > SiteConstants.MAX_LENGTH_255) {
                form.setContent(form.getContent().substring(0, SiteConstants.MAX_LENGTH_255));
            }
            // Validate visibility is not null
            validateVisibility(form);
            copyErrors(form, onf);
            copyErrors(form.getVisibility(), onf);
        }
        if (onf.getErrors().size() > 0) {
            return onf;
        }
        OtherNames otherNames = onf.toOtherNames();
        otherNameManager.updateOtherNames(getEffectiveUserOrcid(), otherNames);
    }
    return onf;
}
Also used : OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherNameForm(org.orcid.pojo.ajaxForm.OtherNameForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)1 OtherNameForm (org.orcid.pojo.ajaxForm.OtherNameForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1