public void updateDocument(Document doc) {
   if (null != doc) {
     Document document = getDocument(doc.getId());
     if ((document instanceof DocumentStorageBean) && (doc instanceof DocumentStorageBean)) {
       ((DocumentStorageBean) document).mergeDocuments((DocumentStorageBean) doc);
     } else {
       if (null != document) {
         remove(document);
       }
       add(doc);
     }
   }
 }
  public Document getDocument(String id) {
    Document result = null;

    for (Iterator i = iterator(); i.hasNext(); ) {
      Document doc = (Document) i.next();
      if (CompareHelper.areEqual(id, doc.getId())) {
        result = doc;
        break;
      }
    }

    return result;
  }
 public void removeDocument(Document doc) {
   if (null != doc) {
     removeDocument(doc.getId());
   }
 }