Package org.wso2.carbon.registry.core

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


    // Method to remove a resource, which is used when moving resources.
    private void removeIndividual(ResourceIDImpl resourceID, ResourceDO resourceDO)
            throws RegistryException {
        ResourceImpl resource;
        if (resourceID.isCollection()) {
            resource = new CollectionImpl(resourceID.getPath(), resourceDO);
        } else {
            resource = new ResourceImpl(resourceID.getPath(), resourceDO);
        }
        // we are always creating versions for resources (files), if the resource has changed.
        if (!(resource instanceof Collection) && this.versionOnChange &&
View Full Code Here


        put(targetPath, targetResource);


        if (sourceResource instanceof CollectionImpl) {
            // copy all the children recursively
            CollectionImpl collection = (CollectionImpl) sourceResource;

            for (String childSourcePath : collection.getChildren()) {
                String childResourceName = RegistryUtils.getResourceName(childSourcePath);
                String childTargetPath =
                        targetPath + RegistryConstants.PATH_SEPARATOR + childResourceName;

View Full Code Here

        resourceDAO.update(resource);

        ResourceImpl oldResourceImpl;
        if (oldResourceDO.getName() == null) {
            // this is a collection
            oldResourceImpl = new CollectionImpl(resourceID.getPath(), oldResourceDO);
        } else {
            oldResourceImpl = new ResourceImpl(resourceID.getPath(), oldResourceDO);
        }
        // copying old required attributes to the new version
        commentsDAO.copyComments(oldResourceImpl, resource);
View Full Code Here

            log.error(msg);
            throw new RegistryException(msg);
        }


        CollectionImpl collection = new CollectionImpl();
        RegistryContext registryContext = null;
        if (CurrentSession.getUserRegistry() != null) {
            registryContext = CurrentSession.getUserRegistry().getRegistryContext();
        }
        if (registryContext == null) {
View Full Code Here

        }

        ResourceImpl resourceImpl;
        byte[] contentBytes = new byte[0];
        if (isCollection) {
            resourceImpl = new CollectionImpl();
        } else {
            resourceImpl = new ResourceImpl();
        }

        List<CommentDO> commentDOList = new ArrayList<CommentDO>();
View Full Code Here

            child.serialize(xmlWriter);
        }

        // getting children and applying dump recursively
        if (resource instanceof CollectionImpl) {
            CollectionImpl collection = (CollectionImpl) resource;
            resourceDAO.fillChildren(collection, 0, -1);
            String childPaths[] = collection.getChildren();

            xmlWriter.writeStartElement(DumpConstants.CHILDREN);
            OMText emptyText = factory.createOMText("");
            emptyText.serialize(xmlWriter);
            xmlWriter.flush();
View Full Code Here

            if (files.length > 0) {
                for (File childFile : files) {
                    processImport(childFile, resourcePath, registry);
                }
            } else {
                CollectionImpl resource = new CollectionImpl();
                resource.setPath(resourcePath);
                registry.put(resourcePath, resource);
            }
        } else {
            ResourceImpl resource = new ResourceImpl();
            resource.setContent(new FileInputStream(file));
            resource.setPath(resourcePath);
            registry.put(resourcePath, resource);
        }
    }
View Full Code Here

        Resource resource;
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
            resource.addProperty(RegistryConstants.REGISTRY_EXISTING_RESOURCE, "true");
        } else {
            resource = new CollectionImpl();
        }
        resource.addProperty(RegistryConstants.REGISTRY_NON_RECURSIVE, "true");
        resource.addProperty(RegistryConstants.REGISTRY_LINK_RESTORATION,
                path + RegistryConstants.URL_SEPARATOR + target +
                        RegistryConstants.URL_SEPARATOR + targetSubPath +
View Full Code Here

        //assertTrue("/d15/d14/r1 is not tagged with the tag \"tag1\"", artifactFound);
        assertTrue("tag 'tag1' is not associated with the artifact /d15/d14/r1", tagFound);
    }

    public void testRemoveCollectionTagging() throws Exception {
        CollectionImpl r1 = new CollectionImpl();
        r1.setAuthorUserName("Author q1 remove");
        registry.put("/d15/d14/d13/d12", r1);

        registry.applyTag("/d15/d14/d13", "tag1");
        registry.applyTag("/d15/d14/d13", "tag2");
        registry.applyTag("/d15/d14/d13", "tag3");
View Full Code Here

    }

    public Item getItem(String s) throws PathNotFoundException, RepositoryException {

        Item anItem = null;
        CollectionImpl collection = null;
        String[] tempArr = null;
        String tempPath = s; // example:tempP="/abc/post/test";

        if ((tempPath != null) && (tempPath.contains("["))) {

            tempPath = tempPath.substring(1, tempPath.length() - 1);

        }

        if ((tempPath != null) && (tempPath.contains("/"))) {

            tempArr = tempPath.split("/");

            if (tempArr.length == 2) {
                tempPath = "/";
            } else {

                tempPath = tempPath.substring(0, (tempPath.length()) -
                        (tempArr[tempArr.length - 1].length()) - 1); //parent path
            }

            try {

                if (userRegistry.resourceExists(s)) {

                    if (userRegistry.get(s) instanceof CollectionImpl) {
                        anItem = new RegistryNode(s, this);

                    } else {

                        if (userRegistry.resourceExists(tempPath)) {
                            anItem = new RegistryNode(tempPath, this).getProperty(tempArr[tempArr.length - 1]);

                        }

                    }
                } else {

                    if ((userRegistry.resourceExists(tempPath))) {  // tempPath  is the parent path

                        CollectionImpl parentCol = (CollectionImpl) userRegistry.get(tempPath);   //need to know the int values to be passed

                        if ((parentCol != null) && (parentCol.getProperty(tempArr[tempArr.length - 1]) != null)) {

                            anItem = new RegistryProperty(parentCol, this, tempArr[tempArr.length - 1]);
                            ((RegistryProperty) anItem).setValue(parentCol.getProperty(tempArr[tempArr.length - 1]));

                        }
                    }

                }
View Full Code Here

TOP

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

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.