Package org.apache.jackrabbit.uuid

Examples of org.apache.jackrabbit.uuid.UUID


        state.setNodeTypeName(NameFactoryImpl.getInstance().create(s));
        // parentUUID (may be null)
        byte[] uuidBytes = new byte[UUID.UUID_BYTE_LENGTH];
        in.readFully(uuidBytes);
        if (!Arrays.equals(uuidBytes, NULL_UUID_PLACEHOLDER_BYTES)) {
            state.setParentId(new NodeId(new UUID(uuidBytes)));
        }
        // definitionId
        s = in.readUTF();
        state.setDefinitionId(NodeDefId.valueOf(s));
        // mixin types
        int count = in.readInt();   // count
        Set<Name> set = new HashSet<Name>(count);
        for (int i = 0; i < count; i++) {
            set.add(NameFactoryImpl.getInstance().create(in.readUTF()));
        }
        if (set.size() > 0) {
            state.setMixinTypeNames(set);
        }
        // modCount
        short modCount = in.readShort();
        state.setModCount(modCount);
        // properties (names)
        count = in.readInt();   // count
        for (int i = 0; i < count; i++) {
            state.addPropertyName(NameFactoryImpl.getInstance().create(in.readUTF())); // name
        }
        // child nodes (list of name/uuid pairs)
        count = in.readInt();   // count
        for (int i = 0; i < count; i++) {
            Name name = NameFactoryImpl.getInstance().create(in.readUTF());    // name
            // uuid
            in.readFully(uuidBytes);
            state.addChildNodeEntry(name, new NodeId(new UUID(uuidBytes)));
        }
    }
View Full Code Here


            reader.release();
        }
        String[] uuids = queueStore.getPending();
        for (int i = 0; i < uuids.length; i++) {
            try {
                UUID uuid = UUID.fromString(uuids[i]);
                Document doc = index.createDocument(new NodeId(uuid));
                pendingDocuments.put(uuids[i], doc);
                log.debug("added node {}. New size of indexing queue: {}",
                        uuid, new Integer(pendingDocuments.size()));
            } catch (IllegalArgumentException e) {
View Full Code Here

                return (NodeId) nodeIdIndex.getKey(index);
            }
        } else if (uuidType == UUID_LITERAL) {
            byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
            readFully(b);
            NodeId nodeId = new NodeId(new UUID(b));
            nodeIdIndex.put(nodeId, nodeIdIndex.size());
            return nodeId;
        } else {
            String msg = "Unknown UUID type found: " + uuidType;
            throw new JournalException(msg);
View Full Code Here

                }
                if (reader.isDeleted(i)) {
                    continue;
                }
                Document d = reader.document(i, FieldSelectors.UUID);
                UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
                if (stateMgr.hasItemState(new NodeId(uuid))) {
                    if (!documentUUIDs.add(uuid)) {
                        multipleEntries.add(uuid);
                    }
                } else {
                    errors.add(new NodeDeleted(uuid));
                }
            }
        } finally {
            reader.release();
        }

        // create multiple entries errors
        for (UUID uuid : multipleEntries) {
            errors.add(new MultipleEntries(uuid));
        }

        reader = index.getIndexReader();
        try {
            // run through documents again and check parent
            for (int i = 0; i < reader.maxDoc(); i++) {
                if (i > 10 && i % (reader.maxDoc() / 5) == 0) {
                    long progress = Math.round((100.0 * (float) i) / ((float) reader.maxDoc() * 2f));
                    log.info("progress: " + (progress + 50) + "%");
                }
                if (reader.isDeleted(i)) {
                    continue;
                }
                Document d = reader.document(i, FieldSelectors.UUID_AND_PARENT);
                UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
                String parentUUIDString = d.get(FieldNames.PARENT);
                UUID parentUUID = null;
                if (parentUUIDString.length() > 0) {
                    parentUUID = UUID.fromString(parentUUIDString);
                }
                if (parentUUID == null || documentUUIDs.contains(parentUUID)) {
                    continue;
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<UUID> uuidList = new ArrayList<UUID>(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 Iterable<NodeId> 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<NodeId> result = new ArrayList<NodeId>();
            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(new NodeId(current));
            }
View Full Code Here

     */
    public NodeId readNodeId(DataInputStream in) throws IOException {
        if (in.readBoolean()) {
            byte[] bytes = new byte[16];
            in.readFully(bytes);
            return new NodeId(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

                    buff.append('-');
                }
            }
        }
        String u = buff.toString();
        return new UUID(u);
    }
View Full Code Here

        }
        String[] files = itemFs.listFiles(path);
        Arrays.sort(files);
        for (int i = 0; i < files.length; i++) {
            String f = files[i];
            UUID u = getUUIDFromFileName(path + FileSystem.SEPARATOR + f);
            if (u == null) {
                continue;
            }
            if (bigger != null && bigger.toString().compareTo(u.toString()) >= 0) {
                continue;
            }
            NodeId n = new NodeId(u);
            list.add(n);
            if (maxCount > 0 && list.size() >= maxCount) {
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.