本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.setUUID方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setUUID方法的具体用法?Java Resource.setUUID怎么用?Java Resource.setUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.Resource
的用法示例。
在下文中一共展示了Resource.setUUID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given endpoint artifact to the given resource on the
* registry.
*
* @param endpoint the endpoint artifact.
* @param endpointResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
public void setContent(Endpoint endpoint, Resource endpointResource) throws GovernanceException {
// set the endpoint url
String url = ((EndpointImpl)endpoint).getUrl();
try {
String content = EndpointUtils.getEndpointContentWithOverview(url, EndpointUtils.deriveEndpointFromUrl(url),
EndpointUtils.deriveEndpointNameFromUrl(url), CommonConstants.ENDPOINT_VERSION_DEFAULT_VALUE);
endpointResource.setContent(content);
} catch (RegistryException e) {
String msg =
"Error in setting the resource content for endpoint. path: " +
endpoint.getPath() + ", " + "id: " + endpoint.getId() + ".";
log.error(msg);
throw new GovernanceException(msg, e);
}
// and set all the attributes as properties.
String[] attributeKeys = endpoint.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = endpoint.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
endpointResource.setProperties(properties);
}
endpointResource.setUUID(endpoint.getId());
}
示例3: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given policy artifact to the given resource on the
* registry.
*
* @param policy the policy artifact.
* @param policyResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
protected void setContent(Policy policy, Resource policyResource) throws GovernanceException {
if (policy.getPolicyContent() != null) {
String policyContent = policy.getPolicyContent();
try {
policyResource.setContent(policyContent);
} catch (RegistryException e) {
String msg =
"Error in setting the content from policy, policy id: " + policy.getId() +
", policy path: " + policy.getPath() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
}
// and set all the attributes as properties.
String[] attributeKeys = policy.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = policy.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
policyResource.setProperties(properties);
}
policyResource.setUUID(policy.getId());
}
示例4: addService
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void addService(OMElement service, RequestContext context)throws RegistryException{
Registry registry = context.getRegistry();
Resource resource = registry.newResource();
String path;
if (Utils.getRxtService() == null){
String version = context.getResource().getProperty(RegistryConstants.VERSION_PARAMETER_NAME);
String tempNamespace = CommonUtil.derivePathFragmentFromNamespace(
CommonUtil.getServiceNamespace(service));
path = getChrootedServiceLocation(registry, context.getRegistryContext()) + tempNamespace + version +
RegistryConstants.PATH_SEPARATOR + CommonUtil.getServiceName(service);
path = CommonUtil.getRegistryPath(context.getRegistry().getRegistryContext(),path);
} else {
String pathExpression = Utils.getRxtService().getStoragePath(RegistryConstants.SERVICE_MEDIA_TYPE);
path = RegistryUtils.getAbsolutePath(context.getRegistryContext(),getPathFromPathExpression(pathExpression, service,context.getResource().getProperties()));
log.info("Checking local paths, absolute path: " +path+ " | path: "+ CommonUtil.getRegistryPath(context.getRegistry().getRegistryContext(),path));
}
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 {
// We check for an existing resource and add its UUID here.
if(registry.resourceExists(path)){
Resource existingResource = registry.get(path);
resource.setUUID(existingResource.getUUID());
} else {
resource.setUUID(UUID.randomUUID().toString());
}
resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO);
resource.setProperty("registry.DefinitionImport","true");
registry.put(path, resource);
String defaultLifeCycle = getDefaultLifecycle(registry, "service");
if(defaultLifeCycle != null && !defaultLifeCycle.isEmpty()) {
String[] lifeCycles = defaultLifeCycle.split(",");
for (String lifeCycle : lifeCycles) {
if (StringUtils.isNotEmpty(lifeCycle)){
registry.associateAspect(resource.getId(),lifeCycle);
}
}
}
} 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);
}
示例5: addSoapService
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* This method will populate the registry path and store the SOAP service.
* Afterwards create an association between WSDL and SOAP service.
* @param service XML representation of the SOAP service.
* @param context RequestContext
* @throws RegistryException
*/
public static void addSoapService(OMElement service, RequestContext context) throws RegistryException {
Registry registry = context.getRegistry();
Resource resource = registry.newResource();
String path;
if (Utils.getRxtService() == null){
String version = context.getResource().getProperty(RegistryConstants.VERSION_PARAMETER_NAME);
String tempNamespace = CommonUtil.derivePathFragmentFromNamespace(
CommonUtil.getServiceNamespace(service));
path = getChrootedServiceLocation(registry, context.getRegistryContext()) + tempNamespace + version +
RegistryConstants.PATH_SEPARATOR + CommonUtil.getServiceName(service);
} else {
String pathExpression = Utils.getRxtService().getStoragePath(CommonConstants.SOAP_SERVICE_MEDIA_TYPE);
String absolutePath = RegistryUtils.getAbsolutePath(context.getRegistryContext(),getPathFromPathExpression(pathExpression, service, context.getResource().getProperties()));
/**
* Fix for the REGISTRY-3052 : validation is to check the whether this invoked by ZIPWSDLMediaTypeHandler
* Setting the registry and absolute paths to current session to avoid incorrect resource path entry in REG_LOG table
*/
if (CurrentSession.getLocalPathMap() != null && !Boolean.valueOf(CurrentSession.getLocalPathMap().get(CommonConstants.ARCHIEVE_UPLOAD))) {
path = CommonUtil.getRegistryPath(context.getRegistry().getRegistryContext(), absolutePath);
if (log.isDebugEnabled()) {
log.debug("Saving current session local paths, key: " + path + " | value: " + absolutePath);
}
CurrentSession.getLocalPathMap().put(path, absolutePath);
} else {
path = absolutePath;
}
}
String content = service.toString();
resource.setContent(RegistryUtils.encodeString(content));
resource.setMediaType(CommonConstants.SOAP_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 {
// We check for an existing resource and add its UUID here.
if (registry.resourceExists(path)) {
Resource existingResource = registry.get(path);
resource.setUUID(existingResource.getUUID());
} else {
resource.setUUID(UUID.randomUUID().toString());
}
resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO);
resource.setProperty("registry.DefinitionImport", "true");
registry.put(path, resource);
String defaultLifeCycle = getDefaultLifecycle(registry, "soapservice");
applyDefaultLifeCycle(registry, resource, path, defaultLifeCycle);
} 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);
}
示例6: 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);
}
示例7: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given schema artifact to the given resource on the
* registry.
*
* @param schema the schema artifact.
* @param schemaResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
protected void setContent(Schema schema, Resource schemaResource) throws GovernanceException {
if (schema.getSchemaElement() != null) {
OMElement contentElement = schema.getSchemaElement().cloneOMElement();
try {
for (String importType : new String[] {"import", "include", "redefine"}) {
List<OMElement> schemaImports =
GovernanceUtils.evaluateXPathToElements("//xsd:" + importType,
contentElement);
for (OMElement schemaImport : schemaImports) {
OMAttribute location = schemaImport.getAttribute(
new QName("schemaLocation"));
if (location != null) {
String path = location.getAttributeValue();
if (path.indexOf(";version:") > 0) {
location.setAttributeValue(path.substring(0,
path.lastIndexOf(";version:")));
}
}
}
}
} catch (JaxenException ignore) { }
String schemaContent = contentElement.toString();
try {
schemaResource.setContent(schemaContent);
} catch (RegistryException e) {
String msg =
"Error in setting the content from schema, schema id: " + schema.getId() +
", schema path: " + schema.getPath() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
}
// and set all the attributes as properties.
String[] attributeKeys = schema.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = schema.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
schemaResource.setProperties(properties);
}
schemaResource.setUUID(schema.getId());
}