+
+ }
+ /**
+ * write to the StoreWatcher file to indicate that a storeDocumentRequest has been made.
+ * The local client's storeWatcher FileWatcher object is updated so the initial change is not registered.
+ * @param client
+ * @param user
+ * @return
+ */
+ public void addStoreDocumentRequest(ClientHandle client, UserHandle user) throws IOException {
+ SessionFile sfw = new SessionFile(new File(sessionDir, CLOSEANDSAVE_FILE));
+ while (!sfw.lockFile())
+ log.debug("Trying to get lock for "+CLOSEANDSAVE_FILE);
+ sfw.fileLock.rafile.setLength(0); // wipe out any old info.
+ // TODO: rationalise what gets written to this file (ie do we want other clients to read the id of the requestor?)
+ sfw.fileLock.rafile.writeUTF(client.getClientUrn()+":"+user.getFullName()+"@"+user.getOrganization());
+ sfw.unlockFile();
+ if (store_doc_file!=null)
+ store_doc_file.setState();
+ slog.info("FinalizeAppData request from "+user.getFullName()+" using "+client.getClientUrn()+"");
+ }
+ /**
+ * create a new session with an existing vamsas Document - by copying it into the session.
+ * @param archive
+ */
+ protected void setVamsasDocument(File archive) throws IOException {
+ log.debug("Transferring vamsas data from "+archive+" to session:"+vamArchive.sessionFile);
+ SessionFile xtantdoc = new SessionFile(archive);
+ vamArchive.updateFrom(null, xtantdoc);
+ // LATER: decide if session archive provenance should be updated to reflect access.
+ // TODO: soon! do a proper import objects from external file
+ log.debug("Transfer complete.");
+ }
+ /**
+ * write session as a new vamsas Document (this will overwrite any existing file without warning)
+ * TODO: test
+ * TODO: verify that lock should be released for vamsas document.
+ * @param destarchive
+ */
+ protected void writeVamsasDocument(File destarchive, Lock extlock) throws IOException {
+ log.debug("Transferring vamsas data from "+vamArchive.sessionFile+" to session:"+destarchive);
+ SessionFile newdoc = new SessionFile(destarchive);
+ if (extlock==null && !vamArchive.lockFile())
+ while (!vamArchive.lockFile())
+ log.info("Trying to get lock for "+vamArchive.sessionFile);
+ // TODO: LATER: decide if session archive provenance should be written in vamsasDocument file for this export.
+ newdoc.updateFrom(extlock, vamArchive);
+ // LATER: LATER: fix use of updateFrom for file systems where locks cannot be made (because they don't have a lockManager, ie NFS/Unix, etc).
+ vamArchive.unLock();
+ newdoc.unlockFile();
+ log.debug("Transfer complete.");