renamed base class for all vamsas document objects (now org.vamsas.client.Vobject)
[vamsas.git] / src / org / vamsas / client / simpleclient / VamsasArchive.java
index 6e86407..93c775c 100644 (file)
@@ -24,7 +24,7 @@ import org.vamsas.client.SessionHandle;
 import org.vamsas.client.UserHandle;
 import org.vamsas.client.VorbaIdFactory;
 import org.vamsas.client.VorbaXmlBinder;
-import org.vamsas.client.object;
+import org.vamsas.client.Vobject;
 import org.vamsas.objects.core.ApplicationData;
 import org.vamsas.objects.core.VAMSAS;
 import org.vamsas.objects.core.VamsasDocument;
@@ -48,7 +48,7 @@ public class VamsasArchive {
    * @return vector of vamsas roots from original document
    * @throws IOException
    */
-  public static object[] getOriginalRoots(VamsasArchive ths) throws IOException, 
+  public static Vobject[] getOriginalRoots(VamsasArchive ths) throws IOException, 
   org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
     VamsasArchiveReader oReader = ths.getOriginalArchiveReader();
     if (oReader!=null) {
@@ -199,7 +199,7 @@ public class VamsasArchive {
           ? "File cannot be overwritten." : "Null Object not valid constructor parameter"));
       return;
     }
-
+    
     this.vamsasdocument = vamsasdocument;
     if (archive.exists() && !overwrite) {
       this.original = archive;
@@ -422,21 +422,47 @@ public class VamsasArchive {
    * @throws org.exolab.castor.xml.MarshalException
    * @throws org.exolab.castor.xml.ValidationException
    */
-  public object[] getOriginalRoots() throws IOException, 
+  public Vobject[] getOriginalRoots() throws IOException, 
   org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException  {
     return VamsasArchive.getOriginalRoots(this);
   }
+  /**
+   * @return original document or a new empty document (with default provenance)
+   * @throws IOException
+   * @throws org.exolab.castor.xml.MarshalException
+   * @throws org.exolab.castor.xml.ValidationException
+   */
   public VamsasDocument getVamsasDocument() throws IOException, 
   org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
+    return getVamsasDocument("org.vamsas.simpleclient.VamsasArchive", "Created new empty document", null);
+  }
+  /**
+   * Return the original document or a new empty document with initial provenance entry.
+   * @param provenance_user (null sets user to be the class name)
+   * @param provenance_action (null sets action to be 'created new document')
+   * @param version (null means use latest version)
+   * @return (original document or a new vamsas document with supplied provenance and version info)
+   * @throws IOException
+   * @throws org.exolab.castor.xml.MarshalException
+   * @throws org.exolab.castor.xml.ValidationException
+   */
+  public VamsasDocument getVamsasDocument(String provenance_user, String provenance_action, String version) throws IOException, 
+  org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
     if (_doc!=null)
       return _doc;
     _doc = getOriginalVamsasDocument(this, getVorba());
     if (_doc!=null)
       return _doc;
+    // validate parameters
+    if (provenance_user==null)
+      provenance_user = "org.vamsas.simpleclient.VamsasArchive";
+    if (provenance_action == null)
+      provenance_action="Created new empty document";
+    if (version==null)
+      version = VersionEntries.latestVersion();
     // Create a new document and return it
     _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS()}, 
-        ProvenanceStuff.newProvenance("org.vamsas.simpleclient.VamsasArchive", "Created new empty document")
-        , VersionEntries.latestVersion());
+        ProvenanceStuff.newProvenance(provenance_user, provenance_action), version);
     return _doc;
   }
   /**