|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.vamsas.client.simpleclient.VamsasArchive
Class for high-level io and Jar manipulation involved in creating or updating a vamsas archive (with backups). Writes to a temporary file and then swaps new file for backup. uses the sessionFile locking mechanism for safe I/O
Field Summary | |
protected SimpleDocument |
vorba
|
Constructor Summary | |
VamsasArchive(java.io.File archive,
boolean vamsasdocument)
Create a new vamsas archive File locks are made immediately to avoid contention |
|
VamsasArchive(java.io.File archive,
boolean vamsasdocument,
boolean overwrite)
|
|
VamsasArchive(java.io.File archive,
boolean overwrite,
boolean vamsasdocument,
SessionFile extantLock)
|
|
VamsasArchive(VamsasFile archive)
read and write to archive - will not overwrite original contents, and will always write an up to date vamsas document structure. |
|
VamsasArchive(VamsasFile archive,
boolean vamsasdocument,
boolean overwrite)
Constructor for accessing Files under file-lock management (ie a session file) |
Method Summary | |
protected boolean |
_validNewAppDataReference(java.lang.String newAppDataReference)
Validates the AppDataReference: not null and not already written to archive. |
java.io.File |
backupFile()
called by app to get name of backup if it was made. |
boolean |
cancelArchive()
Stops any current write to archive, and reverts to the backup if it exists. |
void |
closeArchive()
Tidies up and closes archive, removing any backups that were created. |
AppDataOutputStream |
getAppDataStream(java.lang.String appdataReference)
Opens and returns the applicationData output stream for the appdataReference string. |
protected java.lang.String |
getDocumentJarEntry()
|
java.io.PrintWriter |
getDocumentOutputStream()
Safely initializes the VAMSAS XML document Jar Entry. |
VamsasArchiveReader |
getOriginalArchiveReader()
Access original archive if it exists, pass the reader to the client Note: this is NOT thread safe and a call to closeArchive() will by necessity close and invalidate the VamsasArchiveReader object. |
Vobject[] |
getOriginalRoots()
returns original document's root vamsas elements. |
static Vobject[] |
getOriginalRoots(VamsasArchive ths)
Access original document if it exists, and get VAMSAS root objects. |
static VamsasDocument |
getOriginalVamsasDocument(VamsasArchive ths)
Access the original vamsas document for a VamsasArchive class, and return it. |
static VamsasDocument |
getOriginalVamsasDocument(VamsasArchive ths,
VorbaIdFactory vorba)
Uses VorbaXmlBinder to retrieve the VamsasDocument from the original archive referred to by ths |
VamsasDocument |
getVamsasDocument()
|
VamsasDocument |
getVamsasDocument(java.lang.String provenance_user,
java.lang.String provenance_action,
java.lang.String version)
Return the original document or a new empty document with initial provenance entry. |
VorbaIdFactory |
getVorba()
|
protected boolean |
isDocumentWritten()
|
void |
putVamsasDocument(VamsasDocument doc)
|
void |
putVamsasDocument(VamsasDocument doc,
VorbaIdFactory vorba)
|
void |
setVorba(VorbaIdFactory Vorba)
|
boolean |
transferAppDataEntry(java.lang.String AppDataReference)
Convenience method to copy over the referred entry from the backup to the new version. |
boolean |
transferAppDataEntry(java.lang.String AppDataReference,
java.lang.String NewAppDataReference)
Transfers an AppDataReference from old to new vamsas archive, with a name change. |
boolean |
transferRemainingAppDatas()
transfers any AppDataReferences existing in the old document that haven't already been transferred to the new one LATER: do the same for transfers requiring a namechange - more document dependent. |
boolean |
writeAppdataFromStream(java.lang.String AppDataReference,
java.io.InputStream adstream)
write data from a stream into an appData reference. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SimpleDocument vorba
Constructor Detail |
public VamsasArchive(java.io.File archive, boolean vamsasdocument) throws java.io.IOException
archive
- - file spec for new vamsas archivevamsasdocument
- true if archive is to be a fully fledged vamsas document archive
java.io.IOException
- if call to accessOriginal failed for updates, or openArchive
failed.public VamsasArchive(java.io.File archive, boolean vamsasdocument, boolean overwrite) throws java.io.IOException
public VamsasArchive(VamsasFile archive, boolean vamsasdocument, boolean overwrite) throws java.io.IOException
archive
- vamsasdocument
- overwrite
-
java.io.IOException
public VamsasArchive(VamsasFile archive) throws java.io.IOException
archive
-
java.io.IOException
public VamsasArchive(java.io.File archive, boolean overwrite, boolean vamsasdocument, SessionFile extantLock) throws java.io.IOException
archive
- file to writeoverwrite
- true if original contents should be deletedvamsasdocument
- true if a proper VamsasDocument archive is to be written.extantLock
- SessionFile object holding a lock for the
java.io.IOException
Method Detail |
public static Vobject[] getOriginalRoots(VamsasArchive ths) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
ths
-
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths, VorbaIdFactory vorba) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
ths
- vorba
-
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public java.io.File backupFile()
public boolean cancelArchive()
public void closeArchive() throws java.io.IOException
java.io.IOException
public AppDataOutputStream getAppDataStream(java.lang.String appdataReference) throws java.io.IOException
appdataReference
-
java.io.IOException
protected java.lang.String getDocumentJarEntry()
public java.io.PrintWriter getDocumentOutputStream() throws java.io.IOException
java.io.IOException
- if a document entry has already been written.public VamsasArchiveReader getOriginalArchiveReader() throws java.io.IOException
java.io.IOException
public Vobject[] getOriginalRoots() throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public VamsasDocument getVamsasDocument() throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public VamsasDocument getVamsasDocument(java.lang.String provenance_user, java.lang.String provenance_action, java.lang.String version) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
provenance_user
- (null sets user to be the class name)provenance_action
- (null sets action to be 'created new document')version
- (null means use latest version)
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public VorbaIdFactory getVorba()
protected boolean isDocumentWritten()
public void putVamsasDocument(VamsasDocument doc) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public void putVamsasDocument(VamsasDocument doc, VorbaIdFactory vorba) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
doc
- vorba
-
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
public void setVorba(VorbaIdFactory Vorba)
public boolean transferAppDataEntry(java.lang.String AppDataReference) throws java.io.IOException
AppDataReference
-
java.io.IOException
protected boolean _validNewAppDataReference(java.lang.String newAppDataReference) throws java.io.IOException
java.io.IOException
- for really broken references!public boolean transferAppDataEntry(java.lang.String AppDataReference, java.lang.String NewAppDataReference) throws java.io.IOException
AppDataReference
- NewAppDataReference
- - AppDataReference in new Archive
java.io.IOException
transferAppDataEntry(String AppDataReference)
public boolean writeAppdataFromStream(java.lang.String AppDataReference, java.io.InputStream adstream) throws java.io.IOException
AppDataReference
- - New AppDataReference not already written to archiveadstream
- Source of data for appData reference - read until .read(buffer)
returns -1
java.io.IOException
- for file IO or invalid AppDataReference stringpublic boolean transferRemainingAppDatas() throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |