Package org.apache.jackrabbit.core.state

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


     * @throws RepositoryException
     */
    private void resolvePropertyNameConflict(NodeState parent, QName name)
            throws RepositoryException {
        PropertyId propId = new PropertyId(parent.getNodeId(), name);
        PropertyState conflicting = itemOps.getPropertyState(propId);
        if (conflicting.getStatus() == ItemState.STATUS_NEW) {
            // assume this property has been imported as well;
            // rename conflicting property
            // @todo use better reversible escaping scheme to create unique name
            QName newName = new QName(name.getNamespaceURI(), name.getLocalName() + "_");
            while (parent.hasPropertyName(newName)) {
                newName = new QName(newName.getNamespaceURI(), newName.getLocalName() + "_");
            }
            InternalValue[] values = conflicting.getValues();
            PropertyState newProp = itemOps.createPropertyState(
                    parent, newName, conflicting.getType(), values.length);
            newProp.setValues(values);
            parent.removePropertyName(name);
            itemOps.store(parent);
            itemOps.destroy(conflicting);
        }
    }
View Full Code Here


             * adjust references that refer to uuid's which have been mapped to
             * newly gererated uuid's on import
             */
            Iterator iter = refTracker.getProcessedReferences();
            while (iter.hasNext()) {
                PropertyState prop = (PropertyState) iter.next();
                // being paranoid...
                if (prop.getType() != PropertyType.REFERENCE) {
                    continue;
                }
                boolean modified = false;
                InternalValue[] values = prop.getValues();
                InternalValue[] newVals = new InternalValue[values.length];
                for (int i = 0; i < values.length; i++) {
                    InternalValue val = values[i];
                    UUID original = (UUID) val.internalValue();
                    UUID adjusted = refTracker.getMappedUUID(original);
                    if (adjusted != null) {
                        newVals[i] = InternalValue.create(adjusted);
                        modified = true;
                    } else {
                        // reference doesn't need adjusting, just copy old value
                        newVals[i] = val;
                    }
                }
                if (modified) {
                    prop.setValues(newVals);
                    itemOps.store(prop);
                }
            }
            refTracker.clear();

View Full Code Here

            InternalValue value)
            throws RepositoryException {
        if (!node.hasPropertyName(name)) {
            PropDef def = itemOps.findApplicablePropertyDefinition(
                    name, type, multiple, node);
            PropertyState prop = itemOps.createPropertyState(
                    node, name, type, def);
            prop.setValues(new InternalValue[] { value });
        }
    }
View Full Code Here

                if (!rs.next()) {
                    throw new NoSuchItemStateException(id.toString());
                }

                in = rs.getBinaryStream(1);
                PropertyState state = createNew(id);
                Serializer.deserialize(state, in, blobStore);

                return state;
            } catch (Exception e) {
                if (e instanceof NoSuchItemStateException) {
View Full Code Here

                throw new NoSuchItemStateException(id.toString());
            }
            InputStream in = itemStateFS.getInputStream(propFilePath);
            try {
                DOMWalker walker = new DOMWalker(in);
                PropertyState state = createNew(id);
                readState(walker, state);
                return state;
            } finally {
                in.close();
            }
View Full Code Here

        Set props = node.getPropertyNames();
        for (Iterator it = props.iterator(); it.hasNext();) {
            QName propName = (QName) it.next();
            PropertyId id = new PropertyId(node.getNodeId(), propName);
            try {
                PropertyState propState = (PropertyState) stateProvider.getItemState(id);
                InternalValue[] values = propState.getValues();
                for (int i = 0; i < values.length; i++) {
                    addValue(doc, values[i], propState.getName());
                }
                if (values.length > 1) {
                    // real multi-valued
                    addMVPName(doc, propState.getName());
                }
            } catch (NoSuchItemStateException e) {
                throwRepositoryException(e);
            } catch (ItemStateException e) {
                throwRepositoryException(e);
View Full Code Here

            if (!jcrData.equals(fieldName)) {
                // don't know how to index
                return;
            }
            if (node.hasPropertyName(QName.JCR_MIMETYPE)) {
                PropertyState dataProp = (PropertyState) stateProvider.getItemState(
                        new PropertyId(node.getNodeId(), QName.JCR_DATA));
                PropertyState mimeTypeProp =
                        (PropertyState) stateProvider.getItemState(
                                new PropertyId(node.getNodeId(), QName.JCR_MIMETYPE));

                // jcr:encoding is not mandatory
                String encoding = null;
                if (node.hasPropertyName(QName.JCR_ENCODING)) {
                    PropertyState encodingProp =
                            (PropertyState) stateProvider.getItemState(
                                    new PropertyId(node.getNodeId(), QName.JCR_ENCODING));
                    encoding = encodingProp.getValues()[0].internalValue().toString();
                }

                String mimeType = mimeTypeProp.getValues()[0].internalValue().toString();
                Map fields = Collections.EMPTY_MAP;
                for (Iterator it = textFilters.iterator(); it.hasNext();) {
View Full Code Here

                        }
                    }
                }
            } else {
                // the transient item is a property
                PropertyState propState = (PropertyState) itemState;
                ItemId propId = propState.getPropertyId();
                org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl propDef = (org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl) def;

                /**
                 * check value constraints
                 * (no need to check value constraints of protected properties
                 * as those are set by the implementation only, i.e. they
                 * cannot be set by the user through the api)
                 */
                if (!def.isProtected()) {
                    String[] constraints = propDef.getValueConstraints();
                    if (constraints != null) {
                        InternalValue[] values = propState.getValues();
                        try {
                            EffectiveNodeType.checkSetPropertyValueConstraints(
                                    propDef.unwrap(), values);
                        } catch (RepositoryException e) {
                            // repack exception for providing more verbose error message
View Full Code Here

     * Loads the state via the appropriate NodePropBundle.
     */
    public PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
        NodePropBundle bundle = getBundle(id.getParentId());
        if (bundle != null) {
            PropertyState state = createNew(id);
            PropertyEntry p = bundle.getPropertyEntry(id.getName());
            if (p != null) {
                state.setMultiValued(p.isMultiValued());
                state.setType(p.getType());
                state.setValues(p.getValues());
                state.setModCount(p.getModCount());
            } else if (id.getName().equals(JCR_UUID)) {
                state.setType(PropertyType.STRING);
                state.setMultiValued(false);
                state.setValues(new InternalValue[] {
                        InternalValue.create(id.getParentId().toString()) });
            } else if (id.getName().equals(JCR_PRIMARYTYPE)) {
                state.setType(PropertyType.NAME);
                state.setMultiValued(false);
                state.setValues(new InternalValue[] {
                        InternalValue.create(bundle.getNodeTypeName()) });
            } else if (id.getName().equals(JCR_MIXINTYPES)) {
                state.setType(PropertyType.NAME);
                state.setMultiValued(true);
                Set<Name> mixins = bundle.getMixinTypeNames();
                state.setValues(InternalValue.create(
                        mixins.toArray(new Name[mixins.size()])));
            } else {
                throw new NoSuchItemStateException(id.toString());
            }
            return state;
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public PropertyState createNew(PropertyId id) {
        return new PropertyState(id, PropertyState.STATUS_NEW, false);
    }
View Full Code Here

TOP

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

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.