--- /dev/null
+/*
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.util.Hashtable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.vamsas.objects.core.VAMSAS;
+
+/**
+ * skeleton abstract class to allow client implementations
+ * access to vamsas.client.Vobject registry mechanism.
+ */
+public abstract class ClientDocument implements IClientDocument {
+ static Log log = LogFactory.getLog(ClientDocument.class);
+
+ /**
+ * collection of uk.ac.vamsas.client.Vobject references
+ */
+ protected Hashtable vamsasObjects;
+ protected IVorbaIdFactory vorbafactory;
+
+ protected ClientDocument(Hashtable objects, IVorbaIdFactory factory) {
+ vamsasObjects = objects;
+ vorbafactory = factory;
+ }
+
+ /**
+ * @see IClientHandle.registerObject(Vobject unregistered)
+ */
+ protected VorbaId _registerObject(Vobject unregistered) {
+ // be ultra safe here because the user may be trying to mix different factories
+ if (unregistered.__vorba==null)
+ unregistered.__vorba = vorbafactory;
+ else
+ if (unregistered.__vorba!=vorbafactory) {
+ // LATER: decide if this is allowed - it isn't for the moment.
+ log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed.");
+ return null;
+ } else {
+ // probably didn't need to call registerObject.
+ log.debug("Redundant call to registerObject");
+ }
+ // TODO: add default provenance.
+ // TODO: decide if we need to do call __ensure_instance_ids here
+ // TODO: check if __ensure_instance_ids works correctly with new 'visit flag' mechanism
+ unregistered.__ensure_instance_ids(); // call cascade method here :
+ return unregistered.getVorbaId();
+ }
+}
--- /dev/null
+/*
+ */
+package uk.ac.vamsas.client;
+
+import java.io.Serializable;
+
+/**
+ * Uniquely describes a vamsas client application.
+ * @author jimp
+ */
+public class ClientHandle implements Serializable {
+ static final long serialVersionUID = 0;
+ /**
+ * @param clientName
+ * @param version
+ */
+ public ClientHandle(String clientName, String version) {
+ super();
+ this.clientName = clientName;
+ this.version = version;
+ this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: decide on application handle ornthing (used to prefix new ids made by a particular application)
+ }
+ /**
+ * (non-unique) human readable vamsas client name
+ */
+ String clientName;
+
+ /**
+ * the unambiguous client identifier
+ * This may be rewritten by the Vorba object if
+ * other clients with the same name, version
+ * and user are involved in a session.
+ *
+ */
+ String clientUrn;
+
+ /**
+ * version modifier to tag application space
+ */
+ String version;
+
+ /**
+ * @return Returns the clientUrn.
+ */
+ public String getClientUrn() {
+ return clientUrn;
+ }
+
+ /**
+ * May become protected - should only be set by a Vorba object.
+ * @param clientUrn
+ * The clientUrn to set.
+ */
+ public void setClientUrn(String clientUrn) {
+ this.clientUrn = clientUrn;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * @param version
+ * The version to set.
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+
+ /**
+ * @return Returns the clientName.
+ */
+ public String getClientName() {
+ return clientName;
+ }
+
+ /**
+ * @param clientName
+ * The clientName to set.
+ */
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ }
+
+ public boolean equals(Object that) {
+ if (that instanceof ClientHandle)
+ return this.equals((ClientHandle) that);
+ return false;
+ }
+ public boolean equals(ClientHandle that) {
+ return (clientName.equals(that.clientName) && version.equals(that.version) && clientUrn.equals(that.clientUrn));
+ }
+}
--- /dev/null
+package uk.ac.vamsas.client;
+
+/**
+ * Enumerates the event types generated during the lifecycle of a Vamsas
+ * session.
+ * See the excel spreadsheet in VamsasClient/docs/VamsasSessionEventAnalysis.xls for
+ * some more information about when these are generated and how they should be
+ * handled.
+ *
+ */
+
+public class Events {
+ /**
+ * Generated when a client has finished updating the document.
+ * Client which has completed an update should
+ * not receive the event.
+ * NewValue: uk.ac.vamsas.client.IClient for session.
+ */
+ public static final String DOCUMENT_UPDATE = "uk.ac.vamsas.client.events.documentUpdateEvent";
+
+ /**
+ * Generated when a new vamsas document is created (perhaps from some existing
+ * Vamsas data) so an application may do its own data space initialization.
+ * Raised for a new application connecting to a vamsas document
+ * NewValue: uk.ac.vamsas.client.IClient for session.
+ * LATER: DOCUMENT_CREATE event may be redundant
+ */
+ public static final String DOCUMENT_CREATE = "uk.ac.vamsas.client.events.documentCreateEvent";
+
+ /**
+ * Generated when a new vamsas client is attached to a session (Handle is
+ * passed) Note: the newly created client does not receive the event.
+ */
+ public static final String CLIENT_CREATION = "uk.ac.vamsas.client.events.clientCreateEvent";
+
+ /**
+ * Generated when a vamsas client leaves a session (Handle is passed to all
+ * others).
+ */
+ public static final String CLIENT_FINALIZATION = "uk.ac.vamsas.client.events.clientFinalizationEvent";
+
+ /**
+ * Generated prior to session Shutdown, after the last participating vamsas
+ * client has finalized.
+ * Probably only useful to IClientFactory implementations.
+ * NewValue: <Vamsas-session URN>
+ */
+ public static final String SESSION_SHUTDOWN = "uk.ac.vamsas.client.events.SessionShutdownEvent";
+
+ /**
+ * Generated for all clients when any client calls IClient.storeDocument() to
+ * allow them to store any updates before an offline copy of the session is
+ * created.
+ * Any client that handles this should call the
+ * IClient.getDocument(), update and then IClient.updateDocument in the same
+ * handler thread (the lock on the document is held until the handler exits).
+ * EventName: <Vamsas-session URN>
+ * NewValue: uk.ac.vamsas.client.IClient for session.
+ */
+ public static final String DOCUMENT_FINALIZEAPPDATA = "uk.ac.vamsas.client.events.DocumentFinalizeAppData";
+
+ /**
+ * Generated by Vorba stub for the sole remaining client instance in a session,
+ * when it makes a call to finalizeClient().
+ * It is only raised if the session has been modified since the
+ * last call to storeDocument() by any application.
+ * LATER: copies of a document should be on a per-user basis for multi-user sessions.
+ * Sequence is as follows : 1. All other vamsas clients have
+ * called finalizeClient() 2. Final living client monitors closures, and
+ * realises that it is last. 3. Final client generates event to prompt
+ * associated application to inquire if the user wishes to save the document
+ * for future reference.
+ * * Any call to finalizeClient in a thread other than the registered
+ * EventListener will block until the RequestToClose handler has exited.
+ * NewValue: uk.ac.vamsas.client.IClient for session.
+ */
+ public static final String DOCUMENT_REQUESTTOCLOSE = "org.vamas.client.DocumentRequestToCloseEvent";
+
+ public static java.util.Vector EventList = initList();
+
+ private static java.util.Vector initList() {
+ java.util.Vector vec = new java.util.Vector();
+ vec.add((Object) DOCUMENT_UPDATE);
+ vec.add((Object) DOCUMENT_CREATE);
+ vec.add((Object) CLIENT_CREATION);
+ vec.add((Object) CLIENT_FINALIZATION);
+ vec.add((Object) SESSION_SHUTDOWN);
+ vec.add((Object) DOCUMENT_REQUESTTOCLOSE);
+ vec.add((Object) DOCUMENT_FINALIZEAPPDATA);
+ return vec;
+ }
+}
--- /dev/null
+/**
+ * uk.ac.vamsas.client.IClient
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+
+/**
+ * Defines the methods availabable to a vamsas
+ * application for interacting with its Vorba agent
+ * created by an IClientFactory instance for a particular session,
+ * user, and application handle.
+ * (it's VORBA, not CORBA!)
+ * LATER: add exceptions for timeouts raised when there are problems accessing session data (because another application is hogging it).
+ * LATER: think about situations when two applications both want a ClientDocument at the same time - can one have read-only access (and be told that another is about to update)
+ */
+
+public interface IClient {
+
+ /**
+ * Self-documenting/describing info for the application to present
+ * to the user.
+ * LATER: formalise this for describing VAMSAS system, a particular
+ * Vorba client agent, and a particular session.
+ * @return string like VamsasClient v.1.1.1 (GPL) and whatever
+ */
+ public String getAbout();
+
+ /**
+ * convenience method to get the SessionUrn as a string (for passing directly to a text box...).
+ * @return current SessionUrn
+ */
+ public String getSessionUrn();
+ /**
+ * Returns a valid URN for other applications to connect to
+ * the vamsas session.
+ * @return session handle for this session.
+ */
+ public SessionHandle getSessionHandle();
+ /**
+ * Included for applications with several ClientHandle
+ * identities.
+ * @return ClientHandle used to interact with
+ * other Vamsas applications.
+ */
+ public ClientHandle getClientHandle();
+ /**
+ *
+ * @return UserHandle used when interacting
+ * with other Vamsas applications.
+ */
+ public UserHandle getUserHandle();
+ /**
+ * Method called by client application on exit.
+ * Vorba will inform other clients if they exist.
+ * If this is the last application in the session
+ * then the session will be closed.
+ * Note: The application should be ready to handle
+ * 'RequestToCloseDocument' events from the Vorba
+ * agent in the latter case and so prompt the user
+ * to save the session locally.
+ * LATER: pick a better name ?
+ */
+ public void finalizeClient();
+ /**
+ * register handler for updates for the current session
+ */
+ public void addDocumentUpdateHandler(PropertyChangeListener evt);
+ /**
+ * get vamsas document with
+ * user and app specific data
+ * IClientDocuments are not thread-safe.
+ * TODO: New exception for failed document lock.
+ * @throws IOException if lock is not obtainable for the document in the session
+ */
+ public IClientDocument getClientDocument() throws IOException;
+ /**
+ * Queue new Vorba objects for storage and propagation
+ * to other clients (via Event.DOCUMENT_UPDATE based
+ * notification of document change)
+ * New objects without provenance information will be
+ * given a default entry using the IClient's application,
+ * user (and session) handles
+ * Validity of IClientDocument object instances after this call is implementation dependent
+ * TODO: consider refactoring to remove the redundant IClientDocument parameter for this method
+ */
+ public void updateDocument(IClientDocument newdoc);
+ /**
+ * Any application may call storeDocument to
+ * save a local copy of the current vamsas document
+ * including all application specific entries.
+ *
+ * @param location to write zip file
+ */
+ public void storeDocument(java.io.File location);
+ /**
+ * Any application may call importDocument to merge a stored
+ * vamsasDocument into the current session.
+ * Note: use a IClientFactory's implementation to make sessions out of vamsas documnts
+ * LATER: VAMSAS: The IClient implementation will handle all ID 'relocations'
+ * @param location
+ */
+ public void importDocument(java.io.File location);
+ /**
+ * Add a listener to a particular event chain.
+ * See uk.ac.vamsas.client.Events for allowed
+ * values for EventChain.
+ * The EventChain value is passed as the
+ * propertyName in the java.bean.PropertyChangeEvent
+ * LATER: extend class to form own vamsas Event/Listener model.
+ * @param EventChain Name of event. Blank/null registers handler for all events.
+ * @param evt - event handler function.
+ */
+ public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt);
+ /**
+ * Sets the update handler that will be called when any updates occur to objects of type rootObject.
+ * @param rootObject
+ * @param handler
+ */
+ public void setUpdateHandler(IObjectUpdate handler);
+ public IObjectUpdate getUpdateHandler(Class rootObject);
+ public void removeUpdateHandler(Class rootObject);
+ public IObjectUpdate[] getUpdateHandlers();
+ /**
+ * client application calls this to force the
+ * Vorba client to check for updates immediately.
+ *
+ */
+ public void pollUpdate();
+
+ /**
+ * Client application calls this after any pre-session initialization
+ * (registering of Handlers, etc)
+ * Exceptions are raised for any failures. Any stateful calls to the session prior to
+ * this will result in an implicit call to joinSession - if that results in an exception
+ * then the VamsasClient should raise an Error.
+ * LATER: create VAMSAS exception hierarchy (in a language agnostic manner)
+ */
+ public void joinSession() throws Exception;
+}
--- /dev/null
+/**
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+
+/**
+ * Object for accessing Client and User specific data
+ * in an IClientDocument instance.
+ *
+ */
+public interface IClientAppdata {
+ /**
+ * @return true if Client's non-user specific application data is non-zero length.
+ */
+ boolean hasClientAppdata();
+ /**
+ * @return true if User's Client Application data is non-zero length
+ */
+ boolean hasUserAppdata();
+ /**
+ *
+ * @return byte array containing the Client's non-user specific application data
+ */
+ byte[] getClientAppdata();
+ /**
+ *
+ * @return byte array containing the Client's user specific application data
+ */
+ byte[] getUserAppdata();
+ /**
+ * set the non-User-specific application data
+ * @param data - the new non-user-specific data
+ */
+ void setClientAppdata(byte[] data);
+ /**
+ * set the User-specific application data
+ * @param data - the new user-specific data
+ */
+ void setUserAppdata(byte[] data);
+ /**
+ * @return non-user specific data output stream
+ */
+ DataOutput getClientOutputStream();
+ /**
+ * @return non-user specific data input stream
+ */
+ DataInput getClientInputStream();
+ /**
+ *
+ * @return user specific data output stream
+ */
+ DataOutput getUserOutputStream();
+ /**
+ *
+ * @return user specific data input stream
+ */
+ DataInput getUserInputStream();
+}
--- /dev/null
+/*
+ * Created on 13-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+import org.vamsas.objects.core.VAMSAS;
+
+
+/**
+ * Defines the API for the Vamsas XML Document
+ * as accessed by a Vamsas SimpleClient Application.
+ * An instance of this interface is valid for a
+ * particular set of user, session and application
+ * handles.
+ *
+ * It initially represents a snapshot of the
+ * XML document at a particular time - queriable by
+ * reference or by retrieval of root objects.
+ * It provides methods to make new Vobject references,
+ * These are guaranteed to be unique amongst existing
+ * objects in the document, all other references created
+ * by this Vobject's instance and all other references
+ * constructed by any other vamsas agents in the session.
+ * TODO: LATER: finegrained access control for public/private user access
+ * Finegrained access control: Since a clientDocument is created for a particular
+ * UserHandle, there is scope for fine grain data access
+ * control based on user identity.
+ * A user may also want to make private notes, not
+ * available to other people using the same application
+ * in the same session.
+ * TODO: LATER: implement a more sophisticated query interface for quickly identifying new data in a vamsas document and manipulating existing objects
+ * @author jimp
+ */
+public interface IClientDocument {
+
+ /**
+ * Get a single Vobject.
+ * @param id
+ * @return Vobject referred to by id or null if it doesn't exist.
+ */
+ Vobject getObject(VorbaId id);
+ /**
+ * Get a list of objects.
+ * @param ids
+ * @return array of objects using a vector of VorbaId ids.
+ */
+ Vobject[] getObjects(VorbaId[] ids);
+ /**
+ * Returns all root objects in document. All objects inherit
+ * from uk.ac.vamsas.client.Vobject and have valid VorbaIds and provenance entries.
+ * @return array of root Vamsas element objects.
+ */
+ VAMSAS[] getVamsasRoots();
+ /**
+ * set the VAMSAS roots in the document
+ * TODO: decide if objects are verified for provenance and VorbaIds by this call or when document is stored
+ * TODO: decide if this call should throw InvalidVamsasObject exceptions.
+ * TODO: decide how this call deals with applications that 'forget' to include all VAMSAS roots (this is where reference counting/garbage collection happens)
+ * @param roots
+ */
+ void setVamsasRoots(VAMSAS[] roots);
+ /**
+ * Adds a new VAMSAS root entry
+ * TODO: decide on same InvalidVamsasObject exceptions.
+ * TODO: decide if a 'removeVamsasRoot' method is really needed.
+ * @param newroot
+ */
+ void addVamsasRoot(VAMSAS newroot);
+ /**
+ * Returns an Vobject with a valid VorbaId, and provenance element.
+ * The VorbaId is so the application may refer to it in
+ * its own dataspace.
+ *
+ * Note: An Vobject with valid VorbaId will not be reregistered.
+ * Advice: Calling this method for a high-level Vobject
+ * (such as org.vamsas.objects.core.VAMSAS) will
+ * register all its component objects too.
+ *
+ * @param unregistered unregistered vamsas Vobject
+ * @return VorbaId registered for vamsas Vobject
+ */
+ VorbaId registerObject(Vobject unregistered);
+ /**
+ * Returns an array of objects, each with a valid VorbaId
+ * (and completed provenance entry).
+ * Note: An Vobject with valid VorbaId will not be reregistered.
+ * @param unregistered array of unregistered objects.
+ * @return array of VorbaIds for the registered objects
+ */
+ VorbaId[] registerObjects(Vobject[] unregistered);
+ /**
+ * Get instance of Client and User specific vamsas document data access interface.
+ * @return Interface to Client and user specific application data
+ */
+ IClientAppdata getClientAppdata();
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Created on 13-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * Defines methods for instantiating Vorba client application agents
+ * @author jimp
+ *
+ * (it's VORBA, not CORBA!)
+ */
+
+public interface IClientFactory {
+
+ /**
+ * Create a new Vorba Session
+ * @param applicationHandle is the application's VAMSAS handle string
+ * @throws NoDefaultSessionException if more than one session exists that the client may connect to
+ */
+ IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException;
+ /**
+ * returns new Vorba for a given session.
+ * @param applicationHandle
+ * @param sessionUrn session to connect to (or null to create a new session)
+ * @return
+ */
+ IClient getIClient(ClientHandle applicationHandle, String sessionUrn);
+ /**
+ * returns new vorba for a given session acting as a particular identity
+ * @param applicationHandle
+ * @param userId
+ * @param sessionUrn session to connect to (or null to create a new session)
+ * @return
+ */
+ IClient getIClient(ClientHandle applicationHandle, UserHandle userId, String sessionUrn);
+ /**
+ * New session for application and specific user
+ * @param applicationHandle
+ * @param userId
+ * @return
+ * @throws NoDefaultSessionException if more than one session exists that the client may connect to
+ */
+ IClient getIClient(ClientHandle applicationHandle, UserHandle userId) throws NoDefaultSessionException;
+
+ /**
+ * enumerate the active sessions this IClientFactory instance knows about.
+ * Can be used by caller to pick a session on catching a NoDefaultSessionException.
+ * LATER: Define interface for discovering more information about a session (so it can be presented to a user in a meaningful way)
+ * @return possibly empty array of sessionUrn strings
+ */
+ public String[] getCurrentSessions();
+
+}
--- /dev/null
+package uk.ac.vamsas.client;\r
+\r
+/**\r
+ * Methods implemented by a Vamsas Application's Object Update handler\r
+ * @author vamsas\r
+ * Introduced November 2006 Vamsas Meeting\r
+ * TODO: verify this is sufficient for the per-object update event mechanism\r
+ */\r
+public interface IObjectUpdate {\r
+ /**\r
+ * Called by the library to find out which vamsas document object this update handler is interested in\r
+ * @return class that extends org.vamsas.Vobject\r
+ */\r
+ Class getRootVobject();\r
+ /**\r
+ * Called to test if this handler is to be called for updates to any Vobjects below the Root Vobject in the vamsas document.\r
+ * @return false means IObjectUpdate.update(updated, cdoc) will only be called with instances of type getRootVobject(). \r
+ */\r
+ boolean handlesSubtreeUpdates();\r
+ /**\r
+ * Method called by Vamsas Client Library for all updated objects that the handler is registered for.\r
+ * @param updated\r
+ * @param cdoc\r
+ */\r
+ void update(uk.ac.vamsas.client.Vobject updated, uk.ac.vamsas.client.IClientDocument cdoc);\r
+}\r
--- /dev/null
+/*
+ * Created on 14-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * @author jimp
+ * middleware interface for generating new VorbaId objects
+ * for a particular vamsas client based on the current
+ * session, user and client handle. Generally implemented
+ * by instances of the vamsas library api only.
+ */
+public interface IVorbaIdFactory {
+ /**
+ * construct a new id appropriate for this client in the vamsas session.
+ * @param vobject TODO
+ *
+ * @return valid VorbaId for session, or null if VorbaIdFactory not configured
+ * correctly.
+ */
+ public abstract VorbaId makeVorbaId(Vobject vobject);
+
+ public abstract SessionHandle getSessionHandle();
+
+ public abstract ClientHandle getClientHandle();
+
+ public abstract UserHandle getUserHandle();
+ /**
+ * called when an object is touched by the vamsas library prior to writing
+ * to record last hash for the object's VorbaId
+ * @param vobject
+ */
+ public abstract void updateHashValue(Vobject vobject);
+}
\ No newline at end of file
--- /dev/null
+/**
+ * uk.ac.vamsas.client.Iapp
+ */
+package uk.ac.vamsas.client;
+public interface Iapp {
+ /**
+ * Define core callback functionality that a fully
+ * fledged vamsas application Vobject must implement
+ * TODO: define some Application Callbacks and create use cases for them
+ */
+
+};
--- /dev/null
+package uk.ac.vamsas.client;
+
+public class InvalidSessionUrnException extends Exception {
+
+ /**
+ *
+ */
+ public InvalidSessionUrnException() {
+ super("Invalid Vamsas Session URN.");
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public InvalidSessionUrnException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public InvalidSessionUrnException(String message) {
+ super("Invalid Vamsas Session URN: "+message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public InvalidSessionUrnException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
--- /dev/null
+/**
+ *
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * @author jimp
+ * Raised if an IClient instance is requested without
+ * specifying a particular vamsas session handle
+ * when more than one candidate session exists.
+ */
+public class NoDefaultSessionException extends Exception {
+
+ /**
+ *
+ */
+ public NoDefaultSessionException() {
+ super("No Default Session Defined");
+ }
+
+ /**
+ * @param message
+ */
+ public NoDefaultSessionException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public NoDefaultSessionException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public NoDefaultSessionException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
--- /dev/null
+/*
+ * Created on 12-Sep-2005
+ *
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * Uniquely locates a particular VAMSAS session.
+ * @author jimp
+ *
+ */
+public class SessionHandle {
+
+ /**
+ * @param sessionUrn
+ */
+ public SessionHandle(String sessionUrn) {
+ super();
+ SessionUrn = sessionUrn;
+ }
+ /**
+ * @return Returns the sessionUrn.
+ */
+ public String getSessionUrn() {
+ return SessionUrn;
+ }
+ /**
+ * @param sessionUrn The sessionUrn to set.
+ */
+ public void setSessionUrn(String sessionUrn) {
+ SessionUrn = sessionUrn;
+ }
+ /**
+ * The path to the vamsas session file.
+ */
+ String SessionUrn;
+
+}
--- /dev/null
+/**
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * @author jimp
+ * base class for vamsas session/document types
+ * uses java.net.URI internally for construction of URN
+ */
+public abstract class SessionUrn {
+ protected URI urn;
+ /**
+ * The types of URI protocols we understand
+ */
+ protected static final Hashtable TYPES=new Hashtable();
+
+ /**
+ * construct urn for a locally stored session file
+ * @param type
+ * @param url
+ */
+ protected SessionUrn(String type, java.net.URL url) {
+ if (!TYPES.containsKey(type.toLowerCase()))
+ throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'");
+ try {
+ urn = URI.create(type+"://"+url.getPath());
+ } catch (Exception e) {
+ // TODO: something better than throwing an error should be done here.
+ throw new Error(e);
+ }
+ }
+ public String getSessionUrn() {
+ return urn.toString();
+ }
+}
--- /dev/null
+/*
+ * Created on 12-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * Unique user identifier for a vamsas session.
+ * Used to write user provenance information, and
+ * track view/access control in multiuser sessions.
+ * @author jimp
+ */
+public class UserHandle {
+ /**
+ * @param fullName
+ * @param organization
+ */
+ public UserHandle(String fullName, String organization) {
+ this.fullName = fullName;
+ Organization = organization;
+ }
+ String fullName;
+ String Organization;
+ /**
+ * @return Returns the fullName.
+ */
+ public String getFullName() {
+ return fullName;
+ }
+ /**
+ * @param fullName The fullName to set.
+ */
+ public void setFullName(String fullname) {
+ fullName = fullname;
+ }
+ /**
+ * @return Returns the organization.
+ */
+ public String getOrganization() {
+ return Organization;
+ }
+ /**
+ * @param organization The organization to set.
+ */
+ public void setOrganization(String organization) {
+ Organization = organization;
+ }
+}
--- /dev/null
+/**
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.exolab.castor.mapping.FieldDescriptor;
+import org.exolab.castor.mapping.FieldHandler;
+import org.exolab.castor.xml.util.XMLClassDescriptorImpl;
+import org.vamsas.test.simpleclient.VamsasArchive;
+
+/**
+ * Base class for all Vamsas objects extracted from an IClientDocument. An
+ * Vobject maybe registered or unregistered.
+ *
+ * @author jimp
+ *
+ */
+public abstract class Vobject {
+ static Log log = LogFactory.getLog(Vobject.class);
+
+ /**
+ * true if Vobject was stored in a vamsas Document or has been retrieved from it
+ */
+ protected boolean __stored_in_document = false;
+ /**
+ * true if Vobject was updated since the vamsas library last read a Vobj with the same VorbaId from a document.
+ */
+ protected boolean __updated_since_last_read = false;
+ /**
+ * memory of the last doHash() value computed for the Vobject
+ * @see doHash()
+ */
+ protected int __last_hash = 0;
+ /**
+ * set by testInstanceForIdField() if Vobject should have a VorbaId
+ */
+ protected boolean registerable = false;
+ protected boolean __visited = false;
+ /**
+ * reference to containing object for this Vobject.
+ */
+ protected Vobject V_parent=null;
+ /**
+ * unique id for all vamsas objects allows unambiguous referencing to any
+ * Vobject in the vamsas document
+ */
+ protected VorbaId vorbaId = null;
+
+ /**
+ * the source of unique VorbaIds.
+ */
+ protected IVorbaIdFactory __vorba = null;
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ protected void finalize() throws Throwable {
+ V_parent=null;
+ __vorba=null;
+ vorbaId=null;
+ super.finalize();
+ }
+
+ /**
+ *
+ */
+ protected Vobject() {
+ super();
+ testInstanceForIdField();
+ }
+ java.lang.reflect.Field ___id_field=null; // set to ease pain of reflection
+ /**
+ * set the isRegisterable flag based on the presence of a 'private String _id' field in
+ * the reflected class instance.
+ */
+ private void testInstanceForIdField() {
+ // TODO: decide if 'id' is an appropriate reserved attribute name for the VorbaId
+ // look for the id field in all castor classes (should be an NCName string)
+
+ Class thisclass=this.getClass();
+ setRegisterable(false);
+ while (!thisclass.equals(Vobject.class)) {
+ try {
+ java.lang.reflect.Field fd = thisclass.getDeclaredField("_id");
+ if (String.class.isAssignableFrom(fd.getType())) {
+ ___id_field=fd;
+ this.setRegisterable(true);
+ break;
+ }
+ } catch (SecurityException e) {
+ log.error("Unexpected Security Exception whilst finding id fields to set!",e);
+ } catch (NoSuchFieldException e) {
+ thisclass=thisclass.getSuperclass();
+ }
+ }
+ }
+ // boolean __testedInstance=false;
+ /**
+ * update the Vobject instance's _id field, based on the contents of the
+ * VorbaId. Only call this if you mean to do it!
+ */
+ protected void setInstanceIdField() {
+ /*if (!registerable && !__testedInstance) {
+ testInstanceForIdField();
+ __testedInstance=true;
+ }*/
+ if (registerable) {
+ if (__vorba != null)
+ try {
+ Method fd = this.getClass().getMethod("setId", new Class[] { String.class });
+ fd.invoke((Object) this, new Object[] {new String(this.getVorbaId().id)});
+ log.debug(this.getClass().getName()+" called setInstanceIdField!");
+ } catch (InvocationTargetException e) {
+ log.error("SourceGeneration of "
+ + this.getClass().toString()
+ + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e);
+ }
+ catch (IllegalAccessException e) {
+ log.error("SourceGeneration of "
+ + this.getClass().toString()
+ + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e);
+ } catch (SecurityException e) {
+ log.error("Security access violation for "+this.getClass().toString(),e);
+ } catch (NoSuchMethodException e) {
+ log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)");
+ this.setRegisterable(false);
+ }
+ } else {
+ System.err.println("Client error. Trying to setInstanceIdField on a "
+ + this.getClass().toString() + " (which cannot be given a vorbaId)");
+ }
+ }
+
+ protected String __getInstanceIdField() {
+ /*if (!registerable && !__testedInstance) {
+ testInstanceForIdField();
+ __testedInstance=true;
+ }*/
+ if (registerable) {
+ if (__vorba != null)
+ try {
+ Method fd = this.getClass().getMethod("getId", (Class[]) null);
+ Object idstring = fd.invoke((Object) this, (Object[]) null);
+ log.debug(this.getClass().getName()+" called getInstanceIdField!");
+ if (idstring!=null && idstring instanceof String) {
+ if (((String) idstring).length()>0)
+ return (String) idstring;
+ }
+ } catch (InvocationTargetException e) {
+ log.error("SourceGeneration of "
+ + this.getClass().toString()
+ + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e);
+ }
+ catch (IllegalAccessException e) {
+ log.error("SourceGeneration of "
+ + this.getClass().toString()
+ + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e);
+ } catch (SecurityException e) {
+ log.error("Security access violation for "+this.getClass().toString(),e);
+ } catch (NoSuchMethodException e) {
+ log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)");
+ this.setRegisterable(false);
+ }
+ } else {
+ System.err.println("Client error. Trying to getInstanceIdField on a "
+ + this.getClass().toString() + " (which cannot be given a vorbaId)");
+ }
+ return null;
+ }
+
+ /**
+ * calculate a hash for the Vobject with all housekeeping fields at standard
+ * values. (isRegisterable is an immutable attribute property)
+ * TODO: decide if __stored_in_document should be included in the hash or not.
+ * @return true if new hash different to last hash
+ */
+ synchronized protected boolean doHash() {
+ long __old_hash = __last_hash;
+ __last_hash = 0;
+ Vobject _V_parent=V_parent;
+ V_parent=null;
+ VorbaId thisid = vorbaId;
+ IVorbaIdFactory factory = __vorba;
+ boolean stored = __stored_in_document;
+ boolean updated = __updated_since_last_read;
+ boolean visited = __visited;
+ java.lang.reflect.Field idfield = ___id_field;
+ ___id_field=null;
+ __updated_since_last_read=false;
+ vorbaId = null;
+ __vorba = null;
+ __visited=false;
+ // compute hash
+ __last_hash = this.hashCode();
+ // reset houseskeeping variables
+ ___id_field=idfield;
+ vorbaId = thisid;
+ __vorba = factory;
+ __stored_in_document = stored;
+ __updated_since_last_read=updated;
+ V_parent=_V_parent;
+ __visited=visited;
+ return (__old_hash==0) || (__old_hash == __last_hash);
+ }
+
+ /**
+ * TODO: combine two versions of the same collection Vobject to resolve
+ * asynchronous updates to the same vamsas Vobject Merges two vamsas objects,
+ * one of which is a later version of the earlier (ie they have the same
+ * vorbaId but one is a later version recently read from the vamsasDocument
+ * collection.
+ *
+ * @return
+ */
+ protected boolean merge(Vobject laterCopy) {
+ log.warn(this.getClass().getName()+".merge() not implemented.");
+ return true;
+ }
+
+ /**
+ *
+ * @return true if Vobject is registered
+ */
+ public boolean isRegistered() {
+ return (registerable) ? (vorbaId != null) : false;
+ }
+
+ /**
+ * Method to get fixed reference for the Vobject in the vamsas document.
+ *
+ * @returns null if Vobject is neither registered or not associated with a
+ * properly instantiated VorbaIdFactory.
+ */
+ public VorbaId getVorbaId() {
+ if (registerable && vorbaId == null) {
+ if (this.__stored_in_document) {
+ if (__vorba!=null)
+ vorbaId=uk.ac.vamsas.client.VorbaId.newId(this.__getInstanceIdField());
+ }
+ // Try to use the associated factory.
+ if (__vorba != null)
+ if ((vorbaId = __vorba.makeVorbaId(this)) == null)
+ return null; // Factory not valid.
+ else {
+ this.setInstanceIdField();
+ return vorbaId;
+ }
+ }
+ return vorbaId;
+ }
+
+ /**
+ * used by the IClient implementation to generate unique Id based on client
+ * applications current namespace.
+ */
+ protected void setVorbaId(VorbaId newid) {
+ vorbaId = newid;
+ }
+
+ /**
+ * @return true if Vobject is present in Vamsas Document.
+ */
+ public boolean is__stored_in_document() {
+ return __stored_in_document;
+ }
+
+ /**
+ * @return true if this object has been updated in the currently stored document since the last time a Vobject with the same ID was read from a Vamsas Document
+ */
+ public boolean is__updated_since_last_read() {
+ return __updated_since_last_read;
+ }
+
+ /**
+ * Set internal flag to indicate this object was updated since the last document read
+ * @param __updated_since_last_read the __updated_since_last_read to set
+ */
+ protected void set__updated_since_last_read(boolean __updated_since_last_read) {
+ this.__updated_since_last_read = __updated_since_last_read;
+ }
+
+ /**
+ * for use by Vorba agent to reflect state of vamsas Vobject to client
+ * application.
+ * Setting stored_in_document on a registerable Vobject without a
+ * vorbaId will mean is will *never* get a vorbaId and
+ * horrible things will happen.
+ * @param __stored_in_document true if Vobject has been marshalled into current document.
+ */
+ protected void set__stored_in_document(boolean __stored_in_document) {
+ this.__stored_in_document = __stored_in_document;
+ }
+
+ /**
+ * __last_hash is the hash value computed when the Vobject was last checked
+ * against a IClientDocument generated by the Vobject's parent IClient
+ * instance.
+ *
+ * @return Returns the __last_hash.
+ */
+ public int get__last_hash() {
+ return __last_hash;
+ }
+
+ /**
+ * @return true if Vobject can have a vorbaId
+ */
+ public boolean isRegisterable() {
+ return registerable;
+ }
+
+ /**
+ * Called by __testInstanceForidField and the post-unmarshalling handler
+ * to indicate if Vobject will have a vorbaId.
+ * @param registerable
+ */
+ protected void setRegisterable(boolean registerable) {
+ this.registerable = registerable;
+ }
+ /**
+ * ensure's internal id field corresponds to vorbaId and
+ * cascade through all fields referring to an instance of Vobject
+ * calling the same method on them.
+ * TODO: LATER: properly apply castors own field mechanisms to get at accessors
+ * TODO: FIX CYCLIC __ensure+instance_ids
+ * Implementation note for the todo:
+ * this works like a depth-first search over all vamsas objects in an vamsasDocument.
+ * __visited is the visited flag, any Vobj who's flag is of a different parity
+ * to the visited argument will be recursed on.
+ * note - the doHash() function used to be used as the 'visited' flag -
+ * this *is not* a valid heuristic, although it will work "most of the time".
+ * TODO: LATER? Add another method for setDefaultProvenanceField (in the spirit of setInstanceIdField) using the info from the __vorba.getClient/User/Session methods
+ */
+ protected void __ensure_instance_ids() {
+ __ensure_instance_ids(!__visited);
+ }
+ protected void __ensure_instance_ids(boolean visited) {
+ if (__vorba==null)
+ throw new Error("Improperly intialised uk.ac.vamsas.client.Vobject - no VorbaFactory given.");
+ log.debug("doing "+this.getClass()+".__ensure_instance_ids()");
+ if (!__stored_in_document && registerable)
+ setInstanceIdField();
+ if (__visited==visited)
+ return;
+ __visited=visited;
+ __vorba.updateHashValue(this);
+
+ Class descriptor = null;
+ XMLClassDescriptorImpl descimpl = null;
+ try {
+ // castor descriptor resolver magic
+ descriptor = this.getClass().getClassLoader().loadClass(this.getClass().getName()+"Descriptor");
+ descimpl = (XMLClassDescriptorImpl) descriptor.getConstructor((Class[])null).newInstance((Object[])null);
+ } catch (Exception e) {
+ log.fatal("Source Generation Error!: Couldn't resolve descriptor for "
+ +this.getClass().getName()
+ +" was 'generate descriptors' set for castorbuilder.properties?");
+ return;
+ }
+ FieldDescriptor fields[] = descimpl.getFields();
+ for (int i=0,j=fields.length; i<j; i++) {
+ Class type= fields[i].getFieldType();
+ if (type.isArray()) {
+ if (Vobject[].class.isAssignableFrom(type)) {
+ try {
+ Object val = fields[i].getHandler().getValue(this);
+ if (val!=null) {
+ Vobject vals[] = (Vobject[]) val;
+ for (int k=0, l=vals.length; k<l; k++) {
+ if (vals[k].__vorba==null)
+ vals[k].__vorba = __vorba; // propagate IVorbaIdFactory
+ if (vals[k].V_parent==null)
+ vals[k].V_parent=this; // propagate parent reference to this element.
+ vals[k].__ensure_instance_ids(visited);
+ }
+ }
+ }
+ catch (Exception e) {
+ log.error("Client error - could not access array "+type.getName()+" in "+this.getClass().getName(), e);
+ }
+ }
+ } else
+ if (Vobject.class.isAssignableFrom(type)) {
+ try {
+ FieldHandler fh = fields[i].getHandler();
+ Vobject rf = null;
+ if (fh != null) {
+ Object fval = fh.getValue(this);
+ if (fval!=null) {
+ if (fval.getClass().isArray()) {
+ //if (Vobject[].class.isAssignableFrom(type)) {
+ try {
+ Vobject vals[] = (Vobject[]) fval;
+ for (int k=0, l=vals.length; k<l; k++) {
+ if (vals[k].__vorba==null)
+ vals[k].__vorba = __vorba; // propagate IVorbaIdFactory
+ if (vals[k].V_parent==null)
+ vals[k].V_parent=this; // propagate parent reference to this field object
+ vals[k].__ensure_instance_ids(visited);
+ }
+ }
+ catch (Exception e) {
+ log.error("Client error - could not access (fhval)array "+type.getName()+" in "+this.getClass().getName(), e);
+ }
+ //}
+ } else {
+ rf = (Vobject) fval;
+ log.debug("Got value for "+fields[i].getFieldName());
+ }
+ }
+ } else {
+ // castor's mechanism doesn't work for this object... so...*/
+ // fuck around, fuck around, jump up jump up and get down! */
+ Object o = fields[i].getClassDescriptor();
+ if (o!=null) {
+ // XMLClassDescriptorImpl fclasdes = (XMLClassDescriptorImpl) o;
+ String methname = "get"+fields[i].getFieldName();
+ Method fgetmeth = this.getClass().getMethod(methname,(Class[])null);
+ if (fgetmeth!=null) {
+ Object fval = fgetmeth.invoke(this,(Object[])null);
+ if (fval!=null)
+ rf = (Vobject) fval;
+ } else {
+ log.warn("Couldn't find "+this.getClass().getName()+"."+methname);
+ }
+ }
+ }
+ if (rf!=null) {
+ if (rf.__vorba==null)
+ rf.__vorba = __vorba; // propagate IVorbaIdFactory
+ if (rf.V_parent==null)
+ rf.V_parent=this; // propagate parent reference
+ rf.__ensure_instance_ids(visited);
+ }
+ }
+ catch (Exception e) {
+ log.error("Client error - could not access "+type.getName()+" in "+this.getClass().getName(), e);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @return the __parent
+ */
+ public Vobject getV_parent() {
+ return V_parent;
+ }
+
+ /**
+ * @param __parent the __parent to set
+ */
+ protected void setV_parent(Vobject V_parent) {
+ this.V_parent = V_parent;
+ }
+}
--- /dev/null
+package uk.ac.vamsas.client;\r
+\r
+/**\r
+ * Holds information about Vobj instances that is held over between different writes to the document.\r
+ * @author JimP\r
+ *\r
+ */\r
+public class Vobjhash {\r
+ int hashvalue;\r
+ /**\r
+ * creates a record of the hash value for a vamsas document object\r
+ * @param tobemarshalled\r
+ */\r
+ public Vobjhash(Vobject tobemarshalled) {\r
+ hashvalue = tobemarshalled.get__last_hash();\r
+ }\r
+ /**\r
+ * compares the old hash value with the unmarshalled object's most recently computed hash value.\r
+ * @param unmarshalled\r
+ * @return true if the hash values differ\r
+ */\r
+ public boolean isUpdated(Vobject unmarshalled) {\r
+ return hashvalue==unmarshalled.get__last_hash();\r
+ }\r
+}\r
--- /dev/null
+/*
+ * Created on 12-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * The unique reference id for a Vamsas document Vobject,
+ * used by applications to refer to the vamsas Vobject
+ * within their own data space in the vamsas document.
+ * TODO: decide if VorbaId should contain a reference
+ * to either the IVorbaIdFactory that made it or the
+ * IClient that defines the session (it might be
+ * convenient).
+ * @author jimp
+ */
+public class VorbaId {
+ protected String id;
+ protected VorbaId() {
+ super();
+ }
+ private VorbaId(String Id) {
+ super();
+ id = Id;
+ }
+ /**
+ *
+ * @param vorbaObject the source of vorba Ids
+ * @param vobject the Vobject to be registered with a new vorba id
+ * @return
+ */
+ protected static VorbaId newId(IVorbaIdFactory vorbaObject, Vobject vobject) {
+ // Make unique id from appSpace info in vorbaObject
+ synchronized (vorbaObject) {
+ vobject.vorbaId=vorbaObject.makeVorbaId(vobject);
+ return vobject.vorbaId;
+ }
+ }
+ protected static VorbaId newId(String id) {
+ return new VorbaId(id);
+ }
+ /**
+ * @return Returns the id.
+ */
+ public String getId() {
+ return id;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof String)
+ return id.equals(obj);
+ else if (obj instanceof VorbaId)
+ return id.equals(((VorbaId)obj).id);
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return id.hashCode();
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return id;
+ }
+
+}
--- /dev/null
+/*
+ * Created on 12-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * A VorbaIdFactory is constructed by an IClient instance.
+ * It guarantees that any new VorbaId objects are unique
+ * within the VAMSAS session.
+ *
+ * @author jimp
+ */
+public abstract class VorbaIdFactory implements IVorbaIdFactory {
+ /**
+ * hash of VorbaIds to Vobject.
+ */
+ protected Hashtable extantids=null;
+ /**
+ * hash of VorbaIds to persisted hash values
+ */
+ protected Hashtable extanthashv=null;
+ /**
+ * list of Vobjects added since last Document read.
+ */
+ protected Vector newobj=null;
+
+ /**
+ * construct a new id appropriate for this client in the vamsas session.
+ *
+ * @return valid VorbaId for session, or null if VorbaIdFactory not configured
+ * correctly.
+ */
+ public abstract VorbaId makeVorbaId(Vobject vobject);
+
+ /**
+ * internal method to access the protected VorbaId object constructor
+ * This shennanigan is to prevent casual generation of VorbaIds
+ * (which may destroy the integrity of a Vamsas Document!)
+ * @param id
+ * @return new VorbaId object
+ */
+ protected VorbaId newId(String id) {
+ return VorbaId.newId(id);
+ }
+ /**
+ * Called by VorbaXmlBinder so the record of newly unmarshalled Vobject Ids
+ * is accessible to the Document's VorbaIdFactory instance.
+ * @param idtable
+ */
+ protected void setNewIdHash(Hashtable idtable) {
+ extantids = idtable;
+ }
+
+ /* (non-Javadoc)
+ * @see uk.ac.vamsas.client.IVorbaIdFactory#updateHashValue(uk.ac.vamsas.client.Vobject)
+ */
+ public void updateHashValue(Vobject vobject) {
+ if (vobject.isRegisterable())
+ extanthashv.put(vobject.getVorbaId(), new Vobjhash(vobject));
+ }
+
+ /**
+ * TODO: decide if these are needed.
+ *
+ * @param sessionHandle
+ */
+ protected abstract void setSession(SessionHandle sessionhandle);
+
+ public abstract SessionHandle getSessionHandle();
+
+ protected abstract void setClient(ClientHandle appHandle);
+
+ public abstract ClientHandle getClientHandle();
+
+ protected abstract void setUser(UserHandle userHandle);
+
+ public abstract UserHandle getUserHandle();
+}
--- /dev/null
+/**
+ *
+ */
+package uk.ac.vamsas.client;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.exolab.castor.mapping.FieldHandler;
+import org.exolab.castor.mapping.GeneralizedFieldHandler;
+import org.exolab.castor.mapping.ValidityException;
+import org.exolab.castor.xml.IDResolver;
+import org.exolab.castor.xml.MarshalException;
+import org.exolab.castor.xml.MarshalListener;
+import org.exolab.castor.xml.Marshaller;
+import org.exolab.castor.xml.UnmarshalListener;
+import org.exolab.castor.xml.Unmarshaller;
+import org.exolab.castor.xml.ValidationException;
+import org.vamsas.objects.core.VamsasDocument;
+/**
+ * Implements the Vamsas Vobject ID machinery for translating
+ * between non-volatile XML IDs and Vobject references. Use the
+ * marshalling and unmarshalling methods in this class in order
+ * to add automatically computed values for required fields in objects,
+ * so as to avoid validation exceptions when marshalling new objects
+ * into the vamsas document.
+ */
+public class VorbaXmlBinder implements UnmarshalListener {
+ private static Log log = LogFactory.getLog(VorbaXmlBinder.class);
+ private final IVorbaIdFactory vorbafactory;
+
+ private final Vector obj;
+ private final Hashtable oldobjhashes;
+ private final Hashtable objrefs;
+ private final Vector updatedobjs;
+
+ public VorbaXmlBinder(IVorbaIdFactory vorbafactory, Vector obj, Hashtable objrefs, Hashtable oldobjhashes, Vector updatedobjs) {
+ this.vorbafactory = vorbafactory;
+ this.obj = obj;
+ this.objrefs = objrefs;
+ this.oldobjhashes = oldobjhashes;
+ this.updatedobjs = updatedobjs;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exolab.castor.xml.UnmarshalListener#attributesProcessed(java.lang.Object)
+ */
+ public void attributesProcessed(Object object) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exolab.castor.xml.UnmarshalListener#fieldAdded(java.lang.String,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void fieldAdded(String fieldName, Object parent, Object child) {
+ if (parent instanceof Vobject && child instanceof Vobject) {
+ if (((Vobject) child).V_parent==null) {
+ // System.err.println("Setting parent of "+fieldName);
+ ((Vobject) child).setV_parent((Vobject) parent);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exolab.castor.xml.UnmarshalListener#initialized(java.lang.Object)
+ */
+ public void initialized(Object object) {
+ }
+
+ /*
+ * Check if the object has an 'id' field - if it does, copy the value into
+ * the VorbaId field of Vobject, and add the Vobject to the VorbaId hash.
+ *
+ * @see org.exolab.castor.xml.UnmarshalListener#unmarshalled(java.lang.Object)
+ */
+ public void unmarshalled(Object newobj) {
+ if (newobj instanceof Vobject) {
+ Vobject nobj = (Vobject) newobj;
+ nobj.set__stored_in_document(true);
+ try {
+ if (nobj.isRegisterable() && nobj.___id_field!=null) {
+ VorbaId nobj_id=null;
+ // look for the id field (should be an NCName string)
+ nobj.__vorba = vorbafactory;
+ // use the Vobject accessor method to avoid unpleasant security exceptions.
+ String idstring = nobj.__getInstanceIdField();
+ if (idstring!=null) {
+ if (idstring.length() > 0) {
+ nobj.setVorbaId(VorbaId.newId(idstring));
+ if (objrefs.containsKey(nobj_id=nobj.getVorbaId()) && !objrefs.get(nobj.getVorbaId()).equals(nobj)) {
+ System.err.println("Serious problem : duplicate id '"+idstring+"' found! expect badness.");
+ // TODO: HANDLE duplicate XML ids correctly
+ }
+ objrefs.put(nobj_id, nobj);
+ } else {
+ // add to list of objects without a valid vorbaId
+ obj.add(nobj);
+ }
+ } else {
+ // TODO: add to list of objects without a valid vorbaId
+ obj.add(nobj);
+ }
+
+ nobj.doHash();
+ // check to see if new object was present in old object hash
+ if (oldobjhashes.containsKey(nobj.getVorbaId())) {
+ Vobjhash oldhash = (Vobjhash) oldobjhashes.get(nobj.getVorbaId());
+ if (oldhash.isUpdated(nobj)) {
+ // mark the object as updated in this document read.
+ nobj.set__updated_since_last_read(true);
+ oldobjhashes.put(nobj_id, new Vobjhash(nobj));
+ updatedobjs.addElement(nobj);
+ }
+ }
+ }
+ } catch (Exception e) {
+ return;
+ };
+
+ }
+ }
+
+ /**
+ * writes the VamsasDocument to the given stream.
+ * TODO: ensure that (at least) default provenance entries are written for objects.
+ * @param outstream
+ * @param vorba valid VorbaIdFactory to construct any missing IDs
+ * @param doc
+ * @throws IOException
+ * @throws MarshalException
+ * @throws ValidationException
+ */
+ public static void putVamsasDocument(PrintWriter outstream, VorbaIdFactory vorba, VamsasDocument doc)
+ throws IOException, MarshalException, ValidationException {
+ // Ensure references
+ if (vorba==null)
+ throw new Error("Null VorbaIdFactory Parameter");
+ if (doc.__vorba==null)
+ doc.__vorba = vorba;
+ doc.__ensure_instance_ids(); // this may take a while. Do we allow for cyclic references ?
+ doc.marshal(outstream);
+
+ }
+ /**
+ * creates new VorbaId references where necessary for newly unmarshalled objects
+ * @param unrefed
+ * @param objrefs
+ * @return false if any new object references were made
+ */
+ private static boolean ensure_references(Vector unrefed, Hashtable objrefs) {
+ boolean sync=true;
+ if (unrefed.size()>0) {
+ sync=false; // document is out of sync - ids have been created.
+ java.util.Iterator newobj = unrefed.listIterator();
+ while (newobj.hasNext()) {
+ Vobject o = (Vobject) newobj.next();
+ // forces registration and id field update.
+ VorbaId id = o.getVorbaId();
+ if (!objrefs.containsKey(id)) {
+ objrefs.put(id, o);
+ } else {
+ if (!objrefs.get(id).equals(o))
+ throw new Error("Serious! Duplicate reference made by vorbaIdFactory!");
+ }
+ }
+ }
+ return sync;
+ }
+ /**
+ * Unmarshals a vamsasDocument Vobject from a stream, registers
+ * unregistered objects, records existing VorbaIds, and completes
+ * the uk.ac.vamsas.client.Vobject housekeeping fields.
+ * For a valid unmarshalling, the array of returned objects also includes
+ * a <return>sync</return> parameter which is true if new VorbaIds
+ * were created. If sync is false, then the caller should ensure that the
+ * vamsasDocument is written back to disk to propagate the new VorbaIds.
+ * TODO: ensure that provenance is correct for newly registered objects
+ * as getVamsasObjects but will detect updated objects based on differing hash values
+ * obtained from the VorbaIdFactory's VorbaId, Vobject.get__last_Hash() pairs (if any)
+ * @param instream - the XML input stream
+ * @param factory - the SimpleClient's properly configured VorbaId factory to make new references.
+ * @param root the root element's org.vamsas.objects.core Vobject.
+ * @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of Vobject references, (Object) Boolean(sync), (Object) Vector of updated objects in document }
+ */
+ public static Object[] getVamsasObjects(Reader instream,
+ VorbaIdFactory factory, Vobject root) {
+ Unmarshaller unmarshaller = new Unmarshaller(root);
+ unmarshaller.setIDResolver(new IDResolver() {
+ public Object resolve(String id) {
+ VorbaXmlBinder.log.warn("Warning - id " + id
+ + " is not found in the Vamsas XML!");
+ return null;
+ }
+ });
+ final Hashtable objrefs = new Hashtable();
+ if (factory.extanthashv==null)
+ factory.extanthashv=new Hashtable();
+ final Hashtable oobjhashes=factory.extanthashv;
+ final VorbaIdFactory vorbafactory = factory;
+ final Vector unrefedObj = new Vector();
+ final Vector updatedObj = new Vector();
+ unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes, updatedObj));
+ // Call the unmarshaller.
+ try {
+ while (instream.ready()) {
+ // TODO: mark objects in oobjhash prior to unmarshalling, to detect when objects have been lost through an update.
+ //tohere
+ Object obj = unmarshaller.unmarshal(instream);
+ boolean sync=ensure_references(unrefedObj, objrefs);
+ if (!(obj instanceof Vobject))
+ return null;
+ vorbafactory.setNewIdHash(objrefs); // update the Document IO Handler's set of vorbaId<>Object bindings.
+ return new Object[] { obj, objrefs, new Boolean(sync),updatedObj};
+ }
+ } catch (MarshalException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ValidationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
\ No newline at end of file
* @author jimp
*
*/
-public class ArchiveUrn extends org.vamsas.client.SessionUrn {
+public class ArchiveUrn extends uk.ac.vamsas.client.SessionUrn {
/**
* a simple vamsas document urn prefix
*/
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.IClientAppdata;
-import org.vamsas.client.IClientDocument;
-import org.vamsas.client.UserHandle;
-import org.vamsas.client.Vobject;
-import org.vamsas.client.VorbaId;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.User;
import org.vamsas.objects.core.VAMSAS;
import org.vamsas.objects.utils.AppDataReference;
import org.vamsas.test.objects.Core;
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.IClientAppdata;
+import uk.ac.vamsas.client.IClientDocument;
+import uk.ac.vamsas.client.UserHandle;
+import uk.ac.vamsas.client.Vobject;
+import uk.ac.vamsas.client.VorbaId;
+
/**
* Maintains a collection of vamsas objects, appdatas and states, and provides api for a SimpleClient's client.
* @author jimp
*/
-public class ClientDocument extends org.vamsas.client.ClientDocument implements IClientDocument {
+public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implements IClientDocument {
private static Log log = LogFactory.getLog(ClientDocument.class);
private VamsasDocument doc;
protected SimpleClient sclient;
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClientDocument#getObject(org.vamsas.client.VorbaId)
+ * @see uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId)
*/
public Vobject getObject(VorbaId id) {
if (vamsasObjects==null) {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClientDocument#getObjects(org.vamsas.client.VorbaId[])
+ * @see uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId[])
*/
public Vobject[] getObjects(VorbaId[] ids) {
if (vamsasObjects==null) {
/*
* (non-Javadoc)
* LATER: currently there is only one Vector of roots ever passed to client - decide if this is correct (means this is not thread safe and may behave unexpectedly)
- * @see org.vamsas.client.IClientDocument#getVamsasRoots()
+ * @see uk.ac.vamsas.client.IClientDocument#getVamsasRoots()
*/
public VAMSAS[] getVamsasRoots() {
if (doc==null) {
/* (non-Javadoc)
* LATER: decide: this affects the next call to getVamsasRoots()
- * @see org.vamsas.client.IClientDocument#addVamsasRoot(org.vamsas.objects.core.VAMSAS)
+ * @see uk.ac.vamsas.client.IClientDocument#addVamsasRoot(org.vamsas.objects.core.VAMSAS)
*/
public void addVamsasRoot(VAMSAS newroot) {
if (doc==null) {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClientDocument#registerObjects(org.vamsas.client.Vobject[])
+ * @see uk.ac.vamsas.client.IClientDocument#registerObjects(uk.ac.vamsas.client.Vobject[])
*/
public VorbaId[] registerObjects(Vobject[] unregistered) {
if (doc==null) {
return null;
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientDocument#registerObject(org.vamsas.client.Vobject)
+ * @see uk.ac.vamsas.client.IClientDocument#registerObject(uk.ac.vamsas.client.Vobject)
*/
public VorbaId registerObject(Vobject unregistered) {
if (doc==null) {
*/
SimpleClientAppdata scappd = null;
/* (non-Javadoc)
- * @see org.vamsas.client.IClientDocument#getClientAppdata()
+ * @see uk.ac.vamsas.client.IClientDocument#getClientAppdata()
*/
public IClientAppdata getClientAppdata() {
if (doc==null) {
package uk.ac.vamsas.client.simpleclient;
-import org.vamsas.client.*;
+import uk.ac.vamsas.client.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.Events;
+
+import uk.ac.vamsas.client.Events;
/**
* monitors watcher objects and generates events.
* Generated when a new vamsas client is attached to a session (Handle is
* passed) Note: the newly created client does not receive the event.
*
- public static final String CLIENT_CREATION = "org.vamsas.client.events.clientCreateEvent";
+ public static final String CLIENT_CREATION = "uk.ac.vamsas.client.events.clientCreateEvent";
*/ // as the test
/**
* Generated when a vamsas client leaves a session (Handle is passed to all
* others).
- public static final String CLIENT_FINALIZATION = "org.vamsas.client.events.clientFinalizationEvent";
+ public static final String CLIENT_FINALIZATION = "uk.ac.vamsas.client.events.clientFinalizationEvent";
*/ // again - as the test.
raised++;
}
* Generated when a client has finished updating the document. Passes
* applicationHandle of client so the updating client can recognise its own
* updates.
- public static final String DOCUMENT_UPDATE = "org.vamsas.client.events.documentUpdateEvent";
+ public static final String DOCUMENT_UPDATE = "uk.ac.vamsas.client.events.documentUpdateEvent";
*/
// read apphandle from 'lastUpdate' session file.
// pass apphandle name to appHandler ?
* Vamsas data) so an application may do its own data space initialization.
* TODO: decide if this is called when an app is connected to a stored
* session...
- public static final String DOCUMENT_CREATE = "org.vamsas.client.events.documentCreateEvent";
+ public static final String DOCUMENT_CREATE = "uk.ac.vamsas.client.events.documentCreateEvent";
*/
// check if this session's appInit flag is set - if not - generate event for this app.
// prolly don't need this at the moment - when an app does getDocument it can to the initing then.
* Generated prior to session Shutdown, after the last participating vamsas
* client has finalized.
* TODO: decide on purpose of this ? is this for benefit of multi-session Apps only ?
- public static final String SESSION_SHUTDOWN = "org.vamsas.client.events.SessionShutdownEvent";
+ public static final String SESSION_SHUTDOWN = "uk.ac.vamsas.client.events.SessionShutdownEvent";
*/
/**
* IClient.getDocument(), update and then IClient.updateDocument in the same
* handler thread.
* EventName: <Vamsas-session URN>
- * NewValue: org.vamsas.client.IClient for session.
+ * NewValue: uk.ac.vamsas.client.IClient for session.
*
- public static final String DOCUMENT_FINALIZEAPPDATA = "org.vamsas.client.events.DocumentFinalizeAppData";
+ public static final String DOCUMENT_FINALIZEAPPDATA = "uk.ac.vamsas.client.events.DocumentFinalizeAppData";
*/
// watch for finalization semaphore (last finalised sessionFile).
}
/**
* count handlers for a particular vamsas event
- * @param event string enumeration from org.vamsas.client.Events
+ * @param event string enumeration from uk.ac.vamsas.client.Events
* @return -1 for an invalid event, otherwise the number of handlers
*/
protected int countHandlersFor(String event) {
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.SessionHandle;
-import org.vamsas.client.UserHandle;
-import org.vamsas.client.VorbaId;
-import org.vamsas.client.VorbaIdFactory;
-import org.vamsas.client.Vobject;
import org.vamsas.objects.utils.document.VersionEntries;
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.SessionHandle;
+import uk.ac.vamsas.client.UserHandle;
+import uk.ac.vamsas.client.Vobject;
+import uk.ac.vamsas.client.VorbaId;
+import uk.ac.vamsas.client.VorbaIdFactory;
+
import java.util.Hashtable;
import java.util.zip.CRC32;
/**
this.extanthashv=new Hashtable();
}
/**
- * values for keys in this hash can be used to reference the org.vamsas.client.Vobject instance for the VorbaId string.
+ * values for keys in this hash can be used to reference the uk.ac.vamsas.client.Vobject instance for the VorbaId string.
* @return the hash of all VorbaIds
*/
protected Hashtable getVorbaIdHash() {
return extanthashv;
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#makeVorbaId()
+ * @see uk.ac.vamsas.client.VorbaIdFactory#makeVorbaId()
*/
public VorbaId makeVorbaId(Vobject vobject) {
if (session==null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#setSession(org.vamsas.client.SessionHandle)
+ * @see uk.ac.vamsas.client.VorbaIdFactory#setSession(uk.ac.vamsas.client.SessionHandle)
*/
protected void setSession(SessionHandle sessionhandle) {
if (sessionhandle!=null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#getSessionHandle()
+ * @see uk.ac.vamsas.client.VorbaIdFactory#getSessionHandle()
*/
public SessionHandle getSessionHandle() {
return session;
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#setClient(org.vamsas.client.ClientHandle)
+ * @see uk.ac.vamsas.client.VorbaIdFactory#setClient(uk.ac.vamsas.client.ClientHandle)
*/
protected void setClient(ClientHandle appHandle) {
if (appHandle!=null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#getClientHandle()
+ * @see uk.ac.vamsas.client.VorbaIdFactory#getClientHandle()
*/
public ClientHandle getClientHandle() {
return client;
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#setUser(org.vamsas.client.UserHandle)
+ * @see uk.ac.vamsas.client.VorbaIdFactory#setUser(uk.ac.vamsas.client.UserHandle)
*/
protected void setUser(UserHandle userHandle) {
if (userHandle!=null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.VorbaIdFactory#getUserHandle()
+ * @see uk.ac.vamsas.client.VorbaIdFactory#getUserHandle()
*/
public UserHandle getUserHandle() {
return user;
* @author jimp
*
*/
-public class SessionUrn extends org.vamsas.client.SessionUrn {
+public class SessionUrn extends uk.ac.vamsas.client.SessionUrn {
/**
* a simple client session urn prefix
*/
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.SessionHandle;
+
+import uk.ac.vamsas.client.SessionHandle;
/**
* @author <a href="mailto:pierre@ebi.ac.uk">Pierre MARGUERITE</a>
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.Events;
-import org.vamsas.client.IClient;
-import org.vamsas.client.IClientDocument;
-import org.vamsas.client.IObjectUpdate;
-import org.vamsas.client.InvalidSessionUrnException;
-import org.vamsas.client.SessionHandle;
-import org.vamsas.client.UserHandle;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.Entry;
import org.vamsas.objects.core.LockFile;
import org.vamsas.objects.utils.ProvenanceStuff;
import org.vamsas.objects.utils.document.VersionEntries;
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.Events;
+import uk.ac.vamsas.client.IClient;
+import uk.ac.vamsas.client.IClientDocument;
+import uk.ac.vamsas.client.IObjectUpdate;
+import uk.ac.vamsas.client.InvalidSessionUrnException;
+import uk.ac.vamsas.client.SessionHandle;
+import uk.ac.vamsas.client.UserHandle;
+
/**
* @author jimp
*/
/*
* (non-Javadoc)
* LATER: check that build substitution variables are correct
- * @see org.vamsas.client.IClient#getAbout()
+ * @see uk.ac.vamsas.client.IClient#getAbout()
*/
public String getAbout() {
return new String("VORBA SimpleClient version $version$ build $build$");
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#getSessionUrn()
+ * @see uk.ac.vamsas.client.IClient#getSessionUrn()
*/
public String getSessionUrn() {
return session.getSessionUrn();
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#getSessionHandle()
+ * @see uk.ac.vamsas.client.IClient#getSessionHandle()
*/
public SessionHandle getSessionHandle() {
// TODO: eliminate SessionHandle ? need to refactor interfaces.
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#getClientHandle()
+ * @see uk.ac.vamsas.client.IClient#getClientHandle()
*/
public ClientHandle getClientHandle() {
return client;
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#getUserHandle()
+ * @see uk.ac.vamsas.client.IClient#getUserHandle()
*/
public UserHandle getUserHandle() {
return user;
/**
* make all the PropertyChangeSupport objects for the
- * events described in org.vamsas.client.Event
+ * events described in uk.ac.vamsas.client.Event
* @return
*/
private static Hashtable initHandlers() {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener)
+ * @see uk.ac.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener)
*/
public void addDocumentUpdateHandler(PropertyChangeListener evt) {
if (handlers.containsKey(Events.DOCUMENT_UPDATE)) {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#finalizeClient()
+ * @see uk.ac.vamsas.client.IClient#finalizeClient()
*/
public void finalizeClient() {
// TODO: determine if this is last client in session
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#getClientDocument()
+ * @see uk.ac.vamsas.client.IClient#getClientDocument()
*/
public IClientDocument getClientDocument() throws IOException {
if (cdocument!=null) {
/*
* (non-Javadoc)
* @throws Errors for invalid newdoc parameter
- * @see org.vamsas.client.IClient#updateDocument(org.vamsas.client.IClientDocument)
+ * @see uk.ac.vamsas.client.IClient#updateDocument(uk.ac.vamsas.client.IClientDocument)
*/
public void updateDocument(IClientDocument newdoc) {
if (!(newdoc instanceof ClientDocument)) {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#storeDocument(java.io.File)
+ * @see uk.ac.vamsas.client.IClient#storeDocument(java.io.File)
*/
public void storeDocument(File location) {
/*
* (non-Javadoc)
*
- * @see org.vamsas.client.IClient#addVorbaEventHandler(java.lang.String,
+ * @see uk.ac.vamsas.client.IClient#addVorbaEventHandler(java.lang.String,
* java.beans.PropertyChangeListener)
*/
public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt) {
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClient#pollUpdate()
+ * @see uk.ac.vamsas.client.IClient#pollUpdate()
*/
public void pollUpdate() {
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClient#joinSession()
+ * @see uk.ac.vamsas.client.IClient#joinSession()
*/
public void joinSession() throws Exception {
// start the EventGenerator thread.
/* (non-Javadoc)
- * @see org.vamsas.client.IClient#importDocument(java.io.File)
+ * @see uk.ac.vamsas.client.IClient#importDocument(java.io.File)
*/
public void importDocument(File location) {
// TODO LATER: implement SimpleClient.importDocument()
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.IClientAppdata;
import org.vamsas.objects.core.AppData;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.User;
import org.vamsas.objects.utils.AppDataReference;
+import uk.ac.vamsas.client.IClientAppdata;
+
/**
* @author jimp
* Access interface to data chunks read from a VamsasArchiveReader stream
return null;
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getClientAppdata()
+ * @see uk.ac.vamsas.client.IClientAppdata#getClientAppdata()
*/
public byte[] getClientAppdata() {
return _getappdataByteArray(false);
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getClientInputStream()
+ * @see uk.ac.vamsas.client.IClientAppdata#getClientInputStream()
*/
public DataInput getClientInputStream() {
return _getappdataInputStream(false);
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getUserAppdata()
+ * @see uk.ac.vamsas.client.IClientAppdata#getUserAppdata()
*/
public byte[] getUserAppdata() {
return _getappdataByteArray(true);
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getUserInputStream()
+ * @see uk.ac.vamsas.client.IClientAppdata#getUserInputStream()
*/
public DataInput getUserInputStream() {
return _getappdataInputStream(true);
istrm.close();
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getClientOutputStream()
+ * @see uk.ac.vamsas.client.IClientAppdata#getClientOutputStream()
*/
public DataOutput getClientOutputStream() {
if (clientdoc==null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#getUserOutputStream()
+ * @see uk.ac.vamsas.client.IClientAppdata#getUserOutputStream()
*/
public DataOutput getUserOutputStream() {
if (clientdoc==null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#hasClientAppdata()
+ * @see uk.ac.vamsas.client.IClientAppdata#hasClientAppdata()
*/
public boolean hasClientAppdata() {
if (clientdoc==null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#hasUserAppdata()
+ * @see uk.ac.vamsas.client.IClientAppdata#hasUserAppdata()
*/
public boolean hasUserAppdata() {
if (clientdoc==null)
return false;
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#setClientAppdata(byte[])
+ * @see uk.ac.vamsas.client.IClientAppdata#setClientAppdata(byte[])
*/
public void setClientAppdata(byte[] data) {
if (clientdoc==null)
}
/* (non-Javadoc)
- * @see org.vamsas.client.IClientAppdata#setUserAppdata(byte[])
+ * @see uk.ac.vamsas.client.IClientAppdata#setUserAppdata(byte[])
*/
public void setUserAppdata(byte[] data) {
if (clientdoc==null)
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.IClient;
-import org.vamsas.client.IClientFactory;
-import org.vamsas.client.InvalidSessionUrnException;
-import org.vamsas.client.NoDefaultSessionException;
-import org.vamsas.client.SessionHandle;
-import org.vamsas.client.UserHandle;
+
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.IClient;
+import uk.ac.vamsas.client.IClientFactory;
+import uk.ac.vamsas.client.InvalidSessionUrnException;
+import uk.ac.vamsas.client.NoDefaultSessionException;
+import uk.ac.vamsas.client.SessionHandle;
+import uk.ac.vamsas.client.UserHandle;
/**
*
}
/**
- * @see org.vamsas.client.IClientFactory#getCurrentSessions()
+ * @see uk.ac.vamsas.client.IClientFactory#getCurrentSessions()
*/
public String[] getCurrentSessions()
{
}
/**
- * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle)
+ * @see uk.ac.vamsas.client.IClientFactory#getIClient(uk.ac.vamsas.client.ClientHandle)
*
* Creates a IClient object, using default UserHandle with system variables:"user.name" or "USERNAME")),
"host.name" or "HOSTNAME"
}
/**
- * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, java.lang.String)
+ * @see uk.ac.vamsas.client.IClientFactory#getIClient(uk.ac.vamsas.client.ClientHandle, java.lang.String)
*/
public IClient getIClient(ClientHandle applicationHandle, String sessionUrn) {
// TODO Auto-generated method stub
}
/**
- * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, org.vamsas.client.UserHandle, java.lang.String)
+ * @see uk.ac.vamsas.client.IClientFactory#getIClient(uk.ac.vamsas.client.ClientHandle, uk.ac.vamsas.client.UserHandle, java.lang.String)
*/
public IClient getIClient(ClientHandle applicationHandle, UserHandle userId,
String sessionUrn) {
}
/**
- * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, org.vamsas.client.UserHandle)
+ * @see uk.ac.vamsas.client.IClientFactory#getIClient(uk.ac.vamsas.client.ClientHandle, uk.ac.vamsas.client.UserHandle)
*/
public IClient getIClient(ClientHandle applicationHandle, UserHandle userId)
throws NoDefaultSessionException {
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.Vobject;
-import org.vamsas.client.VorbaIdFactory;
-import org.vamsas.client.VorbaXmlBinder;
import org.vamsas.objects.core.VAMSAS;
import org.vamsas.objects.core.VamsasDocument;
import org.vamsas.objects.utils.AppDataReference;
import org.vamsas.objects.utils.ProvenanceStuff;
import org.vamsas.objects.utils.document.VersionEntries;
+import uk.ac.vamsas.client.Vobject;
+import uk.ac.vamsas.client.VorbaIdFactory;
+import uk.ac.vamsas.client.VorbaXmlBinder;
+
/**
* Base class for SimpleClient Vamsas Document Object Manipulation
* holds static vamsasDocument from XML routines and
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.VorbaIdFactory;
+
+import uk.ac.vamsas.client.VorbaIdFactory;
/**
* @see SimpleDocBinding
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.IVorbaIdFactory;
-import org.vamsas.client.SessionHandle;
-import org.vamsas.client.UserHandle;
-import org.vamsas.client.VorbaIdFactory;
-import org.vamsas.client.VorbaXmlBinder;
-import org.vamsas.client.Vobject;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.VAMSAS;
import org.vamsas.objects.core.VamsasDocument;
import org.vamsas.objects.utils.ProvenanceStuff;
import org.vamsas.objects.utils.document.VersionEntries;
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.IVorbaIdFactory;
+import uk.ac.vamsas.client.SessionHandle;
+import uk.ac.vamsas.client.UserHandle;
+import uk.ac.vamsas.client.Vobject;
+import uk.ac.vamsas.client.VorbaIdFactory;
+import uk.ac.vamsas.client.VorbaXmlBinder;
+
/**
* Class for high-level io and Jar manipulation involved in creating
* or updating a vamsas archive (with backups).
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
import org.apache.log4j.FileAppender;
-import org.vamsas.client.ClientHandle;
-import org.vamsas.client.UserHandle;
+
+import uk.ac.vamsas.client.ClientHandle;
+import uk.ac.vamsas.client.UserHandle;
/**
* Does all the IO operations for a SimpleClient instance accessing
* a SimpleClient vamsas session.
*/
public static final String SESSION_LOG="Log.txt";
private static Log log = LogFactory.getLog(VamsasSession.class);
- protected Logger slog = Logger.getLogger("org.vamsas.client.SessionLog");
+ protected Logger slog = Logger.getLogger("uk.ac.vamsas.client.SessionLog");
/**
* setup the sessionLog using Log4j.
* @throws IOException