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

x33g5p2x  于2022-01-28 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(122)

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

Registry.getAllAssociations介绍

暂无

代码示例

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

public static Association[] getAssociations(Registry registry, String path)
    throws RegistryException {
  Association[] asso = registry.getAllAssociations(path);
  if (asso == null || asso.length == 0) {
    return asso;

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

public static void makeOtherDependencies(RequestContext requestContext, Map<String, String> oldPathNewPathMap
    , List<String> otherDependencies) throws RegistryException {
  Registry registry = requestContext.getRegistry();
  for (Map.Entry<String, String> entry : oldPathNewPathMap.entrySet()) {
    Association[] associations = registry.getAllAssociations(entry.getKey());
    for (Association association : associations) {
      for (String dependency : otherDependencies) {
        if (association.getDestinationPath().equals(dependency)) {
          registry.addAssociation(entry.getValue(), dependency, association.getAssociationType());
        }
        if (association.getSourcePath().equals(dependency)) {
          registry.addAssociation(dependency, entry.getValue(), association.getAssociationType());
        }
      }
    }
  }
}
public static List evaluateXpath(OMElement contentElement, String xpathString) {

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

for (Association association : registry.getAllAssociations(path)) {
  if (type.equals(association.getAssociationType()) &&
      ((isSource && association.getSourcePath().equals(path)) ||

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

public static AssociationBean[] getAssociations(String path, Registry registry,
                          boolean isDependency) throws RegistryException {
    List<AssociationBean> associationBeanList = new ArrayList<AssociationBean>();

    Association[] associations = registry.getAllAssociations(path);

    for (Association association : associations) {
      if ((!isDependency && path.equals(association.getSourcePath()) &&
          !association.getDestinationPath().contains(";version:")) ||
          (isDependency && association.getAssociationType().equals("depends") &&
              path.equals(association.getDestinationPath()) &&
              !association.getSourcePath().contains(";version:"))) {
        AssociationBean bean = new AssociationBean();
        bean.setAssociationType(association.getAssociationType());
        bean.setDestinationPath(association.getDestinationPath());
        bean.setSourcePath(association.getSourcePath());

        associationBeanList.add(bean);
      }
    }

    return associationBeanList.toArray(new AssociationBean[associationBeanList.size()]);
  }
}

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

private void addDefaultAttributeToAssociations(final GovernanceArtifact artifact) throws GovernanceException {
  try {
    if(mediaType.equals("application/vnd.wso2-soap-service+xml")) {
      Association[] associations = registry.getAllAssociations(artifact.getPath());
      for(Association association : associations) {
        String destinationPath = association.getDestinationPath();
        if(destinationPath.contains("wsdl")) {
          String[] subPaths = destinationPath.split("/");
          final String artifactName = subPaths[subPaths.length - 1];
          GovernanceArtifact[] governanceArtifacts = searchArtifactsByGroupingAttribute(artifact, CommonConstants.WSDL_MEDIA_TYPE, artifactName);
          if(governanceArtifacts != null && governanceArtifacts.length == 0) {
            Resource wsdlResource = registry.get(destinationPath);
            wsdlResource.addProperty("default", "true");
            registry.put(destinationPath, wsdlResource);
          }
        }
      }
    }
  } catch(RegistryException ex) {
    log.error("An error occurred while retrieving association of the resource " + artifact.getPath(), ex);
  }
}

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

public void deleteStore(String keyStoreName) throws SecurityConfigException {
  try {
    String keyStoreNameTrim = keyStoreName.trim();
    if (keyStoreName == null || keyStoreNameTrim.length() == 0) {
      throw new SecurityConfigException("Key Store name can't be null");
    }
    if (KeyStoreUtil.isPrimaryStore(keyStoreName)) {
      throw new SecurityConfigException("Not allowed to delete the primary key store : "
          + keyStoreName);
    }
    String path = SecurityConstants.KEY_STORES + "/" + keyStoreName;
    boolean isFound = false;
    Association[] assocs = registry.getAllAssociations(path);
    if (assocs.length > 0) {
      isFound = true;
    }
    if (isFound) {
      throw new SecurityConfigException("Key store : " + keyStoreName +
          " is already in use and can't be deleted");
    }
    registry.delete(path);
  } catch (RegistryException e) {
    String msg = "Error when deleting a keyStore";
    log.error(msg, e);
    throw new SecurityConfigException(msg, e);
  }
}

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

private static void removeEndpointDependencies(String servicePath, Registry registry) throws RegistryException {
  // update lock check removed from for loop to prevent the database lock
    Association[] associations = registry.getAllAssociations(servicePath);
    for (Association association : associations) {
      String path = association.getDestinationPath();
      if (registry.resourceExists(path)) {
        Resource endpointResource = registry.get(path);
        if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(endpointResource.getMediaType())) {
          registry.removeAssociation(servicePath, path, CommonConstants.DEPENDS);
          registry.removeAssociation(path, servicePath, CommonConstants.USED_BY);
        }
      }
    }
}

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

public static void copyAssociations(Registry registry, String newPath, String path) throws RegistryException {
  Association[] associations = registry.getAllAssociations(path);
  for (Association association : associations) {
    if (!association.getAssociationType().equals(CommonConstants.DEPENDS)) {
      if (association.getSourcePath().equals(path)) {
        registry.addAssociation(newPath,
            association.getDestinationPath(), association.getAssociationType());
      } else {
        registry.addAssociation(association.getSourcePath(), newPath,
            association.getAssociationType());
      }
    }
  }
}

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

try {
  for (Map.Entry<String, String> entry : oldPathNewPathMap.entrySet()) {
    Association[] associations = registry.getAllAssociations(entry.getValue());
    for (Association association : associations) {
      if (!(oldPathNewPathMap.containsValue(association.getSourcePath()))
    Association[] associations = registry.getAllAssociations(keyValueSet.getKey());
    for (Association association : associations) {
      if (oldPathNewPathMap.containsKey(association.getDestinationPath())

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

public void deleteStore(String keyStoreName) throws SecurityConfigException {
  try {
    if (StringUtils.isBlank(keyStoreName)) {
      throw new SecurityConfigException("Key Store name can't be null");
    }
    if (KeyStoreUtil.isPrimaryStore(keyStoreName)) {
      throw new SecurityConfigException("Not allowed to delete the primary key store : "
          + keyStoreName);
    }
    if (isTrustStore(keyStoreName)) {
      throw new SecurityConfigException("Not allowed to delete the trust store : "
          + keyStoreName);
    }
    String path = SecurityConstants.KEY_STORES + "/" + keyStoreName;
    boolean isFound = false;
    Association[] assocs = registry.getAllAssociations(path);
    if (assocs.length > 0) {
      isFound = true;
    }
    if (isFound) {
      throw new SecurityConfigException("Key store : " + keyStoreName +
          " is already in use and can't be deleted");
    }
    registry.delete(path);
  } catch (RegistryException e) {
    String msg = "Error when deleting a keyStore";
    log.error(msg, e);
    throw new SecurityConfigException(msg, e);
  }
}

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

public void deleteStore(String keyStoreName) throws SecurityConfigException {
  try {
    if (StringUtils.isBlank(keyStoreName)) {
      throw new SecurityConfigException("Key Store name can't be null");
    }
    if (KeyStoreUtil.isPrimaryStore(keyStoreName)) {
      throw new SecurityConfigException("Not allowed to delete the primary key store : "
          + keyStoreName);
    }
    if (isTrustStore(keyStoreName)) {
      throw new SecurityConfigException("Not allowed to delete the trust store : "
          + keyStoreName);
    }
    String path = SecurityConstants.KEY_STORES + "/" + keyStoreName;
    boolean isFound = false;
    Association[] assocs = registry.getAllAssociations(path);
    if (assocs.length > 0) {
      isFound = true;
    }
    if (isFound) {
      throw new SecurityConfigException("Key store : " + keyStoreName +
          " is already in use and can't be deleted");
    }
    registry.delete(path);
  } catch (RegistryException e) {
    String msg = "Error when deleting a keyStore";
    log.error(msg, e);
    throw new SecurityConfigException(msg, e);
  }
}

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

/**
 * Save associations to the registry if they do not exist.
 * Execution time could be improved if registry provides a better way to check existing associations.
 *
 * @throws RegistryException Thrown in case a association cannot be saved
 */
private void saveAssociations() throws RegistryException {
  // until registry provides a functionality to check existing associations, this method will consume a LOT of time
  for (Association association : associations) {
    boolean isAssociationExist = false;
    Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath());
    if (existingAssociations != null) {
      for (Association currentAssociation : existingAssociations) {
        if (currentAssociation.getDestinationPath().equals(association.getDestinationPath()) &&
            currentAssociation.getAssociationType().equals(association.getAssociationType())) {
          isAssociationExist = true;
          break;
        }
      }
    }
    if (!isAssociationExist) {
      registry.addAssociation(association.getSourcePath(),
          association.getDestinationPath(),
          association.getAssociationType());
    }
  }
}

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

/**
 * Save associations to the registry if they do not exist.
 * Execution time could be improved if registry provides a better way to check existing associations.
 *
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException Thrown in case a association cannot be saved
 */
private void saveAssociations() throws RegistryException {
  // until registry provides a functionality to check existing associations, this method will consume a LOT of time
  for (Association association : associations) {
    boolean isAssociationExist = false;
    Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath());
    if (existingAssociations != null) {
      for (Association currentAssociation : existingAssociations) {
        if (currentAssociation.getDestinationPath().equals(association.getDestinationPath()) &&
            currentAssociation.getAssociationType().equals(association.getAssociationType())) {
          isAssociationExist = true;
          break;
        }
      }
    }
    if (!isAssociationExist) {
      registry.addAssociation(association.getSourcePath(),
          association.getDestinationPath(),
          association.getAssociationType());
    }
  }
}

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

Association[] associations = registry.getAllAssociations(resourcePath.getPath());
for (Association association : associations) {
  associatedRes.add(association.getDestinationPath());
  Association[] allAssociations = registry.getAllAssociations(path);
  for (Association association : allAssociations) {
    allAssociatedRes.add(association.getDestinationPath());

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

try {
  Association[] associations =
      requestContext.getRegistry().getAllAssociations(requestContext.getResource().getPath());
  if (associations != null && associations.length != 0) {
    for (Association association : associations) {

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

try {
  Association[] associations =
      requestContext.getRegistry().getAllAssociations(requestContext.getResource().getPath());
  if (associations != null && associations.length != 0) {
    for (Association association : associations) {

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

Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath());
if (existingAssociations != null) {
  for (Association currentAssociation: existingAssociations) {

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

Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath());
if (existingAssociations != null) {
  for (Association currentAssociation: existingAssociations) {

相关文章