<VamsasDocument xmlns="http://www.vamsas.ac.uk/vamsasDocument"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.vamsas.ac.uk/vamsasDocument file:/homes/jimp/prj/new-eclipse/VamsasClient/schemas/vamsasDocument.xsd">
- <Version></Version>
- <LockFile></LockFile>
- <Provenance xmlns="http://www.vamsas.org"></Provenance>
+ <Version>alpha</Version>
+ <LockFile>some kind of resolvable session reference.</LockFile>
+ <Provenance xmlns="http://www.vamsas.org">
+ <entry>
+ <User>Jim</User>
+ <Action>updated the xml schema</Action>
+ <Date>2006-01-17</Date>
+ </entry>
+ </Provenance>
<VAMSAS xmlns="http://www.vamsas.org"></VAMSAS>
<VAMSAS xmlns="http://www.vamsas.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vamsas.org
http://www.vamsas.ac.uk/build/VamsasClient/schemas/vamsas.xsd">
</Provenance>
</DataSet>
</VAMSAS>
- <ApplicationData xmlns="http://www.vamsas.org"></ApplicationData>
+ <ApplicationData xmlns="http://www.vamsas.org" version="" name="" urn="">
+ <dataReference>name of accompanying jar entry containing data</dataReference> <!-- alternative is base64 encoded string in <data></data> -->
+ <User fullname="a user" organization="probably very little">
+ <dataReference>another accompanying jar entry or the data tag with embedded data.</dataReference>
+ </User>
+ </ApplicationData>
</VamsasDocument>
<xs:complexType>
<xs:complexContent>
<xs:extension base="vamsas:appData">
+ <xs:sequence>
+ <xs:element name="User" maxOccurs="unbounded" minOccurs="0">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="vamsas:appData">
+ <xs:attribute name="fullname" type="xs:string" use="required"/>
+ <xs:attribute name="organization" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="urn" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:complexType name="appData">
- <xs:sequence>
- <xs:choice>
- <xs:element name="data" type="xs:base64Binary"/>
- <xs:element name="dataReference" type="xs:string"/>
- </xs:choice>
- <xs:element name="User" maxOccurs="unbounded">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="vamsas:appData">
- <xs:attribute name="fullname" type="xs:string" use="required"/>
- <xs:attribute name="organization" type="xs:string" use="required"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:choice>
+ <xs:element name="data" type="xs:base64Binary"/>
+ <xs:element name="dataReference" type="xs:string"/>
+ </xs:choice>
</xs:complexType>
</xs:schema>
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
* to avoid validation exceptions when marshalling new objects
* into the vamsas document.
*/
-public class VorbaXmlBinder extends GeneralizedFieldHandler implements UnmarshalListener, MarshalListener {
+public class VorbaXmlBinder implements UnmarshalListener {
private final IVorbaIdFactory vorbafactory;
private final Vector obj;
if (doc.__vorba==null)
doc.__vorba = vorba;
doc.__ensure_instance_ids(); // this may take a while. Do we allow for cyclic references ?
- final Vector refstomake = new Vector();
- VorbaXmlBinder binder = new VorbaXmlBinder(vorba, refstomake, vorba.extantids);
- Marshaller marshaller = new Marshaller(outstream);
- marshaller.setMarshalAsDocument(true);
- marshaller.setMarshalListener(binder);
- marshaller.marshal(doc);
+ doc.marshal(outstream);
}
private static boolean ensure_references(Vector unrefed, Hashtable objrefs) {
}
return null;
}
-
- /* (non-Javadoc)
- * @see org.exolab.castor.xml.MarshalListener#postMarshal(java.lang.Object)
- */
- public void postMarshal(Object object) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.xml.MarshalListener#preMarshal(java.lang.Object)
- */
- public boolean preMarshal(Object newobj) {
- if (newobj instanceof object) {
- object nobj = (object) newobj;
- nobj.set__stored_in_document(true);
- Field fd = null;
- try {
- if (nobj.isRegisterable()) {
- // make sure the id field is set
- nobj.__vorba = vorbafactory;
- fd = nobj.getClass().getField("_id");
- if (fd.get(nobj) != null) {
- fd.set(nobj, nobj.getVorbaId().getId());
- /* all thats needed perhaps
- *
- *if (idstring.length() > 0) {
- if (!objrefs.containsKey(idstring)) {
- objrefs.put(idstring, nobj);
- nobj.setVorbaId(VorbaId.newId(idstring));
- } else {
- System.err.println("Serious problem : duplicate id '"+idstring+"' found! expect badness.");
- return false; // TODO: HANDLE duplicate XML ids correctly
- }*/
- }
- }
- } catch (Exception e) {
- return false;
- };
-
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#convertUponGet(java.lang.Object)
- */
- public Object convertUponGet(Object value) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#convertUponSet(java.lang.Object)
- */
- public Object convertUponSet(Object value) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#getFieldType()
- */
- public Class getFieldType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#newInstance(java.lang.Object, java.lang.Object[])
- */
- public Object newInstance(Object parent, Object[] args) throws IllegalStateException {
- // TODO Auto-generated method stub
- return super.newInstance(parent, args);
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#newInstance(java.lang.Object)
- */
- public Object newInstance(Object parent) throws IllegalStateException {
- // TODO Auto-generated method stub
- return super.newInstance(parent);
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.GeneralizedFieldHandler#setCollectionIteration(boolean)
- */
- public void setCollectionIteration(boolean autoCollectionIteration) {
- // TODO Auto-generated method stub
- super.setCollectionIteration(autoCollectionIteration);
- }
-
- /* (non-Javadoc)
- * @see org.exolab.castor.mapping.AbstractFieldHandler#hasValue(java.lang.Object)
- */
- public boolean hasValue(Object object) {
- // TODO Auto-generated method stub
- return super.hasValue(object);
- }
}
\ No newline at end of file
* cascade through all fields referring to an instance of object
* calling the same method on them.
* TODO: LATER: properly apply castors own field mechanisms to get at accessors
- *
+ * TODO: FIX CYCLIC __ensure+instance_ids
*/
protected void __ensure_instance_ids() {
if (__vorba==null)
private UserHandle user;
private CRC32 unique=new CRC32(); // used to attempt a unique but predictable stream for IDs
private String idstring;
- int sequence=0; // incrementing value for next new ID
+ int sequence=1; // incrementing value for next new ID
/**
*
*/
this.user = user;
unique.reset();
unique.update(new Object[] { session, client, user}.toString().getBytes());
- idstring = "vamsas:"+session.getSessionUrn()+":"+unique.getValue()+":"+client.getClientUrn()+"/";
- sequence=0;
+ // TODO: Ensure format of URNs and use standard composition methods.
+ idstring = client.getClientUrn()+":"+unique.getValue()+"/";
extantids=new Hashtable();
}
throw new Error("makeVorbaId called on improperly initialised IdFactory object!");
String newidstring;
do {
- if (sequence!=0) {
+ if (sequence>0) {
sequence++;
} else {
idstring+="1/";
+ sequence=1;
}
newidstring=idstring+Integer.toString(sequence);
} while (extantids.containsKey(newidstring));
this.archive = archive; // archive is written in place.
virginArchive = true;
}
- this.openArchive();
+ this.openArchive(); // open archive
}
/**
* name of backup of existing archive that has been updated/overwritten.
if (unmarsh==null)
log.fatal("Couldn't unmarshall document!");
- object[] vobjs = (object[]) unmarsh[0];
+ object vobjs = (object) unmarsh[0];
if (vobjs!=null) {
- VamsasDocument doc=(VamsasDocument) vobjs[0];
+ VamsasDocument doc=(VamsasDocument) vobjs;
if (doc!=null)
return doc;
}
}
public void putVamsasDocument(VamsasDocument doc) throws IOException,
org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- VorbaIdFactory vorba = makeDefaultFactory(null);
+ VorbaIdFactory vorba = makeDefaultFactory(getVorba());
VorbaXmlBinder.putVamsasDocument(getDocumentOutputStream(), vorba, doc);
}
}
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
-import java.util.Enumeration;
-import java.util.Vector;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
//--------------------------/
/**
- * Field _appDataChoice
+ * Internal choice value storage
*/
- private org.vamsas.objects.core.AppDataChoice _appDataChoice;
+ private java.lang.Object _choiceValue;
/**
- * Field _userList
+ * Field _data
*/
- private java.util.Vector _userList;
+ private byte[] _data;
+
+ /**
+ * Field _dataReference
+ */
+ private java.lang.String _dataReference;
//----------------/
public AppData()
{
super();
- _userList = new Vector();
} //-- org.vamsas.objects.core.AppData()
//-----------/
/**
- * Method addUser
- *
- *
- *
- * @param vUser
- */
- public void addUser(org.vamsas.objects.core.User vUser)
- throws java.lang.IndexOutOfBoundsException
- {
- _userList.addElement(vUser);
- } //-- void addUser(org.vamsas.objects.core.User)
-
- /**
- * Method addUser
- *
- *
- *
- * @param index
- * @param vUser
- */
- public void addUser(int index, org.vamsas.objects.core.User vUser)
- throws java.lang.IndexOutOfBoundsException
- {
- _userList.insertElementAt(vUser, index);
- } //-- void addUser(int, org.vamsas.objects.core.User)
-
- /**
- * Method enumerateUser
- *
- *
- *
- * @return Enumeration
- */
- public java.util.Enumeration enumerateUser()
- {
- return _userList.elements();
- } //-- java.util.Enumeration enumerateUser()
-
- /**
* Note: hashCode() has not been overriden
*
* @param obj
if (obj instanceof AppData) {
AppData temp = (AppData)obj;
- if (this._appDataChoice != null) {
- if (temp._appDataChoice == null) return false;
- else if (!(this._appDataChoice.equals(temp._appDataChoice)))
+ if (this._choiceValue != null) {
+ if (temp._choiceValue == null) return false;
+ else if (!(this._choiceValue.equals(temp._choiceValue)))
return false;
}
- else if (temp._appDataChoice != null)
+ else if (temp._choiceValue != null)
return false;
- if (this._userList != null) {
- if (temp._userList == null) return false;
- else if (!(this._userList.equals(temp._userList)))
+ if (this._data != null) {
+ if (temp._data == null) return false;
+ else if (!(this._data.equals(temp._data)))
return false;
}
- else if (temp._userList != null)
+ else if (temp._data != null)
+ return false;
+ if (this._dataReference != null) {
+ if (temp._dataReference == null) return false;
+ else if (!(this._dataReference.equals(temp._dataReference)))
+ return false;
+ }
+ else if (temp._dataReference != null)
return false;
return true;
}
} //-- boolean equals(java.lang.Object)
/**
- * Returns the value of field 'appDataChoice'.
- *
- * @return AppDataChoice
- * @return the value of field 'appDataChoice'.
- */
- public org.vamsas.objects.core.AppDataChoice getAppDataChoice()
- {
- return this._appDataChoice;
- } //-- org.vamsas.objects.core.AppDataChoice getAppDataChoice()
-
- /**
- * Method getUser
+ * Returns the value of field 'choiceValue'. The field
+ * 'choiceValue' has the following description: Internal choice
+ * value storage
*
- *
- *
- * @param index
- * @return User
+ * @return Object
+ * @return the value of field 'choiceValue'.
*/
- public org.vamsas.objects.core.User getUser(int index)
- throws java.lang.IndexOutOfBoundsException
+ public java.lang.Object getChoiceValue()
{
- //-- check bounds for index
- if ((index < 0) || (index > _userList.size())) {
- throw new IndexOutOfBoundsException("getUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
- }
-
- return (org.vamsas.objects.core.User) _userList.elementAt(index);
- } //-- org.vamsas.objects.core.User getUser(int)
+ return this._choiceValue;
+ } //-- java.lang.Object getChoiceValue()
/**
- * Method getUser
+ * Returns the value of field 'data'.
*
- *
- *
- * @return User
+ * @return byte
+ * @return the value of field 'data'.
*/
- public org.vamsas.objects.core.User[] getUser()
+ public byte[] getData()
{
- int size = _userList.size();
- org.vamsas.objects.core.User[] mArray = new org.vamsas.objects.core.User[size];
- for (int index = 0; index < size; index++) {
- mArray[index] = (org.vamsas.objects.core.User) _userList.elementAt(index);
- }
- return mArray;
- } //-- org.vamsas.objects.core.User[] getUser()
+ return this._data;
+ } //-- byte[] getData()
/**
- * Method getUserCount
- *
+ * Returns the value of field 'dataReference'.
*
- *
- * @return int
+ * @return String
+ * @return the value of field 'dataReference'.
*/
- public int getUserCount()
+ public java.lang.String getDataReference()
{
- return _userList.size();
- } //-- int getUserCount()
+ return this._dataReference;
+ } //-- java.lang.String getDataReference()
/**
* Method isValid
} //-- void marshal(org.xml.sax.ContentHandler)
/**
- * Method removeAllUser
- *
- */
- public void removeAllUser()
- {
- _userList.removeAllElements();
- } //-- void removeAllUser()
-
- /**
- * Method removeUser
- *
- *
- *
- * @param index
- * @return User
- */
- public org.vamsas.objects.core.User removeUser(int index)
- {
- java.lang.Object obj = _userList.elementAt(index);
- _userList.removeElementAt(index);
- return (org.vamsas.objects.core.User) obj;
- } //-- org.vamsas.objects.core.User removeUser(int)
-
- /**
- * Sets the value of field 'appDataChoice'.
- *
- * @param appDataChoice the value of field 'appDataChoice'.
- */
- public void setAppDataChoice(org.vamsas.objects.core.AppDataChoice appDataChoice)
- {
- this._appDataChoice = appDataChoice;
- } //-- void setAppDataChoice(org.vamsas.objects.core.AppDataChoice)
-
- /**
- * Method setUser
- *
- *
+ * Sets the value of field 'data'.
*
- * @param index
- * @param vUser
+ * @param data the value of field 'data'.
*/
- public void setUser(int index, org.vamsas.objects.core.User vUser)
- throws java.lang.IndexOutOfBoundsException
+ public void setData(byte[] data)
{
- //-- check bounds for index
- if ((index < 0) || (index > _userList.size())) {
- throw new IndexOutOfBoundsException("setUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
- }
- _userList.setElementAt(vUser, index);
- } //-- void setUser(int, org.vamsas.objects.core.User)
+ this._data = data;
+ this._choiceValue = data;
+ } //-- void setData(byte)
/**
- * Method setUser
- *
+ * Sets the value of field 'dataReference'.
*
- *
- * @param userArray
+ * @param dataReference the value of field 'dataReference'.
*/
- public void setUser(org.vamsas.objects.core.User[] userArray)
+ public void setDataReference(java.lang.String dataReference)
{
- //-- copy array
- _userList.removeAllElements();
- for (int i = 0; i < userArray.length; i++) {
- _userList.addElement(userArray[i]);
- }
- } //-- void setUser(org.vamsas.objects.core.User)
+ this._dataReference = dataReference;
+ this._choiceValue = dataReference;
+ } //-- void setDataReference(java.lang.String)
/**
* Method unmarshal
xmlName = "appData";
//-- set grouping compositor
- setCompositorAsSequence();
+ setCompositorAsChoice();
org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
org.exolab.castor.mapping.FieldHandler handler = null;
org.exolab.castor.xml.FieldValidator fieldValidator = null;
//-- initialize element descriptors
- //-- _appDataChoice
- desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AppDataChoice.class, "_appDataChoice", "-error-if-this-is-used-", org.exolab.castor.xml.NodeType.Element);
+ //-- _data
+ desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(byte[].class, "_data", "data", org.exolab.castor.xml.NodeType.Element);
handler = new org.exolab.castor.xml.XMLFieldHandler() {
public java.lang.Object getValue( java.lang.Object object )
throws IllegalStateException
{
AppData target = (AppData) object;
- return target.getAppDataChoice();
+ return target.getData();
}
public void setValue( java.lang.Object object, java.lang.Object value)
throws IllegalStateException, IllegalArgumentException
{
try {
AppData target = (AppData) object;
- target.setAppDataChoice( (org.vamsas.objects.core.AppDataChoice) value);
+ target.setData( (byte[]) value);
}
catch (java.lang.Exception ex) {
throw new IllegalStateException(ex.toString());
}
}
public java.lang.Object newInstance( java.lang.Object parent ) {
- return new org.vamsas.objects.core.AppDataChoice();
+ return null;
}
};
desc.setHandler(handler);
- desc.setContainer(true);
- desc.setClassDescriptor(new org.vamsas.objects.core.AppDataChoiceDescriptor());
desc.setNameSpaceURI("http://www.vamsas.org");
desc.setRequired(true);
desc.setMultivalued(false);
addFieldDescriptor(desc);
- //-- validation code for: _appDataChoice
+ //-- validation code for: _data
fieldValidator = new org.exolab.castor.xml.FieldValidator();
fieldValidator.setMinOccurs(1);
{ //-- local scope
}
desc.setValidator(fieldValidator);
- //-- _userList
- desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.User.class, "_userList", "User", org.exolab.castor.xml.NodeType.Element);
+ //-- _dataReference
+ desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dataReference", "dataReference", org.exolab.castor.xml.NodeType.Element);
+ desc.setImmutable(true);
handler = new org.exolab.castor.xml.XMLFieldHandler() {
public java.lang.Object getValue( java.lang.Object object )
throws IllegalStateException
{
AppData target = (AppData) object;
- return target.getUser();
+ return target.getDataReference();
}
public void setValue( java.lang.Object object, java.lang.Object value)
throws IllegalStateException, IllegalArgumentException
{
try {
AppData target = (AppData) object;
- target.addUser( (org.vamsas.objects.core.User) value);
+ target.setDataReference( (java.lang.String) value);
}
catch (java.lang.Exception ex) {
throw new IllegalStateException(ex.toString());
}
}
public java.lang.Object newInstance( java.lang.Object parent ) {
- return new org.vamsas.objects.core.User();
+ return null;
}
};
desc.setHandler(handler);
desc.setNameSpaceURI("http://www.vamsas.org");
desc.setRequired(true);
- desc.setMultivalued(true);
+ desc.setMultivalued(false);
addFieldDescriptor(desc);
- //-- validation code for: _userList
+ //-- validation code for: _dataReference
fieldValidator = new org.exolab.castor.xml.FieldValidator();
fieldValidator.setMinOccurs(1);
{ //-- local scope
+ StringValidator typeValidator = new StringValidator();
+ typeValidator.setWhiteSpace("preserve");
+ fieldValidator.setValidator(typeValidator);
}
desc.setValidator(fieldValidator);
} //-- org.vamsas.objects.core.AppDataDescriptor()
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
+import java.util.Enumeration;
+import java.util.Vector;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
*/
private java.lang.String _urn;
+ /**
+ * Field _userList
+ */
+ private java.util.Vector _userList;
+
//----------------/
//- Constructors -/
public ApplicationData()
{
super();
+ _userList = new Vector();
} //-- org.vamsas.objects.core.ApplicationData()
//-----------/
/**
+ * Method addUser
+ *
+ *
+ *
+ * @param vUser
+ */
+ public void addUser(org.vamsas.objects.core.User vUser)
+ throws java.lang.IndexOutOfBoundsException
+ {
+ _userList.addElement(vUser);
+ } //-- void addUser(org.vamsas.objects.core.User)
+
+ /**
+ * Method addUser
+ *
+ *
+ *
+ * @param index
+ * @param vUser
+ */
+ public void addUser(int index, org.vamsas.objects.core.User vUser)
+ throws java.lang.IndexOutOfBoundsException
+ {
+ _userList.insertElementAt(vUser, index);
+ } //-- void addUser(int, org.vamsas.objects.core.User)
+
+ /**
+ * Method enumerateUser
+ *
+ *
+ *
+ * @return Enumeration
+ */
+ public java.util.Enumeration enumerateUser()
+ {
+ return _userList.elements();
+ } //-- java.util.Enumeration enumerateUser()
+
+ /**
* Note: hashCode() has not been overriden
*
* @param obj
}
else if (temp._urn != null)
return false;
+ if (this._userList != null) {
+ if (temp._userList == null) return false;
+ else if (!(this._userList.equals(temp._userList)))
+ return false;
+ }
+ else if (temp._userList != null)
+ return false;
return true;
}
return false;
} //-- java.lang.String getUrn()
/**
+ * Method getUser
+ *
+ *
+ *
+ * @param index
+ * @return User
+ */
+ public org.vamsas.objects.core.User getUser(int index)
+ throws java.lang.IndexOutOfBoundsException
+ {
+ //-- check bounds for index
+ if ((index < 0) || (index > _userList.size())) {
+ throw new IndexOutOfBoundsException("getUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
+ }
+
+ return (org.vamsas.objects.core.User) _userList.elementAt(index);
+ } //-- org.vamsas.objects.core.User getUser(int)
+
+ /**
+ * Method getUser
+ *
+ *
+ *
+ * @return User
+ */
+ public org.vamsas.objects.core.User[] getUser()
+ {
+ int size = _userList.size();
+ org.vamsas.objects.core.User[] mArray = new org.vamsas.objects.core.User[size];
+ for (int index = 0; index < size; index++) {
+ mArray[index] = (org.vamsas.objects.core.User) _userList.elementAt(index);
+ }
+ return mArray;
+ } //-- org.vamsas.objects.core.User[] getUser()
+
+ /**
+ * Method getUserCount
+ *
+ *
+ *
+ * @return int
+ */
+ public int getUserCount()
+ {
+ return _userList.size();
+ } //-- int getUserCount()
+
+ /**
* Returns the value of field 'version'.
*
* @return String
} //-- void marshal(org.xml.sax.ContentHandler)
/**
+ * Method removeAllUser
+ *
+ */
+ public void removeAllUser()
+ {
+ _userList.removeAllElements();
+ } //-- void removeAllUser()
+
+ /**
+ * Method removeUser
+ *
+ *
+ *
+ * @param index
+ * @return User
+ */
+ public org.vamsas.objects.core.User removeUser(int index)
+ {
+ java.lang.Object obj = _userList.elementAt(index);
+ _userList.removeElementAt(index);
+ return (org.vamsas.objects.core.User) obj;
+ } //-- org.vamsas.objects.core.User removeUser(int)
+
+ /**
* Sets the value of field 'name'.
*
* @param name the value of field 'name'.
} //-- void setUrn(java.lang.String)
/**
+ * Method setUser
+ *
+ *
+ *
+ * @param index
+ * @param vUser
+ */
+ public void setUser(int index, org.vamsas.objects.core.User vUser)
+ throws java.lang.IndexOutOfBoundsException
+ {
+ //-- check bounds for index
+ if ((index < 0) || (index > _userList.size())) {
+ throw new IndexOutOfBoundsException("setUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
+ }
+ _userList.setElementAt(vUser, index);
+ } //-- void setUser(int, org.vamsas.objects.core.User)
+
+ /**
+ * Method setUser
+ *
+ *
+ *
+ * @param userArray
+ */
+ public void setUser(org.vamsas.objects.core.User[] userArray)
+ {
+ //-- copy array
+ _userList.removeAllElements();
+ for (int i = 0; i < userArray.length; i++) {
+ _userList.addElement(userArray[i]);
+ }
+ } //-- void setUser(org.vamsas.objects.core.User)
+
+ /**
* Sets the value of field 'version'.
*
* @param version the value of field 'version'.
setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor());
nsURI = "http://www.vamsas.org";
xmlName = "ApplicationData";
+
+ //-- set grouping compositor
+ setCompositorAsSequence();
org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
org.exolab.castor.mapping.FieldHandler handler = null;
org.exolab.castor.xml.FieldValidator fieldValidator = null;
desc.setValidator(fieldValidator);
//-- initialize element descriptors
+ //-- _userList
+ desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.User.class, "_userList", "User", org.exolab.castor.xml.NodeType.Element);
+ handler = new org.exolab.castor.xml.XMLFieldHandler() {
+ public java.lang.Object getValue( java.lang.Object object )
+ throws IllegalStateException
+ {
+ ApplicationData target = (ApplicationData) object;
+ return target.getUser();
+ }
+ public void setValue( java.lang.Object object, java.lang.Object value)
+ throws IllegalStateException, IllegalArgumentException
+ {
+ try {
+ ApplicationData target = (ApplicationData) object;
+ target.addUser( (org.vamsas.objects.core.User) value);
+ }
+ catch (java.lang.Exception ex) {
+ throw new IllegalStateException(ex.toString());
+ }
+ }
+ public java.lang.Object newInstance( java.lang.Object parent ) {
+ return new org.vamsas.objects.core.User();
+ }
+ };
+ desc.setHandler(handler);
+ desc.setNameSpaceURI("http://www.vamsas.org");
+ desc.setMultivalued(true);
+ addFieldDescriptor(desc);
+
+ //-- validation code for: _userList
+ fieldValidator = new org.exolab.castor.xml.FieldValidator();
+ fieldValidator.setMinOccurs(0);
+ { //-- local scope
+ }
+ desc.setValidator(fieldValidator);
} //-- org.vamsas.objects.core.ApplicationDataDescriptor()
import java.io.InputStream;
+import org.vamsas.client.object;
import org.vamsas.client.simpleclient.VamsasArchiveReader;
import org.vamsas.objects.core.Alignment;
+import org.vamsas.objects.core.AppData;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.DataSet;
import org.vamsas.objects.core.Entry;
import org.vamsas.objects.core.Provenance;
import org.vamsas.objects.core.Tree;
+import org.vamsas.objects.core.User;
import org.vamsas.objects.core.VAMSAS;
import org.vamsas.objects.core.VamsasDocument;
/**
System.out.println(pe[i].getDate()+"\t'"+pe[i].getUser()+"'\t"+pe[i].getAction());
return true;
}
+ public static boolean appDataEntryReport(AppData appD, VamsasArchiveReader archive, boolean cascade) {
+ if (appD!=null) {
+ boolean nulldata=false;
+ if (appD.getDataReference()!=null) {
+ String appData=appD.getDataReference();
+ if (appData==null) { System.out.println("Empty DataReference - not valid ?"); }
+ else
+ if (appData.length()>1) {
+ System.out.print("a reference ("+appData+")");
+ InputStream jstrm;
+ if ((jstrm=archive.getAppdataStream(appData))!=null)
+ System.out.println(" which resolves to a JarEntry.");
+ else {
+ System.out.println(" which does not resolve to a JarEntry.");
+ System.err.println("Unresolved appdata reference '"+appData+"'");
+ }
+ } else {
+ nulldata=true;
+ }
+ } else {
+ if (appD.getData()==null)
+ nulldata &= true;
+ else
+ System.out.println("an embedded chunk of "+appD.getData().length+" bytes.");
+ }
+ if (nulldata)
+ System.out.println("Null AppData reference/data chunk.");
+ }
+ return true;
+ }
+
+ public static boolean appDataReport(ApplicationData appD, VamsasArchiveReader archive, boolean cascade) {
+ if (appD!=null) {
+ // Report on root appData
+ appDataEntryReport(appD, archive, cascade);
+ if (appD.getUserCount()>0) {
+ User users[] = appD.getUser();
+ for (int i=0,j=users.length; i<j; i++) {
+ System.out.println("Data for User '"+users[i].getFullname()+"' of '"+users[i].getOrganization()+"'");
+ appDataEntryReport(users[i], archive, cascade);
+ }
+ }
+ }
+
+ return true;
+ }
public static boolean reportDocument(VamsasDocument document, VamsasArchiveReader archive, boolean cascade) {
if (document!=null) {
System.out.println("Vamsas Document version '"+document.getVersion()+"'");
reportProvenance(document.getProvenance());
- System.out.print("Document contains "+document.getVAMSASCount()+" VAMSAS Elements and "+document.getApplicationDataCount()+" elements.\n");
+ System.out.print("Document contains "+document.getVAMSASCount()+" VAMSAS Elements and "+document.getApplicationDataCount()+" Application data elements.\n");
if (document.getVAMSASCount()>0 && cascade)
rootReport(document.getVAMSAS(), true);
if (document.getApplicationDataCount()>0) {
ApplicationData appd[] = document.getApplicationData();
for (int i=0,j=appd.length; i<j; i++) {
System.out.print("Application "+i+": '"+appd[i].getName()+"'\nVersion '"+appd[i].getVersion()+"'\nURN: '"+appd[i].getUrn()+"'\n");
- System.out.print("AppData is ");
- if (appd[i].getAppDataChoice().getDataReference()!=null) {
- String appData=appd[i].getAppDataChoice().getDataReference();
- if (appData.length()>1) {
- System.out.print("a reference ("+appData+")");
- InputStream jstrm;
- if ((jstrm=archive.getAppdataStream(appData))!=null)
- System.out.println(" which resolves to a JarEntry.");
- else {
- System.out.println(" which does not resolve to a JarEntry.");
- System.err.println("Unresolved appdata reference '"+appData+"'");
- }
- } else {
- System.out.println("an empty reference.");
- }
- } else {
- System.out.println("an embedded chunk of "+appd[i].getAppDataChoice().getData().length+" bytes.");
- }
+ System.out.print("AppData is :");
+ appDataReport(appd[i], archive, cascade);
}
}
if (!ht.containsKey(appdatas[i].getUrn())) {
Hashtable aphash = new Hashtable();
ht.put(appdatas[i].getUrn(), aphash);
- aphash.put(appdatas[i], appdatas[i].getAppDataChoice().getDataReference());
+ aphash.put(appdatas[i], appdatas[i].getDataReference());
} else {
// ensure urns and references are unique
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.vamsas.client.simpleclient.*;
-import org.vamsas.objects.core.AppDataChoice;
import org.vamsas.objects.core.ApplicationData;
import org.vamsas.objects.core.User;
import org.vamsas.objects.core.VAMSAS;
// open another and...
ApplicationData appdata = new ApplicationData();
appdata.setName("org.vamsas.test.simpleclient.VamsasArchive");
- appdata.setAppDataChoice(new AppDataChoice());
- appdata.getAppDataChoice().setData(new String("this is some test data.").getBytes());
+ appdata.setData(new String("this is some test data.").getBytes());
User apuser = new User();
apuser.setFullname("arnold Bugger esq");
apuser.setOrganization("disOrganised");
String appdata_ref = "vamsas:org.vamsas.test.simpleclient.VamsasArchive/"+apuser.getOrganization()+"/"+apuser.getFullname();
- org.vamsas.client.simpleclient.VamsasArchive va = new org.vamsas.client.simpleclient.VamsasArchive(backup, true);
+
+
+ File newf=new File(av.getAbsolutePath()+"_new.zip");
+ org.vamsas.client.simpleclient.VamsasArchive va = new org.vamsas.client.simpleclient.VamsasArchive(newf, true);
log.info("Getting the document from the backup-original.");
VamsasDocument vadoc;
VamsasArchiveReader vread = va.getOriginalArchiveReader();
- vadoc = va.getVamsasDocument();
+ vadoc = doc; // putting original data into new archive.
log.info("Got document. Adding stuff.");
-
- if (vread.getAppdataStream(appdata_ref)!=null) {
- int i=0;
- while (vread.getAppdataStream(appdata_ref+"/"+Integer.toString(++i))!=null)
+ if (vread!=null) {
+ if (vread.getAppdataStream(appdata_ref)!=null) {
+ int i=0;
+ while (vread.getAppdataStream(appdata_ref+"/"+Integer.toString(++i))!=null)
;
- appdata_ref+="/"+Integer.toString(i);
+ appdata_ref+="/"+Integer.toString(i);
+ }
}
log.info("Writing an apdata reference using AppDataStream interface.");
- apuser.setAppDataChoice(new AppDataChoice());
- apuser.getAppDataChoice().setDataReference(appdata_ref);
+ apuser.setDataReference(appdata_ref);
appdata.addUser(apuser);
- // TODO: FIX CYCLIC __ensure+instance_ids
+ appdata.setVersion("noggin");
+ appdata.setUrn("program:/the.nog/");
// TODO: FIX schema - User.addUser is unsatisfiable!
- apuser.addUser(apuser);
ObjectOutputStream apdos = new ObjectOutputStream(va.getAppDataStream(appdata_ref));
apdos.writeObject(appdata_ref);
apdos.writeObject(apuser); // some random content
log.info("Preparing to write new document.");
doc.addApplicationData(appdata);
doc.addVAMSAS(Core.getDemoVamsas());
+
va.putVamsasDocument(doc); // gets stream and puts it.
// TODO: verify that the vxml stream close method overridden ?
va.closeArchive();
+
log.info("Dump of new vamsas document :");
- va = new org.vamsas.client.simpleclient.VamsasArchive(backup, true); // TODO - refactor Reader class to have deserializing helpers
+ va = new org.vamsas.client.simpleclient.VamsasArchive(newf, true); // TODO - refactor Reader class to have deserializing helpers
ArchiveReports.reportDocument(va.getVamsasDocument(), va.getOriginalArchiveReader(), true);
// backup.delete(); // tidy up
}