本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils类的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils类的具体用法?Java RegistryUtils怎么用?Java RegistryUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryUtils类属于org.wso2.carbon.registry.core.utils包,在下文中一共展示了RegistryUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setProperty
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* Method to add a property, if there already exist a property with the same name, this
* will add the value to the existing property name. (So please remove the old property with
* the same name before calling this method).
*
* @param path path of the resource.
* @param name property name.
* @param value property value.
*
* @throws RegistryException throws if there is an error.
*/
public void setProperty(String path, String name, String value) throws RegistryException {
if(name != null && name.startsWith("registry.")) {
throw new RegistryException("Property cannot start with the \"registry.\" prefix. " +
"Property name " + name + ". Resource path = " + path);
}
UserRegistry registry = (UserRegistry) getRootRegistry();
if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
return;
}
Resource resource = registry.get(path);
if(resource.getProperties().keySet().contains(name)) {
throw new RegistryException("Cannot duplicate property name. Please choose a different name. " +
"Property name " + name + ". Resource path = " + path);
}
resource.addProperty(name, value);
registry.put(resource.getPath(), resource);
resource.discard();
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:33,代码来源:PropertiesAdminService.java
示例2: getRxtData
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* This method is used to get rxt data.
*
* @param userRegistry userRegistry.
* @return
* @throws RegistryException
*/
public static Map<String, List<String>> getRxtData(UserRegistry userRegistry) throws RegistryException {
String[] paths = getRxtPathLists(userRegistry);
Map<String, List<String>> RxtDetails = new ConcurrentHashMap<>();
for (String path : paths) {
String rxtContent = RegistryUtils.decodeBytes((byte[]) userRegistry.get(path).getContent());
RxtUnboundedEntryBean rxtUnboundedEntryBean = getRxtUnboundedEntries(rxtContent);
String mediaType = rxtUnboundedEntryBean.getMediaType();
List<String> unboundedFields = rxtUnboundedEntryBean.getFields();
if (mediaType != null && unboundedFields.size() > 0) {
RxtDetails.put(rxtUnboundedEntryBean.getMediaType(), rxtUnboundedEntryBean.getFields());
}
}
return RxtDetails;
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:RxtUnboundedDataLoadUtils.java
示例3: getAll
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* @return all meta data instances and their children that denotes from this particular media type
*/
protected static List<VersionBase> getAll(Registry registry, String mt) throws MetadataException {
List<VersionBase> baseResult = new ArrayList<VersionBase>();
Map<String, String> criteria = new HashMap<String, String>();
criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
try {
ResourceData[] results = Util.getAttributeSearchService().search(criteria);
for (ResourceData resourceData : results) {
String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
if (registry.resourceExists(path)) {
Resource resource = registry.get(path);
baseResult.add(Util.getVersionBaseProvider(mt).get(resource, registry));
}
}
} catch (RegistryException e) {
throw new MetadataException(e.getMessage(), e);
}
return baseResult;
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:22,代码来源:VersionBase.java
示例4: testContentStreaming
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public void testContentStreaming() throws Exception {
Resource r3 = registry.newResource();
String path = "/content/stream/content.txt";
r3.setContent(RegistryUtils.encodeString("this is the content"));
r3.setDescription("this is test desc");
r3.setMediaType("plain/text");
r3.setProperty("test2", "value2");
r3.setProperty("test1", "value1");
registry.put(path, r3);
Resource r4 = registry.get("/content/stream/content.txt");
assertEquals("Content is not equal.", RegistryUtils.decodeBytes((byte[]) r3.getContent()),
RegistryUtils.decodeBytes((byte[]) r4.getContent()));
InputStream isTest = r4.getContentStream();
assertEquals("Content stream is not equal.", RegistryUtils.decodeBytes((byte[]) r3.getContent()),
convertStreamToString(isTest));
r3.discard();
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:25,代码来源:TestContentStream.java
示例5: testIndexDocument
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public void testIndexDocument() throws Exception {
String jsonContent = "{\n" +
"\tcolor: \"red\",\n" +
"\tvalue: \"#f00\"\n" +
"}";
String mediaType = "application/json";
int tenantID = -1234;
String tenantDomain = "carbon.super";
String path = "/_system/local/temp";
byte[] byteContent = RegistryUtils.encodeString(jsonContent);
AsyncIndexer.File2Index fileData = new AsyncIndexer.File2Index(byteContent, mediaType,
path, tenantID, tenantDomain);
JSONIndexer jsonIndexer = new JSONIndexer();
final SolrInputDocument[] document = {null};
when(server.add((SolrInputDocument) anyObject())).thenAnswer(new Answer<UpdateResponse>() {
@Override
public UpdateResponse answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
document[0] = (SolrInputDocument) args[0];
return null;
}
});
SolrClient.getInstance().indexDocument(fileData, jsonIndexer);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:26,代码来源:SolrClientTest.java
示例6: setArtifactUIConfiguration
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public boolean setArtifactUIConfiguration(String key, String update) throws RegistryException {
Registry registry = getConfigSystemRegistry();
if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
return false;
}
try {
Util.validateOMContent(Util.buildOMElement(update));
String path = GOVERNANCE_ARTIFACT_CONFIGURATION_PATH + key;
if(registry.resourceExists(path)) {
Resource resource = registry.get(path);
resource.setContent(update);
registry.put(path, resource);
}
return true;
} catch (Exception e) {
log.error("An error occurred while saving configuration", e);
return false;
}
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:21,代码来源:ManageGenericArtifactService.java
示例7: getAllSchemas
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* Finds all schema artifacts on the registry.
*
* @return all schema artifacts on the registry.
* @throws GovernanceException if the operation failed.
*/
public Schema[] getAllSchemas() throws GovernanceException {
List<String> schemaPaths =
Arrays.asList(GovernanceUtils.getResultPaths(registry,
GovernanceConstants.SCHEMA_MEDIA_TYPE));
Collections.sort(schemaPaths, new Comparator<String>() {
public int compare(String o1, String o2) {
// First order by name
int result = RegistryUtils.getResourceName(o1).compareToIgnoreCase(
RegistryUtils.getResourceName(o2));
if (result != 0) {
return result;
}
// Then order by namespace
return o1.compareToIgnoreCase(o2);
}
});
List<Schema> schemas = new ArrayList<Schema>();
for (String schemaPath : schemaPaths) {
GovernanceArtifact artifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(registry, schemaPath);
schemas.add((Schema) artifact);
}
return schemas.toArray(new Schema[schemas.size()]);
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:31,代码来源:SchemaManager.java
示例8: getSavedReports
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public ReportConfigurationBean[] getSavedReports()
throws RegistryException, CryptoException, TaskException {
Registry registry = getConfigSystemRegistry();
List<ReportConfigurationBean> output = new LinkedList<ReportConfigurationBean>();
if (registry.resourceExists(REPORTING_CONFIG_PATH)) {
Collection collection = (Collection) registry.get(REPORTING_CONFIG_PATH);
String[] children = collection.getChildren();
for (String child : children) {
ReportConfigurationBean bean = getConfigurationBean(child);
Registry rootRegistry1 = getRootRegistry();
if (!rootRegistry1.resourceExists(bean.getTemplate())) {
log.warn("Report template " + bean.getTemplate() + " doesn't exist");
}
try {
RegistryUtils.loadClass(bean.getReportClass());
} catch (ClassNotFoundException e) {
log.warn("Report class not found " + bean.getReportClass());
}
output.add(bean);
}
}
return output.toArray(new ReportConfigurationBean[output.size()]);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:ReportingAdminService.java
示例9: removeLink
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public void removeLink(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path);
if (!sendNotifications(requestContext, relativePath)){
return;
}
String parentPath = RegistryUtils.getParentPath(relativePath);
RegistryEvent<String> event = new CollectionUpdatedEvent<String>("The link at " + relativePath + " was removed.");
((CollectionUpdatedEvent)event).setResourcePath(parentPath);
event.setParameter("SymbolicLink", relativePath);
event.setParameter("RegistryOperation", "removeLink");
event.setTenantId(CurrentSession.getCallerTenantId());
try {
notify(event, requestContext.getRegistry(), parentPath);
} catch (Exception e) {
handleException("Unable to send notification for Remove Link Operation", e);
}
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:RegistryEventingHandler.java
示例10: setEndpoint
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
private OMElement setEndpoint(Registry registry, String definitionURL, OMElement serviceInfoElement) throws RegistryException {
Association[] associations = registry.getAssociations(definitionURL, CommonConstants.DEPENDS);
for (Association association: associations) {
String targetPath = association.getDestinationPath();
if (registry.resourceExists(targetPath)) {
Resource targetResource = registry.get(targetPath);
if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(targetResource.getMediaType())) {
byte[] sourceContent = (byte[]) targetResource.getContent();
if (sourceContent == null) {
return serviceInfoElement;
}
String endpointUrl = EndpointUtils.deriveEndpointFromContent(RegistryUtils.decodeBytes(sourceContent));
try {
serviceInfoElement = EndpointUtils.addEndpointToService(serviceInfoElement, endpointUrl, "");
} catch (RegistryException e){}
}
}
}
return serviceInfoElement;
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:22,代码来源:SOAPServiceMediaTypeHandler.java
示例11: getAllWsdls
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* Finds all WSDL artifacts on the registry.
*
* @return all WSDL artifacts on the registry.
* @throws GovernanceException if the operation failed.
*/
public Wsdl[] getAllWsdls() throws GovernanceException {
List<String> wsdlPaths =
Arrays.asList(GovernanceUtils.getResultPaths(registry,
GovernanceConstants.WSDL_MEDIA_TYPE));
Collections.sort(wsdlPaths, new Comparator<String>() {
public int compare(String o1, String o2) {
// First order by name
int result = RegistryUtils.getResourceName(o1).compareToIgnoreCase(
RegistryUtils.getResourceName(o2));
if (result != 0) {
return result;
}
// Then order by namespace
return o1.compareToIgnoreCase(o2);
}
});
List<Wsdl> wsdls = new ArrayList<Wsdl>();
for (String wsdlPath : wsdlPaths) {
GovernanceArtifact artifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(registry, wsdlPath);
wsdls.add((Wsdl) artifact);
}
return wsdls.toArray(new Wsdl[wsdls.size()]);
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:31,代码来源:WsdlManager.java
示例12: saveEndpoint
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
private static void saveEndpoint(RequestContext context, Registry registry, String url, String associatedPath,
Map<String, String> properties, Registry systemRegistry, String environment)
throws RegistryException {
String pathExpression = getEndpointLocation(context, url, systemRegistry, environment);
String urlToPath = deriveEndpointFromUrl(url);
String endpointAbsoluteBasePath = RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
org.wso2.carbon.registry.core.RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
environment);
if (!systemRegistry.resourceExists(endpointAbsoluteBasePath)) {
systemRegistry.put(endpointAbsoluteBasePath, systemRegistry.newCollection());
}
String relativePath = environment + urlToPath;
String endpointAbsolutePath = pathExpression;
saveEndpointValues(context, registry, url, associatedPath, properties, systemRegistry, relativePath,
endpointAbsolutePath);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:20,代码来源:EndpointUtils.java
示例13: testResourceContentVersioning
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public void testResourceContentVersioning() throws Exception {
Resource r1 = registry.newResource();
r1.setContent(RegistryUtils.encodeString("content 1"));
registry.put("/v2/r1", r1);
Resource r12 = registry.get("/v2/r1");
r12.setContent(RegistryUtils.encodeString("content 2"));
registry.put("/v2/r1", r12);
registry.put("/v2/r1", r12);
String[] r1Versions = registry.getVersions("/v2/r1");
Resource r1vv1 = registry.get(r1Versions[1]);
assertEquals("r1's first version's content should be 'content 1'",
RegistryUtils.decodeBytes((byte[]) r1vv1.getContent()), "content 1");
Resource r1vv2 = registry.get(r1Versions[0]);
assertEquals("r1's second version's content should be 'content 2'",
RegistryUtils.decodeBytes((byte[]) r1vv2.getContent()), "content 2");
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:VersionHandlingTest.java
示例14: updateHandler
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public boolean updateHandler(String oldName, String payload) throws Exception {
RegistryUtils.recordStatistics(oldName, payload);
Registry configSystemRegistry = getConfigSystemRegistry();
String parsedPayload;
try {
parsedPayload = parseHandlerConfiguration(payload);
} catch (Exception e) {
log.error("Unable to parse the given handler configuration.", e);
throw new Exception("Unable to parse the given handler configuration. " +
e.getMessage());
}
if (parsedPayload == null) {
throw new Exception("The provided handler configuration is invalid.");
}
return !RegistryUtils.isRegistryReadOnly(configSystemRegistry.getRegistryContext()) &&
CommonUtil.updateHandler(configSystemRegistry, oldName, parsedPayload);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:18,代码来源:HandlerManagementService.java
示例15: setUp
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
Resource resource = registry.newResource();
byte[] r1content = RegistryUtils.encodeString("Resource 17 content");
resource.setContent(r1content);
resource.setMediaType("application/test");
resource.setDescription("Sample 17 Description");
resource.setVersionableChange(true);
resource.addAspect("Servicelifecycle");
registry.put("/test/2017/10/18", resource);
registry.addAspect("Servicelifecycle", new DefaultLifecycle());
SimulationService simulationService = new RegistryCoreServiceComponent.DefaultSimulationService();
simulationService.setSimulation(false);
CommonUtil.setSimulationService(simulationService);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:18,代码来源:CommonUtilTest.java
示例16: move
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public String move(RequestContext requestContext) throws RegistryException {
validateUpdateInProgress();
String sourcePath = requestContext.getSourcePath();
String targetPath = requestContext.getTargetPath();
if (sourcePath.startsWith(mountPath) && targetPath.startsWith(mountPath)) {
String source = RegistryUtils.getRelativePathToOriginal(sourcePath, mountPath);
filesystemManager.copy(source,
RegistryUtils.getRelativePathToOriginal(targetPath, mountPath));
filesystemManager.delete(source);
} else if (targetPath.startsWith(mountPath)) {
preparePut(RegistryUtils.getRelativePathToOriginal(targetPath, mountPath),
requestContext);
} else if (sourcePath.startsWith(mountPath)) {
filesystemManager.delete(
RegistryUtils.getRelativePathToOriginal(sourcePath, mountPath));
}
return null;
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:ExternalContentHandler.java
示例17: getAllPolicies
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* Finds all policy artifacts on the registry.
*
* @return all policy artifacts on the registry.
* @throws GovernanceException if the operation failed.
*/
public Policy[] getAllPolicies() throws GovernanceException {
List<String> policyPaths =
Arrays.asList(GovernanceUtils.getResultPaths(registry,
GovernanceConstants.POLICY_XML_MEDIA_TYPE));
Collections.sort(policyPaths, new Comparator<String>() {
public int compare(String o1, String o2) {
return RegistryUtils.getResourceName(o1).compareToIgnoreCase(
RegistryUtils.getResourceName(o2));
}
});
List<Policy> policies = new ArrayList<Policy>();
for (String policyPath : policyPaths) {
GovernanceArtifact artifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(registry, policyPath);
policies.add((Policy) artifact);
}
return policies.toArray(new Policy[policies.size()]);
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:25,代码来源:PolicyManager.java
示例18: find
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
/**
* Search all meta data instances of this particular type with the given search attributes
*
* @param criteria Key value map that has search attributes
* @return
*/
protected static List<Base> find(Registry registry, Map<String, String> criteria, String mt) throws MetadataException {
BaseProvider provider = Util.getBaseProvider(mt);
if (criteria != null && criteria.get(Constants.ATTRIBUTE_MEDIA_TYPE) == null) {
criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
}
List<Base> baseResult = new ArrayList<Base>();
try {
ResourceData[] results = Util.getAttributeSearchService().search(criteria);
for (ResourceData resourceData : results) {
String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
if (registry.resourceExists(path)) {
Resource resource = registry.get(path);
baseResult.add(provider.get(resource, registry));
}
}
} catch (RegistryException e) {
log.error(e.getMessage());
throw new MetadataException(e.getMessage(), e);
}
return baseResult;
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:Base.java
示例19: testRatingsPath
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
public void testRatingsPath() throws Exception {
Resource r5 = registry.newResource();
String r5Content = "this is r5 content";
r5.setContent(RegistryUtils.encodeString(r5Content));
r5.setDescription("production ready.");
String r5Path = "/c1/r5";
registry.put(r5Path, r5);
registry.rateResource("/c1/r5", 3);
Resource ratings = registry.get("/c1/r5;ratings");
String[] ratingPaths = (String[]) ratings.getContent();
int rating;
Resource c1 = registry.get(ratingPaths[0]);
Object o = c1.getContent();
if (o instanceof Integer) {
rating = (Integer) o;
} else {
rating = Integer.parseInt(o.toString());
}
assertEquals("Ratings are not retrieved properly as resources.", rating, 3);
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:27,代码来源:RatingTest.java
示例20: getTaxonomyBean
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入依赖的package包/类
private TaxonomyBean getTaxonomyBean(String taxonomyName) {
TaxonomyBean taxonomyBean = tenantTaxonomyMap.get(tenantId).get(taxonomyName);
if (taxonomyBean != null) {
return taxonomyBean;
} else {
Registry registry = getGovernanceSystemRegistry();
try {
if (registry.resourceExists(TAXONOMY_CONFIGURATION_PATH + taxonomyName)) {
Resource resource;
resource = registry.get(TAXONOMY_CONFIGURATION_PATH + taxonomyName);
taxonomyBean = CommonUtils.documentBeanBuilder(RegistryUtils.decodeBytes((byte[]) resource.getContent()));
tenantTaxonomyMap.get(tenantId).put(taxonomyName, taxonomyBean);
return taxonomyBean;
} else {
return null;
}
} catch (RegistryException | SAXException | IOException | ParserConfigurationException e) {
//Will ignore registry access and xml parsing related exception here.
return null;
}
}
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:23,代码来源:StorageProviderImpl.java
注:本文中的org.wso2.carbon.registry.core.utils.RegistryUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论