public class ClientDocument extends org.vamsas.client.ClientDocument implements IClientDocument {
private static Log log = LogFactory.getLog(ClientDocument.class);
private VamsasDocument doc;
- protected IClient vorba;
- protected ApplicationData appsglobal=null;
- protected User usersdata=null;
- protected byte[] appData=null;
+ protected SimpleClient sclient;
protected VamsasArchive archive = null;
/**
*
* @param doc - the dataset
* @param docHandler - the sessionFile IO handler
* @param Factory - the source of current and new vorbaIds
- * @param vorba - the client instance
+ * @param sclient - the simpleclient instance
*/
- protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, IClient vorba) {
+ protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient vorba) {
super(Factory.getVorbaIdHash(), Factory);
/**
* prepare Application-side dataset from the vamsas Document archive
*/
- this.vorba = vorba;
+ this.sclient = vorba;
archive = docHandler;
this.doc = doc;
- extractAppData();
- }
- /**
- * gets appropriate app data for the application, if it exists in this dataset
- *
- */
- private void extractAppData() {
- Vector apldataset = AppDataReference.getUserandApplicationsData(
- doc, vorbafactory.getUserHandle(), vorbafactory.getClientHandle());
- if (apldataset!=null) {
- if (apldataset.size()>0) {
- AppData clientdat = (AppData) apldataset.get(0);
- if (clientdat instanceof ApplicationData) {
- appsglobal = (ApplicationData) clientdat;
- if (apldataset.size()>1) {
- clientdat = (AppData) apldataset.get(1);
- if (clientdat instanceof User)
- usersdata = (User) clientdat;
- if (apldataset.size()>2)
- log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query.");
- }
- } else {
- log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName());
- }
- }
- }
}
/*
// TODO: add provenance stuff to newly registered Vobject
return _registerObject(unregistered);
}
+ /**
+ * IClientAppdata instance - if it exists.
+ */
+ SimpleClientAppdata scappd = null;
/* (non-Javadoc)
* @see org.vamsas.client.IClientDocument#getClientAppdata()
*/
public IClientAppdata getClientAppdata() {
- // TODO Auto-generated method stub
+ if (scappd==null) {
+ log.debug("Creating new SimpleClientAppdata instance for "+sclient.getSessionHandle());
+ scappd = new SimpleClientAppdata(this);
+ if (scappd==null) {
+ // LATER: may not need this as a warning message.
+ log.warn("Null appdata object for "+sclient.getSessionHandle());
+ } else {
+ log.debug("Created SimpleClientAppdata successfully.");
+ }
+ } else {
+ log.debug("Returning existing SimpleClientAppdata reference.");
+ }
+ return scappd;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ protected void finalize() throws Throwable {
+ log.debug("Garbage collecting on ClientDocument instance.");
+ if (scappd!=null) {
+ scappd.finalize();
+ scappd = null;
+ }
+
+ super.finalize();
+ }
+ /**
+ * access the vamsas document
+ * @return the session's vamsas document
+ */
+ protected VamsasDocument getVamsasDocument() {
+ // TODO: IMPLEMENT
+ return null;
+ }
+ /**
+ * returns the read-only IO interface for the vamsas document Jar file
+ * @return
+ */
+ protected VamsasArchiveReader getVamsasArchiveReader() {
+ // TODO: IMPLEMENT getVamsasArchiveReader
return null;
}
}