本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils类的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils类的具体用法?Java RegistryUtils怎么用?Java RegistryUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryUtils类属于org.wso2.carbon.registry.core.utils包,在下文中一共展示了RegistryUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
}
示例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()]);
}
示例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()]);
}
示例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);
}
}
示例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;
}
示例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()]);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}