本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.setMediaType方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setMediaType方法的具体用法?Java Resource.setMediaType怎么用?Java Resource.setMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.Resource
的用法示例。
在下文中一共展示了Resource.setMediaType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTagSearchQuery
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* custom query for all the tags search is set as a resource and saved at
* the config registry.space
*/
private boolean setTagSearchQuery() {
if (log.isDebugEnabled()) {
log.debug("tag search customs query is set");
}
String tagsQueryPath =
RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
RegistryConstants.QUERIES_COLLECTION_PATH + "/tags";
try {
if (!super.getUserRegistry().resourceExists(tagsQueryPath)) {
// set-up query for tag-search.
Resource resource = super.getUserRegistry().newResource();
resource.setContent("SELECT RT.REG_TAG_ID FROM REG_RESOURCE_TAG RT ORDER BY "
+ "RT.REG_TAG_ID");
resource.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
resource.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
RegistryConstants.TAGS_RESULT_TYPE);
super.getUserRegistry().put(tagsQueryPath, resource);
}
return true;
} catch (RegistryException e) {
log.error(e.getCause(), e);
return false;
}
}
示例2: setup
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Before
public void setup() throws RegistryException {
userRegistry = mock(UserRegistry.class);
Collection resultCollection = new CollectionImpl();
resultCollection.setContent(new String[]
{"/_system/config/repository/components/org.wso2.carbon.governance/configuration/restservice"});
when(userRegistry.executeQuery(anyString(), (Map) anyObject())).thenReturn(resultCollection);
Resource rxtResource = new ResourceImpl();
rxtResource.setMediaType("application/xml");
InputStream is = null;
try {
is = RxtUnboundedDataLoadUtilsTest.class.getClassLoader().getResourceAsStream("restservice.rxt");
rxtResource.setContentStream(is);
when(userRegistry.get("/_system/config/repository/components/org.wso2.carbon" +
".governance/configuration/restservice")).thenReturn(rxtResource);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignore) {
}
}
}
}
示例3: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的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);
}
示例4: testUpdateService
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testUpdateService() throws Exception {
Resource resource = registry.newResource();
resource.setMediaType(GovernanceConstants.GOVERNANCE_ARTIFACT_CONFIGURATION_MEDIA_TYPE);
resource.setContentStream(this.getClass().getClassLoader().getResourceAsStream("service.rxt"));
registry.put("/service", resource);
GovernanceUtils.loadGovernanceArtifacts((UserRegistry) registry);
ServiceManager serviceManager = new ServiceManager(registry);
QName qName = new QName("Sample");
Service service = serviceManager.newService(qName);
service.setAttribute("overview_name", "Sample");
service.setAttribute("overview_version", "1.0.0");
service.setAttribute("overview_custom", "oldValue");
serviceManager.addService(service);
service.setAttribute("overview_custom", "newValue");
serviceManager.updateService(service);
service = serviceManager.getService(service.getId());
assertEquals("newValue", service.getAttribute("overview_custom"));
serviceManager.removeService(service.getId());
clean();
}
示例5: testGetResourceoperation
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testGetResourceoperation() throws Exception {
Resource r2 = registry.newResource();
String path = "/testk/testa/derby.log";
r2.setContent(RegistryUtils.encodeString("this is the content"));
r2.setDescription("this is test desc this is test desc this is test desc this is test desc this is test desc " +
"this is test desc this is test desc this is test desc this is test descthis is test desc ");
r2.setMediaType("plain/text");
registry.put(path, r2);
r2.discard();
Resource r3 = registry.newResource();
// assertEquals("Author names are not Equal", "admin", r3.getAuthorUserName());
r3 = registry.get(path);
assertEquals("Author User names are not Equal", "admin", r3.getAuthorUserName());
assertNotNull("Created time is null", r3.getCreatedTime());
assertEquals("Author User names are not Equal", "admin", r3.getAuthorUserName());
assertEquals("Description is not Equal", "this is test desc this is test desc this is test desc this is test" +
" desc this is test desc this is test desc this is test desc this is test desc this is test descthis is " +
"test desc ", r3.getDescription());
assertNotNull("Get Id is null", r3.getId());
assertNotNull("LastModifiedDate is null", r3.getLastModified());
assertEquals("Last Updated names are not Equal", "admin", r3.getLastUpdaterUserName());
//System.out.println(r3.getMediaType());
assertEquals("Media Type is not equal", "plain/text", r3.getMediaType());
assertEquals("parent Path is not equal", "/testk/testa", r3.getParentPath());
assertEquals("parent Path is not equal", path, r3.getPath());
assertEquals("Get stated wrong", 0, r3.getState());
String st = r3.getPermanentPath();
// assertTrue("Permenent path contanin the string" + path + " verion", st.contains("/testk/testa/derby.log;version:"));
}
示例6: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setUp() throws RegistryException {
super.setUp();
Resource resource = registry.newResource();
byte[] r1content = RegistryUtils.encodeString("Resource 16 content");
resource.setContent(r1content);
resource.setMediaType("application/test");
registry.put("/test/2017/10/16", resource);
registry.createVersion("/test/2017/10/16"); //version 1
registry.createVersion("/test/2017/10/16"); //version 2
}
示例7: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setUp() throws RegistryException {
super.setUp();
Resource resource = registry.newResource();
byte[] r1content = RegistryUtils.encodeString("Resource content");
resource.setContent(r1content);
resource.setMediaType("application/test");
resource.setDescription("Sample Description");
resource.setVersionableChange(true);
registry.put("/test/2017/10/15", resource);
registry.createVersion("/test/2017/10/15");
}
示例8: testGetResourceAssociation
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testGetResourceAssociation() throws Exception {
Resource r2 = registry.newResource();
String path = "/testk1234/testa/testbsp/test.txt";
r2.setContent(RegistryUtils.encodeString("this is the content"));
r2.setDescription("this is test desc");
r2.setMediaType("plain/text");
r2.setProperty("test2", "value2");
registry.addAssociation(path, "/vtr2121/test", "testasstype1");
registry.addAssociation(path, "/vtr2122/test", "testasstype2");
registry.addAssociation(path, "/vtr2123/test", "testasstype3");
assertTrue("association Destination path not exist", getAssocitionbyDestinationByType(path, "testasstype1", "/vtr2121/test"));
assertTrue("association Destination path not exist", getAssocitionbyDestinationByType(path, "testasstype2", "/vtr2122/test"));
assertTrue("association Destination path not exist", getAssocitionbyDestinationByType(path, "testasstype3", "/vtr2123/test"));
assertTrue("association Type not exist", getAssocitionbyType(path, "testasstype1"));
assertTrue("association Type not exist", getAssocitionbyType(path, "testasstype2"));
assertTrue("association Type not exist", getAssocitionbyType(path, "testasstype3"));
assertTrue("association Source path not exist", getAssocitionbySourceByType(path, "testasstype1"));
assertTrue("association Source path not exist", getAssocitionbySourceByType(path, "testasstype2"));
assertTrue("association Source path not exist", getAssocitionbySourceByType(path, "testasstype3"));
}
示例9: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setUp() throws RegistryException {
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);
registry.put("/test/2017/10/18", resource);
}
示例10: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setUp() throws RegistryException {
super.setUp();
Resource r1 = registry.newResource();
byte[] r1content = RegistryUtils.encodeString("R1 content");
r1.setContent(r1content);
r1.setMediaType("application/test");
registry.put("/test/2017/10/21", r1);
}
示例11: testputResourceasStreamXML
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testputResourceasStreamXML() throws RegistryException, FileNotFoundException, Exception {
final String description = "testPutXMLResourceAsBytes";
final String mediaType = "application/xml";
// Establish where we are putting the resource in registry
final String registryPath = "/wso2registry/conf/pom.xml";
InputStream is = new BufferedInputStream(new FileInputStream("pom.xml"));
String st = null;
try {
st = slurp(is);
} catch (IOException e) {
e.printStackTrace();
}
Resource resource = registry.newResource();
resource.setContent(RegistryUtils.encodeString(st));
resource.setDescription(description);
resource.setMediaType(mediaType);
registry.put(registryPath, resource);
Resource r2 = registry.get(registryPath);
assertEquals("File content is not matching", RegistryUtils.decodeBytes((byte[]) resource.getContent()),
RegistryUtils.decodeBytes((byte[]) r2.getContent()));
}
示例12: setUp
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setUp() throws RegistryException {
super.setUp();
Resource r1 = registry.newResource();
byte[] r1content = RegistryUtils.encodeString("R1 content");
r1.setContent(r1content);
r1.setMediaType("application/test");
r1.setProperty("key", "value");
registry.put("/test/2017/10/24", r1);
}
示例13: writeHistory
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void writeHistory(StatCollection currentCollection) {
try {
Registry systemRegistry;
try {
systemRegistry = currentCollection.getRegistry().getRegistryContext().getEmbeddedRegistryService()
.getGovernanceSystemRegistry(CurrentSession.getTenantId());
} catch (RegistryException ex) {
systemRegistry = currentCollection.getRegistry();
}
String resourcePath = currentCollection.getResourcePath();
Resource statResource;
String statResourcePath;
if (currentCollection.getOriginalPath().equals(resourcePath)) {
statResourcePath = getStatResourcePath(resourcePath);
}else{
statResourcePath = getStatResourcePath(currentCollection.getOriginalPath());
}
if (systemRegistry.resourceExists(statResourcePath)) {
statResource = systemRegistry.get(statResourcePath);
} else {
statResource = systemRegistry.newResource();
statResource.setMediaType("application/xml");
}
statResource.setContent(buildOMContent(statResource, currentCollection));
systemRegistry.put(statResourcePath, statResource);
} catch (Exception e) {
log.error("Failed to add lifecycle history", e);
}
}
示例14: testIndexing
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testIndexing() throws RegistryException {
Resource r6 = registry.newResource();
String r6Content = "this is r6 content";
r6.setContent(RegistryUtils.encodeString(r6Content));
r6.setDescription("production ready.");
r6.setMediaType("text/plain");
String r6Path = "/c1/r6";
try {
registry.put(r6Path, r6);
} catch (RegistryException e) {
}
Collection collection1 = registry.searchContent("r6");
String[] paths1 = (String[]) collection1.getContent();
assertEquals("Search should return the relevant path corresponding to the content which includes " +
"submitted keywords.", "/c1/r6", paths1[0]);
Collection collection2 = registry.searchContent("non existing");
String[] paths2 = (String[]) collection2.getContent();
assertEquals("Search should not return results when non existing keywords are submitted.", 0, paths2.length);
registry.delete(r6Path);
Collection collection3 = registry.searchContent("r6");
String[] paths3 = (String[]) collection3.getContent();
assertEquals("Search should not return results for a deleted document", 0, paths3.length);
}
示例15: loadSecurityScenarios
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void loadSecurityScenarios(Registry registry,
BundleContext bundleContext) throws CarbonException, IOException, RegistryException {
// TODO: Load into all tenant DBs
// Load security scenarios
URL resource = bundleContext.getBundle().getResource("/scenarios/scenario-config.xml");
if (resource != null) {
XmlConfiguration xmlConfiguration = new XmlConfiguration(resource.openStream(),
SecurityConstants.SECURITY_NAMESPACE);
OMElement[] elements = xmlConfiguration.getElements("//ns:Scenario");
try {
boolean transactionStarted = Transaction.isStarted();
if (!transactionStarted) {
registry.beginTransaction();
}
for (OMElement scenarioEle : elements) {
SecurityScenario scenario = new SecurityScenario();
String scenarioId = scenarioEle.getAttribute(SecurityConstants.ID_QN)
.getAttributeValue();
scenario.setScenarioId(scenarioId);
scenario.setSummary(scenarioEle.getFirstChildWithName(SecurityConstants.SUMMARY_QN)
.getText());
scenario.setDescription(scenarioEle.getFirstChildWithName(
SecurityConstants.DESCRIPTION_QN).getText());
scenario.setCategory(scenarioEle.getFirstChildWithName(SecurityConstants.CATEGORY_QN)
.getText());
scenario.setWsuId(scenarioEle.getFirstChildWithName(SecurityConstants.WSUID_QN)
.getText());
scenario.setType(scenarioEle.getFirstChildWithName(SecurityConstants.TYPE_QN).getText());
String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
for (Iterator modules = scenarioEle.getFirstChildWithName(SecurityConstants.MODULES_QN)
.getChildElements(); modules.hasNext(); ) {
String module = ((OMElement) modules.next()).getText();
scenario.addModule(module);
}
// Save it in the DB
SecurityScenarioDatabase.put(scenarioId, scenario);
// Store the scenario in the Registry
if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
!scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
Resource scenarioResource = new ResourceImpl();
scenarioResource.
setContentStream(bundleContext.getBundle().
getResource("scenarios/" + scenarioId + "-policy.xml").openStream());
scenarioResource.setMediaType("application/policy+xml");
if (!registry.resourceExists(resourceUri)) {
registry.put(resourceUri, scenarioResource);
}
// Cache the resource in-memory in order to add it to the newly created tenants
SecurityServiceHolder.addPolicyResource(resourceUri, scenarioResource);
}
}
if (!transactionStarted) {
registry.commitTransaction();
}
} catch (Exception e) {
registry.rollbackTransaction();
throw e;
}
} else {
throw new CarbonException("Can't find the resource url");
}
}