本文整理汇总了Java中org.wso2.carbon.registry.core.session.UserRegistry.newResource方法的典型用法代码示例。如果您正苦于以下问题:Java UserRegistry.newResource方法的具体用法?Java UserRegistry.newResource怎么用?Java UserRegistry.newResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.session.UserRegistry
的用法示例。
在下文中一共展示了UserRegistry.newResource方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
@Override
public void write(int tenantId, Properties props, String resourcePath)
throws IdentityMgtConfigException {
if(log.isDebugEnabled()) {
log.debug("Writing data to registry path : " + resourcePath);
}
RegistryService registry = IdentityMgtServiceComponent.getRegistryService();
try {
UserRegistry userReg = registry.getConfigSystemRegistry(tenantId);
Resource resource = userReg.newResource();
Set<String> names = props.stringPropertyNames();
// Only key value pairs exists and no multiple values exists a key.
for (String keyName : names) {
List<String> value = new ArrayList<String>();
String valueStr = props.getProperty(keyName);
if(log.isDebugEnabled()) {
log.debug("Write key : " + keyName + " value : " + value);
}
// This is done due to casting to List in JDBCRegistryDao
value.add(valueStr);
resource.setProperty(keyName, value);
}
userReg.put(resourcePath, resource);
} catch (RegistryException e) {
throw new IdentityMgtConfigException(
"Error occurred while writing data to registry path : " + resourcePath, e);
}
}
示例2: defineQueries
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private void defineQueries(String queryPath, String queryContent) throws RegistryException {
UserRegistry registry =
(UserRegistry) Utils.getRegistry();
Resource q1 = registry.newResource();
q1.setContent(queryContent);
q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
q1.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
RegistryConstants.RESOURCES_RESULT_TYPE);
registry.put(queryPath, q1);
}
示例3: defineQueries
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private void defineQueries(Registry configSystemRegistry, String queryPath,
String queryContent) throws RegistryException {
UserRegistry registry = (UserRegistry) configSystemRegistry;
Resource q1 = registry.newResource();
q1.setContent(queryContent);
q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
q1.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
RegistryConstants.RESOURCES_RESULT_TYPE);
registry.put(queryPath, q1);
}
示例4: saveAdvancedSearchQueryBean
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static void saveAdvancedSearchQueryBean(UserRegistry userRegistry, CustomSearchParameterBean bean, String filterName)
throws RegistryException {
Resource r = userRegistry.newResource();
if (bean.getParameterValues() != null) {
for (String[] prop : bean.getParameterValues()) {
r.setProperty(prop[0], prop[1]);
}
}
userRegistry.put("users/" + userRegistry.getUserName() + "/searchFilters/" + filterName, r);
}
示例5: isEmailAlreadyAvailable
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private boolean isEmailAlreadyAvailable(Subscription subscription) {
// if one-time email verification is false or not defined, we do not need to check resource, and we will treat it as the resource was
// not available.
if (Boolean.parseBoolean(System.getProperty("onetime.email.verification", Boolean.toString(false)))) {
String email = subscription.getEventSinkURL().substring(subscription.getEventSinkURL().indexOf(":") + 1
, subscription.getEventSinkURL().length());
try {
UserRegistry registry = EventingDataHolder.getInstance().getRegistryService().getConfigSystemRegistry();
String emailIndexPath = this.emailIndexStoragePath;
Resource emailIndexResource;
if (registry.resourceExists(emailIndexPath)) {
emailIndexResource = registry.get(emailIndexPath);
Collection<Object> values = emailIndexResource.getProperties().values();
for (Iterator it = values.iterator(); it.hasNext(); ) {
String value = (((ArrayList) (it.next())).toArray())[0].toString();
if (value.equals(email)) {
return true;
}
}
} else {
emailIndexResource = registry.newResource();
registry.put(emailIndexPath, emailIndexResource);
}
} catch (RegistryException e) {
log.error("Unable to check email verification resource", e);
}
}
return false;
}
示例6: addTextResource
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static void addTextResource(
String parentPath,
String resourceName,
String mediaType,
String description,
String contentString,
UserRegistry userRegistry) throws Exception {
String resourcePath;
if (RegistryConstants.ROOT_PATH.equals(parentPath)) {
resourcePath = RegistryConstants.ROOT_PATH + resourceName;
} else {
resourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + resourceName;
}
byte[] content = null;
if (contentString != null) {
content = RegistryUtils.encodeString(contentString);
}
try {
Resource resource = userRegistry.newResource();
resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_ADMIN_CONSOLE);
resource.setMediaType(mediaType);
resource.setDescription(description);
resource.setContent(RegistryUtils.decodeBytes(content));
userRegistry.put(resourcePath, resource);
resource.discard();
} catch (RegistryException e) {
String msg = "Failed to add resource with text based content to path " +
resourcePath + ". " + ((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw new RegistryException(msg, e);
}
}
示例7: persistConfiguration
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* Save the given DeploymentSynchronizerConfiguration to the registry. The target
* configuration registry space will be selected using the specified tenant ID. As a result
* the configuration will be stored in the configuration registry of the specified
* tenant.
*
* @param config The configuration to be saved
* @param tenantId Tenant ID to select the configuration registry
* @throws org.wso2.carbon.registry.core.exceptions.RegistryException if an error occurs while accessing the registry
*/
public static void persistConfiguration(DeploymentSynchronizerConfiguration config,
int tenantId) throws RegistryException {
Resource resource;
UserRegistry localRepository = getLocalRepository(tenantId);
if (!localRepository.resourceExists(DeploymentSynchronizerConstants.CARBON_REPOSITORY)) {
resource = localRepository.newResource();
} else {
resource = localRepository.get(DeploymentSynchronizerConstants.CARBON_REPOSITORY);
}
resource.setProperty(DeploymentSynchronizerConstants.AUTO_COMMIT_MODE,
String.valueOf(config.isAutoCommit()));
resource.setProperty(DeploymentSynchronizerConstants.AUTO_CHECKOUT_MODE,
String.valueOf(config.isAutoCheckout()));
resource.setProperty(DeploymentSynchronizerConstants.AUTO_SYNC_PERIOD,
String.valueOf(config.getPeriod()));
resource.setProperty(DeploymentSynchronizerConstants.USE_EVENTING,
String.valueOf(config.isUseEventing()));
resource.setProperty(DeploymentSynchronizerConstants.REPOSITORY_TYPE,
config.getRepositoryType());
resource.setContent(config.isEnabled() ? "enabled" : "disabled");
//Get Repository specific configuration parameters from config object.
RepositoryConfigParameter[] parameters = config.getRepositoryConfigParameters();
if (parameters != null && parameters.length != 0) {
//Save each Repository specific configuration parameter in registry.
for (int i = 0; i < parameters.length; i++) {
resource.setProperty(parameters[i].getName(), parameters[i].getValue());
}
}
localRepository.put(DeploymentSynchronizerConstants.CARBON_REPOSITORY, resource);
resource.discard();
}
示例8: addSubscription
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void addSubscription(Subscription subscription) throws EventBrokerException {
try {
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
.getTenantId());
String resourcePath =
getResourcePath(subscription.getId(), subscription.getTopicName());
Resource resource = userRegistry.newResource();
resource.setProperty(EventBrokerConstants.EB_RES_SUBSCRIPTION_URL, subscription
.getEventSinkURL());
resource.setProperty(EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME, subscription
.getEventDispatcherName());
if (subscription.getExpires() != null) {
resource.setProperty(EventBrokerConstants.EB_RES_EXPIRS, ConverterUtil
.convertToString(subscription
.getExpires()));
}
resource.setProperty(EventBrokerConstants.EB_RES_OWNER, subscription.getOwner());
resource.setProperty(EventBrokerConstants.EB_RES_TOPIC_NAME, subscription
.getTopicName());
resource.setProperty(EventBrokerConstants.EB_RES_CREATED_TIME,
System.currentTimeMillis() + "");
resource.setProperty(EventBrokerConstants.EB_RES_MODE, JavaUtil
.getSubscriptionMode(subscription
.getTopicName()));
//set the other properties of the subscription.
Map<String, String> properties = subscription.getProperties();
for (String key : properties.keySet()) {
resource.setProperty(key, properties.get(key));
}
userRegistry.put(resourcePath, resource);
// add the subscription index
String fullPath = this.indexStoragePath;
Resource topicIndexResource;
if (userRegistry.resourceExists(fullPath)) {
topicIndexResource = userRegistry.get(fullPath);
topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
} else {
topicIndexResource = userRegistry.newResource();
topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
}
userRegistry.put(fullPath, topicIndexResource);
} catch (RegistryException e) {
throw new EventBrokerException("Cannot save to registry ", e);
}
}
示例9: importResource
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static String importResource(
String parentPath,
String resourceName,
String mediaType,
String description,
String fetchURL,
String symlinkLocation,
UserRegistry userRegistry,
String[][] properties) throws Exception {
String resourcePath;
if (RegistryConstants.ROOT_PATH.equals(parentPath)) {
resourcePath = RegistryConstants.ROOT_PATH + resourceName;
} else {
resourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + resourceName;
}
try {
Resource metadataResource = userRegistry.newResource();
metadataResource.setMediaType(mediaType);
metadataResource.setDescription(description);
if (symlinkLocation != null) {
if (!symlinkLocation.endsWith(RegistryConstants.PATH_SEPARATOR)) {
symlinkLocation += RegistryConstants.PATH_SEPARATOR;
}
metadataResource.setProperty(RegistryConstants.SYMLINK_PROPERTY_NAME, symlinkLocation);
}
if (properties != null && properties.length > 0) {
for (String[] p : properties) {
metadataResource.setProperty(p[0], p[1]);
}
}
metadataResource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_ADMIN_CONSOLE);
String path = userRegistry.importResource(resourcePath, fetchURL, metadataResource);
/* if (properties != null && properties.length > 0) {
Resource resource = userRegistry.get(path);
for (String[] p : properties) {
resource.setProperty(p[0], p[1]);
}
userRegistry.put(path, resource);
}*/
metadataResource.discard();
return path;
} catch (RegistryException e) {
String msg = "Failed to import resource from the URL " + fetchURL + " to path " +
resourcePath + ". " + ((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw new RegistryException(msg, e);
}
}
示例10: addSubscription
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void addSubscription(Subscription subscription) throws EventBrokerException {
try {
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
.getTenantId());
String resourcePath =
getResourcePath(subscription.getId(), subscription.getTopicName());
Resource resource = userRegistry.newResource();
resource.setProperty(EventBrokerConstants.EB_RES_SUBSCRIPTION_URL, subscription
.getEventSinkURL());
resource.setProperty(EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME, subscription
.getEventDispatcherName());
if (subscription.getExpires() != null) {
resource.setProperty(EventBrokerConstants.EB_RES_EXPIRS, ConverterUtil
.convertToString(subscription
.getExpires()));
}
resource.setProperty(EventBrokerConstants.EB_RES_OWNER, subscription.getOwner());
resource.setProperty(EventBrokerConstants.EB_RES_TOPIC_NAME, subscription
.getTopicName());
resource.setProperty(EventBrokerConstants.EB_RES_CREATED_TIME, Long.toString(System.currentTimeMillis()));
resource.setProperty(EventBrokerConstants.EB_RES_MODE, JavaUtil
.getSubscriptionMode(subscription
.getTopicName()));
//set the other properties of the subscription.
Map<String, String> properties = subscription.getProperties();
for (String key : properties.keySet()) {
resource.setProperty(key, properties.get(key));
}
userRegistry.put(resourcePath, resource);
// add the subscription index
String fullPath = this.indexStoragePath;
Resource topicIndexResource;
if (userRegistry.resourceExists(fullPath)) {
topicIndexResource = userRegistry.get(fullPath);
topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
} else {
topicIndexResource = userRegistry.newResource();
topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
}
userRegistry.put(fullPath, topicIndexResource);
} catch (RegistryException e) {
throw new EventBrokerException("Cannot save to registry ", e);
}
}