当前位置: 首页>>代码示例>>Java>>正文


Java Resource.setContent方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.setContent方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setContent方法的具体用法?Java Resource.setContent怎么用?Java Resource.setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.core.Resource的用法示例。


在下文中一共展示了Resource.setContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetServiceProviders

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test
public void testGetServiceProviders() throws Exception {
    when(mockRegistry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(true);
    Resource collection = new CollectionImpl();
    String[] paths = new String[]{
            getPath("DummyIssuer"), getPath("DummyAdvIssuer")
    };
    Properties dummyResourceProperties = new Properties();
    dummyResourceProperties.putAll(dummyBasicProperties);
    Resource dummyResource = new ResourceImpl();
    dummyResource.setProperties(dummyResourceProperties);

    Properties dummyAdvProperties = new Properties();
    dummyAdvProperties.putAll((Map<?, ?>) dummyAdvProperties);
    Resource dummyAdvResource = new ResourceImpl();
    dummyAdvResource.setProperties(dummyAdvProperties);
    Resource[] spResources = new Resource[]{dummyResource, dummyAdvResource};
    collection.setContent(paths);
    when(mockRegistry.get(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(collection);
    when(mockRegistry.get(paths[0])).thenReturn(spResources[0]);
    when(mockRegistry.get(paths[1])).thenReturn(spResources[1]);
    SAMLSSOServiceProviderDO[] serviceProviders = objUnderTest.getServiceProviders();
    assertEquals(serviceProviders.length, 2, "Should have returned 2 service providers.");
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:SAMLSSOServiceProviderDAOTest.java

示例2: addJWTConfigResourceToRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Get the jwt details from the registry for tenants.
 *
 * @param tenantId for accesing tenant space.
 * @return the config for tenant
 * @throws RegistryException
 */
public static void addJWTConfigResourceToRegistry(int tenantId, String content)
		throws RegistryException {
	try {
		PrivilegedCarbonContext.startTenantFlow();
		PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
		RegistryService registryService = JWTClientExtensionDataHolder.getInstance().getRegistryService();
		if (registryService != null) {
			Registry registry = registryService.getConfigSystemRegistry(tenantId);
			JWTClientUtil.loadTenantRegistry(tenantId);
			if (!registry.resourceExists(TENANT_JWT_CONFIG_LOCATION)) {
				Resource resource = registry.newResource();
				resource.setContent(content.getBytes());
				registry.put(TENANT_JWT_CONFIG_LOCATION, resource);
			}
		}
	} finally {
		PrivilegedCarbonContext.endTenantFlow();
	}
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:27,代码来源:JWTClientUtil.java

示例3: testGeneralCollectionRename

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testGeneralCollectionRename() throws Exception {

        Resource r1 = registry.newResource();
        r1.setProperty("test", "rename");
        r1.setContent("some text");
        registry.put("/c2/rename3/c1/dummy", r1);

        registry.rename("/c2/rename3", "rename4");

        boolean failed = false;
        try {
            Resource originalR1 = registry.get("/c2/rename3/c1/dummy");
        } catch (Exception e) {
            failed = true;
        }
        assertTrue("Resource should not be " +
                "accessible from the old path after renaming the parent.", failed);

        Resource newR1 = registry.get("/c2/rename4/c1/dummy");
        assertEquals("Resource should contain a property with name test and value rename.",
                newR1.getProperty("test"), "rename");
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:23,代码来源:RenameTest.java

示例4: testRemovingMultivaluedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testRemovingMultivaluedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.addProperty("p1", "v1");
        r1.addProperty("p1", "v2");
        registry.put("/props/t2/r1", r1);

        Resource r1e1 = registry.get("/props/t2/r1");
        r1e1.setContent("r1 content updated");
        r1e1.removePropertyValue("p1", "v1");
        registry.put("/props/t2/r1", r1e1);

        Resource r1e2 = registry.get("/props/t2/r1");

        assertFalse("Property is not removed.", r1e2.getPropertyValues("p1").contains("v1"));
        assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:PropertiesTest.java

示例5: testRemovingProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testRemovingProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.setProperty("p1", "v1");
        r1.setProperty("p2", "v2");
        registry.put("/props/t1/r1", r1);

        Resource r1e1 = registry.get("/props/t1/r1");
        r1e1.setContent("r1 content");
        r1e1.removeProperty("p1");
        registry.put("/props/t1/r1", r1e1);

        Resource r1e2 = registry.get("/props/t1/r1");

        assertEquals("Property is not removed.", r1e2.getProperty("p1"), null);
        assertNotNull("Wrong property is removed.", r1e2.getProperty("p2"));
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:PropertiesTest.java

示例6: testEditingMultivaluedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testEditingMultivaluedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.addProperty("p1", "v1");
        r1.addProperty("p1", "v2");
        r1.setProperty("test", "value2");
        r1.setProperty("test2", "value2");
        registry.put("/props/t3/r1", r1);

        Resource r1e1 = registry.get("/props/t3/r1");
        r1e1.setContent("r1 content");
        r1e1.editPropertyValue("p1", "v1", "v3");
        List list = r1e1.getPropertyValues("/props/t3/r");

        registry.put("/props/t3/r1", r1e1);

        Resource r1e2 = registry.get("/props/t3/r1");


        assertFalse("Property is not edited.", r1e2.getPropertyValues("p1").contains("v1"));
        assertTrue("Property is not edited.", r1e2.getPropertyValues("p1").contains("v3"));
        assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));


    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:27,代码来源:PropertiesTest.java

示例7: testResourceContentVersioning

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的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

示例8: persistPolicy

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void persistPolicy(AxisService service, OMElement policy, String policyID) throws RegistryException {

        //Registry registryToLoad = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry();
        Resource resource = registry.newResource();
        resource.setContent(policy.toString());
        String servicePath = getRegistryServicePath(service);
        String policyResourcePath = servicePath + RegistryResources.POLICIES + policyID;
        registry.put(policyResourcePath, resource);

    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:11,代码来源:SecurityConfigAdmin.java

示例9: testResourcePropertyVersioning

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testResourcePropertyVersioning() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("content 1");
        r1.addProperty("p1", "v1");
        registry.put("/v4/r1", r1);

        Resource r1v2 = registry.get("/v4/r1");
        r1v2.addProperty("p2", "v2");
        registry.put("/v4/r1", r1v2);
        registry.put("/v4/r1", r1v2);

        String[] r1Versions = registry.getVersions("/v4/r1");

        Resource r1vv1 = registry.get(r1Versions[1]);

        assertEquals("r1's first version should contain a property p1 with value v1",
                r1vv1.getProperty("p1"), "v1");

        Resource r1vv2 = registry.get(r1Versions[0]);

        assertEquals("r1's second version should contain a property p1 with value v1",
                r1vv2.getProperty("p1"), "v1");

        assertEquals("r1's second version should contain a property p2 with value v2",
                r1vv2.getProperty("p2"), "v2");
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:28,代码来源:VersionHandlingTest.java

示例10: testAddResourceRating

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testAddResourceRating() throws Exception {
    Resource r1 = registry.newResource();
    byte[] r1content = RegistryUtils.encodeString("R1 content");
    r1.setContent(r1content);

    registry.put("/d16/d17/r1", r1);

    registry.rateResource("/d16/d17/r1", 5);

    float rating = registry.getAverageRating("/d16/d17/r1");

    //System.out.println("Start rating:" + rating);
    assertEquals("Rating of the resource /d16/d17/r1 should be 5.", rating, (float) 5.0,
            (float) 0.01);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:16,代码来源:RatingTest.java

示例11: setProperty

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public Property setProperty(String s, BigDecimal bigDecimal) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
    RegistryJCRItemOperationUtil.checkRetentionPolicy(registrySession,getPath());
    RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath());

    registrySession.sessionPending();
    validatePropertyModifyPrivilege(s);

    if (bigDecimal != null) {

        Resource res = null;
        try {
            res = registrySession.getUserRegistry().newResource();
            res.setContent(bigDecimal.toString());
            res.setProperty("registry.jcr.property.type", "big_decimal");
            registrySession.getUserRegistry().put(nodePath + "/" + s, res);
            property = new RegistryProperty(nodePath + "/" + s, registrySession, s,bigDecimal);

        } catch (RegistryException e) {
            String msg = "failed to resolve the path of the given node or violation of repository syntax " + this;
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }
        isModified = true;
        return property;

    } else {
        isModified = true;
        return null;
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:31,代码来源:RegistryNode.java

示例12: 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);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:13,代码来源:DeleteUtilTest.java

示例13: saveTokenToRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Helper method to save new access token to registry.
 *
 * @throws Exception
 */
private void saveTokenToRegistry() throws Exception {
    if (SQLDriverDSComponent.getRegistryService() == null) {
        String msg = "GSpreadConfig.getFeed(): Registry service is not available, authentication key cannot be" +
                     " saved";
        throw new SQLException(msg);
    }
    Registry registry = SQLDriverDSComponent.getRegistryService()
            .getGovernanceSystemRegistry(TDriverUtil.getCurrentTenantId());
    registry.beginTransaction();
    Resource res = registry.newResource();
    res.setContent(this.accessToken.getBytes(this.charSetType));
    registry.put(this.generateAuthTokenResourcePath(), res);
    registry.commitTransaction();
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:20,代码来源:GSpreadFeedProcessor.java

示例14: persist

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Persist a serializable object in the registry with the given resource path.
 *
 * @param object object to be persisted.
 */
@Override
public synchronized void persist(String resourcePath, Object object) throws RegistryException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Persisting resource in registry: [resource-path] %s", resourcePath));
    }

    Registry registry = getRegistry();

    try {
        PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);

        registry.beginTransaction();

        Resource nodeResource = registry.newResource();
        nodeResource.setContent(serializeToByteArray(object));
        registry.put(resourcePath, nodeResource);

        registry.commitTransaction();

        if (log.isDebugEnabled()) {
            log.debug(String.format("Resource persisted successfully in registry: [resource-path] %s",
                    resourcePath));
        }
    } catch (Exception e) {
        try {
            registry.rollbackTransaction();
        } catch (RegistryException e1) {
            if (log.isErrorEnabled()) {
                log.error("Could not rollback transaction", e1);
            }
        }
        throw new RegistryException("Failed to persist resource in registry: [resource-path] " + resourcePath, e);
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:42,代码来源:RegistryManager.java

示例15: 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);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:11,代码来源:MoveResourceUtilTest.java


注:本文中的org.wso2.carbon.registry.core.Resource.setContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。