org.wso2.carbon.registry.core.Collection.getChildren()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(15.9k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.wso2.carbon.registry.core.Collection.getChildren()方法的一些代码示例,展示了Collection.getChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collection.getChildren()方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Collection
类名称:Collection
方法名:getChildren

Collection.getChildren介绍

暂无

代码示例

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

  1. private List<String> getSortedChildrenList(String servicePath, Registry registry)
  2. throws RegistryException {
  3. List<String> paths = Arrays.asList(((Collection) registry.get(servicePath)).getChildren());
  4. Collections.sort(paths, new Comparator<String>() {
  5. public int compare(String o1, String o2) {
  6. int n1, n2;
  7. try {
  8. n1 = Integer.parseInt(RegistryUtils.getResourceName(o1));
  9. } catch (NumberFormatException ignored) {
  10. return 1;
  11. }
  12. try {
  13. n2 = Integer.parseInt(RegistryUtils.getResourceName(o2));
  14. } catch (NumberFormatException ignored) {
  15. return -1;
  16. }
  17. return (n1 < n2) ? 1 : (n1 > n2) ? -1 : 0;
  18. }
  19. });
  20. return paths;
  21. }
  22. }

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement

  1. /**
  2. * This helps to find resources un a recursive manner
  3. *
  4. * @param parentResource parent resource Name
  5. * @param childResources child resource set
  6. * @return child resource set
  7. * @throws RegistryException throws
  8. */
  9. private Set<String> getChildResources(String parentResource, Set<String> childResources)
  10. throws RegistryException {
  11. Resource resource = registry.get(parentResource);
  12. if (resource instanceof Collection) {
  13. Collection collection = (Collection) resource;
  14. String[] resources = collection.getChildren();
  15. for (String res : resources) {
  16. childResources.add(res);
  17. getChildResources(res, childResources);
  18. }
  19. }
  20. return childResources;
  21. }
  22. }

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement

  1. /**
  2. * This helps to find resources un a recursive manner
  3. *
  4. * @param parentResource parent resource Name
  5. * @param childResources child resource set
  6. * @return child resource set
  7. * @throws RegistryException throws
  8. */
  9. private Set<String> getChildResources(String parentResource, Set<String> childResources)
  10. throws RegistryException {
  11. Resource resource = registry.get(parentResource);
  12. if (resource instanceof Collection) {
  13. Collection collection = (Collection) resource;
  14. String[] resources = collection.getChildren();
  15. for (String res : resources) {
  16. childResources.add(res);
  17. getChildResources(res, childResources);
  18. }
  19. }
  20. return childResources;
  21. }
  22. }

代码示例来源:origin: wso2/carbon-identity-framework

  1. /**
  2. * This helps to find resources un a recursive manner
  3. *
  4. * @param parentResource parent resource Name
  5. * @param childResources child resource set
  6. * @return child resource set
  7. * @throws RegistryException throws
  8. */
  9. private Set<String> getChildResources(String parentResource, Set<String> childResources)
  10. throws RegistryException {
  11. Resource resource = registry.get(parentResource);
  12. if (resource instanceof Collection) {
  13. Collection collection = (Collection) resource;
  14. String[] resources = collection.getChildren();
  15. for (String res : resources) {
  16. childResources.add(res);
  17. getChildResources(res, childResources);
  18. }
  19. }
  20. return childResources;
  21. }
  22. }

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

  1. public Set<String> getAPIVersions(String providerName, String apiName)
  2. throws AppManagementException {
  3. Set<String> versionSet = new HashSet<String>();
  4. String apiPath = AppMConstants.API_LOCATION + RegistryConstants.PATH_SEPARATOR +
  5. providerName + RegistryConstants.PATH_SEPARATOR + apiName;
  6. try {
  7. Resource resource = registry.get(apiPath);
  8. if (resource instanceof Collection) {
  9. Collection collection = (Collection) resource;
  10. String[] versionPaths = collection.getChildren();
  11. if (versionPaths == null || versionPaths.length == 0) {
  12. return versionSet;
  13. }
  14. for (String path : versionPaths) {
  15. versionSet.add(path.substring(apiPath.length() + 1));
  16. }
  17. } else {
  18. throw new AppManagementException("WebApp version must be a collection " + apiName);
  19. }
  20. } catch (RegistryException e) {
  21. handleException("Failed to get versions for WebApp: " + apiName, e);
  22. }
  23. return versionSet;
  24. }

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dashboard

  1. public String[] getDashboardsList() throws DashboardException {
  2. List<String> dashboards = new ArrayList<String>();
  3. int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
  4. Registry registry = null;
  5. try {
  6. registry = ServiceHolder.getRegistryService().getConfigSystemRegistry(tenantId);
  7. Collection dashboardsCollection = (Collection) registry.get(DashboardConstants.DASHBOARDS_RESOURCE_PATH);
  8. String[] resourceNames = dashboardsCollection.getChildren();
  9. for (String resourceName : resourceNames) {
  10. String dashboard = resourceName.substring(resourceName.lastIndexOf("/") + 1,
  11. resourceName.length());
  12. dashboards.add(dashboard);
  13. }
  14. } catch (RegistryException e) {
  15. String errorMsg = "Error occurred while reading dashboards list.";
  16. log.error(errorMsg,e);
  17. throw new DashboardException(errorMsg,e);
  18. }
  19. return dashboards.toArray(new String[dashboards.size()]);
  20. }

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

  1. private void deleteRecursively (Registry registry, Resource resource) throws RegistryException {
  2. if (resource instanceof Collection) {
  3. for(String childResource : ((Collection) resource).getChildren()){
  4. deleteRecursively(registry, registry.get(childResource));
  5. }
  6. }
  7. registry.delete(resource.getPath());
  8. }

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.reporting

  1. public ReportConfigurationBean[] getSavedReports()
  2. throws RegistryException, CryptoException, TaskException {
  3. Registry registry = getConfigSystemRegistry();
  4. List<ReportConfigurationBean> output = new LinkedList<ReportConfigurationBean>();
  5. if (registry.resourceExists(REPORTING_CONFIG_PATH)) {
  6. Collection collection = (Collection) registry.get(REPORTING_CONFIG_PATH);
  7. String[] children = collection.getChildren();
  8. for (String child : children) {
  9. ReportConfigurationBean bean = getConfigurationBean(child);
  10. Registry rootRegistry1 = getRootRegistry();
  11. if (!rootRegistry1.resourceExists(bean.getTemplate())) {
  12. log.warn("Report template " + bean.getTemplate() + " doesn't exist");
  13. }
  14. try {
  15. RegistryUtils.loadClass(bean.getReportClass());
  16. } catch (ClassNotFoundException e) {
  17. log.warn("Report class not found " + bean.getReportClass());
  18. }
  19. output.add(bean);
  20. }
  21. }
  22. return output.toArray(new ReportConfigurationBean[output.size()]);
  23. }

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement

  1. @Override
  2. public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
  3. Set<String> resourceSet = new HashSet<String>();
  4. registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
  5. getThreadLocalCarbonContext().getTenantId());
  6. if (registry.resourceExists(parentResourceId)) {
  7. Resource resource = registry.get(parentResourceId);
  8. if (resource instanceof Collection) {
  9. Collection collection = (Collection) resource;
  10. String[] resources = collection.getChildren();
  11. for (String res : resources) {
  12. resourceSet.add(res);
  13. getChildResources(res, resourceSet);
  14. }
  15. } else {
  16. return null;
  17. }
  18. }
  19. return resourceSet;
  20. }

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

  1. private void deleteChildRecursively(String path,Registry registry) throws RegistryException {
  2. Resource currentResource = registry.get(path);
  3. if((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() == 0 ){
  4. String[] childPaths = ((Collection)currentResource).getChildren();
  5. for (String childPath : childPaths) {
  6. deleteChildRecursively(childPath,registry);
  7. }
  8. registry.delete(path);
  9. } else {
  10. registry.delete(path);
  11. }
  12. }
  13. }

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement

  1. @Override
  2. public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
  3. Set<String> resourceSet = new HashSet<String>();
  4. registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
  5. getThreadLocalCarbonContext().getTenantId());
  6. if (registry.resourceExists(parentResourceId)) {
  7. Resource resource = registry.get(parentResourceId);
  8. if (resource instanceof Collection) {
  9. Collection collection = (Collection) resource;
  10. String[] resources = collection.getChildren();
  11. for (String res : resources) {
  12. resourceSet.add(res);
  13. getChildResources(res, resourceSet);
  14. }
  15. } else {
  16. return null;
  17. }
  18. }
  19. return resourceSet;
  20. }

代码示例来源:origin: wso2/carbon-identity-framework

  1. @Override
  2. public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
  3. Set<String> resourceSet = new HashSet<String>();
  4. registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
  5. getThreadLocalCarbonContext().getTenantId());
  6. if (registry.resourceExists(parentResourceId)) {
  7. Resource resource = registry.get(parentResourceId);
  8. if (resource instanceof Collection) {
  9. Collection collection = (Collection) resource;
  10. String[] resources = collection.getChildren();
  11. for (String res : resources) {
  12. resourceSet.add(res);
  13. getChildResources(res, resourceSet);
  14. }
  15. } else {
  16. return null;
  17. }
  18. }
  19. return resourceSet;
  20. }

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.lcm

  1. public static String[] getLifecycleList(Registry registry) throws RegistryException{
  2. Collection collection;
  3. try {
  4. collection = (Collection)registry.get(getContextRoot());
  5. } catch (Exception e) {
  6. return null;
  7. }
  8. if (collection == null) {
  9. CollectionImpl lifeCycleCollection = new CollectionImpl();
  10. registry.put(getContextRoot(), lifeCycleCollection);
  11. return null;
  12. }
  13. else {
  14. if (collection.getChildCount() == 0) {
  15. return null;
  16. }
  17. String[] childrenList = collection.getChildren();
  18. String[] lifeCycleNameList = new String[collection.getChildCount()];
  19. for (int i = 0; i < childrenList.length; i++) {
  20. String path = childrenList[i];
  21. lifeCycleNameList[i] = path.substring(path.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1);
  22. }
  23. return lifeCycleNameList;
  24. }
  25. }

代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bam.lwevent.core

  1. public String subscribe(Subscription subscription) throws RegistryException {
  2. Registry registry = getRegistry();
  3. int topicHash = subscription.getTopicName().hashCode();
  4. String subscriptionPath = registryPath + topicHash;
  5. if (registry.resourceExists(subscriptionPath)) {
  6. Collection subscriptionCollection = (Collection) registry.get(subscriptionPath);
  7. String[] subscriptonPaths = subscriptionCollection.getChildren();
  8. for (String registrySubscriptionPath : subscriptonPaths) {
  9. Resource regSubscription = registry.get(registrySubscriptionPath);
  10. String eventSinkURL = regSubscription.getProperty(ServiceStatisticsPublisherConstants.EVENT_SINK_URL_PROPERTY_NAME);
  11. if (subscription.getEventSinkURL().equals(eventSinkURL)) {
  12. return regSubscription.getProperty(ServiceStatisticsPublisherConstants.UUID_PROPERTY_NAME);
  13. }
  14. }
  15. }
  16. Resource resource = registry.newResource();
  17. resource.setProperty(ServiceStatisticsPublisherConstants.TOPIC_REGISTRY_PROPERTY_NAME, subscription.getTopicName());
  18. resource.setProperty(ServiceStatisticsPublisherConstants.EVENT_SINK_URL_PROPERTY_NAME, subscription.getEventSinkURL());
  19. String uuid = UUID.randomUUID().toString();
  20. resource.setProperty(ServiceStatisticsPublisherConstants.UUID_PROPERTY_NAME, uuid);
  21. registry.put(constructRegistryPath(subscription.getTopicName(), uuid), resource);
  22. log.info("Subscription added for topic : " + subscription.getTopicName() + " for subscriber URL : " + subscription.getEventSinkURL());
  23. return uuid;
  24. }

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.user.mgt

  1. private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
  2. Registry registry, Registry tenantRegistry) throws RegistryException,
  3. UserStoreException {
  4. String[] children = parent.getChildren();
  5. UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
  6. for (int i = 0; i < children.length; i++) {
  7. String child = children[i];
  8. Resource resource = null;
  9. if (registry.resourceExists(child)) {
  10. resource = registry.get(child);
  11. } else if (tenantRegistry != null) {
  12. resource = tenantRegistry.get(child);
  13. } else {
  14. throw new RegistryException("Permission resource not found in the registry.");
  15. }
  16. childNodes[i] = getUIPermissionNode(resource, true);
  17. if (resource instanceof Collection) {
  18. buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
  19. tenantRegistry);
  20. }
  21. }
  22. parentNode.setNodeList(childNodes);
  23. }

代码示例来源:origin: wso2/carbon-identity-framework

  1. private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
  2. Registry registry, Registry tenantRegistry) throws RegistryException,
  3. UserStoreException {
  4. String[] children = parent.getChildren();
  5. UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
  6. for (int i = 0; i < children.length; i++) {
  7. String child = children[i];
  8. Resource resource = null;
  9. if (registry.resourceExists(child)) {
  10. resource = registry.get(child);
  11. } else if (tenantRegistry != null) {
  12. resource = tenantRegistry.get(child);
  13. } else {
  14. throw new RegistryException("Permission resource not found in the registry.");
  15. }
  16. childNodes[i] = getUIPermissionNode(resource, true);
  17. if (resource instanceof Collection) {
  18. buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
  19. tenantRegistry);
  20. }
  21. }
  22. parentNode.setNodeList(childNodes);
  23. }

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.security.mgt

  1. private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
  2. try {
  3. int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
  4. Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
  5. .getConfigSystemRegistry(tenantId);
  6. String servicePath = getRegistryServicePath(service);
  7. String policyResourcePath = servicePath + RegistryResources.POLICIES;
  8. if (configRegistry.resourceExists(policyResourcePath)) {
  9. Resource resource = configRegistry.get(policyResourcePath);
  10. if (resource instanceof Collection) {
  11. for (String policyPath : ((Collection) resource).getChildren()) {
  12. Resource res = configRegistry.get(policyPath);
  13. return loadPolicy(res);
  14. }
  15. }
  16. }
  17. } catch (org.wso2.carbon.registry.api.RegistryException e) {
  18. throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
  19. .getName(), e);
  20. } catch (XMLStreamException e) {
  21. throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
  22. }
  23. return null;
  24. }

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.security.mgt

  1. private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
  2. try {
  3. int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
  4. Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
  5. .getConfigSystemRegistry(tenantId);
  6. String servicePath = getRegistryServicePath(service);
  7. String policyResourcePath = servicePath + RegistryResources.POLICIES;
  8. if (configRegistry.resourceExists(policyResourcePath)) {
  9. Resource resource = configRegistry.get(policyResourcePath);
  10. if (resource instanceof Collection) {
  11. for (String policyPath : ((Collection) resource).getChildren()) {
  12. Resource res = configRegistry.get(policyPath);
  13. return loadPolicy(res);
  14. }
  15. }
  16. }
  17. } catch (org.wso2.carbon.registry.api.RegistryException e) {
  18. throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
  19. .getName(), e);
  20. } catch (XMLStreamException e) {
  21. throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
  22. }
  23. return null;
  24. }

代码示例来源:origin: wso2/carbon-identity-framework

  1. private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
  2. try {
  3. int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
  4. Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
  5. .getConfigSystemRegistry(tenantId);
  6. String servicePath = getRegistryServicePath(service);
  7. String policyResourcePath = servicePath + RegistryResources.POLICIES;
  8. if (configRegistry.resourceExists(policyResourcePath)) {
  9. Resource resource = configRegistry.get(policyResourcePath);
  10. if (resource instanceof Collection) {
  11. for (String policyPath : ((Collection) resource).getChildren()) {
  12. Resource res = configRegistry.get(policyPath);
  13. return loadPolicy(res);
  14. }
  15. }
  16. }
  17. } catch (org.wso2.carbon.registry.api.RegistryException e) {
  18. throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
  19. .getName(), e);
  20. } catch (XMLStreamException e) {
  21. throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
  22. }
  23. return null;
  24. }

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

  1. Resource currentResource = registry.get(requestContext.getResource().getPath());
  2. if ((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() != 0 ){
  3. String[] childPaths = ((Collection)currentResource).getChildren();
  4. for (String childPath : childPaths) {
  5. deleteChildRecursively(childPath,registry);

相关文章