@Override public int compareTo(ResearcherUrl o) { if(o == null || o.getUrlName() == null) { return 1; } if(getUrlName() == null) { return -1; } int urlNameComp = this.getUrlName().compareTo(o.getUrlName()); if(urlNameComp == 0) { if(o.getUrl() == null) { return 1; } if(this.getUrl() == null) { return -1; } return this.getUrl().compareTo(o.getUrl()); } return 0; } }
if(PojoUtil.isEmpty(researcherUrl.getUrlName())) { String message = "Url name must not be empty"; LOGGER.error(message); throw new OrcidValidationException(message); } else { if(SiteConstants.URL_MAX_LENGTH < researcherUrl.getUrlName().length()) { String message = "Url name must not be longer than " + SiteConstants.URL_MAX_LENGTH + " characters"; LOGGER.error(message);
Map<String, String> params = new HashMap<String, String>(); params.put("type", "researcher-url"); params.put("value", researcherUrl.getUrlName()); throw new OrcidDuplicatedElementException(params);
@Override public ResearcherUrl createResearcherUrl(String orcid, ResearcherUrl researcherUrl, boolean isApiRequest) { Source activeSource = sourceManager.retrieveActiveSource(); // Validate the researcher url PersonValidator.validateResearcherUrl(researcherUrl, activeSource, true, isApiRequest, null); // Validate it is not duplicated List<ResearcherUrlEntity> existingResearcherUrls = researcherUrlDao.getResearcherUrls(orcid, getLastModified(orcid)); for (ResearcherUrlEntity existing : existingResearcherUrls) { if (isDuplicated(existing, researcherUrl, activeSource)) { Map<String, String> params = new HashMap<String, String>(); params.put("type", "researcher-url"); params.put("value", researcherUrl.getUrlName()); throw new OrcidDuplicatedElementException(params); } } ResearcherUrlEntity newEntity = jpaJaxbResearcherUrlAdapter.toResearcherUrlEntity(researcherUrl); ProfileEntity profile = profileEntityCacheManager.retrieve(orcid); newEntity.setUser(profile); newEntity.setDateCreated(new Date()); SourceEntityUtils.populateSourceAwareEntityFromSource(activeSource, newEntity); setIncomingPrivacy(newEntity, profile); DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(newEntity, isApiRequest); researcherUrlDao.persist(newEntity); return jpaJaxbResearcherUrlAdapter.toResearcherUrl(newEntity); }
if (!PojoUtil.isEmpty(researcherUrl.getUrlName())) { form.setUrlName(researcherUrl.getUrlName());
existingEntity.setVisibility(updatedOrNew.getVisibility().name()); existingEntity.setUrl(updatedOrNew.getUrl().getValue()); existingEntity.setUrlName(updatedOrNew.getUrlName()); existingEntity.setDisplayIndex(updatedOrNew.getDisplayIndex()); researcherUrlDao.merge(existingEntity);