use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class GroupAdministratorController method getClient.
@RequestMapping(value = "/client.json", method = RequestMethod.GET)
@ResponseBody
public Client getClient() {
Client emptyClient = new Client();
emptyClient.setDisplayName(new Text());
emptyClient.setWebsite(new Text());
emptyClient.setShortDescription(new Text());
emptyClient.setClientId(new Text());
emptyClient.setClientSecret(new Text());
emptyClient.setType(new Text());
emptyClient.setAllowAutoDeprecate(Checkbox.valueOf(false));
ArrayList<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri emptyRedirectUri = new RedirectUri();
emptyRedirectUri.setValue(new Text());
emptyRedirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
emptyRedirectUri.setActType(Text.valueOf(""));
emptyRedirectUri.setGeoArea(Text.valueOf(""));
redirectUris.add(emptyRedirectUri);
emptyClient.setRedirectUris(redirectUris);
return emptyClient;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class ResultContainer method getEmptyGroup.
/**
* Get an empty group
*
* @return an empty group
* */
@RequestMapping(value = "/member.json", method = RequestMethod.GET)
@ResponseBody
public Member getEmptyGroup() {
Text empty = Text.valueOf("");
Member group = new Member();
group.setEmail(empty);
group.setGroupName(empty);
group.setGroupOrcid(empty);
group.setSalesforceId(empty);
// Set the default type as basic
group.setType(Text.valueOf(MemberType.BASIC.value()));
return group;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class WorkspaceControllerTest method validateSmallerThanTest.
@Test
public void validateSmallerThanTest() {
Text text = new Text();
workspaceController.validateNoLongerThan(10, text);
assertTrue(text.getErrors().isEmpty());
text.setValue(tenCharsStr);
workspaceController.validateNoLongerThan(10, text);
assertTrue(text.getErrors().isEmpty());
text.setValue(tenCharsStr + '!');
workspaceController.validateNoLongerThan(10, text);
assertEquals(workspaceController.getMessage("manualWork.length_less_X", 10), text.getErrors().get(0));
text.setValue(tenCharsStr);
text.setErrors(new ArrayList<String>());
workspaceController.validateNoLongerThan(10, text);
assertTrue(text.getErrors().isEmpty());
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class FundingsController method getFunding.
/**
* Returns a blank funding form
* */
@RequestMapping(value = "/funding.json", method = RequestMethod.GET)
@ResponseBody
public FundingForm getFunding() {
FundingForm result = new FundingForm();
result.setAmount(new Text());
result.setCurrencyCode(Text.valueOf(""));
result.setDescription(new Text());
result.setFundingName(new Text());
result.setFundingType(Text.valueOf(""));
result.setSourceName(new String());
OrgDefinedFundingSubType subtype = new OrgDefinedFundingSubType();
subtype.setAlreadyIndexed(false);
subtype.setSubtype(Text.valueOf(""));
result.setOrganizationDefinedFundingSubType(subtype);
FundingTitleForm title = new FundingTitleForm();
title.setTitle(new Text());
TranslatedTitleForm tt = new TranslatedTitleForm();
tt.setContent(new String());
tt.setLanguageCode(new String());
tt.setLanguageName(new String());
title.setTranslatedTitle(tt);
result.setFundingTitle(title);
result.setUrl(new Text());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility v = Visibility.valueOf(profile.getActivitiesVisibilityDefault() == null ? org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.FUNDING_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault());
result.setVisibility(v);
Date startDate = new Date();
result.setStartDate(startDate);
startDate.setDay("");
startDate.setMonth("");
startDate.setYear("");
Date endDate = new Date();
result.setEndDate(endDate);
endDate.setDay("");
endDate.setMonth("");
endDate.setYear("");
// Set empty contributor
Contributor contr = new Contributor();
List<Contributor> contrList = new ArrayList<Contributor>();
Text rText = new Text();
rText.setValue("");
contr.setContributorRole(rText);
Text sText = new Text();
sText.setValue("");
contr.setContributorSequence(sText);
contrList.add(contr);
result.setContributors(contrList);
// Set empty external identifier
List<FundingExternalIdentifierForm> emptyExternalIdentifiers = new ArrayList<FundingExternalIdentifierForm>();
FundingExternalIdentifierForm f = new FundingExternalIdentifierForm();
f.setType(Text.valueOf(DEFAULT_FUNDING_EXTERNAL_IDENTIFIER_TYPE));
f.setUrl(new Text());
f.setValue(new Text());
f.setRelationship(Text.valueOf(Relationship.SELF.value()));
emptyExternalIdentifiers.add(f);
result.setExternalIdentifiers(emptyExternalIdentifiers);
result.setCity(new Text());
result.setCountry(Text.valueOf(""));
result.setRegion(new Text());
return result;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class DeveloperToolsController method validateSSOCredentials.
/**
* Validates the ssoCredentials object
*
* @param ssoCredentials
* @return true if any error is found in the ssoCredentials object
* */
private boolean validateSSOCredentials(SSOCredentials ssoCredentials) {
boolean hasErrors = false;
Set<RedirectUri> redirectUris = ssoCredentials.getRedirectUris();
if (PojoUtil.isEmpty(ssoCredentials.getClientName())) {
if (ssoCredentials.getClientName() == null) {
ssoCredentials.setClientName(new Text());
}
ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name_not_empty")));
hasErrors = true;
} else if (ssoCredentials.getClientName().getValue().length() > CLIENT_NAME_LENGTH) {
ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name_too_long")));
hasErrors = true;
} else if (OrcidStringUtils.hasHtml(ssoCredentials.getClientName().getValue())) {
ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name.html")));
hasErrors = true;
} else {
ssoCredentials.getClientName().setErrors(new ArrayList<String>());
}
if (PojoUtil.isEmpty(ssoCredentials.getClientDescription())) {
if (ssoCredentials.getClientDescription() == null) {
ssoCredentials.setClientDescription(new Text());
}
ssoCredentials.getClientDescription().setErrors(Arrays.asList(getMessage("manage.developer_tools.description_not_empty")));
hasErrors = true;
} else if (OrcidStringUtils.hasHtml(ssoCredentials.getClientDescription().getValue())) {
ssoCredentials.getClientDescription().setErrors(Arrays.asList(getMessage("manage.developer_tools.description.html")));
hasErrors = true;
} else {
ssoCredentials.getClientDescription().setErrors(new ArrayList<String>());
}
if (PojoUtil.isEmpty(ssoCredentials.getClientWebsite())) {
if (ssoCredentials.getClientWebsite() == null) {
ssoCredentials.setClientWebsite(new Text());
}
ssoCredentials.getClientWebsite().setErrors(Arrays.asList(getMessage("manage.developer_tools.website_not_empty")));
hasErrors = true;
} else {
List<String> errors = new ArrayList<String>();
String[] schemes = { "http", "https", "ftp" };
UrlValidator urlValidator = new UrlValidator(schemes);
String websiteString = ssoCredentials.getClientWebsite().getValue();
if (!urlValidator.isValid(websiteString))
websiteString = "http://" + websiteString;
// test validity again
if (!urlValidator.isValid(websiteString)) {
errors.add(getMessage("manage.developer_tools.invalid_website"));
}
ssoCredentials.getClientWebsite().setErrors(errors);
}
if (redirectUris == null || redirectUris.isEmpty()) {
List<String> errors = new ArrayList<String>();
errors.add(getMessage("manage.developer_tools.at_least_one"));
ssoCredentials.setErrors(errors);
hasErrors = true;
} else {
for (RedirectUri redirectUri : redirectUris) {
List<String> errors = validateRedirectUri(redirectUri);
if (errors != null) {
redirectUri.setErrors(errors);
hasErrors = true;
}
}
}
return hasErrors;
}
Aggregations