本文整理了Java中org.wso2.carbon.registry.core.Association.getDestinationPath()
方法的一些代码示例,展示了Association.getDestinationPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association.getDestinationPath()
方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Association
类名称:Association
方法名:getDestinationPath
暂无
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.relations
public int compare(Association o1, Association o2) {
int result = RegistryUtils.getResourceName(o1.getDestinationPath()).
compareToIgnoreCase(
RegistryUtils.getResourceName(o2.getDestinationPath()));
if (result != 0) {
return result;
}
return o1.getDestinationPath().compareTo(o2.getDestinationPath());
}
});
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.resource
private static boolean isADependency(Association associationBean,UserRegistry registry,String scrPath,String COLLECTION) throws Exception {
if(associationBean.getDestinationPath() == null ||
(!registry.resourceExists(associationBean.getDestinationPath()))){
return false;
}
ResourceData resourceData = ContentUtil.getResourceData(new String[]{associationBean.getDestinationPath()}, registry)[0];
boolean isCollection = resourceData.getResourceType().equals(COLLECTION);
return (associationBean.getAssociationType() != null && associationBean.getAssociationType().equals("depends")
&& associationBean.getSourcePath().equals(scrPath) && !isCollection);
}
代码示例来源: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
private void persistAssociations(Registry registry, List <Association> associations)
throws RegistryException {
Iterator <Association> associationIterator = associations.iterator();
while(associationIterator.hasNext()) {
Association association = associationIterator.next();
registry.addAssociation(association.getSourcePath(), association.getDestinationPath(),
association.getAssociationType());
}
}
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
public void persistAssociations() throws RegistryException {
Iterator<Association> associationIterator = associationsBuffer.iterator();
while (associationIterator.hasNext()) {
Association association = associationIterator.next();
registry.addAssociation(association.getSourcePath(), association.getDestinationPath(),
association.getAssociationType());
}
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.indexing
/**
* Method to set the resource Association types and destinations to IndexDocument attribute list.
*/
private void addAssociations() throws RegistryException {
// Add resource association types and destinations
Association[] associations;
try {
associations = registry.getAllAssociations(resourcePath);
} catch (RegistryException e) {
String message = "Error at IndexDocumentCreator when getting Registry Associations.";
log.error(message, e);
throw new RegistryException(message, e);
}
List<String> associationTypeList = new ArrayList<>();
List<String> associationDestinationList = new ArrayList<>();
if (associations != null && associations.length > 0) {
for (Association association : associations) {
associationTypeList.add(association.getAssociationType());
associationDestinationList.add(association.getDestinationPath());
}
if (associationTypeList.size() > 0) {
attributes.put(IndexingConstants.FIELD_ASSOCIATION_TYPES, associationTypeList);
}
if (associationDestinationList.size() > 0) {
attributes.put(IndexingConstants.FIELD_ASSOCIATION_DESTINATIONS, associationDestinationList);
}
}
}
代码示例来源: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.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.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.registry/org.wso2.carbon.registry.resource
private static void createDependencies(Association[] associations, UserRegistry registry, String zipDependencyPath,
String scrPath, String COLLECTION,String content,DataOutputStream srcOutputStream,boolean isMasterArtifact) throws Exception {
for (Association associationBean : associations) {
if (isADependency(associationBean, registry, scrPath, COLLECTION)) {
ContentDownloadBean dependencyBean = GetDownloadContentUtil.getContentDownloadBean(associationBean.getDestinationPath(), registry);
InputStream dependencyContentStream = dependencyBean.getContent().getInputStream();
File tmp = new File(zipDependencyPath + File.separator + dependencyBean.getResourceName());
DataOutputStream fos = new DataOutputStream(new FileOutputStream(tmp));
byte[] bytes = IOUtils.toByteArray(dependencyContentStream);
createDependencies(registry.getAssociations(associationBean.getDestinationPath(),"depends"),
registry,zipDependencyPath,associationBean.getDestinationPath(),COLLECTION,new String(bytes),fos,false);
}
}
if(scrPath.endsWith(".wsdl") || scrPath.endsWith(".xsd")) {
OMElement srcOMElement = AXIOMUtil.stringToOM(content);
updateSchemaImports(srcOMElement, isMasterArtifact, IMPORT_SCHEMA_LOCATION);
updateSchemaImports(srcOMElement, isMasterArtifact, INCLUDE_SCHEMA_LOCATION);
updateWSDLImports(srcOMElement,isMasterArtifact);
IOUtils.write(srcOMElement.toString().getBytes(), srcOutputStream);
} else {
IOUtils.write(content.getBytes(), srcOutputStream);
}
}
代码示例来源: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.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.governance/org.wso2.carbon.governance.api
registry.getAssociations(path, GovernanceConstants.DEPENDS);
for (Association association : associations) {
String destinationPath = association.getDestinationPath();
GovernanceArtifact governanceArtifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(registry, destinationPath);
代码示例来源: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
registry.getAssociations(path, GovernanceConstants.DEPENDS);
for (Association association : associations) {
String destinationPath = association.getDestinationPath();
GovernanceArtifact governanceArtifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(registry, destinationPath);
代码示例来源: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.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.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);
}
内容来源于网络,如有侵权,请联系作者删除!