本文整理汇总了Java中org.wso2.carbon.registry.api.Resource.setContent方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setContent方法的具体用法?Java Resource.setContent怎么用?Java Resource.setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.api.Resource
的用法示例。
在下文中一共展示了Resource.setContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRegistry
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
private void updateRegistry(String path, DeviceIdentifier identifier, Object content, Map<String, String> options)
throws GeoLocationBasedServiceException {
try {
Registry registry = getGovernanceRegistry();
Resource newResource = registry.newResource();
newResource.setContent(content);
newResource.setMediaType("application/json");
for (Map.Entry<String, String> option : options.entrySet()) {
newResource.addProperty(option.getKey(), option.getValue());
}
registry.put(path, newResource);
} catch (RegistryException e) {
throw new GeoLocationBasedServiceException(
"Error occurred while setting the Within Alert for " + identifier.getType() + " with id: " +
identifier.getId(), e);
}
}
示例2: write
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
@Override
public void write(String outPath, InputStream in) throws MLOutputAdapterException {
if (in == null || outPath == null) {
throw new MLOutputAdapterException(String.format(
"Null argument values detected. Input stream: %s Out Path: %s", in, outPath));
}
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(in, byteArrayOutputStream);
byte[] array = byteArrayOutputStream.toByteArray();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.newResource();
resource.setContent(array);
registry.put(outPath, resource);
} catch (RegistryException | IOException e) {
throw new MLOutputAdapterException(
String.format("Failed to save the model to registry %s: %s", outPath, e), e);
}
}
示例3: persistConfig
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
@Override
public void persistConfig(String policyEditorType, String xmlConfig) throws PolicyEditorException {
super.persistConfig(policyEditorType, xmlConfig);
Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
try {
Resource resource = registry.newResource();
resource.setContent(xmlConfig);
String path = null;
if (EntitlementConstants.PolicyEditor.BASIC.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.STANDARD.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_STANDARD_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.RBAC.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_RBAC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.SET.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_SET_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else {
//default
path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
}
registry.put(path, resource);
} catch (RegistryException e) {
throw new PolicyEditorException("Error while persisting policy editor config");
}
}
示例4: saveDASconfigInfo
import org.wso2.carbon.registry.api.Resource; //导入方法依赖的package包/类
/**
* Save DAS configuration details (received from PC), in config registry
*
* @param dasConfigDetailsJSONString Details of analytics configuration with WSO2 DAS as a JSON string
* @throws RegistryException Throws RegistryException if error occurred in accessing registry
* @throws IOException Throws IOException if an error occurred in hadling json content
*/
private void saveDASconfigInfo(String dasConfigDetailsJSONString) throws RegistryException, IOException {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry configRegistry = carbonContext.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode dasConfigDetailsJOb = objectMapper.readTree(dasConfigDetailsJSONString);
String processDefinitionId = dasConfigDetailsJOb.get(AnalyticsPublisherConstants.PROCESS_DEFINITION_ID)
.textValue();
//create a new resource (text file) to keep process variables
Resource procVariableJsonResource = configRegistry.newResource();
procVariableJsonResource.setContent(dasConfigDetailsJSONString);
procVariableJsonResource.setMediaType(MediaType.APPLICATION_JSON);
configRegistry.put(AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/"
+ AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME, procVariableJsonResource);
}