* 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;
}