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

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

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

Registry.getAssociations介绍

暂无

代码示例

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

private static Association[] getDependenciesRecursively(Registry registry, String resourcePath, List<String> traversedDependencyPaths)
    throws RegistryException {
  List<Association> dependencies = new ArrayList<Association>();
  if (!traversedDependencyPaths.contains(resourcePath)) {
    traversedDependencyPaths.add(resourcePath);
    List<Association> tempDependencies =
        Arrays.asList(registry.getAssociations(resourcePath, CommonConstants.DEPENDS));
    for (Association association : tempDependencies) {
      if (!traversedDependencyPaths.contains(association.getDestinationPath())) {
        dependencies.add(association);
        List<Association> childDependencies = Arrays.asList(
            getDependenciesRecursively(
                registry, association.getDestinationPath(), traversedDependencyPaths)
        );
        if (!childDependencies.isEmpty()) {
          dependencies.addAll(childDependencies);
        }
      }
    }
  }
  return dependencies.toArray(new Association[dependencies.size()]);
}

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

public void checkEndpointDependency(Registry registry, String path) throws RegistryException {
  // here we are getting the associations for the endpoint.
  Association[] endpointDependents = registry.getAssociations(path, CommonConstants.USED_BY);
  // for each endpoint we are checking what the resource type is, if it is service, we check the
  // endpoint service, if it is wsdl, we check the wsdl
  List<String> dependents = new ArrayList<String>();
  for (Association endpointDependent: endpointDependents) {
    String targetPath = endpointDependent.getDestinationPath();
    if (registry.resourceExists(targetPath)) {
      Resource targetResource = registry.get(targetPath);
      String mediaType = targetResource.getMediaType();
      if (CommonConstants.WSDL_MEDIA_TYPE.equals(mediaType)) {
        // so there are dependencies for wsdl media
        dependents.add(targetPath);
      } else if ((CommonConstants.SERVICE_MEDIA_TYPE.equals(mediaType) ||
            CommonConstants.SOAP_SERVICE_MEDIA_TYPE.equals(mediaType))) {
        dependents.add(targetPath);
      }
    }
  }
  if (dependents.size() > 0) {
    // so there are dependencies, we are not allowing to delete endpoints if there are dependents
    String msg = "Error in deleting the endpoint resource. Please make sure detach the associations " +
        "to the services and wsdls manually before deleting the endpoint. " +
        "endpoint path: " + path + ".";
    log.error(msg);
    throw new RegistryException(msg);
  }
}

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.USED_BY);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.DEPENDS);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

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

/**
 * Method to retrieve all WSDLs attached to this service artifact.
 *
 * @return all WSDLs attached to this service artifact.
 * @throws GovernanceException if the operation failed.
 */
@Override
public Wsdl[] getAttachedWsdls() throws GovernanceException {
  checkRegistryResourceAssociation();
  Registry registry = getAssociatedRegistry();
  String path = getPath();
  List<Wsdl> wsdls = new ArrayList<Wsdl>();
  try {
    Association[] associations =
        registry.getAssociations(path, GovernanceConstants.DEPENDS);
    for (Association association : associations) {
      String destinationPath = association.getDestinationPath();
      GovernanceArtifact governanceArtifact =
          GovernanceUtils.retrieveGovernanceArtifactByPath(registry, destinationPath);
      if (governanceArtifact instanceof WsdlImpl) {
        wsdls.add((Wsdl) governanceArtifact);
      }
    }
  } catch (RegistryException e) {
    String msg = "Error in getting attached wsdls from the artifact at path: " + path + ".";
    log.error(msg, e);
    throw new GovernanceException(msg, e);
  }
  return wsdls.toArray(new Wsdl[wsdls.size()]);
}

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.DEPENDS);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.DEPENDS);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.DEPENDS);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

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

try {
  Association[] associations =
      registry.getAssociations(path, GovernanceConstants.DEPENDS);
  for (Association association : associations) {
    String destinationPath = association.getDestinationPath();

代码示例来源:origin: org.wso2.greg/org.wso2.carbon.governance.samples.shutterbug

THUMBNAIL_PATH + RegistryConstants.PATH_SEPARATOR + thumnailName);
Association[] associations = registry.getAssociations(resourcePath,
    ASSOCIATION_TYPE_USED_BY);
if (associations != null && associations.length != 0) {
Association[] thumbnailAssociations = registry.getAssociations(resourcePath,
    ASSOCIATION_TYPE_THUMBNAIL);
if (thumbnailAssociations != null && thumbnailAssociations.length != 0) {

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

Association[] openIDAssociations = registry.getAssociations(
    RegistryConstants.PROFILES_PATH + username,
    IdentityRegistryResources.ASSOCIATION_USER_OPENID);

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

Association[] openIDAssociations = registry.getAssociations(
    RegistryConstants.PROFILES_PATH + username,
    IdentityRegistryResources.ASSOCIATION_USER_OPENID);

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

private static void addAssociations(String servicePath, Registry registry) throws RegistryException {
  Association[] associations = registry.getAssociations(servicePath, CommonConstants.DEPENDS);
  for (Association association: associations) {
    String targetPath = association.getDestinationPath();
    if (registry.resourceExists(targetPath)) {
      Resource targetResource = registry.get(targetPath);
      if (CommonConstants.WSDL_MEDIA_TYPE.equals(targetResource.getMediaType())) {
        // for the wsdl, we are getting all the endpoints
        Association[] wsdlAssociations = registry.getAssociations(targetPath,
            CommonConstants.DEPENDS);
        for (Association wsdlAssociation: wsdlAssociations) {
          String wsdlTargetPath = wsdlAssociation.getDestinationPath();
          if (registry.resourceExists(wsdlTargetPath)) {
            Resource wsdlTargetResource = registry.get(wsdlTargetPath);
            if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(
                wsdlTargetResource.getMediaType())) {
              // so it is the wsdl associated to endpoints,
              // so we associate these endpoints to the services as well.
              registry.addAssociation(servicePath, wsdlTargetPath,
                  CommonConstants.DEPENDS);
              registry.addAssociation(wsdlTargetPath, servicePath,
                  CommonConstants.USED_BY);
            }
          }
        }
      }
    }
  }
}

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

Association[] associations = registry.getAssociations(oldWSDL, CommonConstants.DEPENDS);
for (Association association: associations) {
  String targetPath = association.getDestinationPath();

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

providerId;
GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry, appType);
Association[] associations = registry.getAssociations(providerPath,
                           AppMConstants.PROVIDER_ASSOCIATION);
for (Association association : associations) {

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

private OMElement  setEndpoint(Registry registry, String definitionURL, OMElement serviceInfoElement)  throws RegistryException {
  Association[] associations = registry.getAssociations(definitionURL, CommonConstants.DEPENDS);
  for (Association association: associations) {
    String targetPath = association.getDestinationPath();
    if (registry.resourceExists(targetPath)) {
      Resource targetResource = registry.get(targetPath);
      if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(targetResource.getMediaType())) {
        byte[] sourceContent = (byte[]) targetResource.getContent();
        if (sourceContent == null) {
          return serviceInfoElement;
        }
        String endpointUrl = EndpointUtils.deriveEndpointFromContent(RegistryUtils.decodeBytes(sourceContent));
        try {
          serviceInfoElement = EndpointUtils.addEndpointToService(serviceInfoElement, endpointUrl, "");
        } catch (RegistryException e){}
      }
    }
  }
  return serviceInfoElement;
}

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

public void invoke(RequestContext context, String action) throws RegistryException {
  String value;
  if ("approve".equals(action)) {
    value = "approved";
  } else if ("reject".equals(action)) {
    value = "rejected";
  } else {
    throw new RegistryException("Not a valid action");
  }
  Registry registry = context.getRegistry();
  Association[] associations =
      registry.getAssociations(context.getResourcePath().getPath(), "original");
  if (associations == null) {
    throw new RegistryException("No original resource to approve");
  }
  final Resource resource = context.getRepository().get(associations[0].getDestinationPath());
  resource.setProperty("approval", value);
  context.getRepository().put(resource.getPath(), resource);
}

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

Association[] dependencies = registry.getAssociations(schemaPath, CommonConstants.DEPENDS);
for(Association dependency : dependencies) {
  if(dependency.getSourcePath().equals(schemaPath)) {

代码示例来源:origin: org.wso2.greg/org.wso2.carbon.governance.samples.shutterbug

public void addAssociation(RequestContext requestContext) throws RegistryException {
  String type = requestContext.getAssociationType();
  if (!type.equals(ASSOCIATION_TYPE_VOTED)) {
    log.debug("Non-voted association added to votes resource");
    return;
  }
  Registry registry = Utils.getRegistryService().getSystemRegistry();
  Resource shutterbugCollection = registry.get(shutterbugHome);
  String tenantUser = Utils.getTenantUser();
  String uuid = shutterbugCollection.getProperty(tenantUser);
  if (uuid == null) {
    throw new RegistryException("You need to upload an image before you vote");
  }
  String destination = requestContext.getTargetPath();
  if (!registry.resourceExists(destination)) {
    throw new RegistryException("Provided image path is invalid");    
  }
  String source = shutterbugHome + RegistryConstants.PATH_SEPARATOR + uuid +
      RegistryConstants.PATH_SEPARATOR + VOTE_PATH;
  Association[] associations = registry.getAssociations(source,
      ASSOCIATION_TYPE_VOTED);
  if (voteLimit < associations.length + 1) {
    throw new RegistryException("You have reached the vote limit of " + voteLimit);
  }
  registry.addAssociation(destination, source, ASSOCIATION_TYPE_USED_BY);
  registry.addAssociation(source, destination, ASSOCIATION_TYPE_VOTED);
  requestContext.setProcessingComplete(true);
}

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

String apiResourcePath = AppManagerUtil.getAPIPath(appId);
try {
  Association[] docAssociations = registry.getAssociations(apiResourcePath,
                               AppMConstants.DOCUMENTATION_ASSOCIATION);
  for (Association association : docAssociations) {

相关文章