本文整理汇总了Java中org.wso2.carbon.registry.api.Resource.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getContent方法的具体用法?Java Resource.getContent怎么用?Java Resource.getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.api.Resource
的用法示例。
在下文中一共展示了Resource.getContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKPIConfiguration
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
/**
* Get DAS config details of given certain process which are configured for analytics from the config registry
*
* @param processDefinitionId Process definition ID
* @return KPI configuration details in JSON format. Ex:<p>
* {"processDefinitionId":"myProcess3:1:32518","eventStreamName":"t_666_process_stream","eventStreamVersion":"1.0.0"
* ,"eventStreamDescription":"This is the event stream generated to configure process analytics with DAS, for the
* processt_666","eventStreamNickName":"t_666_process_stream","eventStreamId":"t_666_process_stream:1.0.0",
* "eventReceiverName":"t_666_process_receiver","pcProcessId":"t:666",
* "processVariables":[{"name":"processInstanceId","type":"string","isAnalyzeData":"false",
* "isDrillDownData":"false"}
* ,{"name":"valuesAvailability","type":"string","isAnalyzeData":"false","isDrillDownData":"false"}
* ,{"name":"custid","type":"string","isAnalyzeData":false,"isDrillDownData":false}
* ,{"name":"amount","type":"long","isAnalyzeData":false,"isDrillDownData":false}
* ,{"name":"confirm","type":"bool","isAnalyzeData":false,"isDrillDownData":false}]}
* @throws RegistryException
*/
public JsonNode getKPIConfiguration(String processDefinitionId) throws RegistryException, IOException {
String resourcePath = AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/"
+ AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME;
try {
RegistryService registryService = BPMNAnalyticsHolder.getInstance().getRegistryService();
Registry configRegistry = registryService.getConfigSystemRegistry();
if (configRegistry.resourceExists(resourcePath)) {
Resource processRegistryResource = configRegistry.get(resourcePath);
String dasConfigDetailsJSONStr = new String((byte[]) processRegistryResource.getContent(),
StandardCharsets.UTF_8);
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readTree(dasConfigDetailsJSONStr);
}
return null;
} catch (RegistryException e) {
String errMsg = "Error in Getting DAS config details of given process definition id :" + processDefinitionId
+ " from the BPS Config registry-" + resourcePath;
throw new RegistryException(errMsg, e);
}
}
示例2: read
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
@Override
public InputStream read(String path) throws MLInputAdapterException {
try {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.get(path);
byte[] readArray = (byte[]) resource.getContent();
ByteArrayInputStream bis = new ByteArrayInputStream(readArray);
return bis;
} catch (RegistryException e) {
throw new MLInputAdapterException(String.format("Failed to read the model from uri %s: %s", path, e), e);
}
}
示例3: getResourceList
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
public static List<Resource> getResourceList(Registry registry, String pathResource) throws org.wso2.carbon.registry.api.RegistryException {
List<Resource> result = new ArrayList<Resource>();
Resource resource = registry.get(pathResource);
if (resource instanceof Collection) {
Object content = resource.getContent();
for (Object path : (Object[])content) {
result.addAll(getResourceList(registry,(String)path));
}
} else if (resource instanceof Resource){
result.add(resource);
}
return result;
}
示例4: outputResources
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
public static String outputResources(List<Resource> paths,Registry oRegistry) throws RegistryException {
String retVal = null;
for (Resource oResource : paths) {
// we've got all the services here
System.out.println("-------");
System.out.println("resource path:"+oResource.getPath());
System.out.println("description:"+oResource.getDescription());
System.out.println("media type:"+oResource.getMediaType());
System.out.println("created time:"+oResource.getCreatedTime());
System.out.println("last modified time:"+oResource.getLastModified());
Object oObjectR = oResource.getContent();
String stRegValue = null;
if (oObjectR.getClass() == String.class )
stRegValue = (String)oObjectR;
else
stRegValue = new String((byte[])oObjectR);
System.out.println("content:"+stRegValue);
Properties props = oResource.getProperties();
for (Object prop : props.keySet()) {
// System.out.println(prop + " - " + props.get(prop));
String stPropName = (String)prop;
String stPropertyValue = oResource.getProperty(stPropName);
System.out.println(stPropName+":"+stPropertyValue);
}
Association[] associations = oRegistry.getAssociations(oResource.getPath(), "Documentation");
for (Association association : associations) {
System.out.println(association.getAssociationType());
}
}
return retVal;
}