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


Java Resource类代码示例

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


Resource类属于org.wso2.carbon.registry.api包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findDescendantResources

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
    Set<String> resourceSet = new HashSet<String>();
    registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
            getThreadLocalCarbonContext().getTenantId());
    if (registry.resourceExists(parentResourceId)) {
        Resource resource = registry.get(parentResourceId);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] resources = collection.getChildren();
            for (String res : resources) {
                resourceSet.add(res);
                getChildResources(res, resourceSet);
            }
        } else {
            return null;
        }
    }
    return resourceSet;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultResourceFinder.java

示例2: getChildResources

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
/**
 * This helps to find resources un a recursive manner
 *
 * @param node           attribute value node
 * @param parentResource parent resource Name
 * @return child resource set
 * @throws RegistryException throws
 */
private EntitlementTreeNodeDTO getChildResources(EntitlementTreeNodeDTO node,
                                                 String parentResource) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        String[] resourcePath = parentResource.split("/");
        EntitlementTreeNodeDTO childNode =
                new EntitlementTreeNodeDTO(resourcePath[resourcePath.length - 1]);
        node.addChildNode(childNode);
        Resource root = registry.get(parentResource);
        if (root instanceof Collection) {
            Collection collection = (Collection) root;
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                getChildResources(childNode, resource);
            }
        }
    }
    return node;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:CarbonEntitlementDataFinder.java

示例3: buildUIPermissionNodeAllSelected

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

示例4: getSpeedAlerts

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
@Override
public String getSpeedAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException {
    try {
        Registry registry = getGovernanceRegistry();
        Resource resource = registry.get(GeoServices.REGISTRY_PATH_FOR_ALERTS +
                                                 GeoServices.ALERT_TYPE_SPEED + "/" + identifier.getId());
        if (resource == null) {
            return "{'content': false}";
        }
        InputStream inputStream = resource.getContentStream();
        StringWriter writer = new StringWriter();
        IOUtils.copy(inputStream, writer, "UTF-8");
        return "{'speedLimit':" + writer.toString() + "}";
    } catch (RegistryException | IOException e) {
        return "{'content': false}";
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:18,代码来源:GeoLocationProviderServiceImpl.java

示例5: getProximityAlerts

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
@Override
public String getProximityAlerts(DeviceIdentifier identifier) throws GeoLocationBasedServiceException {
    try {
        Registry registry = getGovernanceRegistry();
        Resource resource = registry.get(GeoServices.REGISTRY_PATH_FOR_ALERTS +
                                                 GeoServices.ALERT_TYPE_PROXIMITY
                                                 + "/" + identifier.getId());
        if (resource != null) {
            Properties props = resource.getProperties();

            List proxDisObj = (List) props.get(GeoServices.PROXIMITY_DISTANCE);
            List proxTimeObj = (List) props.get(GeoServices.PROXIMITY_TIME);

            return String.format("{proximityDistance:\"%s\", proximityTime:\"%s\"}",
                                 proxDisObj != null ? proxDisObj.get(0).toString() : "",
                                 proxTimeObj != null ? proxTimeObj.get(0).toString() : "");
        } else {
            return "{'content': false}";
        }
    } catch (RegistryException e) {
        return "{'content': false}";
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:24,代码来源:GeoLocationProviderServiceImpl.java

示例6: 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

示例7: putRegistryResource

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
public static boolean putRegistryResource(String path,
                                          Resource resource)
		throws ConfigurationManagementException {
	boolean status;
	try {
		ConfigurationManagerUtil.getConfigurationRegistry().beginTransaction();
		ConfigurationManagerUtil.getConfigurationRegistry().put(path, resource);
		ConfigurationManagerUtil.getConfigurationRegistry().commitTransaction();
		status = true;
	} catch (RegistryException e) {
		throw new ConfigurationManagementException(
				"Error occurred while persisting registry resource : " +
				e.getMessage(), e);
	}
	return status;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:17,代码来源:ConfigurationManagerUtil.java

示例8: 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

示例9: addTrustedService

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
/**
 * Add a trusted service to which tokens are issued with given claims.
 *
 * @param realmName    - this uniquely represents the trusted service
 * @param claimDialect - claim dialects uris
 * @param claims       - these comma separated default claims are issued when a request is done from the given realm
 * @throws Exception - if fails to add trusted service
 */
public void addTrustedService(String realmName, String claimDialect, String claims)
        throws Exception {
    realmName = replaceSlashWithConstantString(realmName);
    try {
        Registry registry = IdentityPassiveSTSServiceComponent.getConfigSystemRegistry();
        String trustedServicePath = registryTrustedServicePath + realmName;
        // if registry collection does not exists, create
        if (!registry.resourceExists(trustedServicePath)) {
            Resource resource = registry.newResource();
            resource.addProperty(REALM_NAME, realmName);
            resource.addProperty(CLAIMS, claims);
            resource.addProperty(CLAIM_DIALECT, claimDialect);
            registry.put(trustedServicePath, resource);
        } else {
            throw new Exception(realmName + " already added. Please remove first and add again.");
        }
    } catch (RegistryException e) {
        String error = "Error occurred when adding a trusted service due to error in accessing registry.";
        throw new Exception(error, e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:RegistryBasedTrustedServiceStore.java

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

示例11: getLatestChecksum

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

示例12: delete

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
@Override
public void delete(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource instanceof Collection) {
        if(!isDeleteLockAvailable()){
            return;
        }
        acquireDeleteLock();
        try {
            deleteRecursively(requestContext.getRegistry(), resource);
            requestContext.setProcessingComplete(true);
        } finally {
            releaseDeleteLock();
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:17,代码来源:RecursiveDeleteHandler.java

示例13: getChildResources

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
/**
 * This helps to find resources un a recursive manner
 *
 * @param parentResource parent resource Name
 * @param childResources child resource set
 * @return child resource set
 * @throws RegistryException throws
 */
private Set<String> getChildResources(String parentResource, Set<String> childResources)
        throws RegistryException {

    Resource resource = registry.get(parentResource);
    if (resource instanceof Collection) {
        Collection collection = (Collection) resource;
        String[] resources = collection.getChildren();
        for (String res : resources) {
            childResources.add(res);
            getChildResources(res, childResources);
        }
    }
    return childResources;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:DefaultResourceFinder.java

示例14: 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

示例15: checkAndDeleteRegistryResource

import org.wso2.carbon.registry.api.Resource; //导入依赖的package包/类
/**
 * Check if resource has expired and delete.
 *
 * @param registry Registry instance to use.
 * @param resourcePath Path of resource to be deleted.
 * @throws RegistryException
 */
private static void checkAndDeleteRegistryResource (Registry registry, String resourcePath) throws
        RegistryException {

    Resource resource = registry.get(resourcePath);
    long currentEpochTime = System.currentTimeMillis();
    long resourceExpireTime = Long.parseLong(resource.getProperty(EXPIRE_TIME_PROPERTY));
    if (currentEpochTime > resourceExpireTime) {

        registry.delete(resource.getId());
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:19,代码来源:RegistryCleanUpService.java


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