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()]); }
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); } }
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.USED_BY); for (Association association : associations) { String destinationPath = association.getDestinationPath();
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.DEPENDS); for (Association association : associations) { String destinationPath = association.getDestinationPath();
/** * 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()]); }
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.DEPENDS); for (Association association : associations) { String destinationPath = association.getDestinationPath();
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.DEPENDS); for (Association association : associations) { String destinationPath = association.getDestinationPath();
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.DEPENDS); for (Association association : associations) { String destinationPath = association.getDestinationPath();
try { Association[] associations = registry.getAssociations(path, GovernanceConstants.DEPENDS); for (Association association : associations) { String destinationPath = association.getDestinationPath();
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) {
Association[] openIDAssociations = registry.getAssociations( RegistryConstants.PROFILES_PATH + username, IdentityRegistryResources.ASSOCIATION_USER_OPENID);
Association[] openIDAssociations = registry.getAssociations( RegistryConstants.PROFILES_PATH + username, IdentityRegistryResources.ASSOCIATION_USER_OPENID);
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); } } } } } } }
Association[] associations = registry.getAssociations(oldWSDL, CommonConstants.DEPENDS); for (Association association: associations) { String targetPath = association.getDestinationPath();
providerId; GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry, appType); Association[] associations = registry.getAssociations(providerPath, AppMConstants.PROVIDER_ASSOCIATION); for (Association association : associations) {
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; }
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); }
Association[] dependencies = registry.getAssociations(schemaPath, CommonConstants.DEPENDS); for(Association dependency : dependencies) { if(dependency.getSourcePath().equals(schemaPath)) {
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); }
String apiResourcePath = AppManagerUtil.getAPIPath(appId); try { Association[] docAssociations = registry.getAssociations(apiResourcePath, AppMConstants.DOCUMENTATION_ASSOCIATION); for (Association association : docAssociations) {