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


Java Resource.getUUID方法代码示例

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


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

示例1: getEndpointByUrl

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Finds the endpoint artifact that matches the given URL.
 * 
 * @param url the URL.
 * 
 * @return the endpoint artifact that corresponds.
 * @throws GovernanceException if the operation failed.
 */
public Endpoint getEndpointByUrl(String url) throws GovernanceException {
    String path = CommonUtil.getEndpointPathFromUrl(url);
    Resource r;
    try {
        if (registry.resourceExists(path)) {
            r = registry.get(path);
        } else {
            return null;
        }
    } catch (RegistryException e) {
        String msg =
                "Error in retrieving the endpoint resource. url:" + url + ", path:" + path +
                        ".";
        log.error(msg, e);
        throw new GovernanceException(msg, e);
    }
    String artifactId = r.getUUID();
    if (artifactId != null) {
        return getEndpoint(artifactId);
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:31,代码来源:EndpointManager.java

示例2: addEndpointToRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Adds the service endpoint element to the registry.
 *
 * @param requestContext        current request information.
 * @param endpointElement       endpoint metadata element.
 * @param endpointPath          endpoint location.
 * @return                      The resource path of the endpoint.
 * @throws RegistryException    If fails to add the endpoint to the registry.
 */
public static String addEndpointToRegistry(RequestContext requestContext, OMElement endpointElement, String endpointPath)
		throws RegistryException {

	if(requestContext == null || endpointElement == null || endpointPath == null) {
		throw new IllegalArgumentException("Some or all of the arguments may be null. Cannot add the endpoint to registry. ");
	}

       endpointPath = getEndpointPath(requestContext, endpointElement, endpointPath);

	Registry registry = requestContext.getRegistry();
	//Creating new resource.
	Resource endpointResource = new ResourceImpl();
	//setting endpoint media type.
	endpointResource.setMediaType(CommonConstants.ENDPOINT_MEDIA_TYPE);
	//set content.
	endpointResource.setContent(RegistryUtils.encodeString(endpointElement.toString()));
       //copy other property
       endpointResource.setProperties(copyProperties(requestContext));
	//set path
	//endpointPath = getChrootedEndpointLocation(requestContext.getRegistryContext()) + endpointPath;

	String resourceId = endpointResource.getUUID();
	//set resource UUID
	resourceId = (resourceId == null) ? UUID.randomUUID().toString() : resourceId;

	endpointResource.setUUID(resourceId);
	//saving the api resource to repository.
	registry.put(endpointPath, endpointResource);
       if (log.isDebugEnabled()){
           log.debug("Endpoint created at " + endpointPath);
       }
	return endpointPath;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:43,代码来源:RESTServiceUtils.java

示例3: ResourceModel

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public ResourceModel(Resource resource) throws RegistryException 
{
	this.mediaType = resource.getMediaType();
	this.uuid = resource.getUUID();
	this.authorUsername = resource.getAuthorUserName();
	this.lastModifiedUsername = resource.getLastUpdaterUserName();
	this.description = resource.getDescription();
	this.createdTime = resource.getCreatedTime().toGMTString();
	this.lastModifiedTime = resource.getLastModified().toGMTString();		
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:11,代码来源:ResourceModel.java

示例4: clearPreFetchArtifact

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的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

示例5: get

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public Base get(Resource resource, Registry registry) throws MetadataException {
    try {
        byte[] contentBytes = (byte[]) resource.getContent();
        OMElement root = Util.buildOMElement(contentBytes);
        Map<String, List<String>> propBag = Util.getPropertyBag(root);
        return getFilledBean(root, propBag, registry);
    } catch (RegistryException e) {
        throw new MetadataException("Error occurred while obtaining resource metadata content uuid = " + resource.getUUID(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:12,代码来源:HTTPEndpointProviderV1.java

示例6: get

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public ServiceVersionV1 get(Resource resource, Registry registry) throws MetadataException {
    try {
        byte[] contentBytes = (byte[]) resource.getContent();
        OMElement root = Util.buildOMElement(contentBytes);
        Map<String, List<String>> propBag = Util.getPropertyBag(root);
        return getFilledBean(root, propBag, registry);
    } catch (RegistryException e) {
        throw new MetadataException("Error occurred while obtaining resource metadata content uuid = " + resource.getUUID(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:12,代码来源:ServiceVersionProviderV1.java

示例7: get

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public GenericVersionV1 get(Resource resource, Registry registry) throws MetadataException {
    try {
        byte[] contentBytes = (byte[]) resource.getContent();
        OMElement root = Util.buildOMElement(contentBytes);
        Map<String, List<String>> propBag = Util.getPropertyBag(root);
        return getFilledBean(root, propBag, registry);
    } catch (RegistryException e) {
        throw new MetadataException("Error occurred while obtaining resource metadata content uuid = " + resource.getUUID(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:12,代码来源:GenericVersionProviderV1.java

示例8: saveEndpointValues

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private static void saveEndpointValues(RequestContext context,Registry registry, String url, String associatedPath
            , Map<String, String> properties, Registry systemRegistry, String relativePath
            , String endpointAbsolutePath) throws RegistryException {
        Resource resource;
        String endpointId = null;
        if (registry.resourceExists(endpointAbsolutePath)) {
            resource = registry.get(endpointAbsolutePath);
            endpointId = resource.getUUID();
            String existingContent;
            String newContent = updateEndpointContent(context, getEndpointContentWithOverview(url, endpointAbsolutePath,
                                                      ((ResourceImpl) resource).getName(),endpointVersion));
            if (resource.getContent() != null) {
                existingContent = new String((byte[]) (resource.getContent()));
                if (!existingContent.equals(newContent)) {
                    resource.setContent(RegistryUtils.encodeString(newContent));
                }
            } else {
                resource.setContent(RegistryUtils.encodeString(newContent));
            }
        } else {
            resource = registry.newResource();
            resource.setContent(RegistryUtils.encodeString(updateEndpointContent(context,
                                                        getEndpointContentWithOverview(url,endpointAbsolutePath,
                                                        deriveEndpointNameWithNamespaceFromUrl(url),endpointVersion))));
        }
        boolean endpointIdCreated = false;
        if (endpointId == null) {
            endpointIdCreated = true;
            endpointId = UUID.randomUUID().toString();
            resource.setUUID(endpointId);
        }

//        CommonUtil.addGovernanceArtifactEntryWithRelativeValues(
//                systemRegistry, endpointId, relativePath);

        boolean propertiesChanged = false;
        if (properties != null) {
            for (Map.Entry<String, String> e : properties.entrySet()) {
                propertiesChanged = true;
                resource.setProperty(e.getKey(), e.getValue());
            }
        }

        if (endpointIdCreated || propertiesChanged) {
            // this will be definitely false for a brand new resource
            resource.setMediaType(endpointMediaType);
            registry.put(endpointAbsolutePath, resource);
            // we need to create a version here.
        }
        String defaultLifeCycle = CommonUtil.getDefaultLifecycle(registry, "endpoint");
        CommonUtil.applyDefaultLifeCycle(registry, resource, endpointAbsolutePath, defaultLifeCycle);
        registry.addAssociation(associatedPath, endpointAbsolutePath, CommonConstants.DEPENDS);
        registry.addAssociation(endpointAbsolutePath, associatedPath, CommonConstants.USED_BY);
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:55,代码来源:EndpointUtils.java

示例9: execute

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public boolean execute(RequestContext requestContext, String currentState, String targetState) {

        String resourcePath = requestContext.getResource().getPath();
        String newPath;

//        Now we are going to get the list of parameters from the context and add it to a map
        Map<String, String> currentParameterMap = new HashMap<String, String>();

//        Here we are populating the parameter map that was given from the UI
        if (!populateParameterMap(requestContext, currentParameterMap)) {
            log.error("Failed to populate the parameter map");
            return false;
        }

//        This section is there to add a version to the path if needed.
//        This is all based on the lifecycle configuration and the configuration should be as follows.
//        path = /_system/governance/environment/{@version}
//        Also for this the user has to have a transition UI where he can give the version
        String currentEnvironment = getReformattedPath((String) parameterMap.get(ExecutorConstants.CURRENT_ENVIRONMENT),
                KEY, currentParameterMap.get(resourcePath));
        String targetEnvironment = getReformattedPath((String) parameterMap.get(ExecutorConstants.TARGET_ENVIRONMENT),
                KEY, currentParameterMap.get(resourcePath));

        if(resourcePath.startsWith(currentEnvironment)){
            newPath = resourcePath.substring(currentEnvironment.length());
            newPath = targetEnvironment + newPath;
        }else{
            log.warn("Resource is not in the given environment");
            return true;
        }

        try {
            doCopy(requestContext, resourcePath, newPath);
            Resource newResource = requestContext.getRegistry().get(newPath);

            if(newResource.getUUID() != null){
                addNewId(requestContext.getRegistry(), newResource, newPath);
            }

//            Copying comments
            copyComments(requestContext.getRegistry(), newPath, resourcePath);

//           Copying tags
            copyTags(requestContext.getRegistry(), newPath, resourcePath);

//           Copying ratings. We only copy the average ratings
            copyRatings(requestContext.getSystemRegistry(), newPath, resourcePath);

//           Copying all the associations.
//           We avoid copying dependencies here
            copyAllAssociations(requestContext.getRegistry(), newPath, resourcePath);

            return true;
        } catch (RegistryException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            return false;
        }

    }
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:60,代码来源:CopyExecutor.java


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