use of org.orcid.pojo.ajaxForm.WebsiteForm in project ORCID-Source by ORCID.
the class WorkspaceController method setWebsitesFormJson.
/**
* Retrieve all external identifiers as a json string
* */
@RequestMapping(value = "/my-orcid/websitesForms.json", method = RequestMethod.POST)
@ResponseBody
public WebsitesForm setWebsitesFormJson(HttpServletRequest request, @RequestBody WebsitesForm ws) throws NoSuchRequestHandlingMethodException {
ws.setErrors(new ArrayList<String>());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
if (ws != null) {
Set<String> existingUrls = new HashSet<String>();
for (WebsiteForm w : ws.getWebsites()) {
//Clean old errors
w.setErrors(new ArrayList<String>());
//Validate
if (!validateUrl(w.getUrl())) {
w.getErrors().add(getMessage("common.invalid_url"));
}
if (isLongerThan(w.getUrlName(), SiteConstants.URL_MAX_LENGTH)) {
w.getErrors().add(getMessage("manualWork.length_less_X"));
}
//Check there are no duplicates
if (existingUrls.contains(w.getUrl())) {
w.getErrors().add(getMessage("researcher_url.error.duplicated", w.getUrl()));
} else {
existingUrls.add(w.getUrl());
}
//Set default visibility in case it is null
if (w.getVisibility() == null || w.getVisibility().getVisibility() == null) {
w.setVisibility(defaultVisibility);
}
copyErrors(w, ws);
}
if (ws.getErrors().size() > 0) {
return ws;
}
ResearcherUrls rUrls = ws.toResearcherUrls();
researcherUrlManager.updateResearcherUrls(getCurrentUserOrcid(), rUrls);
}
return ws;
}
Aggregations