org.wso2.carbon.registry.core.Collection类的使用及代码示例

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

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

Collection介绍

暂无

代码示例

代码示例来源: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.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/org.wso2.carbon.user.mgt

if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
  regRoot = (Collection) registry.get(UserMgtConstants.UI_PERMISSION_ROOT);
  String displayName = regRoot.getProperty(UserMgtConstants.DISPLAY_NAME);
  nodeRoot = new UIPermissionNode(UserMgtConstants.UI_PERMISSION_ROOT, displayName);
} else {
    appRoot = (Collection) tenentRegistry.get(APPLICATIONS_PATH);
    parent = (Collection) tenentRegistry.newCollection();
    parent.setProperty(UserMgtConstants.DISPLAY_NAME, "All Permissions");
    parent.setChildren(new String[]{regRoot.getPath(), appRoot.getPath()});
    displayName = parent.getProperty(UserMgtConstants.DISPLAY_NAME);
  } else {
    displayName = regRoot.getProperty(UserMgtConstants.DISPLAY_NAME);

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

/**
 * See CMIS 1.0 section 2.2.4.14 deleteObject
 *
 * @throws CmisRuntimeException
 */
@Override
public void delete(boolean allVersions, boolean isPwc) {
  try {
    if (getNode().getChildCount()>0) {
      throw new CmisConstraintException("Folder is not empty!");
    } else {
      super.delete(allVersions, isPwc);
    }
  }
  catch (RegistryException e) {
    String msg = "Failed to delete the object " + getNode().getPath();
    log.error(msg, e);
    throw new CmisRuntimeException(msg, e);
  }
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.event.core

Collection subscriptionCollection = (Collection) userRegistry.get(resourcePath);
subscriptionsArray =
    new Subscription[subscriptionCollection.getChildCount()];
for (String subs : subscriptionCollection.getChildren()) {
  Collection subscription = (Collection) userRegistry.get(subs);
  subscriptionDetails.setId(subscription.getProperty("Name"));
  subscriptionDetails.setOwner(subscription.getProperty("Owner"));
  subscriptionDetails.setCreatedTime(ConverterUtil.convertToDate(subscription.getProperty("createdTime")));

代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel

throws RegistryException, IOException, NoSuchAlgorithmException {
Collection bpelPackage = configRegistry.newCollection();
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM,
    Utils.getMD5Checksum(deploymentContext.getBpelArchive()));
if (log.isDebugEnabled()) {
  bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS,
      BPELConstants.STATUS_FAILED);
  bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG,
      deploymentContext.getDeploymentFailureCause());
  bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS,
      BPELConstants.STATUS_DEPLOYED);
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION,
    Long.toString(deploymentContext.getVersion()));

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

@Override
public String getGlobalPolicyAlgorithmName() {
  String algorithm = null;
  try {
    Registry registry = getGovernanceRegistry();
    if (registry.resourceExists(policyDataCollection)) {
      Collection collection = (Collection) registry.get(policyDataCollection);
      algorithm = collection.getProperty("globalPolicyCombiningAlgorithm");
    }
  } catch (RegistryException e) {
    if (log.isDebugEnabled()) {
      log.debug(e);
    }
  } catch (EntitlementException e) {
    log.error("Error while getting Global Policy Combining Algorithm Name.", e);
  }
  // set default
  if (algorithm == null) {
    algorithm = "deny-overrides";
  }
  return algorithm;
}

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

String noOfPolicies = policyCollection.getProperty(PDPConstants.MAX_POLICY_ORDER);
if (noOfPolicies != null && Integer.parseInt(noOfPolicies) < policy.getPolicyOrder()) {
  policyCollection.setProperty(PDPConstants.MAX_POLICY_ORDER,
                 Integer.toString(policy.getPolicyOrder()));
  registry.put(policyPath, policyCollection);
  if (policyCollection != null) {
    int policyOrder = 1;
    String noOfPolicies = policyCollection.getProperty(PDPConstants.MAX_POLICY_ORDER);
    if (noOfPolicies != null) {
      policyOrder = policyOrder + Integer.parseInt(noOfPolicies);
    policyCollection.setProperty(PDPConstants.MAX_POLICY_ORDER,
                   Integer.toString(policyOrder));
    resource.setProperty(PDPConstants.POLICY_ORDER, Integer.toString(policyOrder));

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.mashup.javascript.hostobjects.registry

public int jsGet_childCount() throws CarbonException {
  try {
    return ((Collection)this.getResource()).getChildCount();
  } catch (RegistryException e) {
    throw new CarbonException("Error occurred while creating a new Resource.", e);
  }
}

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

@Override
public void setGlobalPolicyAlgorithm(String policyCombiningAlgorithm) throws EntitlementException {
  Registry registry = EntitlementServiceComponent.
      getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
  try {
    Collection policyCollection;
    if (registry.resourceExists(policyDataCollection)) {
      policyCollection = (Collection) registry.get(policyDataCollection);
    } else {
      policyCollection = registry.newCollection();
    }
    policyCollection.setMediaType(PDPConstants.REGISTRY_MEDIA_TYPE);
    policyCollection.setProperty("globalPolicyCombiningAlgorithm", policyCombiningAlgorithm);
    registry.put(policyDataCollection, policyCollection);
  } catch (RegistryException e) {
    log.error("Error while updating Global combing algorithm in policy store ", e);
    throw new EntitlementException("Error while updating combing algorithm in policy store");
  }
}

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

/**
 * Retrieve all the governance artifact paths which associated with the given lifecycle
 *
 * @param registry  registry instance
 * @param lcName    lifecycle name
 * @param mediaType mediatype of the artifacts
 * @return String array of all the artifact paths
 * @throws GovernanceException if the operation failed.
 */
public static String[] getAllArtifactPathsByLifecycle(Registry registry, String lcName, String mediaType) throws GovernanceException {
  String sql = "SELECT R.REG_PATH_ID, R.REG_NAME FROM REG_RESOURCE R, REG_PROPERTY PP, " +
      "REG_RESOURCE_PROPERTY RP WHERE R.REG_VERSION=RP.REG_VERSION AND RP.REG_PROPERTY_ID=PP.REG_ID " +
      "AND PP.REG_NAME = ?  AND  PP.REG_VALUE = ? AND R.REG_MEDIA_TYPE = ?";
  Map<String, String> parameter = new HashMap<String, String>();
  parameter.put("1", "registry.LC.name");
  parameter.put("2", lcName);
  parameter.put("3", mediaType);
  parameter.put("query", sql);
  try {
    return (String[]) registry.executeQuery(null, parameter).getContent();
  } catch (RegistryException e) {
    String msg = "Error occured while executing custom query";
    throw new GovernanceException(msg, e);
  }
}

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

public void updateDataArchivalPeriod(TimeRange timeRange) throws BAMException {
  try {
    Collection configCollection;
    if (registry.resourceExists(BAMRegistryResources.GLOBAL_CONFIG_PATH)) {
      configCollection = (Collection)registry.get(BAMRegistryResources.GLOBAL_CONFIG_PATH);
    } else {
      configCollection = registry.newCollection();
    }
    configCollection.setProperty(BAMRegistryResources.DATA_RETENTION_PROPERTY, timeRange.toString());
    configCollection.setProperty(BAMRegistryResources.DATA_ARCHIVAL_PROPERTY, timeRange.toString());
    registry.put(BAMRegistryResources.GLOBAL_CONFIG_PATH, configCollection);
  } catch (RegistryException e) {
    String msg = "Could not save the data retention policy in registry";
    log.error(msg, e);
    throw new BAMException(msg, e);
  }
}

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

@Override
public String getGlobalPolicyAlgorithmName() {
  String algorithm = null;
  try {
    Registry registry = getGovernanceRegistry();
    if (registry.resourceExists(policyDataCollection)) {
      Collection collection = (Collection) registry.get(policyDataCollection);
      algorithm = collection.getProperty("globalPolicyCombiningAlgorithm");
    }
  } catch (RegistryException e) {
    if (log.isDebugEnabled()) {
      log.debug(e);
    }
  } catch (EntitlementException e) {
    log.error("Error while getting Global Policy Combining Algorithm Name.", e);
  }
  // set default
  if (algorithm == null) {
    algorithm = "deny-overrides";
  }
  return algorithm;
}

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

String noOfPolicies = policyCollection.getProperty(PDPConstants.MAX_POLICY_ORDER);
if (noOfPolicies != null && Integer.parseInt(noOfPolicies) < policy.getPolicyOrder()) {
  policyCollection.setProperty(PDPConstants.MAX_POLICY_ORDER,
                 Integer.toString(policy.getPolicyOrder()));
  registry.put(policyPath, policyCollection);
  if (policyCollection != null) {
    int policyOrder = 1;
    String noOfPolicies = policyCollection.getProperty(PDPConstants.MAX_POLICY_ORDER);
    if (noOfPolicies != null) {
      policyOrder = policyOrder + Integer.parseInt(noOfPolicies);
    policyCollection.setProperty(PDPConstants.MAX_POLICY_ORDER,
                   Integer.toString(policyOrder));
    resource.setProperty(PDPConstants.POLICY_ORDER, Integer.toString(policyOrder));

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

private void deleteRecursively(String path,Registry registry) throws RegistryException {
  Resource currentResource = registry.get(path);
  if((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() == 0 ){
    registry.delete(path);
    deleteRecursively(currentResource.getParentPath(),registry);
  }
}

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

/**
 * Retrieve all the governance artifact paths which associated with the given lifecycle in the given lifecycle state
 *
 * @param registry  registry instance
 * @param lcName    lifecycle name
 * @param lcState   lifecycle state
 * @param mediaType mediatype of the artifacts
 * @return String array of all the artifact paths
 * @throws GovernanceException if the operation failed.
 */
public static String[] getAllArtifactPathsByLifecycleState(
    Registry registry, String lcName, String lcState, String mediaType) throws GovernanceException {
  String sql = "SELECT R.REG_PATH_ID, R.REG_NAME FROM REG_RESOURCE R, REG_PROPERTY PP, " +
      "REG_RESOURCE_PROPERTY RP WHERE R.REG_VERSION=RP.REG_VERSION AND RP.REG_PROPERTY_ID=PP.REG_ID " +
      "AND PP.REG_NAME = ?  AND  PP.REG_VALUE = ? AND R.REG_MEDIA_TYPE = ?";
  Map<String, String> parameter = new HashMap<String, String>();
  parameter.put("1", "registry.lifecycle." + lcName + ".state");
  parameter.put("2", lcState);
  parameter.put("3", mediaType);
  parameter.put("query", sql);
  try {
    return (String[]) registry.executeQuery(null, parameter).getContent();
  } catch (RegistryException e) {
    String msg = "Error occured while executing custom query";
    throw new GovernanceException(msg, e);
  }
}

代码示例来源: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.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.identity/org.wso2.carbon.user.mgt

String displayName = regRoot.getProperty(UserMgtConstants.DISPLAY_NAME);
  nodeRoot = new UIPermissionNode(UserMgtConstants.UI_PERMISSION_ROOT, displayName);
} else {
    appRoot = (Collection) tenentRegistry.get(APPLICATIONS_PATH);
    parent = (Collection) tenentRegistry.newCollection();
    parent.setProperty(UserMgtConstants.DISPLAY_NAME, "All Permissions");
    parent.setChildren(new String[]{regRoot.getPath(), appRoot.getPath()});
    displayName = parent.getProperty(UserMgtConstants.DISPLAY_NAME);
  } else {
    displayName = regRoot.getProperty(UserMgtConstants.DISPLAY_NAME);

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

resource.setProperty(UserMgtConstants.DISPLAY_NAME, displayName);
registry.put(resourcePath, resource);

相关文章