Package org.apache.xindice.core.meta

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


    {
        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
    {
        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

      {
         // meta information is not enabled !
         throw new Exception(MISSING_META_CONFIGURATION);
      }
      String metaxml = (String)message.get(META);
      MetaData meta = new MetaData();

      Document doc = DOMParser.toDocument( metaxml );

      meta.streamFromXML(doc.getDocumentElement());
      col.setDocumentMeta(docname,meta);

    MetaData ret_meta = col.getDocumentMeta(docname);
      Document ret_doc = new DocumentImpl();
      ret_meta.streamToXML(ret_doc, true);
       
      result.put( RESULT, TextWriter.toString( ret_doc ) );
      return result;
   }
View Full Code Here

      if( !col.isMetaEnabled() )
      {
         // meta information is not enabled !
         throw new Exception(MISSING_META_CONFIGURATION);
      }
      MetaData meta = col.getCollectionMeta();
      Document doc = new DocumentImpl();
      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();
      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);
      }
      String metaxml = (String)message.get(META);
      MetaData meta = new MetaData();

      Document doc = DOMParser.toDocument( metaxml );
      meta.streamFromXML(doc.getDocumentElement());
      col.setCollectionMeta(meta);

    MetaData ret_meta = col.getCollectionMeta();
      Document ret_doc = new DocumentImpl();
      ret_meta.streamToXML(ret_doc, true);
   
      result.put( RESULT, TextWriter.toString( ret_doc ) );
      return result;
   }
View Full Code Here

   {
      // update the meta data if necessary
      if( isMetaEnabled() )
      {
         MetaSystemCollection metacol = getMetaSystemCollection();
         MetaData meta = null;
         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 collection meta. "+e);
            return;
         }
    
     if(log.isInfoEnabled())
      log.info("Updating modified time for this collection's meta");
         long now = System.currentTimeMillis();
         if( null == meta )
         {
            meta = new MetaData(MetaData.COLLECTION, getCanonicalName(),
                                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) {
            if( log.isWarnEnabled() )
View Full Code Here

      if( null == doc )
         throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
                "Document " + id + " does not exist");

      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...
      long created = System.currentTimeMillis();
      long modified = System.currentTimeMillis();


      if( null == meta )
      {
         meta = new MetaData(MetaData.DOCUMENT, path, created, modified);
      }
      else if( !meta.hasContext() )
      {
         meta.setContext(created, modified);
      }
      else
      {
         meta.setContext(0,modified);
     
      metacol.setDocumentMeta(this,id,meta);
   }
View Full Code Here

    * returned will be null.
    * @return MetaData this collection's metadata.
    */
   public MetaData getCollectionMeta() throws DBException
   {
      MetaData meta = null;
      if( ! isMetaEnabled() )
      {
         if(log.isWarnEnabled())
         {
            log.warn("Meta information requested but not enabled in config!");
         }
         return meta;
      }
      MetaSystemCollection metacol = getMetaSystemCollection();
      meta = metacol.getCollectionMeta(this);
      long now = System.currentTimeMillis();
      if( null == meta )
      {
         meta = new MetaData(MetaData.COLLECTION, getCanonicalName(), now, now);
         metacol.setCollectionMeta(this, meta);
      }
      return meta;
   }
View Full Code Here

    * If metadata is not enabled, the MetaData object returned will be null.
    * @param id the document whose metadata you want
    */
   public MetaData getDocumentMeta( String id ) throws DBException
   {
      MetaData meta = null;
      if( ! isMetaEnabled() )
      {
         if(log.isWarnEnabled())
         {
            log.warn("Meta information requested but not enabled in config!");
         }
         return meta;
      }
      Document doc = getDocument(id);
      if( null == doc )
         throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
                "Document " + id + " does not exist");

      MetaSystemCollection metacol = getMetaSystemCollection();
      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...
      long created = System.currentTimeMillis();
      long modified = System.currentTimeMillis();


      if( null == meta )
      {
         meta = new MetaData(MetaData.DOCUMENT, path, created, modified);
         metacol.setDocumentMeta(this, id, meta);
      }
      else if( !meta.hasContext() )
      {
         meta.setContext(created, modified);
      }

      return meta;
   }
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.