本文整理了Java中org.wso2.carbon.registry.core.Registry.addAssociation
方法的一些代码示例,展示了Registry.addAssociation
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.addAssociation
方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Registry
类名称:Registry
方法名:addAssociation
暂无
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions
private void addDependency(String source, String target) throws RegistryException {
registry.addAssociation(source, target, CommonConstants.DEPENDS);
registry.addAssociation(target, source, CommonConstants.USED_BY);
}
}
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
/**
* Adds associations for a given source and target
*
* @param registry registry.
* @param source source path.
* @param target target path.
* @throws RegistryException If fails to add a dependency.
*/
public static void addDependency(Registry registry, String source, String target) throws RegistryException {
registry.addAssociation(source, target, CommonConstants.DEPENDS);
registry.addAssociation(target, source, CommonConstants.USED_BY);
}
代码示例来源: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.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.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
@Override
public void addBidirectionalAssociation(String forwardType, String backwardType,
GovernanceArtifact attachedToArtifact) throws GovernanceException {
checkRegistryResourceAssociation();
// uses the path from the getter to make sure the used overloaded method
String path = getPath();
String attachedToArtifactPath = attachedToArtifact.getPath();
if (attachedToArtifactPath == null) {
String msg = "'Attached to artifact' is not associated with a registry path.";
log.error(msg);
throw new GovernanceException(msg);
}
try {
registry.addAssociation(path, attachedToArtifactPath, forwardType);
registry.addAssociation(attachedToArtifactPath, path, backwardType);
} catch (RegistryException e) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Error in attaching the artifact. source id: ")
.append(id)
.append(", path: ")
.append(path)
.append(", target id: ")
.append(attachedToArtifact.getId())
.append(", path:")
.append(attachedToArtifactPath)
.append(", attachment type: ")
.append(attachedToArtifact.getClass().getName());
throw new GovernanceException(stringBuilder.toString(), e);
}
}
代码示例来源: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.api
@Override
public void addAssociation(String associationType, GovernanceArtifact attachedToArtifact)
throws GovernanceException {
checkRegistryResourceAssociation();
// uses the path from the getter to make sure the used overloaded method
String path = getPath();
String attachedToArtifactPath = attachedToArtifact.getPath();
if (attachedToArtifactPath == null) {
String msg = "'Attached to artifact' is not associated with a registry path.";
log.error(msg);
throw new GovernanceException(msg);
}
try {
registry.addAssociation(path, attachedToArtifactPath, associationType);
} catch (RegistryException e) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Error in attaching the artifact. source id: ")
.append(id)
.append(", path: ")
.append(path)
.append(", target id: ")
.append(attachedToArtifact.getId())
.append(", path:")
.append(attachedToArtifactPath)
.append(", attachment type: ")
.append(attachedToArtifact.getClass().getName());
throw new GovernanceException(stringBuilder.toString(), e);
} }
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.api
/**
* Attach the current artifact to an another artifact. Both the artifacts should be saved,
* before calling this method. This method will two generic artifact types. There are specific
* methods
*
* @param attachedToArtifact the artifact the current artifact is attached to
* @throws GovernanceException throws if the operation failed.
*/
public void attach(GovernanceArtifact attachedToArtifact) throws GovernanceException {
checkRegistryResourceAssociation();
// uses the path from the getter to make sure the used overloaded method
String path = getPath();
String attachedToArtifactPath = attachedToArtifact.getPath();
if (attachedToArtifactPath == null) {
String msg = "'Attached to artifact' is not associated with a registry path.";
log.error(msg);
throw new GovernanceException(msg);
}
try {
registry.addAssociation(attachedToArtifactPath, path, GovernanceConstants.USED_BY);
registry.addAssociation(path, attachedToArtifactPath, GovernanceConstants.DEPENDS);
} catch (RegistryException e) {
String msg = "Error in attaching the artifact. source id: " + id + ", path: " + path +
", target id: " + attachedToArtifact.getId() + ", path:" +
attachedToArtifactPath +
", attachment type: " + attachedToArtifact.getClass().getName() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
}
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.api
registry.addAssociation(params[0], params[1], params[2]);
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions
private void addPolicyImportys(RequestContext context, String version) throws RegistryException {
/* storing policyReferences in to Registry if available in the WSDL */
for (WSDLInfo wsdlInfo : wsdls.values()) {
if(wsdlInfo.isExistPolicyReferences()){
Iterator iter = wsdlInfo.getPolicyDependencies().iterator();
while(iter.hasNext()){
String policyURL = (String)iter.next();
boolean lockAlreadyAcquired = !CommonUtil.isUpdateLockAvailable();
CommonUtil.releaseUpdateLock();
try{
Resource policyResource = registry.newResource();
policyResource.setMediaType("application/policy+xml");
String path = policyURL.substring(policyURL.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1);
if(policyURL.lastIndexOf(RegistryConstants.PATH_SEPARATOR) > 0){
policyResource.setProperty("version", version);
policyResource.setProperties(copyProperties(context));
String policyPath = registry.importResource(path ,policyURL,policyResource);
registry.addAssociation(policyPath, wsdlInfo.getProposedRegistryURL(), CommonConstants.USED_BY);
registry.addAssociation(wsdlInfo.getProposedRegistryURL(), policyPath, CommonConstants.DEPENDS);
}
}finally {
if (lockAlreadyAcquired) {
CommonUtil.acquireUpdateLock();
}
}
}
}
}
}
代码示例来源: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.governance/org.wso2.carbon.governance.registry.extensions
if (oldPathNewPathMap.containsKey(association.getDestinationPath())
&& oldPathNewPathMap.containsKey(association.getSourcePath())) {
registry.addAssociation(
oldPathNewPathMap.get(association.getSourcePath())
, oldPathNewPathMap.get(association.getDestinationPath())
代码示例来源: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.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
/**
* 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.extensions
registry.addAssociation(association.getSourcePath(),
association.getDestinationPath(),
association.getAssociationType());
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions
private void addService(OMElement service, RequestContext context)throws RegistryException {
Resource resource = registry.newResource();
String tempNamespace = CommonUtil.derivePathFragmentFromNamespace(
CommonUtil.getServiceNamespace(service));
String path = getChrootedServiceLocation(registry, context.getRegistryContext()) + tempNamespace +
CommonUtil.getServiceName(service);
String artifactId = UUID.randomUUID().toString();
resource.setUUID(artifactId);
String content = service.toString();
resource.setContent(RegistryUtils.encodeString(content));
resource.setMediaType(RegistryConstants.SERVICE_MEDIA_TYPE);
// when saving the resource we are expecting to call the service media type handler, so
// we intentionally release the lock here.
boolean lockAlreadyAcquired = !CommonUtil.isUpdateLockAvailable();
CommonUtil.releaseUpdateLock();
try {
registry.put(path, resource);
} finally {
if (lockAlreadyAcquired) {
CommonUtil.acquireUpdateLock();
}
}
registry.addAssociation(path, RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
CommonUtil.getDefinitionURL(service)), CommonConstants.DEPENDS);
registry.addAssociation(RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
CommonUtil.getDefinitionURL(service)),path, CommonConstants.USED_BY);
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl
String apiPath = AppManagerUtil.getAPIPath(apiId);
registry.addAssociation(apiPath, artifact.getPath(),
AppMConstants.DOCUMENTATION_ASSOCIATION);
String[] authorizedRoles=getAuthorizedRoles(apiPath);
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl
private String saveWebAppRegistryArtifact(WebApp webApp) throws RegistryException, AppManagementException {
String artifactId = null;
GenericArtifactManager artifactManager = getArtifactManager(registry, AppMConstants.WEBAPP_ASSET_TYPE);
GenericArtifact appArtifact = buildRegistryArtifact(artifactManager, AppMConstants.WEBAPP_ASSET_TYPE, webApp);
artifactManager.addGenericArtifact(appArtifact);
artifactId = appArtifact.getId();
// Set the life cycle for the persisted artifact
GenericArtifact persistedArtifact = artifactManager.getGenericArtifact(artifactId);
persistedArtifact.invokeAction(AppMConstants.LifecycleActions.CREATE, AppMConstants.WEBAPP_LIFE_CYCLE);
// Apply tags
String artifactPath = GovernanceUtils.getArtifactPath(registry, artifactId);
if (webApp.getTags() != null) {
for (String tag : webApp.getTags()) {
registry.applyTag(artifactPath, tag);
}
}
// Set resources permissions based on app visibility.
if (webApp.getAppVisibility() != null) {
AppManagerUtil.setResourcePermissions(webApp.getId().getProviderName(), AppMConstants.API_RESTRICTED_VISIBILITY, webApp.getAppVisibility(), artifactPath);
}
// Add registry associations.
String providerPath = AppManagerUtil.getAPIProviderPath(webApp.getId());
registry.addAssociation(providerPath, artifactPath, AppMConstants.PROVIDER_ASSOCIATION);
return artifactId;
}
内容来源于网络,如有侵权,请联系作者删除!