org.wso2.carbon.registry.core.Resource.getUUID()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(15.2k)|赞(0)|评价(0)|浏览(51)

本文整理了Java中org.wso2.carbon.registry.core.Resource.getUUID方法的一些代码示例,展示了Resource.getUUID的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getUUID方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Resource
类名称:Resource
方法名:getUUID

Resource.getUUID介绍

暂无

代码示例

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

private void saveResource(String url, String path, Resource resource,
             boolean isMasterWSDL)
    throws RegistryException {
  log.trace("Started saving resource");
  String source = getSource(path);
  GenericArtifactManager genericArtifactManager = new GenericArtifactManager(governanceUserRegistry, "uri");
  GenericArtifact wsdl = genericArtifactManager.newGovernanceArtifact(new QName(source));
  if (isMasterWSDL){
    wsdl.setId(resource.getUUID());
  }
  wsdl.setAttribute("overview_name", source);
  wsdl.setAttribute("overview_uri", url);
  wsdl.setAttribute("overview_type", HandlerConstants.WSDL);
  genericArtifactManager.addGenericArtifact(wsdl);
  log.trace("Finished saving resource");
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

Resource resource, boolean isMasterSchema) throws RegistryException {
String schemaId = resource.getUUID();

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

log.trace("Started saving resource");
String artifactId = resource.getUUID();

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.api

/**
 * 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;
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

Resource resource = registry.newResource();
String version = requestContext.getResource().getProperty("version");
if (resource.getUUID() == null) {
  resource.setUUID(UUID.randomUUID().toString());

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public WebApp getAPI(String apiPath) throws AppManagementException {
  try {
    GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry,
                                      AppMConstants.API_KEY);
    Resource apiResource = registry.get(apiPath);
    String artifactId = apiResource.getUUID();
    if (artifactId == null) {
      throw new AppManagementException("artifact id is null for : " + apiPath);
    }
    GenericArtifact apiArtifact = artifactManager.getGenericArtifact(artifactId);
    return AppManagerUtil.getAPI(apiArtifact);
  } catch (RegistryException e) {
    handleException("Failed to get WebApp from : " + apiPath, e);
    return null;
  }
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public Documentation getDocumentation(APIIdentifier apiId, DocumentationType docType,
                   String docName) throws AppManagementException {
  Documentation documentation = null;
  String docPath = AppManagerUtil.getAPIDocPath(apiId) + docName;
  GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry,
                                    AppMConstants.DOCUMENTATION_KEY);
  try {
    Resource docResource = registry.get(docPath);
    GenericArtifact artifact = artifactManager.getGenericArtifact(docResource.getUUID());
    documentation = AppManagerUtil.getDocumentation(artifact);
  } catch (RegistryException e) {
    handleException("Failed to get documentation details", e);
  }
  return documentation;
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * Method that gets called instructing a policy to be added the registry.
 *
 * @param path     the path to add the resource to.
 * @param url      the path from which the resource was imported from.
 * @param resource the resource to be added.
 *
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException if the operation failed.
 */
protected void addPolicyToRegistry(String path, String url, Resource resource) throws RegistryException {
  String source = getSource(path);
  GenericArtifactManager genericArtifactManager = new GenericArtifactManager(governanceUserRegistry, "uri");
  GenericArtifact policy = genericArtifactManager.newGovernanceArtifact(new QName(source));
  policy.setId(resource.getUUID());
  policy.setAttribute("overview_name", source);
  policy.setAttribute("overview_uri", url);
  policy.setAttribute("overview_type", HandlerConstants.POLICY);
  genericArtifactManager.addGenericArtifact(policy);
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

private void deleteOldResource(RequestContext context, Resource metaDataResource, WSDLInfo wsdlInfo, String wsdlPath, Resource wsdlResource) throws RegistryException {
  if(wsdlInfo.isMasterWSDL()){
    if (metaDataResource != null) {
      wsdlResource.setUUID(metaDataResource.getUUID());
    }
    if(!wsdlPath.equals(context.getResourcePath().getPath())
        && registry.resourceExists(context.getResourcePath().getPath())){
      registry.delete(context.getResourcePath().getPath());
    }
  }
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

GenericArtifact xsd = genericArtifactManager.newGovernanceArtifact(new QName(source));
  if(isMasterSchema){
    xsd.setId(resource.getUUID());
} else {
  Resource existResource = registry.get(path);
  GenericArtifact artifact = genericArtifactManager.getGenericArtifact(existResource.getUUID());
  if(!artifact.getAttribute("overview_uri").equals(url)){
    throw new RegistryException("Different schema URI already exists in " + path + ".");

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

String apiPath = association.getDestinationPath();
Resource resource = registry.get(apiPath);
String apiArtifactId = resource.getUUID();
if (apiArtifactId != null) {
  GenericArtifact apiArtifact = artifactManager.getGenericArtifact(apiArtifactId);

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * @param context      the request context that was generated from the registry core.
 * @param currentState the current lifecycle state.
 * @param targetState  the target lifecycle state.
 * @return             Returns whether the execution was successful or not.
 */
@Override
public boolean execute(RequestContext context, String currentState, String targetState) {
  boolean deleted = false;
  String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
  try {
    GenericArtifactManager manager = new GenericArtifactManager(
        RegistryCoreServiceComponent.getRegistryService().getGovernanceUserRegistry(user, CarbonContext
            .getThreadLocalCarbonContext().getTenantId()), ExecutorConstants.REST_SERVICE_KEY);
    GenericArtifact api = manager.getGenericArtifact(context.getResource().getUUID());
    deleted = deleteFromAPIManager(api);
  } catch (GovernanceException e) {
    log.error("Failed to read the REST API artifact from the registry. ", e);
  } catch (RegistryException e) {
    log.error(ExecutorConstants.API_DEMOTE_FAIL, e);
  }
  return deleted;
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public WebApp getAPI(APIIdentifier identifier,APIIdentifier oldIdentifier) throws
                                      AppManagementException {
  String apiPath = AppManagerUtil.getAPIPath(identifier);
  try {
    GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry,
                                      AppMConstants.API_KEY);
    Resource apiResource = registry.get(apiPath);
    String artifactId = apiResource.getUUID();
    if (artifactId == null) {
      throw new AppManagementException("artifact id is null for : " + apiPath);
    }
    GenericArtifact apiArtifact = artifactManager.getGenericArtifact(artifactId);
    return AppManagerUtil.getAPI(apiArtifact, registry,oldIdentifier);
  } catch (RegistryException e) {
    handleException("Failed to get WebApp from : " + apiPath, e);
    return null;
  }
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

/**
 * get details of provider
 *
 * @param providerName name of the provider
 * @return Provider
 * @throws org.wso2.carbon.apimgt.api.APIManagementException
 *          if failed to get Provider
 */
public Provider getProvider(String providerName) throws AppManagementException {
  Provider provider = null;
  String providerPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
             AppMConstants.PROVIDERS_PATH + RegistryConstants.PATH_SEPARATOR + providerName;
  try {
    GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry,
                                      AppMConstants.PROVIDER_KEY);
    Resource providerResource = registry.get(providerPath);
    String artifactId =
        providerResource.getUUID();
    if (artifactId == null) {
      throw new AppManagementException("artifact it is null");
    }
    GenericArtifact providerArtifact = artifactManager.getGenericArtifact(artifactId);
    provider = AppManagerUtil.getProvider(providerArtifact);
  } catch (RegistryException e) {
    handleException("Failed to get Provider form : " + providerName, e);
  }
  return provider;
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

GenericArtifactManager artifactManager = new GenericArtifactManager(registry, AppMConstants.API_KEY);
GenericArtifact artifact = artifactManager.getGenericArtifact(
    resource.getUUID());
WebApp api = AppManagerUtil.getAPI(artifact, registry);
apiSortedSet.add(api);

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.keymgt

/**
 * This returns API object for given APIIdentifier. Reads from registry entry for given APIIdentifier
 * creates API object
 *
 * @param identifier APIIdentifier object for the API
 * @return API object for given identifier
 * @throws APIManagementException on error in getting API artifact
 */
public static API getAPI(APIIdentifier identifier) throws APIManagementException {
  String apiPath = APIUtil.getAPIPath(identifier);
  try {
    Registry registry = APIKeyMgtDataHolder.getRegistryService().getGovernanceSystemRegistry();
    GenericArtifactManager artifactManager = APIUtil.getArtifactManager(registry,
        APIConstants.API_KEY);
    if (artifactManager == null) {
      String errorMessage = "Artifact manager is null when retrieving API " + identifier.getApiName();
      log.error(errorMessage);
      throw new APIManagementException(errorMessage);
    }
    Resource apiResource = registry.get(apiPath);
    String artifactId = apiResource.getUUID();
    if (artifactId == null) {
      throw new APIManagementException("artifact id is null for : " + apiPath);
    }
    GenericArtifact apiArtifact = artifactManager.getGenericArtifact(artifactId);
    return APIUtil.getAPI(apiArtifact, registry);
  } catch (RegistryException e) {
    return null;
  }
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * @param context      the request context that was generated from the registry core.
 * @param currentState the current lifecycle state.
 * @param targetState  the target lifecycle state.
 * @return             Returns whether the execution was successful or not.
 */
@Override
public boolean execute(RequestContext context, String currentState, String targetState) {
  Resource resource = context.getResource();
  try {
    String artifactString = RegistryUtils.decodeBytes((byte[]) resource.getContent());
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    OMElement xmlContent = AXIOMUtil.stringToOM(artifactString);
    GenericArtifactManager manager = new GenericArtifactManager(
        RegistryCoreServiceComponent.getRegistryService().getGovernanceUserRegistry(user, CarbonContext
            .getThreadLocalCarbonContext().getTenantId()), ExecutorConstants.REST_SERVICE_KEY);
    GenericArtifact api = manager.getGenericArtifact(context.getResource().getUUID());
    publishData(api, xmlContent);
  } catch (RegistryException e) {
    log.error("Failed to publish service to API store ", e);
    return false;
  } catch (XMLStreamException e) {
    log.error("Failed to convert service to xml content", e);
    return false;
  }
  return true;
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * @param context      The request context that was generated from the registry core.
 *                     The request context contains the resource, resource path and other
 *                     variables generated during the initial call.
 * @param currentState The current lifecycle state.
 * @param targetState  The target lifecycle state.
 * @return Returns whether the execution was successful or not.
 */
public boolean execute(RequestContext context, String currentState, String targetState) {
  Resource resource = context.getResource();
  try {
    String artifactString = RegistryUtils.decodeBytes((byte[]) resource.getContent());
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    OMElement xmlContent = AXIOMUtil.stringToOM(artifactString);
    String serviceName = CommonUtil.getServiceName(xmlContent);
    GenericArtifactManager manager = new GenericArtifactManager(
        RegistryCoreServiceComponent.getRegistryService().getGovernanceUserRegistry(user, CarbonContext
            .getThreadLocalCarbonContext().getTenantId()), "restservice");
    GenericArtifact api = manager.getGenericArtifact(context.getResource().getUUID());
    publishDataToAPIM(api, serviceName);
  } catch (RegistryException e) {
    log.error("Failed to publish service to API store ", e);
    return false;
  } catch (XMLStreamException e) {
    log.error("Failed to convert service to xml content");
    return false;
  }
  return true;
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * @param context      The request context that was generated from the registry core.
 *                     The request context contains the resource, resource path and other
 *                     variables generated during the initial call.
 * @param currentState The current lifecycle state.
 * @param targetState  The target lifecycle state.
 * @return Returns whether the execution was successful or not.
 */
public boolean execute(RequestContext context, String currentState, String targetState) {
  Resource resource = context.getResource();
  try {
    String artifactString = RegistryUtils.decodeBytes((byte[]) resource.getContent());
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    OMElement xmlContent = AXIOMUtil.stringToOM(artifactString);
    String serviceName = CommonUtil.getServiceName(xmlContent);      
    ServiceManager serviceManager = new ServiceManager(RegistryCoreServiceComponent.
        getRegistryService().getGovernanceUserRegistry(user,CarbonContext.getThreadLocalCarbonContext().getTenantId()));
    Service service = serviceManager.getService(context.getResource().getUUID());
    publishDataToAPIM(service,serviceName);
  } catch (RegistryException e) {
    log.error("Failed to publish service to API store ", e);
    return false;
  } catch (XMLStreamException e) {
    log.error("Failed to convert service to xml content");
    return false;
  }
  return true;
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.ws.client

public static WSResource transformResourceToWSResource(Resource resource, DataHandler dataHandler) {
  WSResource wsResource = new WSResource();
  wsResource.setContentFile(dataHandler);
  wsResource.setAuthorUserName(resource.getAuthorUserName());
  if (resource.getCreatedTime() != null) wsResource.setCreatedTime(resource.getCreatedTime().getTime());
  //         wsResource.setDbBasedContentID(resource)
  wsResource.setDescription(resource.getDescription());
  wsResource.setId(resource.getId());
  if (resource.getLastModified() != null) wsResource.setLastModified(resource.getLastModified().getTime());
  wsResource.setLastUpdaterUserName(resource.getLastUpdaterUserName());
  //         wsResource.setMatchingSnapshotID(resource.get)
  wsResource.setMediaType(resource.getMediaType());
  //         wsResource.setName(resource.)
  wsResource.setParentPath(resource.getParentPath());
  wsResource.setPath(resource.getPath());
  //         wsResource.setPathID();
  wsResource.setPermanentPath(resource.getPermanentPath());
  if (!resource.getProperties().isEmpty()) wsResource.setProperties(getPropertiesForWSResource(resource.getProperties()));
  wsResource.setState(resource.getState());
  wsResource.setUUID(resource.getUUID());
  //         resource.get
  return wsResource;
}

相关文章