本文整理汇总了Java中org.ligoj.bootstrap.core.NamedBean类的典型用法代码示例。如果您正苦于以下问题:Java NamedBean类的具体用法?Java NamedBean怎么用?Java NamedBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamedBean类属于org.ligoj.bootstrap.core包,在下文中一共展示了NamedBean类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateGroup
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的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
示例2: findGroupsByName
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Search the LDAP Groups matching to the given criteria and for type
* "Project". Node identifier is ignored for now.
*
* @param criteria
* the search criteria.
* @return LDAP Groups matching the criteria.
* @see ContainerScope#TYPE_PROJECT
*/
@GET
@Path("group/{node}/{criteria}")
@Consumes(MediaType.APPLICATION_JSON)
public List<INamableBean<String>> findGroupsByName(@PathParam("criteria") final String criteria) {
final List<INamableBean<String>> result = new ArrayList<>();
final String criteriaClean = Normalizer.normalize(criteria);
final Set<GroupOrg> managedGroups = groupLdapResource.getContainers();
final List<ContainerScope> types = containerScopeResource.findAllDescOrder(ContainerType.GROUP);
for (final GroupOrg group : managedGroups) {
final ContainerScope scope = groupLdapResource.toScope(types, group);
// Check type and criteria
if (scope != null && ContainerScope.TYPE_PROJECT.equals(scope.getName())
&& group.getId().contains(criteriaClean)) {
// Return the nice name
final INamableBean<String> bean = new NamedBean<>();
NamedBean.copy(group, bean);
result.add(bean);
}
}
return result;
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:33,代码来源:LdapPluginResource.java
示例3: findCustomersByName
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Search the LDAP Customers matching to the given criteria and for type
* "Project". Node identifier is ignored for now. Node is ignored.
*
* @param criteria
* the search criteria.
* @return LDAP Customers matching the criteria.
* @see ContainerScope#TYPE_PROJECT
*/
@GET
@Path("customer/{node}/{criteria}")
@Consumes(MediaType.APPLICATION_JSON)
public Collection<INamableBean<String>> findCustomersByName(@PathParam("criteria") final String criteria) {
final Set<INamableBean<String>> result = new TreeSet<>();
final String criteriaClean = Normalizer.normalize(criteria);
final ContainerScope findByName = containerScopeResource.findByName(ContainerScope.TYPE_PROJECT);
final Collection<String> allCustomers = projectCustomerLdapRepository.findAll(findByName.getDn()).keySet();
// Check type and criteria
allCustomers.stream().filter(customer -> customer.contains(criteriaClean)).forEach(customer -> {
// Return the nice name
final INamableBean<String> bean = new NamedBean<>();
// Return the nice name
bean.setName(customer);
bean.setId(customer);
result.add(bean);
});
return result;
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:30,代码来源:LdapPluginResource.java
示例4: newContainerCountVo
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Build a new secured container managing the effective visibility and rights.
*
* @param rawContainer
* the raw container contained sensitive data.
* @param managedWrite
* The containers the current user can write.
* @param managedAdmin
* The containers the current user can administer.
* @param types
* The defined type with locking information.
* @return A secured container with right and lock information the current user has.
*/
protected ContainerCountVo newContainerCountVo(final ContainerOrg rawContainer, final Set<T> managedWrite, final Set<T> managedAdmin,
final List<ContainerScope> types) {
final ContainerCountVo securedUserOrg = new ContainerCountVo();
NamedBean.copy(rawContainer, securedUserOrg);
securedUserOrg.setCanWrite(managedWrite.contains(rawContainer));
securedUserOrg.setCanAdmin(managedAdmin.contains(rawContainer));
securedUserOrg.setContainerType(type);
// Find the closest type
final ContainerScope scope = toScope(types, rawContainer);
if (scope != null) {
securedUserOrg.setScope(scope.getName());
securedUserOrg.setLocked(scope.isLocked());
}
securedUserOrg.setLocked(securedUserOrg.isLocked() || rawContainer.isLocked());
return securedUserOrg;
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:31,代码来源:AbstractContainerResource.java
示例5: findAllByName
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Find the repositories matching to the given criteria.Look into name only.
*
* @param criteria
* the search criteria.
* @param node
* the node to be tested with given parameters.
* @return project name.
*/
@GET
@Path("{node}/{criteria}")
@Consumes(MediaType.APPLICATION_JSON)
public List<NamedBean<String>> findAllByName(@PathParam("node") final String node, @PathParam("criteria") final String criteria) {
final Map<String, String> parameters = pvResource.getNodeParameters(node);
final CurlRequest request = new CurlRequest(HttpMethod.GET, StringUtils.appendIfMissing(parameters.get(parameterUrl), "/"), null);
request.setSaveResponse(true);
newCurlProcessor(parameters).process(request);
// Prepare the context, an ordered set of projects
final Format format = new NormalizeFormat();
final String formatCriteria = format.format(criteria);
// Limit the result
return inMemoryPagination.newPage(
Arrays.stream(StringUtils.splitByWholeSeparator(StringUtils.defaultString(request.getResponse()), "<a href=\"")).skip(1)
.filter(s -> format.format(s).contains(formatCriteria))
.map(s -> StringUtils.removeEnd(s.substring(0, Math.max(0, s.indexOf('\"'))), "/"))
.filter(((Predicate<String>) String::isEmpty).negate()).map(id -> new NamedBean<>(id, id)).collect(Collectors.toList()),
PageRequest.of(0, 10)).getContent();
}
开发者ID:ligoj,项目名称:plugin-scm,代码行数:31,代码来源:AbstractIndexBasedPluginResource.java
示例6: getEC2Keys
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Return EC2 keys
*
* @param subscription
* The related subscription.
* @return EC2 keys related to given subscription.
*/
@Path("ec2/keys/{subscription:\\d+}")
@GET
public List<NamedBean<String>> getEC2Keys(@PathParam("subscription") final int subscription) {
// Call "DescribeKeyPairs" service
final String query = "Action=DescribeKeyPairs&Version=2016-11-15";
final AWS4SignatureQueryBuilder signatureQueryBuilder = AWS4SignatureQuery.builder().service("ec2")
.host("ec2." + getRegion() + ".amazonaws.com").path("/").body(query);
final CurlRequest request = newRequest(signatureQueryBuilder, subscription);
// extract key pairs from response
final List<NamedBean<String>> keys = new ArrayList<>();
if (new CurlProcessor().process(request)) {
final Matcher keyNames = Pattern.compile("<keyName>(.*)</keyName>").matcher(request.getResponse());
while (keyNames.find()) {
keys.add(new NamedBean<>(keyNames.group(1), null));
}
}
return keys;
}
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:26,代码来源:ProvAwsPluginResource.java
示例7: getEC2Keys
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* retrieve keys from AWS
*
* @throws Exception
* exception
*/
@Test
public void getEC2Keys() throws Exception {
final ProvAwsPluginResource resource = Mockito.spy(this.resource);
final CurlRequest mockRequest = new CurlRequest("GET", MOCK_URL, null);
mockRequest.setSaveResponse(true);
Mockito.doReturn(mockRequest).when(resource).newRequest(ArgumentMatchers.any(AWS4SignatureQueryBuilder.class),
ArgumentMatchers.eq(subscription));
httpServer.stubFor(
get(urlEqualTo("/mock")).willReturn(aResponse().withStatus(HttpStatus.SC_OK).withBody("<keyName>my-key</keyName>")));
httpServer.start();
final List<NamedBean<String>> keys = resource.getEC2Keys(subscription);
Assert.assertFalse(keys.isEmpty());
Assert.assertEquals(1, keys.size());
Assert.assertEquals("my-key", keys.get(0).getId());
}
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:23,代码来源:ProvAwsPluginResourceTest.java
示例8: write
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
@Test
public void write() throws IOException {
final ActivitiesComputations computations = new ActivitiesComputations();
// Nodes
final Collection<INamableBean<String>> nodes = new ArrayList<>();
final NamedBean<String> node1 = new NamedBean<>();
nodes.add(node1);
node1.setId("J0");
node1.setName("J0N");
final NamedBean<String> node2 = new NamedBean<>();
nodes.add(node2);
node2.setId("J1");
node2.setName("J1N");
computations.setNodes(nodes);
// Activities
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final Map<String, Activity> userActivities = new HashMap<>();
activities.put("U0", userActivities);
final Activity activity1 = new Activity();
activity1.setLastConnection(new Date(0));
userActivities.put("J0", activity1);
computations.setActivities(activities);
// Users
final Collection<UserOrg> users = new ArrayList<>();
final UserOrg user = new UserOrg();
user.setFirstName("F0");
user.setLastName("L0");
user.setId("U0");
user.setMails(new ArrayList<>());
users.add(user);
final UserOrg user2 = new UserOrg();
user2.setFirstName("F1");
user2.setLastName("L1");
user2.setId("U1");
user2.setMails(Arrays.asList("M1", "M2"));
users.add(user2);
computations.setUsers(users);
// Call
final ByteArrayOutputStream out = new ByteArrayOutputStream();
new CsvStreamingOutput(computations).write(out);
final List<String> lines = IOUtils.readLines(new ByteArrayInputStream(out.toByteArray()), StandardCharsets.UTF_8);
// Check
Assert.assertEquals(3, lines.size());
Assert.assertEquals("user;firstName;lastName;mail;J0N;J1N", lines.get(0));
Assert.assertEquals("U0;F0;L0;;1970/01/01 01:00:00;", lines.get(1));
Assert.assertEquals("U1;F1;L1;M1", lines.get(2));
}
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:54,代码来源:CsvStreamingOutputTest.java
示例9: findAllByName
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
@Test
public void findAllByName() throws Exception {
prepareMockAdmin();
httpServer.start();
final List<NamedBean<String>> projects = resource.findAllByName("service:scm:svn:dig", "as-");
Assert.assertEquals(4, projects.size());
Assert.assertEquals("has-evamed", projects.get(0).getId());
Assert.assertEquals("has-evamed", projects.get(0).getName());
}
开发者ID:ligoj,项目名称:plugin-scm-svn,代码行数:11,代码来源:SvnPluginResourceTest.java
示例10: findAllByNameNoListing
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
@Test
public void findAllByNameNoListing() throws Exception {
httpServer.start();
final List<NamedBean<String>> projects = resource.findAllByName("service:scm:svn:dig", "as-");
Assert.assertEquals(0, projects.size());
}
开发者ID:ligoj,项目名称:plugin-scm-svn,代码行数:8,代码来源:SvnPluginResourceTest.java
示例11: toVo
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
/**
* Simple transformer, securing sensible date. DN is not forwarded.
*/
protected ContainerWithScopeVo toVo(final T rawGroupLdap) {
// Find the closest type
final ContainerWithScopeVo securedUserOrg = new ContainerWithScopeVo();
final List<ContainerScope> scopes = containerScopeResource.findAllDescOrder(type);
final ContainerScope scope = toScope(scopes, rawGroupLdap);
NamedBean.copy(rawGroupLdap, securedUserOrg);
if (scope != null) {
securedUserOrg.setScope(scope.getName());
}
return securedUserOrg;
}
开发者ID:ligoj,项目名称:plugin-id,代码行数:15,代码来源:AbstractContainerResource.java
示例12: findAllByName
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
@Test
public void findAllByName() throws Exception {
prepareMockAdmin();
httpServer.start();
final List<NamedBean<String>> projects = resource.findAllByName("service:impl:node", "as-");
Assert.assertEquals(4, projects.size());
Assert.assertEquals("has-evamed", projects.get(0).getId());
Assert.assertEquals("has-evamed", projects.get(0).getName());
}
开发者ID:ligoj,项目名称:plugin-scm,代码行数:11,代码来源:IndexBasedPluginResourceTest.java
示例13: findAllByNameNoListing
import org.ligoj.bootstrap.core.NamedBean; //导入依赖的package包/类
@Test
public void findAllByNameNoListing() throws Exception {
httpServer.start();
final List<NamedBean<String>> projects = resource.findAllByName("service:impl:node", "as-");
Assert.assertEquals(0, projects.size());
}
开发者ID:ligoj,项目名称:plugin-scm,代码行数:8,代码来源:IndexBasedPluginResourceTest.java
注:本文中的org.ligoj.bootstrap.core.NamedBean类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论