本文整理汇总了Java中org.ligoj.bootstrap.core.validation.ValidationJsonException类的典型用法代码示例。如果您正苦于以下问题:Java ValidationJsonException类的具体用法?Java ValidationJsonException怎么用?Java ValidationJsonException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationJsonException类属于org.ligoj.bootstrap.core.validation包,在下文中一共展示了ValidationJsonException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: removeUserSchema
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Mock a managed LDAP schema violation
*/
@Test
public void removeUserSchema() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("groups", "last-member-of-group"));
final GroupLdapRepository groupRepository = new GroupLdapRepository() {
@Override
public GroupOrg findById(final String name) {
// The group has only the user user we want to remove
return new GroupOrg("dc=" + name, name, Collections.singleton("flast1"));
}
};
groupRepository.setLdapCacheRepository(Mockito.mock(LdapCacheRepository.class));
final LdapTemplate ldapTemplate = Mockito.mock(LdapTemplate.class);
groupRepository.setTemplate(ldapTemplate);
Mockito.doThrow(new org.springframework.ldap.SchemaViolationException(new SchemaViolationException("any"))).when(ldapTemplate)
.modifyAttributes(ArgumentMatchers.any(LdapName.class), ArgumentMatchers.any());
removeUser(groupRepository);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:24,代码来源:GroupLdapRepositoryTest.java
示例2: validateGroup
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Validate the group settings.
*
* @param parameters
* the administration parameters.
* @return real group name.
*/
protected INamableBean<String> validateGroup(final Map<String, String> parameters) {
// Get group configuration
final String group = parameters.get(IdentityResource.PARAMETER_GROUP);
final ContainerWithScopeVo groupLdap = groupLdapResource.findByName(group);
// Check the group exists
if (groupLdap == null) {
throw new ValidationJsonException(IdentityResource.PARAMETER_GROUP, BusinessException.KEY_UNKNOW_ID, group);
}
// Check the group has type TYPE_PROJECT
if (!ContainerScope.TYPE_PROJECT.equals(groupLdap.getScope())) {
// Invalid type
throw new ValidationJsonException(IdentityResource.PARAMETER_GROUP, "group-type", group);
}
// Return the nice name
final INamableBean<String> result = new NamedBean<>();
result.setName(groupLdap.getName());
result.setId(group);
return result;
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:30,代码来源:LdapPluginResource.java
示例3: removeMember
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Remove an "uniqueMember" from given group. Cache is not updated there.
*
* @param uniqueMember
* DN of the member to remove.
* @param group
* CN of the group to update. Must be normalized.
* @return the {@link GroupOrg} where the member has just been removed from.
*/
private GroupOrg removeMember(final ResourceOrg uniqueMember, final String group) {
final GroupOrg groupLdap = findById(group);
if (groupLdap.getMembers().contains(uniqueMember.getId()) || groupLdap.getSubGroups().contains(uniqueMember.getId())) {
// Not useless LDAP operation, avoid LDAP duplicate deletion
final ModificationItem[] mods = new ModificationItem[1];
mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute(UNIQUE_MEMBER, uniqueMember.getDn()));
try {
template.modifyAttributes(org.springframework.ldap.support.LdapUtils.newLdapName(groupLdap.getDn()), mods);
} catch (final org.springframework.ldap.AttributeInUseException aiue) {
// Even if the membership update failed, the user does not exist anymore. A broken reference can remains
// in LDAP, but this case is well managed.
log.info("Unable to remove user {} from the group {} : {}", uniqueMember.getDn(), group, aiue);
} catch (final org.springframework.ldap.SchemaViolationException sve) { // NOSONAR - Exception is logged
// Occurs when there is a LDAP schema violation such as as last member removed
log.warn("Unable to remove user {} from the group {}", uniqueMember.getDn(), group, sve);
throw new ValidationJsonException("groups", "last-member-of-group", "user", uniqueMember.getId(), "group", group);
}
}
return groupLdap;
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:30,代码来源:GroupLdapRepository.java
示例4: addUserToGroupNotWritableGroup
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Add a user to a group the principal does not manage.
*/
@Test
public void addUserToGroupNotWritableGroup() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("group", "read-only"));
initSpringSecurityContext("mlavoine");
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("user1"));
final GroupOrg groupOrg2 = new GroupOrg("cn=DIG RHA,cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("user1"));
final UserOrg user = new UserOrg();
user.setCompany("gfi");
user.setGroups(Collections.singleton("dig rha"));
final CompanyOrg company = new CompanyOrg("ou=gfi,ou=france,ou=people,dc=sample,dc=com", "gfi");
Mockito.when(companyRepository.findById("gfi")).thenReturn(company);
Mockito.when(userRepository.findByIdExpected("wuser")).thenReturn(user);
Mockito.when(userRepository.findById("wuser")).thenReturn(user);
groupFindById("mlavoine", "dig", groupOrg1);
groupFindById("mlavoine", "dig rha", groupOrg2);
resource.addUserToGroup("wuser", "dig");
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:22,代码来源:UserOrgResourceTest.java
示例5: zcreateUserNoDelegateGroup
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void zcreateUserNoDelegateGroup() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("group", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flastg");
user.setFirstName("FirstG");
user.setLastName("LastG");
user.setCompany("ing");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
groups.add("dig sud ouest");
user.setGroups(groups);
initSpringSecurityContext("someone");
resource.create(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例6: checkResolutionDate
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Check the resolution/resolution date
*/
private void checkResolutionDate(final ImportEntry rawEntry) {
if (rawEntry.getResolutionDate() == null) {
if (rawEntry.getResolution() != null) {
rawEntry.setResolutionDateValid(rawEntry.getDateValid());
}
} else {
if (rawEntry.getResolution() == null) {
rawEntry.setResolution("Fixed");
}
rawEntry.setResolutionDateValid(DateEditor.toDate(rawEntry.getResolutionDate()));
if (rawEntry.getResolutionDateValid().getTime() < rawEntry.getDateValid().getTime()) {
throw new ValidationJsonException("resolutionDate",
"Resolution date must be greater or equals to the change date for issue " + toLog(rawEntry));
}
}
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:20,代码来源:JiraImportPluginResource.java
示例7: updateUserChangeDepartmentNotVisible
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test(expected = ValidationJsonException.class)
public void updateUserChangeDepartmentNotVisible() {
initSpringSecurityContext("assist");
Assert.assertEquals("uid=flast0,ou=socygan,ou=external,ou=people,dc=sample,dc=com", getContext("flast0").getDn().toString());
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flast0");
user.setFirstName("First0"); // Unchanged
user.setLastName("Last0"); // Unchanged
user.setCompany("socygan"); // Unchanged
user.setDepartment("456987"); // Previous is null -> "DIG AS" (not visible)
user.setMail("[email protected]"); // Unchanged
final List<String> groups = new ArrayList<>();
user.setGroups(groups);
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例8: validateSpaceInternal
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Validate the space configuration and return the corresponding details.
*/
protected CurlRequest[] validateSpaceInternal(final Map<String, String> parameters, final String... partialRequests) {
final String url = StringUtils.removeEnd(parameters.get(PARAMETER_URL), "/");
final String space = ObjectUtils.defaultIfNull(parameters.get(PARAMETER_SPACE), "0");
final CurlRequest[] result = new CurlRequest[partialRequests.length];
for (int i = 0; i < partialRequests.length; i++) {
result[i] = new CurlRequest(HttpMethod.GET, url + partialRequests[i] + space, null);
result[i].setSaveResponse(true);
}
// Prepare the sequence of HTTP requests to Confluence
final ConfluenceCurlProcessor processor = new ConfluenceCurlProcessor();
authenticate(parameters, processor);
// Execute the requests
processor.process(result);
// Get the space if it exists
if (result[0].getResponse() == null) {
// Invalid couple PKEY and id
throw new ValidationJsonException(PARAMETER_SPACE, "confluence-space", parameters.get(PARAMETER_SPACE));
}
return result;
}
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:27,代码来源:ConfluencePluginResource.java
示例9: updateNotVisibleTargetCompany
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void updateNotVisibleTargetCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flast0");
user.setFirstName("First0");
user.setLastName("Last0");
user.setCompany("socygan");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
groups.add("Biz Agency");
user.setGroups(groups);
initSpringSecurityContext("mlavoine");
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例10: updateUserNoDelegateCompany
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void updateUserNoDelegateCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flast0");
user.setFirstName("FirstA");
user.setLastName("LastA");
user.setCompany("socygan");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
user.setGroups(groups);
initSpringSecurityContext("any");
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例11: updateUserNoDelegateGroupForTarget
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void updateUserNoDelegateGroupForTarget() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("group", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flast1");
user.setFirstName("FirstA");
user.setLastName("LastA");
user.setCompany("ing");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
groups.add("dig sud ouest"); // no right on this group
user.setGroups(groups);
initSpringSecurityContext("fdaugan");
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例12: deleteLastMember
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void deleteLastMember() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("id", "last-member-of-group"));
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
final UserOrg user = new UserOrg();
user.setCompany("ing");
user.setGroups(Collections.singleton("dig"));
Mockito.when(userRepository.findByIdExpected(DEFAULT_USER, "wuser")).thenReturn(user);
Mockito.when(groupRepository.findAll()).thenReturn(groupsMap);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findById("ing")).thenReturn(company);
resource.delete("wuser");
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:17,代码来源:UserOrgResourceTest.java
示例13: createNotCompliantGroupForProject
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Create a group for an existing project, but without reusing the pkey of this project.
*/
@Test
public void createNotCompliantGroupForProject() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "pattern"));
// Preconditions
Assert.assertNotNull(getGroup().findById("sea-octopus"));
Assert.assertNull(getGroup().findById("sea-octopusZZ"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-octopus"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-octopusZZ");
setOu(subscription2, "sea");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:LdapPluginResourceTest.java
示例14: createNotCompliantGroupForProject2
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Create a group for an existing project, reusing the pkey of this project and without suffix.
*/
@Test
public void createNotCompliantGroupForProject2() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "pattern"));
// Preconditions
Assert.assertNotNull(getGroup().findById("sea-octopus"));
Assert.assertNull(getGroup().findById("sea-octopus-"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-octopus"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-octopus-");
setOu(subscription2, "sea");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:LdapPluginResourceTest.java
示例15: resetPasswordUserNoWriteCompany
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void resetPasswordUserNoWriteCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("id", BusinessException.KEY_UNKNOW_ID));
initSpringSecurityContext("mtuyer");
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG",
new HashSet<>(Arrays.asList("wuser", "user1")));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
final UserOrg user = new UserOrg();
user.setCompany("ing");
user.setGroups(Collections.singleton("dig"));
Mockito.when(userRepository.findByIdExpected("mtuyer", "wuser")).thenReturn(user);
Mockito.when(companyRepository.findById("ing")).thenReturn(company);
Mockito.when(groupRepository.findAll()).thenReturn(groupsMap);
resource.resetPassword("wuser");
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:19,代码来源:UserOrgResourceTest.java
示例16: checkOverlaps
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
/**
* Check business hours overlaps.
*/
private void checkOverlaps(final BusinessHours newBusinessHours) {
// Order business hours. BusinessHours is comparable
final Set<BusinessHours> businessHours = new TreeSet<>(newBusinessHours.getConfiguration().getBusinessHours());
businessHours.add(newBusinessHours);
// Check the start<=end
if (newBusinessHours.getEnd() <= newBusinessHours.getStart()) {
throw ValidationJsonException.newValidationJsonException("Overlap", "stop");
}
// Check the overlaps
BusinessHours previous = null;
for (final BusinessHours step : businessHours) {
if (previous != null && step.getStart() < previous.getEnd()) {
throw ValidationJsonException.newValidationJsonException("Overlap", "start");
}
previous = step;
}
}
开发者ID:ligoj,项目名称:plugin-bt,代码行数:23,代码来源:BugTrackerResource.java
示例17: linkInvalidProject
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void linkInvalidProject() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(JiraBaseResource.PARAMETER_PKEY, "jira-project"));
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
project.setTeamLeader(getAuthenticationName());
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:bt:jira:6"));
em.persist(subscription);
addProjectParameters(subscription, 11111);
em.flush();
em.clear();
resource.link(subscription.getId());
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:20,代码来源:JiraPluginResourceTest.java
示例18: checkAndSaveSchedule
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
private VmSchedule checkAndSaveSchedule(final VmScheduleVo schedule, final VmSchedule entity) {
// Check the subscription is visible
final Subscription subscription = subscriptionResource.checkVisibleSubscription(schedule.getSubscription());
if (schedule.getCron().split(" ").length == 6) {
// Add the missing "seconds" part
schedule.setCron(schedule.getCron() + " *");
}
// Check expressions first
if (!CronExpression.isValidExpression(schedule.getCron())) {
throw new ValidationJsonException("cron", "vm-cron");
}
// Every second is not accepted
if (schedule.getCron().startsWith("* ")) {
throw new ValidationJsonException("cron", "vm-cron-second");
}
entity.setSubscription(subscription);
entity.setOperation(schedule.getOperation());
entity.setCron(schedule.getCron());
// Persist the new schedules for each provided CRON
vmScheduleRepository.saveAndFlush(entity);
return entity;
}
开发者ID:ligoj,项目名称:plugin-vm,代码行数:27,代码来源:VmResource.java
示例19: addSlaBoundStart
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void addSlaBoundStart() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("start", "SlaBound"));
final SlaEditionVo vo = new SlaEditionVo();
vo.setName("AA");
vo.setStart(identifierHelper.asList("Open"));
vo.setStop(identifierHelper.asList("Resolved"));
vo.setPause(new ArrayList<>());
vo.getPause().add("Open");
vo.setSubscription(subscription);
em.flush();
em.clear();
resource.addSla(vo);
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:17,代码来源:BugTrackerResourceTest.java
示例20: testUploadInvalidWorkflowType
import org.ligoj.bootstrap.core.validation.ValidationJsonException; //导入依赖的package包/类
@Test
public void testUploadInvalidWorkflowType() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("type",
"Specified type 'Bug' exists but is not mapped to a workflow and there is no default association"));
final JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
try {
// Delete the default workflow mapping, where type = '0'
jdbcTemplate.update("update workflowschemeentity SET SCHEME=? WHERE ID = ?", 1, 10272);
resource.upload(new ClassPathResource("csv/upload/nominal-simple.csv").getInputStream(), ENCODING, subscription,
UploadMode.PREVIEW);
} finally {
jdbcTemplate.update("update workflowschemeentity SET SCHEME=? WHERE ID = ?", 10025, 10272);
}
}
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:17,代码来源:JiraImportPluginResourceTest.java
注:本文中的org.ligoj.bootstrap.core.validation.ValidationJsonException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论