Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Resource


    private void removeTrustedService(String groupName, String serviceName, String trustedService)
            throws SecurityConfigException {
        Registry registry;
        String resourcePath;
        Resource resource;
        try {
            resourcePath = RegistryResources.SERVICE_GROUPS + groupName
                    + RegistryResources.SERVICES + serviceName + "/trustedServices";
            registry = getConfigSystemRegistry(); //TODO: Multitenancy
            if (registry != null) {
                if (registry.resourceExists(resourcePath)) {
                    resource = registry.get(resourcePath);
                    if (resource.getProperty(trustedService) != null) {
                        resource.removeProperty(trustedService);
                    }
                    registry.put(resourcePath, resource);
                }
            }
        } catch (Exception e) {
View Full Code Here


        }
    }

    public void testPathCache() throws RegistryException {

        Resource r1 = registry.newResource();
        r1.setContent("some content");
        registry.put("/test/paths/r1", r1);

        double rate1 = PathCache.getPathCache().hitRate();
        registry.put("/test/paths/r2", r1);
        double rate2 = PathCache.getPathCache().hitRate();
View Full Code Here

        }
    }

    public void testRootLevelProperties() throws RegistryException {

        Resource root = registry.get("/");
        root.addProperty("p1", "v1");
        registry.put("/", root);

        Resource rootB = registry.get("/");
        assertEquals("Root should have a property named p1 with value v1",
                rootB.getProperty("p1"), "v1");
    }
View Full Code Here

                rootB.getProperty("p1"), "v1");
    }

    public void testSingleValuedProperties() throws RegistryException {

        Resource r2 = registry.newResource();
        r2.setContent("Some content for r2");
        r2.addProperty("p1", "p1v1");
        registry.put("/propTest/r2", r2);

        Resource r2b = registry.get("/propTest/r2");
        String p1Value = r2b.getProperty("p1");

        assertEquals("Property p1 of /propTest/r2 should contain the value p1v1",
                p1Value, "p1v1");
    }
View Full Code Here

     * @throws RegistryException This exception is thrown for all exceptions occurred inside
     *                           handlers or filters.
     */
    public Resource get(RequestContext requestContext) throws RegistryException {

        Resource resource = null;

        Set<Filter> filters = getHandlerMap.keySet();
        for (Filter filter : filters) {
            if (filter != null && filter.handleGet(requestContext)) {
                Set<Handler> handlerSet = getHandlerMap.get(filter);
View Full Code Here

                p1Value, "p1v1");
    }

    public void testMultiValuedProperties() throws RegistryException {

        Resource r1 = registry.newResource();
        r1.setContent("Some content for r1");
        r1.addProperty("p1", "p1v1");
        r1.addProperty("p1", "p1v2");
        registry.put("/propTest/r1", r1);

        Resource r1b = registry.get("/propTest/r1");
        List<String> propValues = r1b.getPropertyValues("p1");

        assertTrue("Property p1 of /propTest/r1 should contain the value p1v1",
                propValues.contains("p1v1"));

        assertTrue("Property p1 of /propTest/r1 should contain the value p1v2",
View Full Code Here

                propValues.contains("p1v2"));
    }

    public void testNullValuedProperties() throws RegistryException {

        Resource r2 = registry.newResource();
        r2.setContent("Some content for r2");
        r2.addProperty("p1", null);
        registry.put("/propTest3/r2", r2);

        Resource r2b = registry.get("/propTest3/r2");
        String p1Value = r2b.getProperty("p1");

        assertEquals("Property p1 of /propTest3/r2 should contain the value null",
                p1Value, null);
    }
View Full Code Here

                p1Value, null);
    }

    public void testNullMultiValuedProperties() throws RegistryException {

        Resource r1 = registry.newResource();
        r1.setContent("Some content for r1");
        r1.addProperty("p1", null);
        r1.addProperty("p1", null);
        registry.put("/propTest4/r1", r1);

        Resource r1b = registry.get("/propTest4/r1");
        List<String> propValues = r1b.getPropertyValues("p1");

        assertEquals("Property p1 of /propTest4/r1 should contain the value null",
                propValues.get(0), null);

        assertEquals("Property p1 of /propTest4/r1 should contain the value null",
View Full Code Here

    private void dumpToFileSystem(Registry registry, UserInputCallback callback)
            throws SynchronizationException {
        addedCount = 0;

        // first try getting the path and confirmed it is a collection
        Resource r;
        try {
            r = registry.get(checkOutPath);
        } catch (Exception e) {
            throw new SynchronizationException(
                    MessageCode.ERROR_IN_DUMPING_NO_RESOURCE_OR_NO_PERMISSION,
View Full Code Here

                propValues.get(1), null);
    }

    public void testRemovingProperties() throws RegistryException {

        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.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"));
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.