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


Java Resource.setContent方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:19,代码来源:GeoLocationProviderServiceImpl.java

示例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);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:24,代码来源:RegistryOutputAdapter.java

示例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");
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:RegistryPersistenceManager.java

示例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);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:22,代码来源:PublishProcessVariablesService.java


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