com.limegroup.gnutella.xml
Class MetaFileManager

java.lang.Object
  extended bycom.limegroup.gnutella.FileManager
      extended bycom.limegroup.gnutella.xml.MetaFileManager

public class MetaFileManager
extends FileManager

This class handles querying shared files with XML data and returning XML data in replies.


Field Summary
 
Fields inherited from class com.limegroup.gnutella.FileManager
BROWSE_QUERY, DELIMETERS, DIRECTORY_FILTER, INDEXING_QUERY, SHAREABLE_FILE_FILTER
 
Constructor Summary
MetaFileManager()
           
 
Method Summary
 FileDesc addFileIfShared(java.io.File file, java.util.List metadata)
           
protected  void addXMLToResponse(Response response, FileDesc fd)
          Adds XML to the response.
 FileDesc fileChanged(java.io.File f)
          Notification that a file has changed.
 java.util.List getIndivisibleKeyWords()
           
 java.util.List getKeyWords()
          Returns a list of all the words in the annotations - leaves out numbers.
protected  void loadSettingsBlocking(boolean notifyOnClear)
          This method overrides FileManager.loadSettingsBlocking(), though it calls the super method to load up the shared file DB.
 Response[] query(QueryRequest request)
          Overrides FileManager.query.
 FileDesc removeFileIfShared(java.io.File f)
          Removes the LimeXMLDocuments associated with the removed FileDesc from the various LimeXMLReplyCollections.
protected  boolean shouldIncludeXMLInResponse(QueryRequest qr)
          Returns whether or not a response to this query should include XML.
 
Methods inherited from class com.limegroup.gnutella.FileManager
addFileIfShared, addIncompleteFile, debug, get, getAllSharedFileDescriptors, getFileDescForFile, getFileDescForUrn, getFilesRecursive, getIncompleteFileDescriptors, getNumFiles, getNumIncompleteFiles, getNumPendingFiles, getSharedFileDescriptors, getSize, isFileShareable, isValidIndex, loadSettings, loadThreadInterrupted, renameFileIfShared, repOk, search, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaFileManager

public MetaFileManager()
Method Detail

query

public Response[] query(QueryRequest request)
Overrides FileManager.query. Used to search XML information in addition to normal searches.

Overrides:
query in class FileManager

shouldIncludeXMLInResponse

protected boolean shouldIncludeXMLInResponse(QueryRequest qr)
Returns whether or not a response to this query should include XML. Currently only includes XML if the request desires it or if the request wants an out of band reply.

Specified by:
shouldIncludeXMLInResponse in class FileManager

addXMLToResponse

protected void addXMLToResponse(Response response,
                                FileDesc fd)
Adds XML to the response. This assumes that shouldIncludeXMLInResponse was already consulted and returned true. If the FileDesc has no XMLDocuments, this does nothing. If the FileDesc has one XML Document, this sets it as the response doc. If the FileDesc has multiple XML Documents, this does nothing. The reasoning behind not setting the document when there are multiple XML docs is that presumably the query will be a 'rich' query, and we want to include only the schema that was in the query.

Specified by:
addXMLToResponse in class FileManager
Parameters:
response - the Response instance that XML should be added to
fd - the FileDesc that provides access to the LimeXMLDocuments to add to the response

fileChanged

public FileDesc fileChanged(java.io.File f)
Notification that a file has changed. This implementation is different than FileManager's in that it maintains the XML. Important note: This method is called AFTER the file has changed. It is possible that the metadata we wanted to write did not get written out completely. We should NOT attempt to add the old metadata again, because we may end up recursing infinitely trying to write this metadata. However, it isn't very robust to blindly assume that the only metadata associated with this file was audio metadata. So, we make use of the fact that addFileIfShared will only add one type of metadata per file. We read the ID3 tags off the file and insert it first into the list, ensuring that the existing metadata is the one that's added, short-circuiting any infinite loops.

Overrides:
fileChanged in class FileManager
Returns:
the new FileDesc for the file if it was successfully changed, otherwise null

removeFileIfShared

public FileDesc removeFileIfShared(java.io.File f)
Removes the LimeXMLDocuments associated with the removed FileDesc from the various LimeXMLReplyCollections.

Overrides:
removeFileIfShared in class FileManager

addFileIfShared

public FileDesc addFileIfShared(java.io.File file,
                                java.util.List metadata)
Specified by:
addFileIfShared in class FileManager
Returns:
The FileDesc that was added, or null if nothing added.

loadSettingsBlocking

protected void loadSettingsBlocking(boolean notifyOnClear)
This method overrides FileManager.loadSettingsBlocking(), though it calls the super method to load up the shared file DB. Then, it processes these files and annotates them automatically as apropos. TODO2: Eventually we will think that its too much of a burden to have this thread be blocking in which case we will have to have the load thread also handle the reloading of the meta-data. Question: Do we really want to reload the meta-data whenever a we want to update the file information?? It depends on how we want to handle the meta-data and its relation to the file system

Overrides:
loadSettingsBlocking in class FileManager

getKeyWords

public java.util.List getKeyWords()
Returns a list of all the words in the annotations - leaves out numbers. The list also includes the set of words that is contained in the names of the files.

Overrides:
getKeyWords in class FileManager

getIndivisibleKeyWords

public java.util.List getIndivisibleKeyWords()
Overrides:
getIndivisibleKeyWords in class FileManager
Returns:
A List of KeyWords from the FS that one does NOT want broken upon hashing into a QRT. Initially being used for schema uri hashing.