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


Java RegistryUtils.getRelativePathToOriginal方法代码示例

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


在下文中一共展示了RegistryUtils.getRelativePathToOriginal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: move

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String move(RequestContext requestContext) throws RegistryException {
    validateUpdateInProgress();
    String sourcePath = requestContext.getSourcePath();
    String targetPath = requestContext.getTargetPath();
    if (sourcePath.startsWith(mountPath) && targetPath.startsWith(mountPath)) {
        String source = RegistryUtils.getRelativePathToOriginal(sourcePath, mountPath);
        filesystemManager.copy(source,
                RegistryUtils.getRelativePathToOriginal(targetPath, mountPath));
        filesystemManager.delete(source);
    } else if (targetPath.startsWith(mountPath)) {
        preparePut(RegistryUtils.getRelativePathToOriginal(targetPath, mountPath),
                requestContext);
    } else if (sourcePath.startsWith(mountPath)) {
        filesystemManager.delete(
                RegistryUtils.getRelativePathToOriginal(sourcePath, mountPath));
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:ExternalContentHandler.java

示例2: deleteReportTemplate

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * @param templateName name of the report
 * @param registry     Registry
 * @throws ReportingException if failed to delete report template
 */
public static void deleteReportTemplate(String templateName, Registry registry) throws ReportingException {
    try {
        String resourcePath = RegistryUtils.getRelativePathToOriginal(ReportConstants.JRXML_PATH,
                RegistryConstants.CONFIG_REGISTRY_BASE_PATH);
        if (registry.resourceExists(resourcePath)) {
            registry.delete(resourcePath + RegistryConstants.PATH_SEPARATOR + templateName + ".jrxml");
        } else {
            if (log.isDebugEnabled()) {
                log.info("no any report templates called " + templateName + " , to delete");
            }
        }
    } catch (RegistryException e) {
        throw new ReportingException("Error occurred deleting the report template : " + templateName, e);
    }


}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:23,代码来源:CommonUtil.java

示例3: getAll

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * @return all meta data instances and their children that denotes from this particular media type
 */
protected static List<VersionBase> getAll(Registry registry, String mt) throws MetadataException {
    List<VersionBase> baseResult = new ArrayList<VersionBase>();
    Map<String, String> criteria = new HashMap<String, String>();
    criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
    try {
        ResourceData[] results = Util.getAttributeSearchService().search(criteria);
        for (ResourceData resourceData : results) {
            String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
            if (registry.resourceExists(path)) {
                Resource resource = registry.get(path);
                baseResult.add(Util.getVersionBaseProvider(mt).get(resource, registry));
            }
        }
    } catch (RegistryException e) {
        throw new MetadataException(e.getMessage(), e);
    }
    return baseResult;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:22,代码来源:VersionBase.java

示例4: find

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * Search all meta data instances of this particular type with the given search attributes
 *
 * @param criteria Key value map that has search attributes
 * @return
 */
protected static List<VersionBase> find(Registry registry, Map<String, String> criteria, String mt) throws MetadataException {
    if (criteria != null && criteria.get(Constants.ATTRIBUTE_MEDIA_TYPE) == null) {
        criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
    }
    List<VersionBase> baseResult = new ArrayList<VersionBase>();
    try {
        ResourceData[] results = Util.getAttributeSearchService().search(criteria);
        for (ResourceData resourceData : results) {
            String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
            if (registry.resourceExists(path)) {
                Resource resource = registry.get(path);
                baseResult.add(Util.getVersionBaseProvider(mt).get(resource, registry));
            }
        }
    } catch (RegistryException e) {
        throw new MetadataException(e.getMessage(), e);
    }
    return baseResult;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:26,代码来源:VersionBase.java

示例5: getAll

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * @return all meta data instances and their children that denotes from this particular media type
 */
protected static List<Base> getAll(Registry registry, String mt) throws MetadataException {
    BaseProvider provider = Util.getBaseProvider(mt);
    List<Base> baseResult = new ArrayList<Base>();
    Map<String, String> criteria = new HashMap<String, String>();
    criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
    try {
        ResourceData[] results = Util.getAttributeSearchService().search(criteria);
        for (ResourceData resourceData : results) {
            String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
            if (registry.resourceExists(path)) {
                Resource resource = registry.get(path);
                baseResult.add(provider.get(resource, registry));
            }
        }
    } catch (RegistryException e) {
        log.error(e.getMessage());
        throw new MetadataException(e.getMessage(), e);
    }
    return baseResult;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:24,代码来源:Base.java

示例6: find

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * Search all meta data instances of this particular type with the given search attributes
 *
 * @param criteria Key value map that has search attributes
 * @return
 */
protected static List<Base> find(Registry registry, Map<String, String> criteria, String mt) throws MetadataException {
    BaseProvider provider = Util.getBaseProvider(mt);
    if (criteria != null && criteria.get(Constants.ATTRIBUTE_MEDIA_TYPE) == null) {
        criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
    }
    List<Base> baseResult = new ArrayList<Base>();
    try {
        ResourceData[] results = Util.getAttributeSearchService().search(criteria);
        for (ResourceData resourceData : results) {
            String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
            if (registry.resourceExists(path)) {
                Resource resource = registry.get(path);
                baseResult.add(provider.get(resource, registry));
            }
        }
    } catch (RegistryException e) {
        log.error(e.getMessage());
        throw new MetadataException(e.getMessage(), e);
    }
    return baseResult;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:Base.java

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

示例8: saveEndpoint

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private static void saveEndpoint(RequestContext context, Registry registry, String url, String associatedPath,
                                 Map<String, String> properties, Registry systemRegistry, String environment,
                                 List<String> dependencies, String version) throws RegistryException {
    String urlToPath = deriveEndpointFromUrl(url);

    String pathExpression = getEndpointLocation(context, url, systemRegistry, environment);

    String endpointAbsoluteBasePath = RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
            environment);
    if (!systemRegistry.resourceExists(endpointAbsoluteBasePath)) {
        systemRegistry.put(endpointAbsoluteBasePath, systemRegistry.newCollection());
    }

    String prefix = urlToPath.substring(0,urlToPath.lastIndexOf(RegistryConstants.PATH_SEPARATOR) +1 );
    String name = urlToPath.replace(prefix,"");

    String regex = endpointAbsoluteBasePath + prefix + "[\\d].[\\d].[\\d]" + RegistryConstants.PATH_SEPARATOR + name;

    for (String dependency : dependencies) {
        if(dependency.matches(regex)){
            String newRelativePath =  RegistryUtils.getRelativePathToOriginal(dependency,
                    org.wso2.carbon.registry.core.RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH );
            saveEndpointValues(context,registry, url, associatedPath, properties, systemRegistry, newRelativePath, dependency);
            return;
        }
    }
    String endpointAbsolutePath = environment + prefix + version + RegistryConstants.PATH_SEPARATOR + name;
    String relativePath = environment.substring(0,RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH.length())
            + prefix + version + RegistryConstants.PATH_SEPARATOR + name;
    saveEndpointValues(context, registry, url, associatedPath, properties, systemRegistry, relativePath,
                       endpointAbsolutePath);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:33,代码来源:EndpointUtils.java

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

示例10: put

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void put(RequestContext requestContext) throws RegistryException {
    if (!CommonUtil.isSCMLockAvailable()) {
        return;
    }
    validateUpdateInProgress();
    String path = RegistryUtils.getRelativePathToOriginal(
            requestContext.getResourcePath().getPath(), mountPath);
    preparePut(path, requestContext);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:10,代码来源:ExternalContentHandler.java

示例11: delete

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void delete(RequestContext requestContext) throws RegistryException {
    if (!CommonUtil.isSCMLockAvailable()) {
        return;
    }
    validateUpdateInProgress();
    String path = RegistryUtils.getRelativePathToOriginal(
            requestContext.getResourcePath().getPath(), mountPath);
    filesystemManager.delete(path);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:10,代码来源:ExternalContentHandler.java

示例12: rename

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String rename(RequestContext requestContext) throws RegistryException {
    validateUpdateInProgress();
    String sourcePath = requestContext.getSourcePath();
    String targetPath = requestContext.getTargetPath();
    String source = RegistryUtils.getRelativePathToOriginal(sourcePath, mountPath);
    filesystemManager.copy(source,
            RegistryUtils.getRelativePathToOriginal(targetPath, mountPath));
    filesystemManager.delete(source);
    return null;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:11,代码来源:ExternalContentHandler.java

示例13: getAllReports

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 * @param registry Registry
 * @return report name list
 * @throws ReportingException if failed to get report name list
 */
public static List<String> getAllReports(Registry registry) throws ReportingException {
    Resource resource;
    List<String> reportNames = null;
    try {

        String relativePath = RegistryUtils.getRelativePathToOriginal(ReportConstants.JRXML_PATH,
                RegistryConstants.CONFIG_REGISTRY_BASE_PATH);
        if (registry.resourceExists(relativePath)) {
            resource = registry.get(relativePath);
            if (resource instanceof Collection) {
                reportNames = new ArrayList<String>();
                String[] paths = ((Collection) resource).getChildren();
                for (String resourcePath : paths) {
                    Resource childResource = registry.get(resourcePath);

                    if (!(childResource instanceof Collection)) {
                        String name = ((ResourceImpl) childResource).getName();
                        reportNames.add(name.split(".jrxml")[0]);
                    }

                }
            }
        } else {
            if (log.isDebugEnabled()) {
                log.info("no any report templates available to generate reports");
            }
        }
    } catch (RegistryException e) {
        throw new ReportingException("Error occurred getting all the reports names", e);
    }
    return reportNames;

}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:39,代码来源:CommonUtil.java

示例14: clearPreFetchArtifact

import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
 *  Clear meta data cache
 * @param requestContext RequestContext
 */
private void clearPreFetchArtifact(RequestContext requestContext) throws RegistryException {
    if(!CommonUtil.isMetaDataClearLockAvailable()){
        return;
    }
    CommonUtil.acquireMetaDataClearLock();
    try{
        Resource resource = requestContext.getResource();
        if (resource == null || resource.getUUID() == null) {
           return;
        }
    String mediaType = resource.getMediaType();
    String artifactPath = null;
    try {
        artifactPath = GovernanceUtils.getDirectArtifactPath(requestContext.getRegistry(), resource.getUUID());
    } catch (GovernanceException e) {
        String msg = "Failed to get path of artifact id = " + resource.getUUID();
        log.error(msg, e);
        throw new RegistryException(msg, e);
    }

    if (mediaType == null || artifactPath == null) {
        return;
    }
    if (mediaType.matches("application/.[a-zA-Z0-9.-]+\\+xml")) {
        ArtifactCache artifactCache =
                ArtifactCacheManager.getCacheManager().
                        getTenantArtifactCache(CurrentSession.getTenantId());
        String cachePath = RegistryUtils.getRelativePathToOriginal(artifactPath,
                RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
        if (artifactCache != null) {
            if (artifactCache.getArtifact(cachePath) != null) {
                artifactCache.invalidateArtifact(cachePath);
            }
        }
    }
    }finally {
        CommonUtil.releaseMetaDataClearLock();
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:44,代码来源:MetaDataCacheHandler.java

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


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