/** * Store a file * * @param req FileRequest * @return int * @exception Exception */ public int storeFile(FileRequest req) throws Exception { // Check for a single file request int saveSts = StsError; SingleFileRequest saveReq = (SingleFileRequest) req; // Check if the temporary file still exists, if not then the file has been deleted from the // filesystem File tempFile = new File(saveReq.getTemporaryFile()); FileSegment fileSeg = findFileSegmentForPath(saveReq.getVirtualPath()); if (tempFile.exists() == false || fileSeg == null) { // DEBUG if (Debug.EnableInfo && hasDebug()) Debug.println(" Temporary file deleted"); // Return an error status return StsError; } // Run any file store processors runFileStoreProcessors(m_dbCtx, saveReq.getFileState(), fileSeg); // Update the segment status, and clear the updated flag fileSeg.setStatus(FileSegmentInfo.Saving); fileSeg.getInfo().setUpdated(false); // Save the file data try { // Save the file data and get the assigned object id String objectId = saveFileData(saveReq.getFileId(), saveReq.getStreamId(), fileSeg, req.getAttributes()); // Save the object id to the mapping database getDBObjectIdInterface().saveObjectId(saveReq.getFileId(), saveReq.getStreamId(), objectId); // Indicate that the save was successful saveSts = StsSuccess; } catch (DBException ex) { // DEBUG if (Debug.EnableError && hasDebug()) Debug.println(ex); // Indicate the file save failed saveSts = StsError; } catch (IOException ex) { // DEBUG if (Debug.EnableError && hasDebug()) Debug.println(ex); // Indicate the file save failed saveSts = StsError; } // Update the segment status if (saveSts == StsSuccess) fileSeg.setStatus(FileSegmentInfo.Saved, false); else fileSeg.setStatus(FileSegmentInfo.Error, false); // Return the data save status return saveSts; }