Package primarydatamanager.mirrorupdater

Examples of primarydatamanager.mirrorupdater.UpdateException


 
 
 
  public String[] listFiles() throws UpdateException {
    if (! mDir.exists()) {
      throw new UpdateException("Directory does not exist: "
        + mDir.getAbsolutePath());
    }
   
    return mDir.list();
  }
View Full Code Here



  public void deleteFile(String fileName) throws UpdateException {
    File file = new File(mDir, fileName);
    if (! file.delete()) {
      throw new UpdateException("Deleting file failed: " + fileName);
    }
  }
View Full Code Here

      if (stream != null) {
        try { stream.close(); } catch (IOException exc2) {}
      }
      file.delete();
     
      throw new UpdateException("Writing file failed: " + fileName, exc);
    }
    finally {
      if (stream != null) {
        try { stream.close(); } catch (IOException exc) {}
      }
View Full Code Here

      mBytesRead += data.length;
     
      return data;
    }
    catch (IOException exc) {
      throw new UpdateException("Loading file failed: " + fileName, exc);
    }
    finally {
      if (in != null) {
        try { in.close(); } catch (IOException exc) {}
      }
View Full Code Here

             mFTPClient.disconnect();
           } catch(IOException exc2) {
             // do nothing
           }
         }
         throw new UpdateException("Could not connect to server '" + mServerUrl
                                   + "'", exc);
       }
   
       // Log in
       try {
         boolean success = mFTPClient.login(mUser, mPassword);
         checkReplyCode();
         if (! success) {
           throw new UpdateException("Login failed");
         }
       } catch (Exception exc) {
         throw new UpdateException("Login using user='" + mUser
             + "' and password=(" + mPassword.length() + " characters) failed", exc);
       }
   
       // Set the file type to binary
       try {
         boolean success = mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
         checkReplyCode();
         if (! success) {
           throw new UpdateException("Setting file type to binary failed");
         }
       } catch (Exception exc) {
         throw new UpdateException("Setting file type to binary failed", exc);
       }
   
       // Change directory
       try {
         boolean success = mFTPClient.changeWorkingDirectory(mPath);
         checkReplyCode();
         if (! success) {
           throw new UpdateException("Could not change to directory '" + mPath + "'");
         }
       } catch (Exception exc) {
         throw new UpdateException("Could not change to directory '" + mPath + "'",
                                   exc);
       }
       mLog.fine("Changed to directory " + mPath);
   
  }
View Full Code Here

  private void checkReplyCode() throws UpdateException {
    // Check the reply code to verify success.
    int reply = mFTPClient.getReplyCode();
     
    if (! FTPReply.isPositiveCompletion(reply)) {
      throw new UpdateException("FTP server '" + mServerUrl
        + "' sent negative completion. Reply: " + reply + ": "
        + mFTPClient.getReplyString());
    }
  }
View Full Code Here

    FTPFile[] fileArr;
    try {
      fileArr = mFTPClient.listFiles();
      checkReplyCode();
    } catch (Exception exc) {
      throw new UpdateException("Getting file list failed", exc);
    }
   
    if (fileArr == null) {
      return new String[0];
    } else {
View Full Code Here

  public void deleteFile(String fileName) throws UpdateException {
    try {
      boolean success = mFTPClient.deleteFile(fileName);
      checkReplyCode();
      if (! success) {
        throw new UpdateException("Could not delete file '" + fileName + "'");
      }
    } catch (Exception exc) {
      throw new UpdateException("Could not delete file '" + fileName + "'", exc);
    }
  }
View Full Code Here

       
        ByteArrayInputStream stream = new ByteArrayInputStream(data);
        success = mFTPClient.storeFile(fileName, stream);
        checkReplyCode();
        if (!success) {
          throw new UpdateException("Could not write file '" + fileName + "'");
        }
      } catch (Exception exc) {
        // Try to delete the corrupt file
        try {
          deleteFile(fileName);
        }
        catch (Exception exc2) {
          // Do nothing
        }
        tryCount--;
        success=false;
        System.err.println("Could not write file '"+fileName+"'. Reason: "+exc.getMessage());
        if (tryCount>0) {
          System.err.println("trying again...");
          reset();
        }
      }
    }
   
    if (success) {
      mBytesWritten += data.length;
    } else {
      throw new UpdateException("Could not write file '" + fileName + "'");
    }
  }
View Full Code Here

    if (mFTPClient.isConnected()) {
      try {
        mFTPClient.disconnect();
        checkReplyCode();
      } catch(Exception exc) {
        throw new UpdateException("Could not disconnect from server '"
          + mServerUrl + "'", exc);
      }
    }
   
    mLog.fine("Disconnected from " + mServerUrl);
View Full Code Here

TOP

Related Classes of primarydatamanager.mirrorupdater.UpdateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.