本文整理了Java中org.wso2.carbon.registry.core.Collection.getChildren()
方法的一些代码示例,展示了Collection.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collection.getChildren()
方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Collection
类名称:Collection
方法名:getChildren
暂无
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
private List<String> getSortedChildrenList(String servicePath, Registry registry)
throws RegistryException {
List<String> paths = Arrays.asList(((Collection) registry.get(servicePath)).getChildren());
Collections.sort(paths, new Comparator<String>() {
public int compare(String o1, String o2) {
int n1, n2;
try {
n1 = Integer.parseInt(RegistryUtils.getResourceName(o1));
} catch (NumberFormatException ignored) {
return 1;
}
try {
n2 = Integer.parseInt(RegistryUtils.getResourceName(o2));
} catch (NumberFormatException ignored) {
return -1;
}
return (n1 < n2) ? 1 : (n1 > n2) ? -1 : 0;
}
});
return paths;
}
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement
/**
* This helps to find resources un a recursive manner
*
* @param parentResource parent resource Name
* @param childResources child resource set
* @return child resource set
* @throws RegistryException throws
*/
private Set<String> getChildResources(String parentResource, Set<String> childResources)
throws RegistryException {
Resource resource = registry.get(parentResource);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
childResources.add(res);
getChildResources(res, childResources);
}
}
return childResources;
}
}
代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement
/**
* This helps to find resources un a recursive manner
*
* @param parentResource parent resource Name
* @param childResources child resource set
* @return child resource set
* @throws RegistryException throws
*/
private Set<String> getChildResources(String parentResource, Set<String> childResources)
throws RegistryException {
Resource resource = registry.get(parentResource);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
childResources.add(res);
getChildResources(res, childResources);
}
}
return childResources;
}
}
代码示例来源:origin: wso2/carbon-identity-framework
/**
* This helps to find resources un a recursive manner
*
* @param parentResource parent resource Name
* @param childResources child resource set
* @return child resource set
* @throws RegistryException throws
*/
private Set<String> getChildResources(String parentResource, Set<String> childResources)
throws RegistryException {
Resource resource = registry.get(parentResource);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
childResources.add(res);
getChildResources(res, childResources);
}
}
return childResources;
}
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl
public Set<String> getAPIVersions(String providerName, String apiName)
throws AppManagementException {
Set<String> versionSet = new HashSet<String>();
String apiPath = AppMConstants.API_LOCATION + RegistryConstants.PATH_SEPARATOR +
providerName + RegistryConstants.PATH_SEPARATOR + apiName;
try {
Resource resource = registry.get(apiPath);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] versionPaths = collection.getChildren();
if (versionPaths == null || versionPaths.length == 0) {
return versionSet;
}
for (String path : versionPaths) {
versionSet.add(path.substring(apiPath.length() + 1));
}
} else {
throw new AppManagementException("WebApp version must be a collection " + apiName);
}
} catch (RegistryException e) {
handleException("Failed to get versions for WebApp: " + apiName, e);
}
return versionSet;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dashboard
public String[] getDashboardsList() throws DashboardException {
List<String> dashboards = new ArrayList<String>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Registry registry = null;
try {
registry = ServiceHolder.getRegistryService().getConfigSystemRegistry(tenantId);
Collection dashboardsCollection = (Collection) registry.get(DashboardConstants.DASHBOARDS_RESOURCE_PATH);
String[] resourceNames = dashboardsCollection.getChildren();
for (String resourceName : resourceNames) {
String dashboard = resourceName.substring(resourceName.lastIndexOf("/") + 1,
resourceName.length());
dashboards.add(dashboard);
}
} catch (RegistryException e) {
String errorMsg = "Error occurred while reading dashboards list.";
log.error(errorMsg,e);
throw new DashboardException(errorMsg,e);
}
return dashboards.toArray(new String[dashboards.size()]);
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
private void deleteRecursively (Registry registry, Resource resource) throws RegistryException {
if (resource instanceof Collection) {
for(String childResource : ((Collection) resource).getChildren()){
deleteRecursively(registry, registry.get(childResource));
}
}
registry.delete(resource.getPath());
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.reporting
public ReportConfigurationBean[] getSavedReports()
throws RegistryException, CryptoException, TaskException {
Registry registry = getConfigSystemRegistry();
List<ReportConfigurationBean> output = new LinkedList<ReportConfigurationBean>();
if (registry.resourceExists(REPORTING_CONFIG_PATH)) {
Collection collection = (Collection) registry.get(REPORTING_CONFIG_PATH);
String[] children = collection.getChildren();
for (String child : children) {
ReportConfigurationBean bean = getConfigurationBean(child);
Registry rootRegistry1 = getRootRegistry();
if (!rootRegistry1.resourceExists(bean.getTemplate())) {
log.warn("Report template " + bean.getTemplate() + " doesn't exist");
}
try {
RegistryUtils.loadClass(bean.getReportClass());
} catch (ClassNotFoundException e) {
log.warn("Report class not found " + bean.getReportClass());
}
output.add(bean);
}
}
return output.toArray(new ReportConfigurationBean[output.size()]);
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
Set<String> resourceSet = new HashSet<String>();
registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
getThreadLocalCarbonContext().getTenantId());
if (registry.resourceExists(parentResourceId)) {
Resource resource = registry.get(parentResourceId);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
resourceSet.add(res);
getChildResources(res, resourceSet);
}
} else {
return null;
}
}
return resourceSet;
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
private void deleteChildRecursively(String path,Registry registry) throws RegistryException {
Resource currentResource = registry.get(path);
if((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() == 0 ){
String[] childPaths = ((Collection)currentResource).getChildren();
for (String childPath : childPaths) {
deleteChildRecursively(childPath,registry);
}
registry.delete(path);
} else {
registry.delete(path);
}
}
}
代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
Set<String> resourceSet = new HashSet<String>();
registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
getThreadLocalCarbonContext().getTenantId());
if (registry.resourceExists(parentResourceId)) {
Resource resource = registry.get(parentResourceId);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
resourceSet.add(res);
getChildResources(res, resourceSet);
}
} else {
return null;
}
}
return resourceSet;
}
代码示例来源:origin: wso2/carbon-identity-framework
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
Set<String> resourceSet = new HashSet<String>();
registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
getThreadLocalCarbonContext().getTenantId());
if (registry.resourceExists(parentResourceId)) {
Resource resource = registry.get(parentResourceId);
if (resource instanceof Collection) {
Collection collection = (Collection) resource;
String[] resources = collection.getChildren();
for (String res : resources) {
resourceSet.add(res);
getChildResources(res, resourceSet);
}
} else {
return null;
}
}
return resourceSet;
}
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.lcm
public static String[] getLifecycleList(Registry registry) throws RegistryException{
Collection collection;
try {
collection = (Collection)registry.get(getContextRoot());
} catch (Exception e) {
return null;
}
if (collection == null) {
CollectionImpl lifeCycleCollection = new CollectionImpl();
registry.put(getContextRoot(), lifeCycleCollection);
return null;
}
else {
if (collection.getChildCount() == 0) {
return null;
}
String[] childrenList = collection.getChildren();
String[] lifeCycleNameList = new String[collection.getChildCount()];
for (int i = 0; i < childrenList.length; i++) {
String path = childrenList[i];
lifeCycleNameList[i] = path.substring(path.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1);
}
return lifeCycleNameList;
}
}
代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bam.lwevent.core
public String subscribe(Subscription subscription) throws RegistryException {
Registry registry = getRegistry();
int topicHash = subscription.getTopicName().hashCode();
String subscriptionPath = registryPath + topicHash;
if (registry.resourceExists(subscriptionPath)) {
Collection subscriptionCollection = (Collection) registry.get(subscriptionPath);
String[] subscriptonPaths = subscriptionCollection.getChildren();
for (String registrySubscriptionPath : subscriptonPaths) {
Resource regSubscription = registry.get(registrySubscriptionPath);
String eventSinkURL = regSubscription.getProperty(ServiceStatisticsPublisherConstants.EVENT_SINK_URL_PROPERTY_NAME);
if (subscription.getEventSinkURL().equals(eventSinkURL)) {
return regSubscription.getProperty(ServiceStatisticsPublisherConstants.UUID_PROPERTY_NAME);
}
}
}
Resource resource = registry.newResource();
resource.setProperty(ServiceStatisticsPublisherConstants.TOPIC_REGISTRY_PROPERTY_NAME, subscription.getTopicName());
resource.setProperty(ServiceStatisticsPublisherConstants.EVENT_SINK_URL_PROPERTY_NAME, subscription.getEventSinkURL());
String uuid = UUID.randomUUID().toString();
resource.setProperty(ServiceStatisticsPublisherConstants.UUID_PROPERTY_NAME, uuid);
registry.put(constructRegistryPath(subscription.getTopicName(), uuid), resource);
log.info("Subscription added for topic : " + subscription.getTopicName() + " for subscriber URL : " + subscription.getEventSinkURL());
return uuid;
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.user.mgt
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
Registry registry, Registry tenantRegistry) throws RegistryException,
UserStoreException {
String[] children = parent.getChildren();
UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
for (int i = 0; i < children.length; i++) {
String child = children[i];
Resource resource = null;
if (registry.resourceExists(child)) {
resource = registry.get(child);
} else if (tenantRegistry != null) {
resource = tenantRegistry.get(child);
} else {
throw new RegistryException("Permission resource not found in the registry.");
}
childNodes[i] = getUIPermissionNode(resource, true);
if (resource instanceof Collection) {
buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
tenantRegistry);
}
}
parentNode.setNodeList(childNodes);
}
代码示例来源:origin: wso2/carbon-identity-framework
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
Registry registry, Registry tenantRegistry) throws RegistryException,
UserStoreException {
String[] children = parent.getChildren();
UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
for (int i = 0; i < children.length; i++) {
String child = children[i];
Resource resource = null;
if (registry.resourceExists(child)) {
resource = registry.get(child);
} else if (tenantRegistry != null) {
resource = tenantRegistry.get(child);
} else {
throw new RegistryException("Permission resource not found in the registry.");
}
childNodes[i] = getUIPermissionNode(resource, true);
if (resource instanceof Collection) {
buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
tenantRegistry);
}
}
parentNode.setNodeList(childNodes);
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.security.mgt
private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
.getConfigSystemRegistry(tenantId);
String servicePath = getRegistryServicePath(service);
String policyResourcePath = servicePath + RegistryResources.POLICIES;
if (configRegistry.resourceExists(policyResourcePath)) {
Resource resource = configRegistry.get(policyResourcePath);
if (resource instanceof Collection) {
for (String policyPath : ((Collection) resource).getChildren()) {
Resource res = configRegistry.get(policyPath);
return loadPolicy(res);
}
}
}
} catch (org.wso2.carbon.registry.api.RegistryException e) {
throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
.getName(), e);
} catch (XMLStreamException e) {
throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
}
return null;
}
代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.security.mgt
private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
.getConfigSystemRegistry(tenantId);
String servicePath = getRegistryServicePath(service);
String policyResourcePath = servicePath + RegistryResources.POLICIES;
if (configRegistry.resourceExists(policyResourcePath)) {
Resource resource = configRegistry.get(policyResourcePath);
if (resource instanceof Collection) {
for (String policyPath : ((Collection) resource).getChildren()) {
Resource res = configRegistry.get(policyPath);
return loadPolicy(res);
}
}
}
} catch (org.wso2.carbon.registry.api.RegistryException e) {
throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
.getName(), e);
} catch (XMLStreamException e) {
throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
}
return null;
}
代码示例来源:origin: wso2/carbon-identity-framework
private Policy getCurrentPolicy(AxisService service) throws SecurityConfigException {
try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
Registry configRegistry = SecurityMgtServiceComponent.getRegistryService()
.getConfigSystemRegistry(tenantId);
String servicePath = getRegistryServicePath(service);
String policyResourcePath = servicePath + RegistryResources.POLICIES;
if (configRegistry.resourceExists(policyResourcePath)) {
Resource resource = configRegistry.get(policyResourcePath);
if (resource instanceof Collection) {
for (String policyPath : ((Collection) resource).getChildren()) {
Resource res = configRegistry.get(policyPath);
return loadPolicy(res);
}
}
}
} catch (org.wso2.carbon.registry.api.RegistryException e) {
throw new SecurityConfigException("Error while retrieving policy from registry for service " + service
.getName(), e);
} catch (XMLStreamException e) {
throw new SecurityConfigException("Error occurred while loading policy from registry resource", e);
}
return null;
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
Resource currentResource = registry.get(requestContext.getResource().getPath());
if ((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() != 0 ){
String[] childPaths = ((Collection)currentResource).getChildren();
for (String childPath : childPaths) {
deleteChildRecursively(childPath,registry);
内容来源于网络,如有侵权,请联系作者删除!