本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils.getRelativePath方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils.getRelativePath方法的具体用法?Java RegistryUtils.getRelativePath怎么用?Java RegistryUtils.getRelativePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.utils.RegistryUtils
的用法示例。
在下文中一共展示了RegistryUtils.getRelativePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLink
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void createLink(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String parentPath = RegistryUtils.getParentPath(relativePath);
String target = requestContext.getTargetPath();
String relativeTarget = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
target);
RegistryEvent<String> event = new CollectionUpdatedEvent<String>("A link to " + relativeTarget +
" was created at " + relativePath + ".");
event.setParameter("Destination", relativeTarget);
event.setParameter("SymbolicLink", relativePath);
event.setParameter("RegistryOperation", "createLink");
((CollectionUpdatedEvent)event).setResourcePath(parentPath);
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), parentPath);
} catch (Exception e) {
handleException("Unable to send notification for Create Link Operation", e);
}
}
示例2: removeLink
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void removeLink(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String parentPath = RegistryUtils.getParentPath(relativePath);
RegistryEvent<String> event = new CollectionUpdatedEvent<String>("The link at " + relativePath + " was removed.");
((CollectionUpdatedEvent)event).setResourcePath(parentPath);
event.setParameter("SymbolicLink", relativePath);
event.setParameter("RegistryOperation", "removeLink");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), parentPath);
} catch (Exception e) {
handleException("Unable to send notification for Remove Link Operation", e);
}
}
示例3: restore
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void restore(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
boolean isNotCollection = !(requestContext.getResource() instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>(
"The resource at path " + relativePath + " was restored.");
((ResourceUpdatedEvent) event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>(
"The collection at path " + relativePath + " was restored.");
((CollectionUpdatedEvent) event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "restore");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Restore Operation", e);
}
}
示例4: saveResource
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private void saveResource(RequestContext context, String url, String path, Resource resource,
boolean isWSDL)
throws RegistryException {
log.trace("Started saving resource");
String artifactId = resource.getUUID();
if (artifactId == null) {
// generate a service id
artifactId = UUID.randomUUID().toString();
resource.setUUID(artifactId);
}
// if (systemRegistry != null) {
// CommonUtil.addGovernanceArtifactEntryWithAbsoluteValues(systemRegistry, artifactId, path);
// }
String relativeArtifactPath = RegistryUtils.getRelativePath(registry.getRegistryContext(), path);
// adn then get the relative path to the GOVERNANCE_BASE_PATH
relativeArtifactPath = RegistryUtils.getRelativePathToOriginal(relativeArtifactPath,
RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
/* This property will be used in ServiceMediatype handler to recognize that particular service addition is
initialized due to wsdl addition
*/
resource.setProperty("registry.DefinitionImport","true");
if (!isWSDL) {
registry.put(path, resource);
} else {
addWSDLToRegistry(context, path, url, resource, registry);
}
// if (!(resource instanceof Collection) &&
// ((ResourceImpl) resource).isVersionableChange()) {
// registry.createVersion(path);
// }
((ResourceImpl)resource).setPath(relativeArtifactPath);
log.trace("Finished saving resource");
}
示例5: saveToRepositorySafely
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* Saves the resource iff the resource is not already existing in the repository
* @param path: resource path
* @param resource: resource object
* @throws RegistryException
*/
private void saveToRepositorySafely(RequestContext context, String url, String path,
Resource resource) throws RegistryException {
String schemaId = resource.getUUID();
if (schemaId == null) {
// generate a service id
schemaId = UUID.randomUUID().toString();
resource.setUUID(schemaId);
}
// if (systemRegistry != null) {
// CommonUtil.addGovernanceArtifactEntryWithAbsoluteValues(systemRegistry, schemaId, path);
// }
if (!registry.resourceExists(path)) {
addSchemaToRegistry(context, path, url, resource, registry);
} else {
log.debug("A Resource already exists at given location. Overwriting resource content.");
addSchemaToRegistry(context, path, url, resource, registry);
}
// if (!(resource instanceof Collection) &&
// ((ResourceImpl) resource).isVersionableChange()) {
// registry.createVersion(path);
// }
String relativeArtifactPath = RegistryUtils.getRelativePath(registry.getRegistryContext(), path);
// adn then get the relative path to the GOVERNANCE_BASE_PATH
relativeArtifactPath = RegistryUtils.getRelativePathToOriginal(relativeArtifactPath,
RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
((ResourceImpl)resource).setPath(relativeArtifactPath);
}
示例6: put
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void put(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
boolean isNotCollection = !(requestContext.getResource() instanceof Collection);
Resource resource = requestContext.getOldResource();
RegistryEvent<String> event;
if (resource == null) {
if (isNotCollection) {
event = new ResourceAddedEvent<String>("A resource was added at Path: " + relativePath);
((ResourceAddedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionAddedEvent<String>("A collection was added at Path: " + relativePath);
((CollectionAddedEvent)event).setResourcePath(relativePath);
}
event.setTenantId(CurrentSession.getCallerTenantId());
} else {
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("The resource at path " + relativePath + " was updated.");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("The collection at path " + relativePath + " was updated.");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "put");
event.setTenantId(CurrentSession.getCallerTenantId());
}
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Put Operation", e);
}
}
示例7: createVersion
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void createVersion(RequestContext requestContext) throws RegistryException {
boolean isMountPath = false;
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("A Checkpoint was created for the resource at path " +
relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("A Checkpoint was created for the collection at path " +
relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "createVersion");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Create Version Operation", e);
}
}
示例8: applyTag
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void applyTag(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String tag = requestContext.getTag();
boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("The tag " + tag +
" was applied on resource " + relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("The tag " + tag +
" was applied on resource " + relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "applyTag");
event.setParameter("TagsAdded", tag);
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Apply Tag Operation", e);
}
}
示例9: removeTag
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void removeTag(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String tag = requestContext.getTag();
boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("An attempt was made to remove the tag " +
tag + ", applied on resource " + relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("An attempt was made to remove the tag " +
tag + ", applied on collection " + relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "removeTag");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Remove Tag Operation", e);
}
}
示例10: addComment
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String addComment(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return null;
}
if (requestContext.getComment() == null) {
return null;
}
String comment = requestContext.getComment().getText();
boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("A comment was added to the resource at " +
relativePath + ". Comment: " + comment);
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("A comment was added to the collection at " +
relativePath + ". Comment: " + comment);
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "addComment");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Add Comment Operation", e);
}
return null;
}
示例11: rateResource
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void rateResource(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
int rating = requestContext.getRating();
boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection);
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("A rating of " + Integer.toString(rating) +
" was given to the resource at " + relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("A rating of " + Integer.toString(rating) +
" was given to the collection at " + relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "rateResource");
event.setParameter("Rating", Integer.toString(rating));
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Rate Resource Operation", e);
}
}
示例12: addAssociation
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void addAssociation(RequestContext requestContext) throws RegistryException {
String path = getPathWithoutVersion(requestContext.getSourcePath());
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String targetPath = getPathWithoutVersion(requestContext.getTargetPath());
String relativeTargetPath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
targetPath);
String type = requestContext.getAssociationType();
String targetType;
boolean isNotCollection = true;
if (requestContext.getRepository().get(targetPath) == null) {
return;
} else if (!(requestContext.getRepository().get(targetPath) instanceof Collection)) {
targetType = "resource";
} else {
targetType = "collection";
isNotCollection = false;
}
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("An association of type " + type + " to the " + targetType +
" at " + relativeTargetPath + " was added to the resource at " + relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("An association of type " + type + " to the " + targetType +
" at " + relativeTargetPath + " was added to the collection at " + relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "addAssociation");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Add Association Operation", e);
}
}
示例13: removeAssociation
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void removeAssociation(RequestContext requestContext) throws RegistryException {
String path = getPathWithoutVersion(requestContext.getSourcePath());
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String targetPath = getPathWithoutVersion(requestContext.getTargetPath());
String relativeTargetPath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
targetPath);
String type = requestContext.getAssociationType();
String targetType;
boolean isNotCollection = true;
if (requestContext.getRepository().get(targetPath) == null) {
return;
} else if (!(requestContext.getRepository().get(targetPath) instanceof Collection)) {
targetType = "resource";
} else {
targetType = "collection";
isNotCollection = false;
}
RegistryEvent<String> event;
if (isNotCollection) {
event = new ResourceUpdatedEvent<String>("The association of type " + type + " to the " + targetType +
" at " + relativeTargetPath + " was removed from the resource at " + relativePath + ".");
((ResourceUpdatedEvent)event).setResourcePath(relativePath);
} else {
event = new CollectionUpdatedEvent<String>("The association of type " + type + " to the " + targetType +
" at " + relativeTargetPath + " was removed from the collection at " + relativePath + ".");
((CollectionUpdatedEvent)event).setResourcePath(relativePath);
}
event.setParameter("RegistryOperation", "removeAssociation");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), relativePath);
} catch (Exception e) {
handleException("Unable to send notification for Remove Association Operation", e);
}
}
示例14: saveToRepositorySafely
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* Saves the resource iff the resource is not already existing in the repository
*
* @param url url of the resource
* @param path: resource path
* @param resource: resource object
* @param isMasterSchema Whether master schema or not
*
* @throws org.wso2.carbon.registry.core.exceptions.RegistryException if the operation fails
*/
private void saveToRepositorySafely(String url, String path,
Resource resource, boolean isMasterSchema) throws RegistryException {
String schemaId = resource.getUUID();
if (schemaId == null) {
// generate a service id
schemaId = UUID.randomUUID().toString();
resource.setUUID(schemaId);
}
// if (systemRegistry != null) {
// CommonUtil.addGovernanceArtifactEntryWithAbsoluteValues(systemRegistry, schemaId, path);
// }
if (registry.resourceExists(path)) {
log.debug("A Resource already exists at given location. Overwriting resource content.");
}
addSchemaToRegistry(path, url, resource, registry, isMasterSchema);
// if (!(resource instanceof Collection) &&
// ((ResourceImpl) resource).isVersionableChange()) {
// registry.createVersion(path);
// }
String relativeArtifactPath = RegistryUtils.getRelativePath(registry.getRegistryContext(), path);
// adn then get the relative path to the GOVERNANCE_BASE_PATH
relativeArtifactPath = RegistryUtils.getRelativePathToOriginal(relativeArtifactPath,
RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
((ResourceImpl)resource).setPath(relativeArtifactPath);
}
示例15: delete
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void delete(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String parentPath = RegistryUtils.getParentPath(relativePath);
boolean isNotCollection = !(requestContext.getResource() instanceof Collection);
RegistryEvent<String> childDeletedEvent;
RegistryEvent<String> parentEvent;
RegistryEvent<String> event;
if (isNotCollection) {
childDeletedEvent = new ChildDeletedEvent<String>("A resource was removed from the collection " +
parentPath + " at Path: " + relativePath);
((ChildDeletedEvent)childDeletedEvent).setResourcePath(parentPath);
childDeletedEvent.setParameter("ChildPath", relativePath);
event = new ResourceDeletedEvent<String>("A resource at path " + relativePath + " was deleted.");
((ResourceDeletedEvent)event).setResourcePath(relativePath);
} else {
childDeletedEvent = new ChildDeletedEvent<String>("A collection was removed from the collection " +
parentPath + " at Path: " + relativePath);
((ChildDeletedEvent)childDeletedEvent).setResourcePath(parentPath);
childDeletedEvent.setParameter("ChildPath", relativePath);
event = new CollectionDeletedEvent<String>("A collection at path " + relativePath + " was deleted.");
((CollectionDeletedEvent)event).setResourcePath(relativePath);
}
childDeletedEvent.setTenantId(CurrentSession.getCallerTenantId());
event.setTenantId(CurrentSession.getCallerTenantId());
parentEvent = new CollectionUpdatedEvent<String>("The collection at path " + parentPath + " was updated.");
((CollectionUpdatedEvent)parentEvent).setResourcePath(parentPath);
parentEvent.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(childDeletedEvent, requestContext.getRegistry(), parentPath);
notify(event, requestContext.getRegistry(), relativePath);
notify(parentEvent, requestContext.getRegistry(), parentPath);
} catch (Exception e) {
handleException("Unable to send notification for Delete Operation", e);
}
}