Package org.wso2.carbon.registry.core

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


        if (!(introspection instanceof Feed)) {
            abderaClient.teardown();
            throw new RegistryException("Got " + introspection.getQName() +
                    " when expecting <feed>!");
        }
        CollectionImpl resource;
        // This is a collection
        Feed feed = (Feed) introspection;
        String state = feed.getSimpleExtension(new QName(APPConstants.NAMESPACE, "state"));
        if (state != null && state.equals("Deleted")) {
            abderaClient.teardown();
View Full Code Here


     * @throws org.wso2.carbon.registry.core.exceptions.RegistryException
     *          : If user is unable to open the URL connection
     */
    private CollectionImpl createResourceFromFeed(Feed feed)
            throws RegistryException {
        CollectionImpl resource = new CollectionImpl();
        org.wso2.carbon.registry.app.Properties properties =
                feed.getExtension(PropertyExtensionFactory.PROPERTIES);
        RemoteRegistry.createPropertiesFromExtensionElement(properties, resource);
        if (feed.getAuthor() != null) {
            resource.setAuthorUserName(feed.getAuthor().getName());
        }
        resource.setLastModified(feed.getUpdated());
        String createdDate = feed.getSimpleExtension(
                new QName(APPConstants.NAMESPACE, "createdTime"));
        if (createdDate != null) {
            resource.setCreatedTime(new Date(Long.parseLong(createdDate)));
        }

        String lastUpdatedUser = feed.getSimpleExtension(APPConstants.QN_LAST_UPDATER);
        if (lastUpdatedUser != null) {
            resource.setLastUpdaterUserName(lastUpdatedUser);
        }

        final Link pathLink = feed.getLink("path");
        String path = (pathLink != null) ? pathLink.getHref().toString() : feed.getTitle();
        path = URLDecoder.decode(path);
        resource.setPath(path);

        // This MUST be after path is set.
        String snapshotID = feed.getSimpleExtension(APPConstants.QN_SNAPSHOT_ID);
        if (snapshotID != null) {
            resource.setMatchingSnapshotID(Long.parseLong(snapshotID));
        }

        String mediaType = feed.getSimpleExtension(new QName(APPConstants.NAMESPACE, "mediaType"));
        if (mediaType != null) {
            resource.setMediaType(mediaType);
        }

        resource.setDescription(feed.getSubtitle());
        String state = feed.getSimpleExtension(new QName(APPConstants.NAMESPACE, "state"));
        if (state != null && "Deleted".equals(state)) {
            resource.setState(RegistryConstants.DELETED_STATE);
        }

        String childCount = feed.getSimpleExtension(APPConstants.QN_CHILD_COUNT);
        if (childCount != null) {
            resource.setChildCount(Integer.parseInt(childCount));
        }

        String isComments = feed.getSimpleExtension(APPConstants.QN_COMMENTS);
        if (isComments != null) {
            resource.setContent(getCommentsFromFeed(feed));
        } else {
            List entries = feed.getEntries();
            if (entries != null) {
                String[] childNodes = new String[entries.size()];
                for (int i = 0; i < entries.size(); i++) {
                    Entry entry = (Entry) entries.get(i);
                    Link childLink = Utils.getLinkWithRel(entry, "path");
                    /*Link childLink = entry.getLink("path");
                    if (childLink == null) {
                        for (Link link : entry.getLinks()) {
                            if (link.getRel() != null &&
                                    link.getRel().equals("path")) {
                                childLink = link;
                                break;
                            }
                        }
                    }      */
                    childNodes[i] = URLDecoder.decode(childLink.getHref().toString());
                }
                resource.setContent(childNodes);
            }
        }

        return resource;
    }
View Full Code Here

                        registry.getRegistryContext(),
                        RegistryConstants.SYSTEM_COLLECTION_BASE_PATH)
                        + "' collection of the Registry.");
            }

            CollectionImpl systemCollection = (CollectionImpl) registry.newCollection();
            String systemDescription = "System collection of the Registry. This collection is " +
                    "used to store the resources required by the carbon server.";
            systemCollection.setDescription(systemDescription);
            registry.put(RegistryUtils.getAbsolutePath(
                    registry.getRegistryContext(), RegistryConstants.SYSTEM_COLLECTION_BASE_PATH),
                    systemCollection);
            systemCollection.discard();

            CollectionImpl localRepositoryCollection = (CollectionImpl) registry.newCollection();
            String localRepositoryDescription =
                    "Local data repository of the carbon server. This " +
                            "collection is used to store the resources local to this carbon " +
                            "server instance.";
            localRepositoryCollection.setDescription(localRepositoryDescription);
            registry.put(RegistryUtils.getAbsolutePath(
                    registry.getRegistryContext(), RegistryConstants.LOCAL_REPOSITORY_BASE_PATH),
                    localRepositoryCollection);
            localRepositoryCollection.discard();

            CollectionImpl configRegistryCollection = (CollectionImpl) registry.newCollection();
            String configRegistryDescription = "Configuration registry of the carbon server. " +
                    "This collection is used to store the resources of this product cluster.";
            configRegistryCollection.setDescription(configRegistryDescription);
            registry.put(RegistryUtils.getAbsolutePath(
                    registry.getRegistryContext(), RegistryConstants.CONFIG_REGISTRY_BASE_PATH),
                    configRegistryCollection);
            configRegistryCollection.discard();

            CollectionImpl governanceRegistryCollection = (CollectionImpl) registry.newCollection();
            String governanceRegistryDescription = "Governance registry of the carbon server. " +
                    "This collection is used to store the resources common to the whole " +
                    "platform.";
            governanceRegistryCollection.setDescription(governanceRegistryDescription);
            registry.put(RegistryUtils.getAbsolutePath(
                    registry.getRegistryContext(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH),
                    governanceRegistryCollection);
            governanceRegistryCollection.discard();
        }
        // This is to create the repository collections for the various registries and clean
        // them at start-up, if needed.
        boolean cleanRegistry = false;
        if (System.getProperty(RegistryConstants.CARBON_REGISTRY_CLEAN) != null) {
View Full Code Here

                return;
            }
            if (log.isTraceEnabled()) {
                log.trace("Creating the '" + profilesPath + "' collection of the Registry.");
            }
            CollectionImpl systemCollection = (CollectionImpl) registry.newCollection();
            String systemDescription = "Collection which contains user-specific details.";
            systemCollection.setDescription(systemDescription);
            registry.put(profilesPath, systemCollection);
        }
    }
View Full Code Here

                return;
            }
            if (log.isTraceEnabled()) {
                log.trace("Creating the '" + servicePath + "' collection of the Registry.");
            }
            CollectionImpl systemCollection = (CollectionImpl) registry.newCollection();
            String systemDescription = "Collection which contains all the Service information";
            systemCollection.setDescription(systemDescription);
            registry.put(servicePath, systemCollection);
        }
    }
View Full Code Here

        String mountPath = RegistryConstants.LOCAL_REPOSITORY_BASE_PATH +
                RegistryConstants.SYSTEM_MOUNT_PATH;
        if (!systemRegistry.resourceExists(mountPath)) {
            return;
        }
        CollectionImpl mountCollection = (CollectionImpl) systemRegistry.get(mountPath);
        String[] mountPoints = mountCollection.getChildren();
        Resource mountPoint;
        for (String mountPointString : mountPoints) {
            if (!systemRegistry.resourceExists(mountPointString)) {
                log.warn("Unable to add mount. The mount point " + mountPointString +
                        " was not found.");
View Full Code Here

        if (resourceID == null) {
            return null;
        }
        ResourceImpl resourceImpl;
        if (resourceID.isCollection()) {
            resourceImpl = new CollectionImpl();
        } else {
            resourceImpl = new ResourceImpl();
        }
        if (versioned) {
            resourceImpl.setVersionNumber(resourceDAO.getVersion(resourceID));
View Full Code Here

     * @throws RegistryException if the operation failed.
     */
    public Collection get(String path, int start, int pageLen) throws RegistryException {
        String purePath = RegistryUtils.getPureResourcePath(path);

        CollectionImpl resource = (CollectionImpl) resourceDAO.getResourceMetaData(purePath);
        if (resource == null) {
            return null;
        }

        if (!AuthorizationUtils.authorize(purePath, ActionConstants.GET)) {
            String msg = "User " + CurrentSession.getUser() + " is not authorized to " +
                    "read the resource " + purePath + ".";
            log.warn(msg);
            throw new AuthorizationFailedException(msg);
        }
        resourceDAO.fillResource(resource, start, pageLen);
        resource.setDataAccessManager(dataAccessManager);
        resource.setUserName(CurrentSession.getUser());
        resource.setTenantId(CurrentSession.getTenantId());
        resource.setUserRealm(CurrentSession.getUserRealm());

        return resource;
    }
View Full Code Here

            ResourceImpl oldResourceImpl = new ResourceImpl(resourceID.getPath(), oldResourceDO);
            versionRepository.createSnapshot(oldResourceImpl, false, false);
        } else {
            ResourceImpl oldResourceImpl;
            if (resourceID.isCollection()) {
                oldResourceImpl = new CollectionImpl(resourceID.getPath(), oldResourceDO);
            } else {
                oldResourceImpl = new ResourceImpl(resourceID.getPath(), oldResourceDO);
            }
            // just delete the resource and content
            // delete the old entry from the resource table
View Full Code Here

    public void deleteNode(ResourceIDImpl resourceID,
                              ResourceDO resourceDO,
                              boolean keepAuthorization) throws RegistryException {
        ResourceImpl resourceImpl;
        if (resourceID.isCollection()) {
            resourceImpl = new CollectionImpl(resourceID.getPath(), resourceDO);
        } else {
            resourceImpl = new ResourceImpl(resourceID.getPath(), resourceDO);
        }

        // now do the versioning as delete is considered as a change, where
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.