Examples of VersionRetriever


Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

        // restore the versioned things
        //      get each resource from resource_history and copy to resource
        //      restore contents
        // That's all

        VersionRetriever versionRetriever =
                resourceVersionDAO.getVersionList(resourceID, snapshotID);

        if (versionRetriever == null) {
            String msg = "The snapshot " + snapshotID + " doesn't contain the " +
                    "resource " + resourceID.getPath();
            log.warn(msg);
            throw new AuthorizationFailedException(msg);
        }
        int versionIndex = 0;
        while (true) {
            long version = versionRetriever.getVersion(versionIndex);
            if (version == -1) {
                // no more stream
                break;
            }
            // restore resource and content
View Full Code Here

Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

            }
        }
    }

    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);
View Full Code Here

Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

        return resourceImpl;
    }

    public boolean resourceExists(ResourceIDImpl resourceID, long snapshotID)
            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);
View Full Code Here

Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

    public VersionRetriever getVersionList(ResourceIDImpl resourceID, long snapshotID)
            throws RegistryException {
        Connection conn = JDBCDatabaseTransaction.getConnection();
        ResultSet result = null;
        PreparedStatement ps = null;
        VersionRetriever versionRetriever = null;
        try {
            if (resourceID.isCollection()) {
                String sql =
                        "SELECT REG_PATH_ID, REG_RESOURCE_VIDS FROM REG_SNAPSHOT " +
                                "WHERE REG_SNAPSHOT_ID=? AND REG_PATH_ID = ? " +
                                "AND REG_RESOURCE_NAME IS NULL AND REG_TENANT_ID=?";
                ps = conn.prepareStatement(sql);
                ps.setLong(1, snapshotID);
                ps.setInt(2, resourceID.getPathID());
                ps.setInt(3, CurrentSession.getTenantId());
            } else {
                String sql =
                        "SELECT REG_PATH_ID, REG_RESOURCE_VIDS FROM REG_SNAPSHOT " +
                                "WHERE REG_SNAPSHOT_ID=? AND REG_PATH_ID = ? " +
                                "AND REG_RESOURCE_NAME=? AND REG_TENANT_ID=?";
                ps = conn.prepareStatement(sql);
                ps.setLong(1, snapshotID);
                ps.setInt(2, resourceID.getPathID());
                ps.setString(3, resourceID.getName());
                ps.setInt(4, CurrentSession.getTenantId());
            }

            result = ps.executeQuery();

            if (result.next()) {
                InputStream resourceVIDStream = RegistryUtils.getMemoryStream(
                        result.getBinaryStream(DatabaseConstants.RESOURCE_VIDS_FIELD));
                versionRetriever = new VersionRetriever(resourceVIDStream);
            }
        } catch (Exception e) {

            String msg = "Failed to get version of resource " + resourceID.getPath() +
                    " of snapshot " + snapshotID + ". " + e.getMessage();
View Full Code Here

Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

    public VersionRetriever getVersionList(long snapshotID) throws RegistryException {
        Connection conn = JDBCDatabaseTransaction.getConnection();
        ResultSet result = null;
        PreparedStatement ps = null;
        VersionRetriever versionRetriever = null;
        try {
            String sql = "SELECT REG_PATH_ID, REG_RESOURCE_VIDS FROM REG_SNAPSHOT WHERE " +
                    "REG_SNAPSHOT_ID=? AND REG_TENANT_ID=?";
            ps = conn.prepareStatement(sql);
            ps.setLong(1, snapshotID);
            ps.setInt(2, CurrentSession.getTenantId());

            result = ps.executeQuery();

            if (result.next()) {
                InputStream resourceVIDStream = RegistryUtils.getMemoryStream(
                        result.getBinaryStream(DatabaseConstants.RESOURCE_VIDS_FIELD));
                versionRetriever = new VersionRetriever(resourceVIDStream);
            }
        } catch (Exception e) {

            String msg =
                    "Failed to get version of the snapshot " + snapshotID + ". " + e.getMessage();
View Full Code Here

Examples of org.wso2.carbon.registry.core.jdbc.utils.VersionRetriever

                    resourceID.getPath() + " is not a collection.";
            log.error(msg);
            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);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.