Examples of NodePropBundle


Examples of org.apache.jackrabbit.core.persistence.util.NodePropBundle

        NodeId lostNFound = null;
        if (fix && lostNFoundId != null) {
            // do we have a "lost+found" node?
            try {
                NodeId tmpid = new NodeId(lostNFoundId);
                NodePropBundle lfBundle = pm.loadBundle(tmpid);
                if (lfBundle == null) {
                    error(lostNFoundId,
                            "specified 'lost+found' node does not exist");
                } else if (!NameConstants.NT_UNSTRUCTURED.equals(lfBundle
                        .getNodeTypeName())) {
                    error(lostNFoundId,
                            "specified 'lost+found' node is not of type nt:unstructured");
                } else {
                    lostNFound = lfBundle.getId();
                }
            } catch (Exception ex) {
                error(lostNFoundId, "finding 'lost+found' folder", ex);
            }
        }

        if (uuids == null) {
            try {
                List<NodeId> allIds = pm.getAllNodeIds(null, NODESATONCE);

                while (!allIds.isEmpty()) {
                    NodeId lastId = null;

                    for (NodeId id : allIds) {
                        lastId = id;
                        try {
                            // parse and check bundle
                            NodePropBundle bundle = pm.loadBundle(id);
                            if (bundle == null) {
                                error(id.toString(), "No bundle found for id '"
                                        + id + "'");
                            } else {
                                checkBundleConsistency(id, bundle, fix, lostNFound, reports);

                                count++;
                                if (count % 1000 == 0 && listener == null) {
                                    log.info(pm + ": checked " + count
                                            + " bundles...");
                                }
                            }
                        } catch (ItemStateException e) {
                            // problem already logged (loadBundle called with
                            // logDetailedErrors=true)
                        }
                    }

                    if (!allIds.isEmpty()) {
                        allIds = pm.getAllNodeIds(lastId, NODESATONCE);
                    }
                }
            } catch (ItemStateException ex) {
                throw new RepositoryException("getting nodeIds", ex);
            }
        } 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<NodeId> idList = new ArrayList<NodeId>(uuids.length);
            // convert uuid string array to list of UUID objects
            for (int i = 0; i < uuids.length; i++) {
                try {
                    idList.add(new NodeId(uuids[i]));
                } catch (IllegalArgumentException e) {
                    error(uuids[i],
                            "Invalid id for consistency check, skipping: '"
                                    + uuids[i] + "': " + e);
                }
            }

            // iterate over UUIDs (including ones that are newly added inside
            // the loop!)
            for (int i = 0; i < idList.size(); i++) {
                NodeId id = idList.get(i);
                try {
                    // load the node from the database
                    NodePropBundle bundle = pm.loadBundle(id);

                    if (bundle == null) {
                        if (!isVirtualNode(id)) {
                            error(id.toString(), "No bundle found for id '"
                                    + id + "'");
                        }
                    } else {
                        checkBundleConsistency(id, bundle, fix, lostNFound, reports);

                        if (recursive) {
                            for (NodePropBundle.ChildNodeEntry entry : bundle
                                    .getChildNodeEntries()) {
                                idList.add(entry.getId());
                            }
                        }
View Full Code Here

Examples of org.apache.jackrabbit.core.persistence.util.NodePropBundle

                continue;
            }

            try {
                // analyze child node bundles
                final NodePropBundle childBundle = pm.loadBundle(childNodeId);
                String message = null;
                if (childBundle == null) {
                    // double check whether we still exist and the child entry is still there
                    bundle = pm.loadBundle(id);

                    if (bundle != null) {
                        boolean stillThere = false;
                        for (NodePropBundle.ChildNodeEntry entryRetry : bundle.getChildNodeEntries()) {
                            if (entryRetry.getId().equals(childNodeId)) {
                                stillThere = true;
                                break;
                            }
                        }
                        if (stillThere) {
                            message = "NodeState '" + id
                                    + "' references inexistent child" + " '"
                                    + entry.getName() + "' with id " + "'"
                                    + childNodeId + "'";
                            log.error(message);
                            missingChildren.add(entry);
                        }
                    } else {
                        return;
                    }
                } else {
                    NodeId cp = childBundle.getParentId();
                    if (!id.equals(cp)) {
                        // double check whether the child entry is still there
                        bundle = pm.loadBundle(id);
                        if (bundle != null) {
                            boolean stillThere = false;
                            for (NodePropBundle.ChildNodeEntry entryRetry : bundle.getChildNodeEntries()) {
                                if (entryRetry.getId().equals(childNodeId)) {
                                    stillThere = true;
                                    break;
                                }
                            }
                            if (stillThere) {
                                // indeed we have a disconnected child
                                message = "ChildNode has invalid parent id: '" + cp + "' (instead of '" + id + "')";
                                log.error(message);
                                disconnectedChildren.add(entry);
                            }
                        } else {
                            return;
                        }
                    }
                }
                if (message != null) {
                    addMessage(reports, id, message);
                }
            } catch (ItemStateException e) {
                // problem already logged (loadBundle called with
                // logDetailedErrors=true)
                addMessage(reports, id, e.getMessage());
            }
        }
        // remove child node entry (if fixing is enabled)
        if (fix && (!missingChildren.isEmpty() || !disconnectedChildren.isEmpty())) {
            for (NodePropBundle.ChildNodeEntry entry : missingChildren) {
                bundle.getChildNodeEntries().remove(entry);
            }
            for (NodePropBundle.ChildNodeEntry entry : disconnectedChildren) {
                bundle.getChildNodeEntries().remove(entry);
            }
            fixBundle(bundle);
        }

        // check parent reference
        NodeId parentId = bundle.getParentId();
        try {
            // skip root nodes (that point to itself)
            if (parentId != null && !id.toString().endsWith("babecafebabe")) {
                NodePropBundle parentBundle = pm.loadBundle(parentId);

                if (parentBundle == null) {
                    // double check whether we still exist and the parent is still the same
                    bundle = pm.loadBundle(id);
                    if (bundle != null) {
                        if (parentId.equals(bundle.getParentId())) {
                            String message = "NodeState '" + id
                                    + "' references inexistent parent id '" + parentId
                                    + "'";
                            log.error(message);
                            addMessage(reports, id, message);
                            if (fix && lostNFoundId != null) {
                                // add a child to lost+found
                                NodePropBundle lfBundle = pm.loadBundle(lostNFoundId);
                                lfBundle.markOld();
                                String nodeName = id + "-" + System.currentTimeMillis();
                                lfBundle.addChildNodeEntry(NF.create("", nodeName), id);
                                pm.storeBundle(lfBundle);
                                pm.evictBundle(lostNFoundId);

                                // set lost+found parent
                                bundle.setParentId(lostNFoundId);
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.