Package org.wso2.carbon.registry.core

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


     * @throws RegistryException if an error occurs while retrieving resource data.
     */
    public static ResourceImpl getResourceWithMinimumData(String path, ResourceDAO resourceDAO,
                                                          boolean versioned)
            throws RegistryException {
        ResourceIDImpl resourceID = resourceDAO.getResourceID(path);
        if (resourceID == null) {
            return null;
        }
        ResourceImpl resourceImpl;
        if (resourceID.isCollection()) {
            resourceImpl = new CollectionImpl();
        } else {
            resourceImpl = new ResourceImpl();
        }
        if (versioned) {
            resourceImpl.setVersionNumber(resourceDAO.getVersion(resourceID));
        } else {
            resourceImpl.setName(resourceID.getName());
            resourceImpl.setPathID(resourceID.getPathID());
        }
        resourceImpl.setPath(path);
        return resourceImpl;
    }
View Full Code Here


                    "name for a resource.");
        }

        String purePath = RegistryUtils.getPureResourcePath(path);

        ResourceIDImpl resourceID =
                resourceDAO.getResourceID(purePath, resource instanceof CollectionImpl);
        boolean resourceExists = false;
        if (resourceID != null) {

            // existence of the resource id doesn't mean the existence of the
            // resource, so need to verify resource existence

            // load the meta data for the existing resource
            ResourceDO oldResourceDO = resourceDAO.getResourceDO(resourceID);

            if (oldResourceDO != null) {
                // the resource does exists
                resourceExists = true;
                prepareUpdate(resource, resourceID, oldResourceDO);
                update(resourceID, (ResourceImpl) resource, oldResourceDO);
            }
        }
        if (!resourceExists) {

            // now we are checking whether there is an entry with the inverse type
            ResourceIDImpl inverseResourceID = resourceDAO.getResourceID(purePath,
                    !(resource instanceof CollectionImpl));
            if (inverseResourceID != null) {
                ResourceDO inverseResourceDO = resourceDAO.getResourceDO(inverseResourceID);
                if (inverseResourceDO != null) {
                    // well, in fact there is an inverse type => we are deleting the resource
View Full Code Here

     */
    public void delete(String path) throws RegistryException {

        path = RegistryUtils.getPureResourcePath(path);

        ResourceIDImpl resourceID = resourceDAO.getResourceID(path);
        ResourceDO resourceDO = resourceDAO.getResourceDO(resourceID);
        if (resourceDO == null) {
            boolean isCollection = resourceID.isCollection();
            // then we will check for non-collections as the getResourceID only check the collection
            // exist
            if (isCollection) {
                resourceID = resourceDAO.getResourceID(path, false);
                if (resourceID != null) {
View Full Code Here

     */
    public void prepareVersionRestore(String path) throws RegistryException {

        path = RegistryUtils.getPureResourcePath(path);

        ResourceIDImpl resourceID = resourceDAO.getResourceID(path);
        ResourceDO resourceDO = resourceDAO.getResourceDO(resourceID);
        if (resourceDO == null) {
            boolean isCollection = resourceID.isCollection();
            // then we will check for non-collections as the getResourceID only check the collection
            // exist
            if (isCollection) {
                resourceID = resourceDAO.getResourceID(path, false);
                if (resourceID != null) {
View Full Code Here

     * @throws RegistryException if the operation failed.
     */
    public void prepareDumpRestore(String path) throws RegistryException {
        path = RegistryUtils.getPureResourcePath(path);

        ResourceIDImpl resourceID = resourceDAO.getResourceID(path);
        ResourceDO resourceDO = resourceDAO.getResourceDO(resourceID);
        if (resourceDO == null) {
            boolean isCollection = resourceID.isCollection();
            // then we will check for non-collections as the getResourceID only check the collection
            // exist
            if (isCollection) {
                resourceID = resourceDAO.getResourceID(path, false);
                if (resourceID != null) {
View Full Code Here


        // prepare the target parent path
        String targetParentPath = RegistryUtils.getParentPath(newPath);
        // first create a parent path for the target if doesn't exist
        ResourceIDImpl targetParentResourceID = resourceDAO.getResourceID(targetParentPath, true);
        if (targetParentResourceID == null || !resourceDAO.resourceExists(targetParentResourceID)) {
            addEmptyCollection(targetParentPath);
            if (targetParentResourceID == null) {
                targetParentResourceID = resourceDAO.getResourceID(targetParentPath, true);
            }
        } else if (!AuthorizationUtils.authorize(targetParentPath, ActionConstants.PUT)) {
            String msg = "Resource Move failed. User " +
                    CurrentSession.getUser() + " is not authorized to update " +
                    "the parent collection of target " + targetParentPath + ".";
            log.warn(msg);
            throw new AuthorizationFailedException(msg);
        }

        // get the source resource
        ResourceImpl sourceResource = (ResourceImpl) getMetaData(oldPath);
        if (sourceResource == null) {
            throw new ResourceNotFoundException(oldPath);
        }
        ResourceIDImpl sourceID = sourceResource.getResourceIDImpl();

        if (!(sourceResource instanceof CollectionImpl)) {
            prepareMove(oldPath, newPath);
            // get the source resource
            // just rename the resource + all the community features.
            ResourceIDImpl targetID = resourceDAO.getResourceID(newPath, false);
            if (targetID == null) {
                // create resourceID
                targetID = resourceDAO.createResourceID(newPath, targetParentResourceID, false);
            }
View Full Code Here

    public String moveRecursively(ResourceIDImpl sourceID,
                                  String targetPath,
                                  ResourceIDImpl targetParentResourceID) throws RegistryException {
        prepareMove(sourceID.getPath(), targetPath);

        ResourceIDImpl targetID = resourceDAO.getResourceID(targetPath, sourceID.isCollection());
        if (targetID == null) {
            targetID = resourceDAO
                    .createResourceID(targetPath, targetParentResourceID, sourceID.isCollection());
        }
View Full Code Here

            log.warn(msg);
            throw new AuthorizationFailedException(msg);
        }

        // check for existence of target path, if target exist delete them
        ResourceIDImpl targetExistingResourceID = resourceDAO.getResourceID(targetPath);
        ResourceDO targetExistingResourceDO;
        if (targetExistingResourceID != null) {
            targetExistingResourceDO = resourceDAO.getResourceDO(targetExistingResourceID);
            if (targetExistingResourceDO == null && targetExistingResourceID.isCollection()) {
                // we have to check the possibility non collection having this path
                targetExistingResourceID = resourceDAO.getResourceID(targetPath, false);
                if (targetExistingResourceID != null) {
                    targetExistingResourceDO = resourceDAO.getResourceDO(targetExistingResourceID);
                }
View Full Code Here

        String parentPath = RegistryUtils.getParentPath(path);

        // first, let's check if there is a parent for this resource. we do this to speed up the
        // common use case where new resources are added to an existing parent.

        ResourceIDImpl parentResourceID = resourceDAO.getResourceID(parentPath, true);
        if (parentResourceID == null || !resourceDAO.resourceExists(parentResourceID)) {
            addEmptyCollection(parentPath);
            if (parentResourceID == null) {
                parentResourceID = resourceDAO.getResourceID(parentPath, true);
            }
View Full Code Here

     * @throws RegistryException If any ancestor of the given path is a resource.
     */
    private void addEmptyCollection(String path) throws RegistryException {
        // first need to check whether there is a resource (non-collection)
        // where it is asking to create a collection
        ResourceIDImpl assumedResourceID = resourceDAO.getResourceID(path, false);
        if (assumedResourceID != null && resourceDAO.resourceExists(assumedResourceID)) {
            String msg = "Failed to add new Collection " + path + "There already exist " +
                    "non collection resource.";
            log.error(msg);
            throw new RegistryException(msg);
        }

        String parentPath = RegistryUtils.getParentPath(path);
        ResourceIDImpl parentResourceID = null;
        if (parentPath != null) {
            parentResourceID = resourceDAO.getResourceID(parentPath, true);
            if (parentResourceID == null || !resourceDAO.resourceExists(parentResourceID)) {
                addEmptyCollection(parentPath);
                if (parentResourceID == null) {
View Full Code Here

TOP

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

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.