Search in sources :

Example 1 with KeywordForm

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

the class WorkspaceController method setKeywordsFormJson.

@RequestMapping(value = "/my-orcid/keywordsForms.json", method = RequestMethod.POST)
@ResponseBody
public KeywordsForm setKeywordsFormJson(HttpServletRequest request, @RequestBody KeywordsForm kf) throws NoSuchRequestHandlingMethodException {
    kf.setErrors(new ArrayList<String>());
    if (kf != null) {
        Iterator<KeywordForm> it = kf.getKeywords().iterator();
        while (it.hasNext()) {
            KeywordForm k = it.next();
            if (!PojoUtil.isEmpty(k.getContent())) {
                if (k.getContent().length() > SiteConstants.KEYWORD_MAX_LENGTH) {
                    k.setContent(k.getContent().substring(0, SiteConstants.KEYWORD_MAX_LENGTH));
                }
            } else {
                it.remove();
            }
            // Validate visibility is not null
            validateVisibility(k);
            copyErrors(k, kf);
            copyErrors(k.getVisibility(), kf);
        }
        if (kf.getErrors().size() > 0) {
            return kf;
        }
        Keywords updatedKeywords = kf.toKeywords();
        profileKeywordManager.updateKeywords(getCurrentUserOrcid(), updatedKeywords);
    }
    return kf;
}
Also used : KeywordForm(org.orcid.pojo.ajaxForm.KeywordForm) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

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