本文整理汇总了Java中org.wso2.carbon.registry.api.Registry.get方法的典型用法代码示例。如果您正苦于以下问题:Java Registry.get方法的具体用法?Java Registry.get怎么用?Java Registry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.api.Registry
的用法示例。
在下文中一共展示了Registry.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: getSpeedAlerts
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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}";
}
}
示例3: getProximityAlerts
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的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}";
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: getPolicy
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
@Override
public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException {
// Zero means current version
if (version == null || version.trim().length() == 0) {
Registry registry = EntitlementServiceComponent.
getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
try {
Collection collection = (Collection) registry.
get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId);
if (collection != null) {
version = collection.getProperty("version");
}
} catch (RegistryException e) {
log.error(e);
throw new EntitlementException("Invalid policy version");
}
}
PAPPolicyStore policyStore = new PAPPolicyStore();
PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore);
Resource resource = policyStore.getPolicy(version,
PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId +
RegistryConstants.PATH_SEPARATOR);
if (resource == null) {
throw new EntitlementException("Invalid policy version");
}
return reader.readPolicyDTO(resource);
}
示例8: loadVerificationCode
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
/**
* Helper method
*
* @param verificationCode verificationCode as String
*/
private void loadVerificationCode(String verificationCode) {
Registry registry = EntitlementServiceComponent.
getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
try {
org.wso2.carbon.registry.api.Resource resource = registry.
get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode);
List<String> list = resource.getPropertyValues("subscriberIds");
if (list != null) {
subscriberIds = list.toArray(new String[list.size()]);
}
list = resource.getPropertyValues("policyIds");
if (list != null) {
policyIds = list.toArray(new String[list.size()]);
}
String version = resource.getProperty("version");
if (version != null) {
this.version = version;
}
String action = resource.getProperty("action");
if (action != null) {
this.action = action;
}
String order = resource.getProperty("order");
if (order != null) {
this.order = Integer.parseInt(order);
}
} catch (org.wso2.carbon.registry.api.RegistryException e) {
log.error("Error while loading verification code", e);
}
}
示例9: 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);
}
示例10: read
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
@Override
public InputStream read(String path) throws MLInputAdapterException {
try {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.get(path);
byte[] readArray = (byte[]) resource.getContent();
ByteArrayInputStream bis = new ByteArrayInputStream(readArray);
return bis;
} catch (RegistryException e) {
throw new MLInputAdapterException(String.format("Failed to read the model from uri %s: %s", path, e), e);
}
}
示例11: getResourceList
import org.wso2.carbon.registry.api.Registry; //导入方法依赖的package包/类
public static List<Resource> getResourceList(Registry registry, String pathResource) throws org.wso2.carbon.registry.api.RegistryException {
List<Resource> result = new ArrayList<Resource>();
Resource resource = registry.get(pathResource);
if (resource instanceof Collection) {
Object content = resource.getContent();
for (Object path : (Object[])content) {
result.addAll(getResourceList(registry,(String)path));
}
} else if (resource instanceof Resource){
result.add(resource);
}
return result;
}
示例12: 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);
}
}