本文整理汇总了Java中org.ligoj.bootstrap.core.resource.BusinessException类的典型用法代码示例。如果您正苦于以下问题:Java BusinessException类的具体用法?Java BusinessException怎么用?Java BusinessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BusinessException类属于org.ligoj.bootstrap.core.resource包,在下文中一共展示了BusinessException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateParentGroup
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
/**
* Validate the group against its parent and return the corresponding DN.
*/
private String validateParentGroup(final String group, final String parentGroup) {
final GroupOrg parentGroupLdap = groupLdapResource.findById(parentGroup);
if (parentGroupLdap == null) {
// The parent group does not exists
throw new ValidationJsonException(IdentityResource.PARAMETER_PARENT_GROUP, BusinessException.KEY_UNKNOW_ID,
parentGroup);
}
// Compare the group and its parent
if (!group.startsWith(parentGroup + "-")) {
// This sub-group has not a correct form
throw new ValidationJsonException(IdentityResource.PARAMETER_GROUP, PATTERN_PROPERTY, parentGroup + "-.*");
}
// Parent will be another group, return its DN
return parentGroupLdap.getDn();
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:21,代码来源:LdapPluginResource.java
示例2: validateGroup
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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: zcreateUserNoDelegateGroup
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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
示例4: updateUserGroupNotExists
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void updateUserGroupNotExists() {
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("any");
user.setGroups(groups);
initSpringSecurityContext("fdaugan");
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:17,代码来源:UserLdapResourceTest.java
示例5: updateUserNoDelegate
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void updateUserNoDelegate() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flast1");
user.setFirstName("FirstW");
user.setLastName("LastW");
user.setCompany("ing");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
groups.add("dig rha");
user.setGroups(groups);
initSpringSecurityContext("any");
resource.update(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:18,代码来源:UserLdapResourceTest.java
示例6: updateNotVisibleTargetCompany
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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
示例7: updateUserNoDelegateCompany
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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
示例8: updateUserNoDelegateGroupForTarget
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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
示例9: deleteLastBusinessHours
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test(expected = BusinessException.class)
public void deleteLastBusinessHours() {
Assert.assertEquals(2, repository.findBySubscription(subscription).getBusinessHours().size());
int id = repository.findBySubscription(subscription).getBusinessHours().iterator().next().getId();
em.flush();
em.clear();
resource.deleteBusinessHours(id);
em.flush();
em.clear();
Assert.assertEquals(1, repository.findBySubscription(subscription).getBusinessHours().size());
em.flush();
em.clear();
// Try to delete the last one
id = repository.findBySubscription(subscription).getBusinessHours().iterator().next().getId();
resource.deleteBusinessHours(id);
}
开发者ID:ligoj,项目名称:plugin-bt,代码行数:18,代码来源:BugTrackerResourceTest.java
示例10: reset
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
/**
* Reset password from a mail challenge :token + mail + user name.
*
* @param request
* the user request.
* @param uid
* the user UID.
*/
@POST
@Path("reset/{uid}")
@Consumes(MediaType.APPLICATION_JSON)
public void reset(final ResetPasswordByMailChallenge request, @PathParam("uid") final String uid) {
// check token in database : Invalid token, or out-dated, or invalid
// user ?
final PasswordReset passwordReset = repository.findByLoginAndTokenAndDateAfter(uid, request.getToken(),
DateTime.now().minusHours(NumberUtils.INTEGER_ONE).toDate());
if (passwordReset == null) {
throw new BusinessException(BusinessException.KEY_UNKNOW_ID);
}
// Check the user and update his/her password
create(uid, request.getPassword(), false);
// Remove password reset request since this token is no more valid
repository.delete(passwordReset);
}
开发者ID:ligoj,项目名称:plugin-password,代码行数:27,代码来源:PasswordResource.java
示例11: sendMailPasswordWithException
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void sendMailPasswordWithException() throws MessagingException {
final PasswordResource resource = newResource();
Mockito.when(resource.configurationResource.get("password.mail.url")).thenReturn("host");
final MailServicePlugin mailServicePlugin = resource.servicePluginLocator.getResource("service:mail:smtp:local",
MailServicePlugin.class);
Mockito.when(mailServicePlugin.send(ArgumentMatchers.eq("service:mail:smtp:local"),
ArgumentMatchers.any(MimeMessagePreparator.class))).thenAnswer(
i -> {
throw new BusinessException(null, MimeMessagePreparator.class);
});
final UserOrg user = new UserOrg();
user.setFirstName("John");
user.setLastName("Doe");
user.setId("fdauganB");
user.setMails(Collections.singletonList("[email protected]"));
resource.sendMailPassword(user, "passwd");
}
开发者ID:ligoj,项目名称:plugin-password,代码行数:19,代码来源:PasswordResourceTest.java
示例12: confirmRecoveryOldToken
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void confirmRecoveryOldToken() {
thrown.expect(BusinessException.class);
thrown.expectMessage("unknown-id");
// create dataset
final PasswordReset pwdReset = createRequest();
repository.save(pwdReset);
em.flush();
// call business
final ResetPasswordByMailChallenge userResetPassword = new ResetPasswordByMailChallenge();
userResetPassword.setToken("t-t-t-t");
userResetPassword.setPassword("Strong3r");
resource.reset(userResetPassword, "mdupont");
Assert.assertEquals(1, repository.count());
final PasswordReset passwordReset = repository.findAll().get(0);
Assert.assertEquals("mdupont", passwordReset.getLogin());
}
开发者ID:ligoj,项目名称:plugin-password,代码行数:20,代码来源:PasswordResourceTest.java
示例13: create
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Override
public void create(final int subscription) throws Exception {
// Add an empty quote
final ProvQuote quote = new ProvQuote();
quote.setSubscription(subscriptionRepository.findOne(subscription));
// Associate a default name and description
quote.setName(quote.getSubscription().getProject().getName());
final Node provider = quote.getSubscription().getNode().getRefined();
final List<ProvLocation> locations = locationRepository.findAllBy("node.id", provider.getId());
if (locations.isEmpty()) {
// No available location, need a catalog to continue
throw new BusinessException(SERVICE_KEY + "-no-catalog", provider.getId(), provider.getName());
}
quote.setLocation(locations.get(0));
quote.setDescription(quote.getSubscription().getProject().getPkey() + "-> " + provider.getName());
repository.saveAndFlush(quote);
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:19,代码来源:ProvResource.java
示例14: createNoCatalog
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test(expected = BusinessException.class)
public void createNoCatalog() throws Exception {
final Subscription subscription = new Subscription();
subscription.setNode(em.find(Subscription.class, this.subscription).getNode());
subscription.setProject(em.find(Subscription.class, this.subscription).getProject());
em.persist(subscription);
qsRepository.deleteAll();
qiRepository.deleteAll();
ipRepository.deleteAll();
iptRepository.deleteAll();
itRepository.deleteAll();
spRepository.deleteAll();
stRepository.deleteAll();
icsRepository.deleteAll();
repository.deleteAll();
locationRepository.deleteAll();
em.flush();
em.clear();
resource.create(subscription.getId());
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:21,代码来源:ProvResourceTest.java
示例15: deleteUserNoWriteCompany
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void deleteUserNoWriteCompany() {
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.delete("wuser");
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:19,代码来源:UserOrgResourceTest.java
示例16: resetPasswordUserNoWriteCompany
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的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
示例17: testBusinessError
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
/**
* @see ExceptionMapperResource#throwBusiness()
*/
@Test
public void testBusinessError() throws IOException {
final HttpDelete httpdelete = new HttpDelete(BASE_URI + RESOURCE + "/business");
HttpResponse response = null;
try {
response = httpclient.execute(httpdelete);
Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusLine().getStatusCode());
final String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
final Map<?, ?> result = new ObjectMapperTrim().readValue(content, HashMap.class);
Assert.assertEquals(BusinessException.KEY_UNKNOW_ID, result.get("message"));
Assert.assertEquals("business", result.get("code"));
Assert.assertNull(result.get("cause"));
@SuppressWarnings("unchecked")
final List<Object> parameters = (List<Object>) result.get("parameters");
Assert.assertNotNull(parameters);
Assert.assertEquals(2, parameters.size());
Assert.assertEquals("parameter1", parameters.get(0));
Assert.assertEquals("parameter2", parameters.get(1));
} finally {
if (response != null) {
response.getEntity().getContent().close();
}
}
}
开发者ID:ligoj,项目名称:bootstrap,代码行数:29,代码来源:ExceptionMapperIT.java
示例18: zcreateUserDelegateCompanyNotExist
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void zcreateUserDelegateCompanyNotExist() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flastc");
user.setFirstName("FirstC");
user.setLastName("LastC");
user.setCompany("any");
user.setMail("[email protected]");
initSpringSecurityContext("fdaugan");
resource.create(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:14,代码来源:UserLdapResourceTest.java
示例19: zcreateUserNoDelegate
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void zcreateUserNoDelegate() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flastd");
user.setFirstName("FirstD");
user.setLastName("LastD");
user.setCompany("ing");
user.setMail("[email protected]");
initSpringSecurityContext("any");
resource.create(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:15,代码来源:UserLdapResourceTest.java
示例20: zcreateUserNoDelegateCompany
import org.ligoj.bootstrap.core.resource.BusinessException; //导入依赖的package包/类
@Test
public void zcreateUserNoDelegateCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", BusinessException.KEY_UNKNOW_ID));
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flastc");
user.setFirstName("FirstC");
user.setLastName("LastC");
user.setCompany("socygan");
user.setMail("[email protected]");
initSpringSecurityContext("fdaugan");
resource.create(user);
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:14,代码来源:UserLdapResourceTest.java
注:本文中的org.ligoj.bootstrap.core.resource.BusinessException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论