Package org.apache.xindice.core.meta

Examples of org.apache.xindice.core.meta.MetaData


                throw new DBException(FaultCodes.GEN_UNKNOWN,
                                      "Mismatch type of meta data for collection " + getCanonicalName());
            }

            MetaSystemCollection metacol = getMetaSystemCollection();
            MetaData current = metacol.getCollectionMeta(this);
            current.copyDataFrom(meta);
            metacol.setCollectionMeta(this, current);
        }
    }
View Full Code Here


                if (log.isInfoEnabled()) {
                    log.info(debugHeader() + "Set document meta " + id);
                }
                MetaSystemCollection metacol = getMetaSystemCollection();
                MetaData current = metacol.getDocumentMeta(this, id);
                current.copyDataFrom(meta);
                metacol.setDocumentMeta(this, id, current);
            }
        }
    }
View Full Code Here

     */
    protected void updateCollectionMeta() {
        // update the meta data if necessary
        if (isMetaEnabled()) {
            MetaSystemCollection metacol = getMetaSystemCollection();
            MetaData meta;
            try {
                meta = metacol.getCollectionMeta(this);
            } catch (DBException e) {
                // something strange has happened.. can't get the
                // meta data for this collection
                if (log.isWarnEnabled()) {
                    log.warn("Error fetching meta for collection '" + getCanonicalName() + "'", e);
                }
                return;
            }

            if (log.isTraceEnabled()) {
                log.trace(debugHeader() + "Updating modified time for collection");
            }
            long now = System.currentTimeMillis();
            if (null == meta) {
                meta = new MetaData(MetaData.COLLECTION, getCanonicalName(), now, now);
            } else if (!meta.hasContext()) {
                // Newly created meta. Update its created and modified time.
                meta.setContext(now, now);
            } else {
                // This collection already has a meta. So update its modified time.
                meta.setContext(0, now);
            }

            try {
                metacol.setCollectionMeta(this, meta);
            } catch (DBException e) {
View Full Code Here

            throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
                                  "Resource '" + id + "' does not exist in '" + getCanonicalName() + "'");
        }

        MetaSystemCollection metacol = getMetaSystemCollection();
        MetaData meta = metacol.getDocumentMeta(this, id);
        String path = getCanonicalDocumentName(id);

        /*
        TimeRecord rec = null;
        if( null == meta || !meta.hasContext() )
           rec = getDatabase().getTime(path);

        long created = (null != rec) ? rec.getCreatedTime() : System.currentTimeMillis();
        long modified = (null != rec) ? rec.getModifiedTime() : System.currentTimeMillis();
        */

        // this is wrong.. but it should work for now...
        if (log.isTraceEnabled()) {
            log.trace(debugHeader() + "Updating modified time for document '" + id + "'");
        }
        long now = System.currentTimeMillis();
        if (null == meta) {
            meta = new MetaData(MetaData.DOCUMENT, path, now, now);
        } else if (!meta.hasContext()) {
            meta.setContext(now, now);
        } else {
            meta.setContext(0, now);
        }
        metacol.setDocumentMeta(this, id, meta);
    }
View Full Code Here

            // meta information is not enabled !
            throw new Exception(MISSING_META_CONFIGURATION);
        }

        // Read and store sent meta data
        MetaData meta = new MetaData();
        Document doc = DOMParser.toDocument((String) message.get(META));
        meta.streamFromXML(doc.getDocumentElement());
        col.setCollectionMeta(meta);

        // Retreive stored meta data and sent back
        meta = col.getCollectionMeta();
        doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));
        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

            // meta information is not enabled !
            throw new Exception(MISSING_META_CONFIGURATION);
        }

        // Read and store sent meta data
        MetaData meta = new MetaData();
        Document doc = DOMParser.toDocument((String) message.get(META));
        meta.streamFromXML(doc.getDocumentElement());
        col.setDocumentMeta(docname, meta);

        // Retreive stored meta data and sent back
        meta = col.getDocumentMeta(docname);
        doc = new DocumentImpl();
        meta.streamToXML(doc, true);
        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        Hashtable result = new Hashtable();
        if (!col.isMetaEnabled()) {
            // meta information is not enabled !
            throw new Exception(MISSING_META_CONFIGURATION);
        }
        MetaData meta = col.getCollectionMeta();
        Document doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));

        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        if (!message.containsKey(NAME)) {
            throw new Exception(MISSING_NAME_PARAM);
        }
        String docname = (String) message.get(NAME);
        MetaData meta = col.getDocumentMeta(docname);
        Document doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));

        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

     */
    public MetaData getCollectionMeta(Collection collection) throws DBException {
        Collection mcol = getMetaCollection(collection, true);

        if (null != mcol) {
            MetaData meta = (MetaData) mcol.getObject(COLLECTION_META_DATA);
            if (meta == null) {
                meta = new MetaData();
            }

            if (meta.getType() == MetaData.UNKNOWN) {
                meta.setType(MetaData.COLLECTION);
            }
            meta.setOwner(collection.getCanonicalName());
            meta.setDirty(false);
            return meta;
        }
        return null;
    }
View Full Code Here

     * @throws DBException if unable to retrieve document meta data
     */
    public MetaData getDocumentMeta(Collection collection, String id) throws DBException {
        Collection mcol = getMetaCollection(collection, true);
        if (null != mcol) {
            MetaData meta = (MetaData) mcol.getObject(id);

            if (meta == null) {
                meta = new MetaData();
            }

            if (meta.getType() == MetaData.UNKNOWN) {
                meta.setType(MetaData.DOCUMENT);
            }
            meta.setOwner(collection.getCanonicalName() + "/" + id);
            meta.setDirty(false);
            return meta;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.meta.MetaData

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.