当前位置: 首页>>代码示例>>Java>>正文


Java RegistryUtils.getParentPath方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils.getParentPath方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils.getParentPath方法的具体用法?Java RegistryUtils.getParentPath怎么用?Java RegistryUtils.getParentPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.core.utils.RegistryUtils的用法示例。


在下文中一共展示了RegistryUtils.getParentPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:26,代码来源:RegistryEventingHandler.java

示例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);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:RegistryEventingHandler.java

示例3: calculateAbsolutePath

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String calculateAbsolutePath(String wsdlPath, String targetPath) {
    // then only it is considered as relative.
    if (targetPath.startsWith("/") &&
            targetPath.startsWith("http://") && targetPath.startsWith("https://")) {
        return targetPath;
    }
    if (targetPath.startsWith("..") || targetPath.startsWith("./")) {
        if(targetPath.startsWith("./")){
            targetPath = targetPath.replaceFirst("./","/");
        }
        String wsdlCollection = RegistryUtils.getParentPath(wsdlPath);
        String targetCollection = RegistryUtils.getParentPath(targetPath);

        String[] targetPathParts = targetCollection.split("/");
        String[] currentPathParts = wsdlCollection.split("/");

        int countGoUpwardParts = 0;
        for (int i = 0; i < targetPathParts.length; i ++) {
            if (!targetPathParts[i].equals("..")) {
                break;
            }
            countGoUpwardParts++;
        }
        if (currentPathParts.length < countGoUpwardParts) {
            return null;
        }
        StringBuffer absolutePath = new StringBuffer();
        for (int i = 0; i < currentPathParts.length - countGoUpwardParts; i ++) {
            absolutePath.append(currentPathParts[i]).append("/");
        }

        for (int i = countGoUpwardParts; i < targetPathParts.length; i ++) {
            absolutePath.append(targetPathParts[i]).append("/");
        }
        targetPath = absolutePath.toString() + RegistryUtils.getResourceName(targetPath);
        return targetPath.replaceAll("//","/");
    }
    return targetPath;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:40,代码来源:TreeNodeBuilderUtil.java

示例4: putChild

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void putChild(RequestContext requestContext) throws RegistryException {
    Registry registry = requestContext.getRegistry();
    String thisCollectionPath = requestContext.getParentPath();
    String thisCollectionName = RegistryUtils.getResourceName(thisCollectionPath);
    String parentContainerPath = RegistryUtils.getParentPath(thisCollectionPath);
    Resource parentContainer = registry.get(parentContainerPath);

    if (thisCollectionName.equals(parentContainer.getProperty(
            CommonConstants.LATEST_VERSION_PROP_NAME))) {
        String resourcePath = requestContext.getResourcePath().getPath();
        String resourceName = RegistryUtils.getResourceName(resourcePath);
        registry.createLink(parentContainerPath + RegistryConstants.PATH_SEPARATOR +
                resourceName, resourcePath);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:16,代码来源:VersionedCollectionMediaTypeHandler.java

示例5: buildServiceVersionHierarchy

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private Map<String, Map<String, ServiceBean>> buildServiceVersionHierarchy(
        ServiceBean[] serviceBeans) {
    Map<String, Map<String, ServiceBean>> hierarchy =
            new LinkedHashMap<String, Map<String, ServiceBean>>();
    if (serviceBeans == null) {
        return hierarchy;
    }
    for (ServiceBean serviceBean : serviceBeans) {
        if (serviceBean != null) {
            String path = RegistryUtils.getParentPath(serviceBean.getPath());
            String version = RegistryUtils.getResourceName(path);
            if (!version.replace("-SNAPSHOT", "").matches("^\\d+[.]\\d+[.]\\d+$")) {
                version = "SNAPSHOT";
                serviceBean.setPath(serviceBean.getPath());
            } else {
                serviceBean.setPath(RegistryUtils.getParentPath(path));
            }
            Map<String, ServiceBean> versionMap;
            if (hierarchy.containsKey(serviceBean.getQName())) {
                versionMap = hierarchy.get(serviceBean.getQName());
            } else {
                versionMap = new LinkedHashMap<String, ServiceBean>();
                hierarchy.put(serviceBean.getQName(), versionMap);
            }
            versionMap.put(version, serviceBean);
        }
    }
    return hierarchy;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:30,代码来源:GovImpactAnalysisDataProcessor.java

示例6: importResource

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void importResource(RequestContext requestContext) throws RegistryException {
    if (!CommonUtil.isUpdateLockAvailable()) {
        return;
    }
    CommonUtil.acquireUpdateLock();
    try {
        String parentPath = RegistryUtils.getParentPath(requestContext.getResourcePath().getPath());
        String resourcePath = requestContext.getResourcePath().getCompletePath();

        String sourceURL = requestContext.getSourceURL();
        if (requestContext.getSourceURL() != null &&
                requestContext.getSourceURL().toLowerCase().startsWith("file:")) {
            String msg = "The source URL must not be file in the server's local file system";
            throw new RegistryException(msg);
        }
        WSDLValidationInfo validationInfo = null;
        try {
            if (!disableSchemaValidation) {
                validationInfo =
                        SchemaValidator.validate(new XMLInputSource(null, sourceURL, null));
            }
        } catch (Exception e) {
            throw new RegistryException("Exception occured while validating the schema", e);
        }

        String savedName = processSchemaImport(requestContext, resourcePath, validationInfo);

        if (parentPath.endsWith(RegistryConstants.PATH_SEPARATOR)) {
            requestContext.setActualPath(parentPath + RegistryUtils.getResourceName(savedName));
        } else {
            requestContext.setActualPath(parentPath + RegistryConstants.PATH_SEPARATOR +
                    RegistryUtils.getResourceName(savedName));
        }

        onPutCompleted(resourcePath,
                Collections.singletonMap(sourceURL, savedName),
                Collections.<String>emptyList(), requestContext);

        requestContext.setProcessingComplete(true);
    } finally {
        CommonUtil.releaseUpdateLock();
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:44,代码来源:XSDMediaTypeHandler.java

示例7: 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);
        }
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:42,代码来源:RegistryEventingHandler.java

示例8: putChild

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void putChild(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);
        String parentPath = RegistryUtils.getParentPath(relativePath);
        Resource resource = requestContext.getOldResource();
        RegistryEvent<String> parentEvent = null;
        RegistryEvent<String> childCreatedEvent = null;
        if (resource == null) {
            if (isNotCollection) {
                childCreatedEvent = new ChildCreatedEvent<String>("A resource was added to the collection " +
                        parentPath + " at Path: " + relativePath);
                childCreatedEvent.setParameter("ChildPath", relativePath);
                ((ChildCreatedEvent)childCreatedEvent).setResourcePath(parentPath);
            } else {
                childCreatedEvent = new ChildCreatedEvent<String>(
                        "A collection was added to the collection " + parentPath + " at Path: " + relativePath);
                childCreatedEvent.setParameter("ChildPath", relativePath);
                ((ChildCreatedEvent)childCreatedEvent).setResourcePath(parentPath);
            }
            childCreatedEvent.setTenantId(CurrentSession.getCallerTenantId());
            parentEvent = new CollectionUpdatedEvent<String>("The collection at path " + parentPath + " was updated.");
            parentEvent.setParameter("RegistryOperation", "putChild");
            ((CollectionUpdatedEvent)parentEvent).setResourcePath(parentPath);
            parentEvent.setTenantId(CurrentSession.getCallerTenantId());
        }
        try {
            if (childCreatedEvent != null) {
                notify(childCreatedEvent, requestContext.getRegistry(), parentPath);
            }
            if (parentEvent != null) {
                notify(parentEvent, requestContext.getRegistry(), parentPath);
            }
        } catch (Exception e) {
            handleException("Unable to send notification for Put Operation", e);
        }
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:42,代码来源:RegistryEventingHandler.java

示例9: copy

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String copy(RequestContext requestContext) throws RegistryException {
	
  String path = requestContext.getSourcePath();
    String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
    if (!sendNotifications(requestContext, relativePath)){
        return null;
    }
    String targetPath = requestContext.getTargetPath();
    String relativeTargetPath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
            targetPath);
    boolean isNotCollection = !(requestContext.getResource() instanceof Collection);
    String sourceParentPath = RegistryUtils.getParentPath(relativePath);
    String targetParentPath = RegistryUtils.getParentPath(relativeTargetPath);
    RegistryEvent<String> sourceEvent = null;
    RegistryEvent<String> targetEvent = null;
    RegistryEvent<String> childCreatedEvent = null;
    if (isNotCollection) {
        if (sourceParentPath != null) {
            sourceEvent = new CollectionUpdatedEvent<String>("A resource was copied from the collection " +
                    sourceParentPath + " at Path: " + relativePath);
            ((CollectionUpdatedEvent)sourceEvent).setResourcePath(sourceParentPath);
            sourceEvent.setParameter("RegistryOperation", "copyFrom");
            sourceEvent.setTenantId(CurrentSession.getCallerTenantId());
        }
        if (targetParentPath != null) {
            targetEvent = new CollectionUpdatedEvent<String>("A resource was copied to the collection " +
                    targetParentPath + " at Path: " + relativeTargetPath);
            ((CollectionUpdatedEvent)targetEvent).setResourcePath(targetParentPath);
            targetEvent.setParameter("RegistryOperation", "copyTo");
            targetEvent.setTenantId(CurrentSession.getCallerTenantId());
            childCreatedEvent = new ChildCreatedEvent<String>("A resource was added to the collection " +
                    targetParentPath + " at Path: " + relativeTargetPath);
            ((ChildCreatedEvent)childCreatedEvent).setResourcePath(targetParentPath);
            childCreatedEvent.setParameter("ChildPath", relativeTargetPath);
            childCreatedEvent.setTenantId(CurrentSession.getCallerTenantId());
        }
    } else {
        if (sourceParentPath != null) {
            sourceEvent = new CollectionUpdatedEvent<String>("A collection was copied from the collection " +
                    sourceParentPath + " at Path: " + relativePath);
            ((CollectionUpdatedEvent)sourceEvent).setResourcePath(sourceParentPath);
            sourceEvent.setParameter("RegistryOperation", "copyFrom");
            sourceEvent.setTenantId(CurrentSession.getCallerTenantId());
        }
        if (targetParentPath != null) {
            targetEvent = new CollectionUpdatedEvent<String>("A collection was copied to the collection " +
                    targetParentPath + " at Path: " + relativeTargetPath);
            ((CollectionUpdatedEvent)targetEvent).setResourcePath(targetParentPath);
            targetEvent.setParameter("RegistryOperation", "copyTo");
            targetEvent.setTenantId(CurrentSession.getCallerTenantId());
            childCreatedEvent = new ChildCreatedEvent<String>("A collection was added to the collection " +
                    targetParentPath + " at Path: " + relativeTargetPath);
            ((ChildCreatedEvent)childCreatedEvent).setResourcePath(targetParentPath);
            childCreatedEvent.setParameter("ChildPath", relativeTargetPath);
            childCreatedEvent.setTenantId(CurrentSession.getCallerTenantId());
        }
    }
    try {
        if (sourceEvent != null) {
            notify(sourceEvent, requestContext.getRegistry(), sourceParentPath);
        }
        if (targetEvent != null) {
            notify(targetEvent, requestContext.getRegistry(), targetParentPath);
        }
        if (childCreatedEvent != null) {
            notify(childCreatedEvent, requestContext.getRegistry(), targetParentPath);
        }
    } catch (Exception e) {
        handleException("Unable to send notification for Copy Operation", e);
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:73,代码来源:RegistryEventingHandler.java

示例10: rename

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String rename(RequestContext requestContext) throws RegistryException {

        String path = requestContext.getSourcePath();
        String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
        if (!sendNotifications(requestContext, relativePath)){
            return null;
        }
        String targetPath = requestContext.getTargetPath();
        String relativeTargetPath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
                targetPath);
        boolean isNotCollection = !(requestContext.getResource() instanceof Collection);
        String parentPath = RegistryUtils.getParentPath(relativePath);
        RegistryEvent<String> parentEvent = null;
        RegistryEvent<String> event;
        if (isNotCollection) {
            event = new ResourceUpdatedEvent<String>("The resource at Path: " + relativePath +
                    " was renamed to: " + relativeTargetPath);
            ((ResourceUpdatedEvent)event).setResourcePath(relativePath);
            event.setParameter("RegistryOperation", "rename");
            if (parentPath != null) {
                parentEvent = new CollectionUpdatedEvent<String>("A resource in the collection " + parentPath +
                        " at Path: " + relativePath + " was renamed to: " + relativeTargetPath);
                ((CollectionUpdatedEvent)parentEvent).setResourcePath(parentPath);
                parentEvent.setParameter("RegistryOperation", "childRenamed");
                parentEvent.setTenantId(CurrentSession.getCallerTenantId());
            }
        } else {
            event = new CollectionUpdatedEvent<String>("The collection at Path: " + relativePath +
                    " was renamed to: " + relativeTargetPath);
            ((CollectionUpdatedEvent)event).setResourcePath(relativePath);
            event.setParameter("RegistryOperation", "rename");
            if (parentPath != null) {
                parentEvent = new CollectionUpdatedEvent<String>("A collection in the collection " + parentPath +
                        " at Path: " + relativePath + " was renamed to: " + relativeTargetPath);
                ((CollectionUpdatedEvent)parentEvent).setResourcePath(parentPath);
                parentEvent.setParameter("RegistryOperation", "childRenamed");
                parentEvent.setTenantId(CurrentSession.getCallerTenantId());
            }
        }
        event.setTenantId(CurrentSession.getCallerTenantId());
        try {
            notify(event, requestContext.getRegistry(), relativePath);
            if (parentEvent != null) {
                notify(parentEvent, requestContext.getRegistry(), parentPath);
            }
        } catch (Exception e) {
            handleException("Unable to send notification for Rename Operation", e);
        }
        return null;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:51,代码来源:RegistryEventingHandler.java


注:本文中的org.wso2.carbon.registry.core.utils.RegistryUtils.getParentPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。