Package org.apache.jackrabbit.uuid

Examples of org.apache.jackrabbit.uuid.UUID


            byte[] bytes = new byte[16];
            int pos = 0;
            while (pos < 16) {
                pos += in.read(bytes, pos, 16 - pos);
            }
            return new NodeId(new UUID(bytes));
        } else {
            return null;
        }
    }
View Full Code Here


     * @param in the input stream
     * @return the property id
     * @throws IOException in an I/O error occurs.
     */
    public PropertyId readPropertyId(DataInputStream in) throws IOException {
        UUID uuid = readUUID(in);
        Name name = readQName(in);
        return new PropertyId(new NodeId(uuid), name);
    }
View Full Code Here

        } catch (IOException e) {
            log.error("Error while reading NodeTypeName: " + e);
            return false;
        }
        try {
            UUID parentUuid = readUUID(in);
            log.debug("ParentUUID: " + parentUuid);
        } catch (IOException e) {
            log.error("Error while reading ParentUUID: " + e);
            return false;
        }
        try {
            String definitionId = in.readUTF();
            log.debug("DefinitionId: " + definitionId);
        } catch (IOException e) {
            log.error("Error while reading DefinitionId: " + e);
            return false;
        }
        try {
            Name mixinName = readIndexedQName(in);
            while (mixinName != null) {
                log.debug("MixinTypeName: " + mixinName);
                mixinName = readIndexedQName(in);
            }
        } catch (IOException e) {
            log.error("Error while reading MixinTypes: " + e);
            return false;
        }
        try {
            Name propName = readIndexedQName(in);
            while (propName != null) {
                log.debug("PropertyName: " + propName);
                if (!checkPropertyState(in)) {
                    return false;
                }
                propName = readIndexedQName(in);
            }
        } catch (IOException e) {
            log.error("Error while reading property names: " + e);
            return false;
        }
        try {
            boolean hasUUID = in.readBoolean();
            log.debug("hasUUID: " + hasUUID);
        } catch (IOException e) {
            log.error("Error while reading 'hasUUID': " + e);
            return false;
        }
        try {
            UUID cneUUID = readUUID(in);
            while (cneUUID != null) {
                Name cneName = readQName(in);
                log.debug("ChildNodentry: " + cneUUID + ":" + cneName);
                cneUUID = readUUID(in);
            }
View Full Code Here

                        return false;
                    }
                    break;
                case PropertyType.REFERENCE:
                    try {
                        UUID uuid = readUUID(in);
                        log.debug("  reference: " + uuid);
                    } catch (IOException e) {
                        log.error("Error while reading reference value: " + e);
                        return false;
                    }
View Full Code Here

                // iterate over all node bundles in the db
                while (rs.next()) {
                    NodeId id;
                    if (getStorageModel() == SM_BINARY_KEYS) {
                        id = new NodeId(new UUID(rs.getBytes(1)));
                    } else {
                        id = new NodeId(new UUID(rs.getLong(1), rs.getLong(2)));
                    }

                    // issuing 2nd statement to circumvent issue JCR-1474
                    ResultSet bRs = null;
                    byte[] data = null;
                    try {
                        Statement bSmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
                        bRs = bSmt.getResultSet();
                        if (!bRs.next()) {
                            throw new SQLException("bundle cannot be retrieved?");
                        }
                        Blob blob = bRs.getBlob(1);
                        data = getBytes(blob);
                    } finally {
                        closeResultSet(bRs);
                    }


                    try {
                        // parse and check bundle
                        // checkBundle will log any problems itself
                        DataInputStream din = new DataInputStream(new ByteArrayInputStream(data));
                        if (binding.checkBundle(din)) {
                            // reset stream for readBundle()
                            din = new DataInputStream(new ByteArrayInputStream(data));
                            NodePropBundle bundle = binding.readBundle(din, id);
                            checkBundleConsistency(id, bundle, fix, modifications);
                        } else {
                            log.error("invalid bundle '" + id + "', see previous BundleBinding error log entry");
                        }
                    } catch (Exception e) {
                        log.error("Error in bundle " + id + ": " + e);
                    }
                    count++;
                    if (count % 1000 == 0) {
                        log.info(name + ": checked " + count + "/" + total + " bundles...");
                    }
                }
            } catch (Exception e) {
                log.error("Error loading bundle", e);
            } finally {
                closeResultSet(rs);
                total = count;
            }
        } else {
            // check only given uuids, handle recursive flag

            // 1) convert uuid array to modifiable list
            // 2) for each uuid do
            //     a) load node bundle
            //     b) check bundle, store any bundle-to-be-modified in collection
            //     c) if recursive, add child uuids to list of uuids

            List uuidList = new ArrayList(uuids.length);
            // convert uuid string array to list of UUID objects
            for (int i = 0; i < uuids.length; i++) {
                try {
                    uuidList.add(new UUID(uuids[i]));
                } catch (IllegalArgumentException e) {
                    log.error("Invalid uuid for consistency check, skipping: '" + uuids[i] + "': " + e);
                }
            }

            // iterate over UUIDs (including ones that are newly added inside the loop!)
            for (int i = 0; i < uuidList.size(); i++) {
                final UUID uuid = (UUID) uuidList.get(i);
                try {
                    // load the node from the database
                    NodeId id = new NodeId(uuid);
                    NodePropBundle bundle = loadBundle(id, true);
View Full Code Here

     */
    public synchronized NodeIdIterator getAllNodeIds(NodeId bigger, int maxCount)
            throws ItemStateException, RepositoryException {
        ResultSet rs = null;
        try {
            UUID lowUuid;
            Object[] keys;
            String sql;
            if (bigger == null) {
                sql = bundleSelectAllIdsSQL;
                lowUuid = null;
                keys = new Object[0];
            } else {
                sql = bundleSelectAllIdsFromSQL;
                lowUuid = bigger.getUUID();
                keys = getKey(lowUuid);
            }
            if (maxCount > 0) {
                // get some more rows, in case the first row is smaller
                // only required for SM_LONGLONG_KEYS
                // probability is very low to get get the wrong first key, < 1 : 2^64
                // see also bundleSelectAllIdsFrom SQL statement
                maxCount += 10;
            }
            Statement stmt = connectionManager.executeStmt(sql, keys, false, maxCount);
            rs = stmt.getResultSet();
            ArrayList result = new ArrayList();
            while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
                UUID current;
                if (getStorageModel() == SM_BINARY_KEYS) {
                    current = new UUID(rs.getBytes(1));
                } else {
                    long high = rs.getLong(1);
                    long low = rs.getLong(2);
                    current = new UUID(high, low);
                }
                if (lowUuid != null) {
                    // skip the keys that are smaller or equal (see above, maxCount += 10)
                    if (current.compareTo(lowUuid) <= 0) {
                        continue;
                    }
                }
                result.add(current);
            }       
View Full Code Here

            byte[] bytes = new byte[16];
            int pos = 0;
            while (pos < 16) {
                pos += in.read(bytes, pos, 16 - pos);
            }
            return new UUID(bytes);
        } else {
            return null;
        }
    }
View Full Code Here

            byte[] bytes = new byte[16];
            int pos = 0;
            while (pos < 16) {
                pos += in.read(bytes, pos, 16 - pos);
            }
            return new NodeId(new UUID(bytes));
        } else {
            return null;
        }
    }
View Full Code Here

     * @param in the input stream
     * @return the property id
     * @throws IOException in an I/O error occurs.
     */
    public PropertyId readPropertyId(DataInputStream in) throws IOException {
        UUID uuid = readUUID(in);
        Name name = readQName(in);
        return new PropertyId(new NodeId(uuid), name);
    }
View Full Code Here

                // iterate over all node bundles in the db
                while (rs.next()) {
                    NodeId id;
                    if (getStorageModel() == SM_BINARY_KEYS) {
                        id = new NodeId(new UUID(rs.getBytes(1)));
                    } else {
                        id = new NodeId(new UUID(rs.getLong(1), rs.getLong(2)));
                    }

                    // issuing 2nd statement to circumvent issue JCR-1474
                    ResultSet bRs = null;
                    byte[] data = null;
                    try {
                        Statement bSmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
                        bRs = bSmt.getResultSet();
                        if (!bRs.next()) {
                            throw new SQLException("bundle cannot be retrieved?");
                        }
                        Blob blob = bRs.getBlob(1);
                        data = getBytes(blob);
                    } finally {
                        closeResultSet(bRs);
                    }


                    try {
                        // parse and check bundle
                        // checkBundle will log any problems itself
                        DataInputStream din = new DataInputStream(new ByteArrayInputStream(data));
                        if (binding.checkBundle(din)) {
                            // reset stream for readBundle()
                            din = new DataInputStream(new ByteArrayInputStream(data));
                            NodePropBundle bundle = binding.readBundle(din, id);
                            checkBundleConsistency(id, bundle, fix, modifications);
                        } else {
                            log.error("invalid bundle '" + id + "', see previous BundleBinding error log entry");
                        }
                    } catch (Exception e) {
                        log.error("Error in bundle " + id + ": " + e);
                    }
                    count++;
                    if (count % 1000 == 0) {
                        log.info(name + ": checked " + count + "/" + total + " bundles...");
                    }
                }
            } catch (Exception e) {
                log.error("Error loading bundle", e);
            } finally {
                closeResultSet(rs);
                total = count;
            }
        } else {
            // check only given uuids, handle recursive flag

            // 1) convert uuid array to modifiable list
            // 2) for each uuid do
            //     a) load node bundle
            //     b) check bundle, store any bundle-to-be-modified in collection
            //     c) if recursive, add child uuids to list of uuids

            List uuidList = new ArrayList(uuids.length);
            // convert uuid string array to list of UUID objects
            for (int i = 0; i < uuids.length; i++) {
                try {
                    uuidList.add(new UUID(uuids[i]));
                } catch (IllegalArgumentException e) {
                    log.error("Invalid uuid for consistency check, skipping: '" + uuids[i] + "': " + e);
                }
            }

            // iterate over UUIDs (including ones that are newly added inside the loop!)
            for (int i = 0; i < uuidList.size(); i++) {
                final UUID uuid = (UUID) uuidList.get(i);
                try {
                    // load the node from the database
                    NodeId id = new NodeId(uuid);
                    NodePropBundle bundle = loadBundle(id, true);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.uuid.UUID

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.