Package org.wso2.carbon.registry.core

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


                if (!registry.resourceExists(policyResourcePath)) {
                    // do nothing, because no policy
                    return;
                }

                Collection coll = (Collection) registry.get(policyResourcePath);
                String[] policies = coll.getChildren();
                SecurityScenario scenario = null;
                for (int i = 0; i < policies.length; i++) {
                    String value = policies[i];
                    String policyId = value.substring(policyResourcePath.length());
                    scenario = SecurityScenarioDatabase.getByWsuId(policyId);
View Full Code Here


            boolean transactionStarted = Transaction.isStarted();
            if (!transactionStarted) {
                registry.beginTransaction();
            }
            if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
                Collection kstores = registry.newCollection();
                registry.put(SecurityConstants.KEY_STORES, kstores);

                Resource primResource = registry.newResource();
                if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                    registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
View Full Code Here

     * @return Collection of results.
     * @throws RegistryException This exception is thrown for all exceptions occurred inside
     *                           handlers or filters.
     */
    public Collection executeQuery(RequestContext requestContext) throws RegistryException {
        Collection collection = null;
        List<String> results = new LinkedList<String>();
        Set<Filter> filters = executeQueryHandlerMap.keySet();
        for (Filter filter : filters) {
            if (filter != null && filter.handleExecuteQuery(requestContext)) {
                Set<Handler> handlerSet = executeQueryHandlerMap.get(filter);
                Handler[] handlers = handlerSet.toArray(new Handler[handlerSet.size()]);
                for (Handler handler : handlers) {
                    try {
                        collection = handler.executeQuery(requestContext);
                        if (collection != null) {
                            String[] children = collection.getChildren();
                            if (children != null) {
                                for (String child : children) {
                                    if (child != null) {
                                        results.add(child);
                                    }
                                }
                            }
                        }
                        if (!requestContext.isExecutionStatusSet(handler)) {
                            requestContext.setExecutionStatus(handler, true);
                        }
                    } catch (RegistryException e) {
                        requestContext.setExecutionStatus(handler, e);
                        // Don't throw exceptions in simulation mode, but exit lifecycle phase
                        if (requestContext.isSimulation()) {
                            return null;
                        }
                        throw e;
                    } catch (Throwable e) {
                        requestContext.setExecutionStatus(handler, e);
                        // Don't throw exceptions in simulation mode, but exit lifecycle phase
                        if (requestContext.isSimulation()) {
                            return null;
                        }
                        // We will be concatenating the incoming exception's message so that it will
                        // be carried forward, and displayed at the client-side.
                        throw new RegistryException(
                                "An exception occurred while executing handler chain. " +
                                        e.getMessage(), e);
                    }
                    if (isProcessingComplete(requestContext)) {
                        break;
                    }
                }
            }

            if (isProcessingComplete(requestContext)) {
                break;
            }
        }
        if (collection != null) {
            collection.setContent(results.toArray(new String[results.size()]));
        } else if (results.size() > 0) {
            collection = new CollectionImpl(results.toArray(new String[results.size()]));
        }
        return collection;
    }
View Full Code Here

     * @return Collection of content.
     * @throws RegistryException This exception is thrown for all exceptions occurred inside
     *                           handlers or filters.
     */
    public Collection searchContent(RequestContext requestContext) throws RegistryException {
        Collection collection = null;
        Set<Filter> filters = searchContentHandlerMap.keySet();
        for (Filter filter : filters) {
            if (filter != null && filter.handleSearchContent(requestContext)) {
                Set<Handler> handlerSet = searchContentHandlerMap.get(filter);
                Handler[] handlers = handlerSet.toArray(new Handler[handlerSet.size()]);
View Full Code Here

            } catch (ResourceNotFoundException e) {
                // If this is a straight-ahead POST to a non-existent directory, create it?
                if (method.equals("POST") && parts.length == 1) {
                    // Need to create it.
                    try {
                        Collection c = registry.newCollection();
                        registry.put(uri, c);
                        resource = registry.get(uri);
                    } catch (RegistryException e1) {
                        log.error(e1);
                        return null;
View Full Code Here

        List<Subscription> subscriptions = new ArrayList<Subscription>();
        try {
            if (registry.resourceExists(topic)) {
                String subscriptionsCollection = topic + "/" + SUBSCRIPTION_COLLECTION_NAME;
                if (registry.resourceExists(subscriptionsCollection)) {
                    Collection subs = (Collection) registry.get(subscriptionsCollection);
                    String[] subsPaths = (String[]) subs.getContent();
                    for (String subsPath : subsPaths) {
                        Resource resource = registry.get(subsPath);
                        String id = resource.getId();
                        Subscription sub = new Subscription();
                        if (EPR_TYPE.equals(resource.getMediaType())) {
View Full Code Here

                r1vv2.getProperty("p2"), "v2");
    }

    public void testSimpleCollectionVersioning() throws RegistryException {

        Collection c1 = registry.newCollection();
        registry.put("/v3/c1", c1);

        registry.createVersion("/v3/c1");

        Collection c2 = registry.newCollection();
        registry.put("/v3/c1/c2", c2);

        registry.createVersion("/v3/c1");

        Collection c3 = registry.newCollection();
        registry.put("/v3/c1/c3", c3);

        registry.createVersion("/v3/c1");

        Collection c4 = registry.newCollection();
        registry.put("/v3/c1/c2/c4", c4);

        registry.createVersion("/v3/c1");

        Collection c5 = registry.newCollection();
        registry.put("/v3/c1/c2/c5", c5);

        registry.createVersion("/v3/c1");

        String[] c1Versions = registry.getVersions("/v3/c1");
View Full Code Here

                "content 1", new String((byte[]) r1r1.getContent()));
    }

    public void testSimpleCollectionRestore() throws RegistryException {

        Collection c1 = registry.newCollection();
        registry.put("/test/v11/c1", c1);

        registry.createVersion("/test/v11/c1");

        Resource r1 = registry.newResource();
        r1.setContent("r1c1");
        registry.put("/test/v11/c1/r1", r1);

        registry.createVersion("/test/v11/c1");

        Resource r2 = registry.newResource();
        r2.setContent("r1c1");
        registry.put("/test/v11/c1/r2", r2);

        registry.createVersion("/test/v11/c1");

        String[] c1Versions = registry.getVersions("/test/v11/c1");
        assertEquals("/test/v11/c1 should have 3 versions.", c1Versions.length, 3);

        registry.restoreVersion(c1Versions[2]);
        Collection c1r1 = (Collection) registry.get("/test/v11/c1");
        assertEquals("version 1 of c1 should not have any children", 0, c1r1.getChildren().length);

        try {
            registry.get("/test/v11/c1/r1");
            fail("Version 1 of c1 should not have child r1");
        } catch (RegistryException e) {}
       
        try {
            registry.get("/test/v11/c1/r2");
            fail("Version 1 of c1 should not have child r2");
        } catch (RegistryException e) {}

        registry.restoreVersion(c1Versions[1]);
        Collection c1r2 = (Collection) registry.get("/test/v11/c1");
        assertEquals("version 2 of c1 should have 1 child", 1, c1r2.getChildren().length);

        try {
            registry.get("/test/v11/c1/r1");
        } catch (RegistryException e) {
            fail("Version 2 of c1 should have child r1");
        }

        try {
            registry.get("/test/v11/c1/r2");
            fail("Version 2 of c1 should not have child r2");
        } catch (RegistryException e) {

        }

        registry.restoreVersion(c1Versions[0]);
        Collection c1r3 = (Collection) registry.get("/test/v11/c1");
        assertEquals("version 3 of c1 should have 2 children", 2, c1r3.getChildren().length);

        try {
            registry.get("/test/v11/c1/r1");
        } catch (RegistryException e) {
            fail("Version 3 of c1 should have child r1");
View Full Code Here

        }
    }

    public void testAdvancedCollectionRestore() throws RegistryException {

        Collection c1 = registry.newCollection();
        registry.put("/test/v12/c1", c1);

        registry.createVersion("/test/v12/c1");

        Resource r1 = registry.newResource();
        r1.setContent("r1c1");
        registry.put("/test/v12/c1/c11/r1", r1);

        registry.createVersion("/test/v12/c1");

        Collection c2 = registry.newCollection();
        registry.put("/test/v12/c1/c11/c2", c2);

        registry.createVersion("/test/v12/c1");

        Resource r1e1 = registry.get("/test/v12/c1/c11/r1");
View Full Code Here

        assertEquals("Permalink incorrect", r1e3.getPermanentPath(), r1Versions[1]);
    }

    public void testPermalinksForCollections() throws RegistryException {

        Collection c1 = registry.newCollection();
        registry.put("/test/v14/c1", c1);

        registry.createVersion("/test/v14/c1");

        String[] c1Versions = registry.getVersions("/test/v14/c1");
View Full Code Here

TOP

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

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.