import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.vamsas.client.IClientAppdata;
import org.vamsas.client.Vobject;
import org.vamsas.client.VorbaId;
import org.vamsas.client.simpleclient.ClientDocument;
import org.vamsas.objects.utils.ProvenanceStuff;
// simple holder to pass to client.
-public class ClientDoc {
+public class ClientDoc extends org.vamsas.client.ClientDocument {
+ /* (non-Javadoc)
+ * @see org.vamsas.client.IClientDocument#getClientAppdata()
+ */
+ public IClientAppdata getClientAppdata() {
+ throw new Error("Appdata access is not implemented in the test.simpleclient.ClientDoc instance."); // TODO Auto-generated method stub
+ }
protected boolean isModified=false;
private Log log = LogFactory.getLog(ClientDoc.class);
protected VamsasDocument doc;
protected VamsasArchive iohandler=null;
protected VamsasArchiveReader reader=null;
private String user=null;
+ private String app=null;
/**
* @param doc
* @param iohandler
* @param reader
+ * @param app
* @param user
*/
- public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String user, Hashtable objrefs) {
- super();
+ public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String app, String user, Hashtable objrefs) {
+ super(objrefs, (iohandler!=null) ? iohandler.getVorba() : null);
this.doc = doc;
this.iohandler = iohandler;
this.reader = reader;
+ this.app = app;
this.user = user;
this.objrefs = objrefs;
_VamsasRoots = doc.getVAMSAS();
*/
protected Entry getProvenanceEntry(String action) {
// VAMSAS: modify schema to allow referencing of user field (plus other issues, ClientUrn field, machine readable action, input parameters, additional data generated notes
- Entry prov = ProvenanceStuff.newProvenanceEntry(user, action);
+ Entry prov = ProvenanceStuff.newProvenanceEntry(app, user, action);
return prov;
}
public VAMSAS[] getVamsasRoots() {
public VamsasArchiveReader getReader() {
return reader;
}
+ private void _finalize() {
+ log.debug("finalizing clientDoc");
+ if (doc!=null) {
+ doc = null;
+ }
+ if (_VamsasRoots!=null) {
+ for (int i=0; i<_VamsasRoots.length; i++)
+ _VamsasRoots[i]=null;
+ _VamsasRoots=null;
+
+ }
+
+ if (reader!=null) {
+ log.debug("Closing and removing reader reference");
+ reader.close();
+ reader=null;
+ }
+ if (iohandler!=null) {
+ log.debug("Removing ioHandler reference.");
+ iohandler.cancelArchive();
+ iohandler=null;
+ }
+ }
protected void finalize() throws Throwable {
+ _finalize();
super.finalize();
- //if (reader!=null)
- // reader.close();
- //reader=null;
-// if (iohandler!=null) {
-// iohandler.cancelArchive(); // otherwise the original may be overwritten.
-// }
}
private java.util.Hashtable objrefs=null;
}
if (unregistered!=null) {
- VorbaId id = iohandler.getVorba().makeVorbaId(unregistered);
+ VorbaId id = this._registerObject(unregistered);
log.debug("Registered object - total of "+objrefs.size()+" ids.");
return id;
}
log.warn("Null Vobject passed to registerObject.");
return null;
}
-
/*
* (non-Javadoc)
*
log.debug("getObject called on null objrefs list.");
return null;
}
- if (objrefs.containsKey(id))
- return (Vobject) objrefs.get(id);
+ if (objrefs.containsKey(id.getId()))
+ return (Vobject) objrefs.get(id.getId());
log.debug("Returning null Vobject reference for id "+id.getId());
return null;
}
log.debug("Returning null Vobject reference for id "+ids[i].getId());
return vo;
}
+ protected void updateDocumentRoots() {
+ if (doc==null) {
+ log.error("updateDocumentRoots called on null document. Probably an implementation error.");
+ return;
+ }
+ if (isModified) {
+ if (_VamsasRoots!=null) {
+ doc.setVAMSAS(_VamsasRoots);
+ _VamsasRoots=null;
+ }
+ }
+ }
+ /**
+ * tell vamsas client to close the document and reset the object. Once closed, nothing can be done with the object.
+ *
+ */
+ public void closeDoc() {
+ if (doc!=null) {
+ log.debug("Closing open document.");
+ _finalize();
+ } else {
+ log.warn("Ignoring closeDoc on invalid document.");
+ }
+ }
}
\ No newline at end of file