Package org.apache.jackrabbit.core.state

Examples of org.apache.jackrabbit.core.state.ChangeLog


                log.warn(msg);
                return;
            }

            List<EventState> events = update.getEvents();
            ChangeLog changes = update.getChanges();
            boolean succeeded = false;

            try {
                ChangeLogRecord clr = new ChangeLogRecord(changes, events,
                        record, workspace, update.getTimestamp(),
View Full Code Here


                new InternalValue[] { InternalValue.create(CHILD_ID) });

        NodeReferences references = new NodeReferences(CHILD_ID);
        references.addReference(PROPERTY_ID);

        ChangeLog create = new ChangeLog();
        create.added(node);
        create.added(child);
        create.added(property);
        create.modified(references);
        manager.store(create);

        assertTrue(manager.exists(NODE_ID));
        assertTrue(manager.exists(CHILD_ID));
        assertTrue(manager.exists(PROPERTY_ID));
        assertTrue(manager.existsReferencesTo(CHILD_ID));

        assertEquals(node, manager.load(NODE_ID));
        assertEquals(child, manager.load(CHILD_ID));
        assertEquals(property, manager.load(PROPERTY_ID));
        assertEquals(references, manager.loadReferencesTo(CHILD_ID));

        references.removeReference(PROPERTY_ID);
        node.setStatus(ItemState.STATUS_EXISTING);
        ChangeLog update = new ChangeLog();
        update.modified(references);
        node.removePropertyName(TEST);
        update.deleted(property);
        update.modified(node);
        manager.store(update);

        assertTrue(manager.exists(NODE_ID));
        assertTrue(manager.exists(CHILD_ID));
        assertFalse(manager.exists(PROPERTY_ID));
        assertFalse(manager.existsReferencesTo(CHILD_ID));

        assertEquals(node, manager.load(NODE_ID));
        assertEquals(child, manager.load(CHILD_ID));

        ChangeLog delete = new ChangeLog();
        delete.deleted(child);
        delete.deleted(node);
        manager.store(delete);

        assertFalse(manager.exists(NODE_ID));
        assertFalse(manager.exists(CHILD_ID));
        assertFalse(manager.exists(PROPERTY_ID));
View Full Code Here

                PropertyState pt = pMgr.createNew(new PropertyId(historiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            // check for jcr:activities
            if (!pMgr.exists(activitiesId)) {
                NodeState root = pMgr.createNew(activitiesId);
                root.setParentId(systemId);
                root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
                PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking, nodeIdFactory);
View Full Code Here

    public RepositoryChecker(
            PersistenceManager workspace,
            InternalVersionManagerImpl versionManager) {
        this.workspace = workspace;
        this.workspaceChanges = new ChangeLog();
        this.vworkspaceChanges = new ChangeLog();
        this.versionManager = versionManager;
    }
View Full Code Here

                log.warn(msg);
                return;
            }

            List<EventState> events = update.getEvents();
            ChangeLog changes = update.getChanges();
            boolean succeeded = false;

            try {
                ChangeLogRecord clr = new ChangeLogRecord(changes, events,
                        record, workspace, update.getTimestamp(),
View Full Code Here

                PropertyState pt = pMgr.createNew(new PropertyId(historiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            // check for jcr:activities
            if (!pMgr.exists(activitiesId)) {
                NodeState root = pMgr.createNew(activitiesId);
                root.setParentId(systemId);
                root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
                PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking);
View Full Code Here

                PropertyState pt = pMgr.createNew(new PropertyId(historiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            // check for jcr:activities
            if (!pMgr.exists(activitiesId)) {
                NodeState root = pMgr.createNew(activitiesId);
                root.setParentId(systemId);
                root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
                PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }

            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking);
View Full Code Here

                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
                pt.setMultiValued(false);
                pt.setType(PropertyType.NAME);
                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
                root.addPropertyName(pt.getName());
                ChangeLog cl = new ChangeLog();
                cl.added(root);
                cl.added(pt);
                pMgr.store(cl);
            }
            sharedStateMgr = createItemStateManager(pMgr, rootId, ntReg, cacheFactory, ismLocking);

            stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
View Full Code Here

     * @param sourceNode source node state
     * @throws RepositoryException if the copy operation fails
     */
    private void copy(NodeState sourceNode) throws RepositoryException {
        try {
            ChangeLog changes = new ChangeLog();

            // Copy the node state
            NodeState targetNode = target.createNew(sourceNode.getNodeId());
            targetNode.setParentId(sourceNode.getParentId());
            targetNode.setDefinitionId(sourceNode.getDefinitionId());
            targetNode.setNodeTypeName(sourceNode.getNodeTypeName());
            targetNode.setMixinTypeNames(sourceNode.getMixinTypeNames());
            targetNode.setPropertyNames(sourceNode.getPropertyNames());
            targetNode.setChildNodeEntries(sourceNode.getChildNodeEntries());
            if (target.exists(targetNode.getNodeId())) {
                changes.modified(targetNode);
            } else {
                changes.added(targetNode);
            }

            // Copy all associated property states
            Iterator iterator = sourceNode.getPropertyNames().iterator();
            while (iterator.hasNext()) {
                Name name = (Name) iterator.next();
                PropertyId id = new PropertyId(sourceNode.getNodeId(), name);
                PropertyState sourceState = source.load(id);
                PropertyState targetState = target.createNew(id);
                targetState.setDefinitionId(sourceState.getDefinitionId());
                targetState.setType(sourceState.getType());
                targetState.setMultiValued(sourceState.isMultiValued());
                InternalValue[] values = sourceState.getValues();
                if (sourceState.getType() == PropertyType.BINARY) {
                    for (int i = 0; i < values.length; i++) {
                        InputStream stream = values[i].getBLOBFileValue().getStream();
                        try {
                            values[i] = InternalValue.createTemporary(stream, store);
                        } finally {
                            stream.close();
                        }
                    }
                }
                targetState.setValues(values);
                if (target.exists(targetState.getPropertyId())) {
                    changes.modified(targetState);
                } else {
                    changes.added(targetState);
                }
            }

            // Copy all node references
            NodeReferencesId refsId = new NodeReferencesId(sourceNode.getNodeId());
            if (source.exists(refsId)) {
                changes.modified(source.load(refsId));
            } else if (target.exists(refsId)) {
                 NodeReferences references = target.load(refsId);
                references.clearAllReferences();
                changes.modified(references);
            }

            // Persist the copied states
            target.store(changes);
        } catch (IOException e) {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean setNodeReferences(ChangeLog references) {
        ChangeLog changeLog = ((XAItemStateManager) stateMgr).getChangeLog();
        if (changeLog != null) {
            Iterator iterator = references.modifiedRefs();
            while (iterator.hasNext()) {
                changeLog.modified((NodeReferences) iterator.next());
            }
            return true;
        } else {
            return false;
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.state.ChangeLog

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.