JavaDoc


001    /**
002     * Copyright (c) 2003 Daffodil Software Ltd all rights reserved,
003     * Modifications Copyright (c) 2008 Regiscope Digital Imaging Co, LLC, All rights reserved.
004     * This program is free software; you can redistribute it and/or modify
005     * it under the terms of version 2 of the GNU General Public License as
006     * published by the Free Software Foundation.
007     * There are special exceptions to the terms and conditions of the GPL
008     * as it is applied to this software. See the GNU General Public License for more details.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018     */
019    package org.dbreplicator.replication;
020    
021    import java.rmi.server.*;
022    import java.rmi.RemoteException;
023    import java.io.*;
024    
025    public class FileUpload extends  UnicastRemoteObject implements _FileUpload{
026    
027     private File file;
028     private FileOutputStream output;
029    
030      public FileUpload() throws RemoteException {
031      }
032    
033    
034      /**
035       * fileStart
036       *
037       * @param fileName String
038       */
039      public void fileStart(String fileName,boolean isFileForSynchronization)  throws RepException {
040      try {
041        if (isFileForSynchronization) {
042          file = new File(PathHandler.getDefaultZIPFilePathForClient(fileName));
043        }
044        else {
045          file = new File(PathHandler.getDefaultZIPFilePathForCreateStructure(fileName));
046        }
047        output = new FileOutputStream(file);
048      }
049      catch (FileNotFoundException ex) {
050         RepConstants.writeERROR_FILE(ex);
051        throw new RepException("REP085", null);
052      }
053      }
054    
055      /**
056       * writeFileContent
057       *
058       * @param bytes byte[]
059       */
060      public void writeFileContent(byte[] bytes,int offset, int length) throws RepException{
061        try {
062              output.write(bytes,offset,length);
063              output.flush();
064    
065            }
066            catch (IOException ex) {
067              RepConstants.writeERROR_FILE(ex);
068              throw new RepException("REP085", null);
069            }
070      }
071    
072      /**
073       * Close the file
074       *
075       */
076      public void closeFile()  throws RepException {
077            try {
078              output.close();
079            }
080            catch (IOException ex) {
081              RepConstants.writeERROR_FILE(ex);
082             throw new RepException("REP085", null);
083            }
084      }
085    
086    }





























































Powered by Drupal - Theme by Danger4k