本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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);
}
示例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);
}
}