public static Association[] getAssociations(Registry registry, String path) throws RegistryException { Association[] asso = registry.getAllAssociations(path); if (asso == null || asso.length == 0) { return asso;
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) {
for (Association association : registry.getAllAssociations(path)) { if (type.equals(association.getAssociationType()) && ((isSource && association.getSourcePath().equals(path)) ||
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()]); } }
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); } }
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); } }
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); } } } }
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()); } } } }
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())
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); } }
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); } }
/** * 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()); } } }
/** * 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()); } } }
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());
try { Association[] associations = requestContext.getRegistry().getAllAssociations(requestContext.getResource().getPath()); if (associations != null && associations.length != 0) { for (Association association : associations) {
try { Association[] associations = requestContext.getRegistry().getAllAssociations(requestContext.getResource().getPath()); if (associations != null && associations.length != 0) { for (Association association : associations) {
Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath()); if (existingAssociations != null) { for (Association currentAssociation: existingAssociations) {
Association[] existingAssociations = registry.getAllAssociations(association.getSourcePath()); if (existingAssociations != null) { for (Association currentAssociation: existingAssociations) {