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


Java Registry.newResource方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.api.Registry.newResource方法的典型用法代码示例。如果您正苦于以下问题:Java Registry.newResource方法的具体用法?Java Registry.newResource怎么用?Java Registry.newResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.api.Registry的用法示例。


在下文中一共展示了Registry.newResource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: persistVerificationCode

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
 * Helper method
 *
 * @param verificationCode verificationCode as String
 * @param subscriberIds    Array of subscriberIds
 */
private void persistVerificationCode(String verificationCode, String[] subscriberIds) {

    Registry registry = EntitlementServiceComponent.
            getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    try {
        org.wso2.carbon.registry.api.Resource resource = registry.newResource();
        resource.setProperty("subscriberIds", Arrays.asList(subscriberIds));
        resource.setProperty("policyIds", Arrays.asList(policyIds));
        resource.setProperty("action", action);
        resource.setProperty("version", version);
        resource.setProperty("order", Integer.toString(order));
        registry.put(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode,
                resource);
    } catch (org.wso2.carbon.registry.api.RegistryException e) {
        log.error("Error while persisting verification code", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:PolicyPublishExecutor.java

示例2: updateRegistry

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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

示例3: write

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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

示例4: persistConfig

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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

示例5: saveDASconfigInfo

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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

示例6: storePermissions

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
 * @param applicationName
 * @param permissionsConfig
 * @throws IdentityApplicationManagementException
 */
public static void storePermissions(String applicationName, String username, PermissionsAndRoleConfig permissionsConfig)
        throws IdentityApplicationManagementException {

    Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry(
            RegistryType.USER_GOVERNANCE);

    String permissionResourcePath = getApplicationPermissionPath();
    try {
        if (!tenantGovReg.resourceExists(permissionResourcePath)) {
            boolean loggedInUserChanged = false;
            UserRealm realm =
                    (UserRealm) CarbonContext.getThreadLocalCarbonContext().getUserRealm();
            if (!realm.getAuthorizationManager()
                    .isUserAuthorized(username, permissionResourcePath,
                            UserMgtConstants.EXECUTE_ACTION)) {
                //Logged in user is not authorized to create the permission.
                // Temporarily change the user to the admin for creating the permission
                PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(
                        realm.getRealmConfiguration().getAdminUserName());
                tenantGovReg = CarbonContext.getThreadLocalCarbonContext()
                        .getRegistry(RegistryType.USER_GOVERNANCE);
                loggedInUserChanged = true;
            }
            Collection appRootNode = tenantGovReg.newCollection();
            appRootNode.setProperty("name", "Applications");
            tenantGovReg.put(permissionResourcePath, appRootNode);
            if (loggedInUserChanged) {
                PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
            }
        }

        if (permissionsConfig != null) {
            ApplicationPermission[] permissions = permissionsConfig.getPermissions();
            if (permissions == null || permissions.length < 1) {
                return;
            }

            // creating the application node in the tree
            String appNode = permissionResourcePath + PATH_CONSTANT + applicationName;
            Collection appNodeColl = tenantGovReg.newCollection();
            tenantGovReg.put(appNode, appNodeColl);

            // now start storing the permissions
            for (ApplicationPermission permission : permissions) {
                String permissinPath = appNode + PATH_CONSTANT + permission;
                Resource permissionNode = tenantGovReg.newResource();
                permissionNode.setProperty("name", permission.getValue());
                tenantGovReg.put(permissinPath, permissionNode);
            }
        }

    } catch (Exception e) {
        throw new IdentityApplicationManagementException("Error while storing permissions for application " +
                applicationName, e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:62,代码来源:ApplicationMgtUtil.java


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