Examples of ItemStateException


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

                // a node state exists if the result has at least one entry
                return rs.next();
            } catch (Exception e) {
                String msg = "failed to check existence of node state: " + id;
                log.error(msg, e);
                throw new ItemStateException(msg, e);
            } finally {
                closeResultSet(rs);
            }
        }
    }
View Full Code Here

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

                // a property state exists if the result has at least one entry
                return rs.next();
            } catch (Exception e) {
                String msg = "failed to check existence of property state: " + id;
                log.error(msg, e);
                throw new ItemStateException(msg, e);
            } finally {
                closeResultSet(rs);
            }
        }
    }
View Full Code Here

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

                return rs.next();
            } catch (Exception e) {
                String msg = "failed to check existence of node references: "
                        + targetId;
                log.error(msg, e);
                throw new ItemStateException(msg, e);
            } finally {
                closeResultSet(rs);
            }
        }
    }
View Full Code Here

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

        // first do some paranoid sanity checks
        if (!walker.getName().equals(NODE_ELEMENT)) {
            String msg = "invalid serialization format (unexpected element: "
                    + walker.getName() + ")";
            log.debug(msg);
            throw new ItemStateException(msg);
        }
        // check uuid
        if (!state.getNodeId().getUUID().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
            String msg = "invalid serialized state: uuid mismatch";
            log.debug(msg);
            throw new ItemStateException(msg);
        }
        // check nodetype
        String ntName = walker.getAttribute(NODETYPE_ATTRIBUTE);
        if (!QName.valueOf(ntName).equals(state.getNodeTypeName())) {
            String msg = "invalid serialized state: nodetype mismatch";
            log.debug(msg);
            throw new ItemStateException(msg);
        }

        // now we're ready to read state

        // primary parent
View Full Code Here

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

        // first do some paranoid sanity checks
        if (!walker.getName().equals(PROPERTY_ELEMENT)) {
            String msg = "invalid serialization format (unexpected element: "
                    + walker.getName() + ")";
            log.debug(msg);
            throw new ItemStateException(msg);
        }
        // check name
        if (!state.getName().equals(QName.valueOf(walker.getAttribute(NAME_ATTRIBUTE)))) {
            String msg = "invalid serialized state: name mismatch";
            log.debug(msg);
            throw new ItemStateException(msg);
        }
        // check parentUUID
        NodeId parentId = NodeId.valueOf(walker.getAttribute(PARENTUUID_ATTRIBUTE));
        if (!parentId.equals(state.getParentId())) {
            String msg = "invalid serialized state: parentUUID mismatch";
            log.debug(msg);
            throw new ItemStateException(msg);
        }

        // now we're ready to read state

        // type
        String typeName = walker.getAttribute(TYPE_ATTRIBUTE);
        int type;
        try {
            type = PropertyType.valueFromName(typeName);
        } catch (IllegalArgumentException iae) {
            // should never be getting here
            throw new ItemStateException("unexpected property-type: " + typeName, iae);
        }
        state.setType(type);

        // multiValued
        String multiValued = walker.getAttribute(MULTIVALUED_ATTRIBUTE);
        state.setMultiValued(Boolean.getBoolean(multiValued));

        // definition id
        String definitionId = walker.getAttribute(DEFINITIONID_ATTRIBUTE);
        state.setDefinitionId(PropDefId.valueOf(definitionId));

        // modification count
        String modCount = walker.getAttribute(MODCOUNT_ATTRIBUTE);
        state.setModCount(Short.parseShort(modCount));

        // values
        ArrayList values = new ArrayList();
        if (walker.enterElement(VALUES_ELEMENT)) {
            while (walker.iterateElements(VALUE_ELEMENT)) {
                // read serialized value
                String content = walker.getContent();
                if (PropertyType.STRING == type) {
                    // STRING value can be empty; ignore length
                    values.add(InternalValue.valueOf(content, type));
                } else if (content.length() > 0) {
                    // non-empty non-STRING value
                    if (type == PropertyType.BINARY) {
                        try {
                            // special handling required for binary value:
                            // the value stores the id of the BLOB data
                            // in the BLOB store
                            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(content);
                                values.add(InternalValue.create(fsRes));
                            } else {
                                InputStream in = blobStore.get(content);
                                try {
                                    values.add(InternalValue.create(in, false));
                                } finally {
                                    try {
                                        in.close();
                                    } catch (IOException e) {
                                        // ignore
                                    }
                                }
                            }
                        } catch (Exception e) {
                            String msg = "error while reading serialized binary value";
                            log.debug(msg);
                            throw new ItemStateException(msg, e);
                        }
                    } else {
                        // non-empty non-STRING non-BINARY value
                        values.add(InternalValue.valueOf(content, type));
                    }
View Full Code Here

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

            throws ItemStateException {
        // first do some paranoid sanity checks
        if (!walker.getName().equals(NODEREFERENCES_ELEMENT)) {
            String msg = "invalid serialization format (unexpected element: " + walker.getName() + ")";
            log.debug(msg);
            throw new ItemStateException(msg);
        }
        // check targetId
        if (!refs.getId().equals(NodeReferencesId.valueOf(walker.getAttribute(TARGETID_ATTRIBUTE)))) {
            String msg = "invalid serialized state: targetId  mismatch";
            log.debug(msg);
            throw new ItemStateException(msg);
        }

        // now we're ready to read the references data

        // property id's
View Full Code Here

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

            e = fse;
            // fall through
        }
        String msg = "failed to read node state: " + id;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
View Full Code Here

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

            e = fse;
            // fall through
        }
        String msg = "failed to read property state: " + id.toString();
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
View Full Code Here

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

                writer.close();
            }
        } catch (Exception e) {
            String msg = "failed to write node state: " + id;
            log.debug(msg);
            throw new ItemStateException(msg, e);
        }
    }
View Full Code Here

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

                int type = state.getType();
                try {
                    typeName = PropertyType.nameFromValue(type);
                } catch (IllegalArgumentException iae) {
                    // should never be getting here
                    throw new ItemStateException("unexpected property-type ordinal: " + type, iae);
                }

                writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
                writer.write("<" + PROPERTY_ELEMENT + " "
                        + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
                        + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId().getUUID() + "\" "
                        + MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
                        + DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
                        + MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
                        + TYPE_ATTRIBUTE + "=\"" + typeName + "\">\n");
                // values
                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");
                    }
                }
                writer.write("\t</" + VALUES_ELEMENT + ">\n");
                writer.write("</" + PROPERTY_ELEMENT + ">\n");
            } finally {
                writer.close();
            }
        } catch (Exception e) {
            String msg = "failed to store property state: " + state.getParentId() + "/" + state.getName();
            log.debug(msg);
            throw new ItemStateException(msg, e);
        }
    }
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.