Package org.apache.jackrabbit.core.value

Examples of org.apache.jackrabbit.core.value.InternalValue


            }
            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 {
View Full Code Here


        // delete binary values (stored as files)
        InternalValue[] values = state.getValues();
        if (values != null) {
            for (int i = 0; i < values.length; i++) {
                InternalValue val = values[i];
                if (val != null) {
                    if (val.getType() == PropertyType.BINARY) {
                        BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
                        // delete blob file and prune empty parent folders
                        blobVal.delete(true);
                    }
                }
            }
View Full Code Here

        out.writeShort(state.getModCount());
        // values
        InternalValue[] values = state.getValues();
        out.writeInt(values.length); // count
        for (int i = 0; i < values.length; i++) {
            InternalValue val = values[i];
            if (state.getType() == PropertyType.BINARY) {
                // special handling required for binary value:
                // put binary value in BLOB store
                BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
                InputStream in = blobVal.getStream();
                String blobId = blobStore.createId(state.getPropertyId(), i);
                try {
                    blobStore.put(blobId, in, blobVal.getLength());
                } finally {
                    try {
                        in.close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
                // store id of BLOB as property value
                out.writeUTF(blobId);   // value
                // replace value instance with value backed by resource
                // in BLOB store and discard old value instance (e.g. temp file)
                if (blobStore instanceof ResourceBasedBLOBStore) {
                    // optimization: if the BLOB store is resource-based
                    // retrieve the resource directly rather than having
                    // to read the BLOB from an input stream
                    FileSystemResource fsRes =
                            ((ResourceBasedBLOBStore) blobStore).getResource(blobId);
                    values[i] = InternalValue.create(fsRes);
                } else {
                    in = blobStore.get(blobId);
                    try {
                        values[i] = InternalValue.create(in, false);
                    } finally {
                        try {
                            in.close();
                        } catch (IOException e) {
                            // ignore
                        }
                    }
                }
                blobVal.discard();
            } else {
                /**
                 * because writeUTF(String) has a size limit of 65k,
                 * Strings are serialized as <length><byte[]>
                 */
                //out.writeUTF(val.toString());   // value
                byte[] bytes = val.toString().getBytes(ENCODING);
                out.writeInt(bytes.length); // lenght of byte[]
                out.write(bytes);   // byte[]
            }
        }
    }
View Full Code Here

        state.setModCount(modCount);
        // values
        int count = in.readInt();   // count
        InternalValue[] values = new InternalValue[count];
        for (int i = 0; i < count; i++) {
            InternalValue val;
            if (type == PropertyType.BINARY) {
                s = in.readUTF();   // value (i.e. blobId)
                // special handling required for binary value:
                // the value stores the id of the BLOB data
                // in the BLOB store
View Full Code Here

                }
                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 {
View Full Code Here

                writer.write("\t<" + VALUES_ELEMENT + ">\n");
                InternalValue[] values = state.getValues();
                if (values != null) {
                    for (int i = 0; i < values.length; i++) {
                        writer.write("\t\t<" + VALUE_ELEMENT + ">");
                        InternalValue val = values[i];
                        if (val != null) {
                            if (type == PropertyType.BINARY) {
                                // special handling required for binary value:
                                // put binary value in BLOB store
                                BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
                                InputStream in = blobVal.getStream();
                                String blobId = blobStore.createId(state.getPropertyId(), i);
                                try {
                                    blobStore.put(blobId, in, blobVal.getLength());
                                } finally {
                                    try {
                                        in.close();
                                    } catch (IOException e) {
                                        // ignore
                                    }
                                }
                                // store id of BLOB as property value
                                writer.write(blobId);
                                // replace value instance with value backed by resource
                                // in BLOB store and discard old value instance (e.g. temp file)
                                if (blobStore instanceof ResourceBasedBLOBStore) {
                                    // optimization: if the BLOB store is resource-based
                                    // retrieve the resource directly rather than having
                                    // to read the BLOB from an input stream
                                    FileSystemResource fsRes =
                                            ((ResourceBasedBLOBStore) blobStore).getResource(blobId);
                                    values[i] = InternalValue.create(fsRes);
                                } else {
                                    in = blobStore.get(blobId);
                                    try {
                                        values[i] = InternalValue.create(in, false);
                                    } finally {
                                        try {
                                            in.close();
                                        } catch (IOException e) {
                                            // ignore
                                        }
                                    }
                                }
                                blobVal.discard();
                            } else {
                                writer.write(Text.encodeIllegalXMLCharacters(val.toString()));
                            }
                        }
                        writer.write("</" + VALUE_ELEMENT + ">\n");
                    }
                }
View Full Code Here

        // delete binary values (stored as files)
        InternalValue[] values = state.getValues();
        if (values != null) {
            for (int i = 0; i < values.length; i++) {
                InternalValue val = values[i];
                if (val != null) {
                    if (val.getType() == PropertyType.BINARY) {
                        BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
                        // delete blob file and prune empty parent folders
                        blobVal.delete(true);
                    }
                }
            }
View Full Code Here

                // they depend on the current namespace context
                // of the xml document

                // convert serialized value to InternalValue using
                // current namespace context of xml document
                InternalValue ival =
                    InternalValue.create(ValueHelper.convert(
                            retrieve(), targetType, ValueFactoryImpl.getInstance()), nsContext);
                // convert InternalValue to Value using this
                // session's namespace mappings
                return ival.toJCRValue(resolver);
            } else if (targetType == PropertyType.BINARY) {
                if (length() < 0x10000) {
                    // < 65kb: deserialize BINARY type using String
                    return ValueHelper.deserialize(retrieve(), targetType, false, ValueFactoryImpl.getInstance());
                } else {
View Full Code Here

        // free old values as necessary
        InternalValue[] oldValues = thisState.getValues();
        if (oldValues != null) {
            for (int i = 0; i < oldValues.length; i++) {
                InternalValue old = oldValues[i];
                if (old != null && old.getType() == PropertyType.BINARY) {
                    // make sure temporarily allocated data is discarded
                    // before overwriting it
                    ((BLOBFileValue) old.internalValue()).discard();
                }
            }
        }

        // set new values
View Full Code Here

        if (name == null) {
            internalSetValue(null, reqType);
            return;
        }

        InternalValue internalValue;
        if (reqType != PropertyType.NAME) {
            // type conversion required
            Value targetValue = ValueHelper.convert(
                    InternalValue.create(name).toJCRValue(session.getNamespaceResolver()),
                    reqType,
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.value.InternalValue

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.