Package org.wso2.carbon.registry.core.jdbc.dataobjects

Examples of org.wso2.carbon.registry.core.jdbc.dataobjects.ResourceDO


                ps.setInt(1, resourceID.getPathID());
                ps.setString(2, resourceID.getName());
                ps.setInt(3, CurrentSession.getTenantId());
            }

            ResourceDO resourceDO = null;
            result = ps.executeQuery();
            if (result.next()) {
                resourceDO = new ResourceDO();

                resourceDO.setPathID(result.getInt(DatabaseConstants.PATH_ID_FIELD));
                resourceDO.setName(result.getString(DatabaseConstants.NAME_FIELD));
                resourceDO.setVersion(result.getInt(DatabaseConstants.VERSION_FIELD));
                resourceDO.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
                resourceDO.setAuthor(result.getString(DatabaseConstants.CREATOR_FIELD));
                resourceDO.setCreatedOn(
                        result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD).getTime());
                resourceDO.setLastUpdater(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
                resourceDO.setLastUpdatedOn(
                        result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD).getTime());
                resourceDO.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
                resourceDO.setContentID(result.getInt(DatabaseConstants.CONTENT_ID_FIELD));
            }

            return resourceDO;

        } catch (SQLException e) {
View Full Code Here


        }
        return null;
    }

    public String getPath(long version) throws RegistryException {
        ResourceDO resourceDO = getResourceDO(version);
        if (resourceDO == null) {
            return null;
        }
        return getPath(resourceDO.getPathID(), resourceDO.getName(), false);
    }
View Full Code Here

            ResourceIDImpl resourceID = new ResourceIDImpl();
            resourceID.setCollection(resourceName == null);
            resourceID.setName(resourceName);
            resourceID.setPath(correctPath);
            resourceID.setPathID(pathId);
            ResourceDO resourceDO = getResourceDO(resourceID);
            if (resourceDO == null) {
                return null;
            }
        }
        return correctPath;
View Full Code Here

                // add descendants recursively
                addDescendants(childId, versionList, isRenewing, keepProperties);
            }
        }
        // we have to explicitly copy the collections to the history table
        ResourceDO resourceDO = resourceDAO.getResourceDO(resourceID);
        if (resourceID.isCollection() &&
                !resourceVersionDAO.isResourceHistoryExist(resourceDO.getVersion())) {
            resourceVersionDAO.putResourceToHistory(resourceDO);
        }
    }
View Full Code Here

    // Method to create version for a resource.
    private void createVersionForResource(ResourceImpl resourceImpl,
                                          boolean isRenewing,
                                          boolean keepProperties) throws RegistryException {
        ResourceDO resourceDO = resourceImpl.getResourceDO();
        if (resourceDO.getVersion() <= 0) {
            // we need to fetch the resource from the database
            resourceDO = resourceDAO.getResourceDO(resourceImpl.getResourceIDImpl());
            isRenewing = false;
        }
        if (isRenewing) {
View Full Code Here

        }
    }

    public ResourceImpl get(ResourceIDImpl resourceID, long snapshotID) throws RegistryException {
        VersionRetriever versionRetriever = getVersionList(snapshotID);
        ResourceDO resourceDO = null;
        int versionIndex = 0;
        while (true) {
            long version = versionRetriever.getVersion(versionIndex);
            if (version == -1) {
                // stream is over..
                break;
            }
            resourceDO = getResourceDOArchived(version);
            if (resourceDO.getPathID() == resourceID.getPathID() &&
                    ((resourceID.isCollection() && resourceDO.getName() == null) ||
                            (resourceID.getName() != null &&
                                    resourceID.getName().equals(resourceDO.getName())))) {
                break;
            }
            resourceDO = null;
            versionIndex++;
        }
View Full Code Here

            throws RegistryException {
        VersionRetriever versionRetriever = getVersionList(snapshotID);
        if (versionRetriever == null) {
            return false;  
        }
        ResourceDO resourceDO = null;
        int versionIndex = 0;
        while (true) {
            long version = versionRetriever.getVersion(versionIndex);
            if (version == -1) {
                // stream is over..
                break;
            }
            resourceDO = getResourceDOArchived(version);
            if (resourceDO.getPathID() == resourceID.getPathID() &&
                    ((resourceID.isCollection() && resourceDO.getName() == null) ||
                            (resourceID.getName() != null &&
                                    resourceID.getName().equals(resourceDO.getName())))) {
                break;
            }
            resourceDO = null;
            versionIndex++;
        }
View Full Code Here

            throw new RegistryException(msg);
        }

        VersionRetriever versionRetriever = getVersionList(snapshotID);
        int versionIndex = 0;
        ResourceDO resourceDO = null;
        while (true) {
            long version = versionRetriever.getVersion(versionIndex);
            if (version == -1) {
                // no more stream
                break;
            }
            resourceDO = getResourceDOArchived(version);
            if (resourceDO.getPathID() == resourceID.getPathID() &&
                    ((resourceID.isCollection() && resourceDO.getName() == null) ||
                            (resourceID.getName() != null &&
                                    resourceID.getName().equals(resourceDO.getName())))) {
                break;
            }
            resourceDO = null;
            versionIndex++;
        }
View Full Code Here

        return false;
    }

    public String restoreResources(long version, long snapshotID) throws RegistryException {
        // get the archived resource
        ResourceDO resourceDO = getResourceDOArchived(version);
        String resourcePath =
                resourceDAO.getPath(resourceDO.getPathID(), resourceDO.getName(), false);

        // create the resourceId
        ResourceImpl oldResource;
        if (resourceDO.getName() == null) {
            // this is a collection
            oldResource = new CollectionImpl(resourcePath, resourceDO);
        } else {
            oldResource = new ResourceImpl(resourcePath, resourceDO);
        }

        int oldContentID = resourceDO.getContentID();
        if (oldContentID > 0) {
            // if the non-collection restore content
            // get the archived content
            InputStream contentData = getContentArchived(oldContentID);
            if (contentData != null) {
                resourceDO.setContentID(resourceDAO.addContentBytes(contentData));
            }
        }
        resourceDAO.addResourceDO(resourceDO);
        // copy comments, taggings, ratings to new version
        ResourceImpl newResource;
        if (resourceDO.getName() == null) {
            newResource = new CollectionImpl(resourcePath, resourceDO);
        } else {
            newResource = new ResourceImpl(resourcePath, resourceDO);
        }
View Full Code Here

            ps.setInt(2, CurrentSession.getTenantId());

            result = ps.executeQuery();

            if (result.next()) {
                ResourceDO resourceDO = new ResourceDO();

                // this is always the current version of the resource
                resourceDO.setPathID(result.getInt(DatabaseConstants.PATH_ID_FIELD));
                resourceDO.setName(result.getString(DatabaseConstants.NAME_FIELD));
                resourceDO.setVersion(result.getInt(DatabaseConstants.VERSION_FIELD));
                resourceDO.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
                resourceDO.setAuthor(result.getString(DatabaseConstants.CREATOR_FIELD));
                resourceDO.setCreatedOn(
                        result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD).getTime());
                resourceDO.setLastUpdater(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
                resourceDO.setLastUpdatedOn(
                        result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD).getTime());
                resourceDO.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
                resourceDO.setContentID(result.getInt(DatabaseConstants.CONTENT_ID_FIELD));

                return resourceDO;
            }
        } catch (SQLException e) {
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.jdbc.dataobjects.ResourceDO

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.