Package org.apache.jackrabbit.jcr2spi.operation

Examples of org.apache.jackrabbit.jcr2spi.operation.Operation


                    log.debug(msg);
                    throw new ConstraintViolationException(msg);
                }
                // do remove conflicting (recursive) including validation check
                try {
                    Operation op = Remove.create(conflicting.getNodeState());
                    stateMgr.execute(op);
                } catch (ItemNotFoundException e) {
                    // conflicting does not exist any more. no need for a removal
                }
                // create new with given uuid:
                nodeState = importNode(nodeInfo, parent);
                break;

            case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING:
                if (conflicting.getNodeState().isRoot()) {
                    msg = "Root node cannot be replaced";
                    log.debug(msg);
                    throw new RepositoryException(msg);
                }

                // 'replace' current parent with parent of conflicting
                parent = conflicting.getParent().getNodeState();

                // do remove conflicting (recursive), including validation checks
                Operation op = Remove.create(conflicting.getNodeState());
                stateMgr.execute(op);
                // create new with given uuid at same location as conflicting
                nodeState = importNode(nodeInfo, parent);
                break;
View Full Code Here


                } else {
                    // can only be multi-valued (n == 0 || n > 1)
                    propDef = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, newName, conflicting.getType(), true);
                }

                Operation ap = AddProperty.create(parent, newName, conflicting.getType(), propDef, conflicting.getValues());
                stateMgr.execute(ap);
                Operation rm = Remove.create(conflicting);
                stateMgr.execute(rm);
            }
        }

        // do create new nodeState
        QNodeDefinition def = session.getItemDefinitionProvider().getQNodeDefinition(parentNtNames, nodeInfo.getName(), nodeInfo.getNodeTypeName());
        if (def.isProtected()) {
            log.debug("Skipping protected nodeState (" + nodeInfo.getName() + ")");
            return null;
        } else {
            Name ntName = nodeInfo.getNodeTypeName();
            if (ntName == null) {
                // use default node type
                ntName = def.getDefaultPrimaryType();
            }
            Operation an = AddNode.create(parent, nodeInfo.getName(), ntName, nodeInfo.getUUID());
            stateMgr.execute(an);
            // retrieve id of state that has been created during execution of AddNode
            NodeState childState = (NodeState) ((AddNode) an).getAddedStates().get(0);

            // and set mixin types
            Name[] mixinNames = nodeInfo.getMixinNames();
            if (mixinNames != null && mixinNames.length > 0) {
                Operation sm = SetMixin.create(childState, nodeInfo.getMixinNames());
                stateMgr.execute(sm);
            }
            return childState;
        }
    }
View Full Code Here

        }

        QValue[] values = getPropertyValues(pi, targetType, def.isMultiple(), resolver);
        if (propState == null) {
            // create new property
            Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
            stateMgr.execute(ap);
            propState = parentEntry.getPropertyEntry(propName).getPropertyState();
        } else {
            // modify value of existing property
            Operation sp = SetPropertyValue.create(propState, values, targetType);
            stateMgr.execute(sp);
        }

        // store reference for later resolution
        if (propState.getType() == PropertyType.REFERENCE) {
View Full Code Here

        // retrieve qualified paths
        Path srcPath = getQPath(srcAbsPath);
        Path destPath = getQPath(destAbsPath);

        // all validation is performed by Move Operation and state-manager
        Operation op = Move.create(srcPath, destPath, getHierarchyManager(), getPathResolver(), true);
        itemStateManager.execute(op);
    }
View Full Code Here

            try {
                ItemState target = changeLog.getTarget();
                batch = service.createBatch(sessionInfo, target.getId());
                Iterator it = changeLog.getOperations().iterator();
                while (it.hasNext()) {
                    Operation op = (Operation) it.next();
                    log.debug("executing " + op.getName());
                    op.accept(this);
                }
            } catch (RepositoryException e) {
                ex = e;
            } finally {
                if (batch != null) {
View Full Code Here

            // setting a property to null removes it automatically
            remove();
            return;
        }
        // modify the state of this property
        Operation op = SetPropertyValue.create(getPropertyState(), qValues, valueType);
        session.getSessionItemStateManager().execute(op);
    }
View Full Code Here

        // do intra-workspace copy
        Path srcPath = session.getQPath(srcAbsPath);
        Path destPath = session.getQPath(destAbsPath);

        Operation op = Copy.create(srcPath, destPath, getName(), this, this);
        getUpdatableItemStateManager().execute(op);
    }
View Full Code Here

            // (may throw NoSuchWorkspaceException and AccessDeniedException)
            srcSession = session.switchWorkspace(srcWorkspace);
            WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();

            // do cross-workspace copy
            Operation op = Copy.create(srcPath, destPath, srcWsp.getName(), srcWsp, this);
            getUpdatableItemStateManager().execute(op);
        } finally {
            if (srcSession != null) {
                // we don't need the other session anymore, logout
                srcSession.logout();
View Full Code Here

            // (may throw NoSuchWorkspaceException and AccessDeniedException)
            srcSession = session.switchWorkspace(srcWorkspace);
            WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();

            // do clone
            Operation op = Clone.create(srcPath, destPath, srcWsp.getName(), removeExisting, srcWsp, this);
            getUpdatableItemStateManager().execute(op);
        } finally {
            if (srcSession != null) {
                // we don't need the other session anymore, logout
                srcSession.logout();
View Full Code Here

        session.checkIsAlive();

        Path srcPath = session.getQPath(srcAbsPath);
        Path destPath = session.getQPath(destAbsPath);

        Operation op = Move.create(srcPath, destPath, getHierarchyManager(), getPathResolver(), false);
        getUpdatableItemStateManager().execute(op);
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.jcr2spi.operation.Operation

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.