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


Java Registry.resourceExists方法代码示例

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


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

示例1: deletePermissions

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
 * Delete the resource
 *
 * @param applicationName
 * @throws IdentityApplicationManagementException
 */
public static void deletePermissions(String applicationName) throws IdentityApplicationManagementException {

    String applicationNode = getApplicationPermissionPath() + PATH_CONSTANT + applicationName;
    Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry(
            RegistryType.USER_GOVERNANCE);

    try {
        boolean exist = tenantGovReg.resourceExists(applicationNode);

        if (exist) {
            tenantGovReg.delete(applicationNode);
        }

    } catch (RegistryException e) {
        throw new IdentityApplicationManagementException("Error while storing permissions", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:ApplicationMgtUtil.java

示例2: buildUIPermissionNodeAllSelected

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
                                              Registry registry, Registry tenantRegistry) throws RegistryException,
        UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else if (tenantRegistry != null) {
            resource = tenantRegistry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        childNodes[i] = getUIPermissionNode(resource, true);
        if (resource instanceof Collection) {
            buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
                    tenantRegistry);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:UserRealmProxy.java

示例3: getResourceStream

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
@Override
public InputStream getResourceStream(String name) throws ResourceNotFoundException {
    try {
        Registry registry =
                CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
        if (registry == null) {
            throw new IllegalStateException("No valid registry instance is attached to the current carbon context");
        }
        if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) {
            throw new ResourceNotFoundException("Resource '" + name + "' does not exist");
        }
        org.wso2.carbon.registry.api.Resource resource =
                registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name);
        resource.setMediaType("text/plain");
        return resource.getContentStream();
    } catch (RegistryException e) {
        throw new ResourceNotFoundException("Error occurred while retrieving resource", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:20,代码来源:RegistryBasedResourceLoader.java

示例4: getKPIConfiguration

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:40,代码来源:BPMNDataPublisher.java

示例5: getLatestChecksum

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
 * Get the checksum of latest deployment for given deployment name
 *
 * @param deploymentName
 * @return
 * @throws BPSFault
 */
public String getLatestChecksum(String deploymentName) throws BPSFault {

    try {
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
        Registry tenantRegistry = registryService.getConfigSystemRegistry(tenantId);
        String deploymentRegistryPath = BPMNConstants.BPMN_REGISTRY_PATH + BPMNConstants.REGISTRY_PATH_SEPARATOR
                + deploymentName;
        if (tenantRegistry.resourceExists(deploymentRegistryPath)) {
            Resource deploymentEntry = tenantRegistry.get(deploymentRegistryPath);
            return deploymentEntry.getProperty(BPMNConstants.LATEST_CHECKSUM_PROPERTY);
        } else {
            return null;
        }
    } catch (RegistryException e) {
        String msg = "Error while accessing registry to get latest checksum for package : " + deploymentName;
        throw new BPSFault(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:27,代码来源:BPMNDeploymentService.java

示例6: deletePolicy

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
@Override
public void deletePolicy(String policyId) throws EntitlementException {

    Registry registry = EntitlementServiceComponent.
            getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    try {
        if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId)) {
            registry.delete(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId);
        }
    } catch (RegistryException e) {
        log.error("Error while deleting all versions of policy", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:14,代码来源:DefaultPolicyVersionManager.java

示例7: buildUIPermissionNodeNotAllSelected

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
private void buildUIPermissionNodeNotAllSelected(Collection parent, UIPermissionNode parentNode,
                                                 Registry registry, Registry tenantRegistry,
                                                 AuthorizationManager authMan, String roleName, String userName)
        throws RegistryException, UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];

    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (tenantRegistry != null && child.startsWith("/permission/applications")) {
            resource = tenantRegistry.get(child);
        } else if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        boolean isSelected = false;
        if (roleName != null) {
            isSelected = authMan.isRoleAuthorized(roleName, child,
                    UserMgtConstants.EXECUTE_ACTION);
        } else if (userName != null) {
            isSelected = authMan.isUserAuthorized(userName, child,
                    UserMgtConstants.EXECUTE_ACTION);
        }
        childNodes[i] = getUIPermissionNode(resource, isSelected);
        if (resource instanceof Collection) {
            buildUIPermissionNodeNotAllSelected((Collection) resource, childNodes[i],
                    registry, tenantRegistry, authMan, roleName, userName);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:37,代码来源:UserRealmProxy.java

示例8: updatePermissions

import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
 * Updates the permissions of the application
 *
 * @param applicationName
 * @param permissions
 * @throws IdentityApplicationManagementException
 */
public static void updatePermissions(String applicationName, ApplicationPermission[] permissions)
        throws IdentityApplicationManagementException {

    applicationNode = getApplicationPermissionPath() + PATH_CONSTANT + applicationName;

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

    try {

        boolean exist = tenantGovReg.resourceExists(applicationNode);
        if (!exist) {
            Collection appRootNode = tenantGovReg.newCollection();
            appRootNode.setProperty("name", applicationName);
            tenantGovReg.put(applicationNode, appRootNode);
        }

        Collection appNodeCollec = (Collection) tenantGovReg.get(applicationNode);
        String[] childern = appNodeCollec.getChildren();

        // new permissions are null. deleting all permissions case
        if ((childern != null && childern.length > 0)
                && (permissions == null || permissions.length == 0)) { // there are permissions
            tenantGovReg.delete(applicationNode);
        }

        if (ArrayUtils.isEmpty(permissions)) {
            return;
        }

        // no permission exist for the application, create new
        if (childern == null || appNodeCollec.getChildCount() < 1) {

            addPermission(permissions, tenantGovReg);

        } else { // there are permission
            List<ApplicationPermission> loadPermissions = loadPermissions(applicationName);
            for (ApplicationPermission applicationPermission : loadPermissions) {
                tenantGovReg.delete(applicationNode + PATH_CONSTANT + applicationPermission.getValue());
            }
            addPermission(permissions, tenantGovReg);
        }

    } catch (RegistryException e) {
        throw new IdentityApplicationManagementException("Error while storing permissions", e);
    }

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

示例9: 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.resourceExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。