コード例 #1
0
ファイル: FileUploadSession.java プロジェクト: herike/rcsjta
 /** Background processing */
 public void run() {
   try {
     if (sLogger.isActivated()) {
       sLogger.info("Initiate a new HTTP upload ".concat(mUploadId));
     }
     /* Create fileIcon content is requested */
     MmContent fileIconContent = null;
     if (mFileIcon) {
       fileIconContent = FileTransferUtils.createFileicon(mFile.getUri(), mUploadId, mRcsSettings);
     }
     mUploadManager = new HttpUploadManager(mFile, fileIconContent, this, mUploadId, mRcsSettings);
     byte[] result = mUploadManager.uploadFile();
     storeResult(result);
   } catch (SecurityException e) {
     sLogger.error(
         "File icon creation has failed as the file is not accessible for HTTP uploadId "
             .concat(mUploadId),
         e);
     removeSession();
     mListener.handleUploadNotAllowedToSend();
   } catch (IOException e) {
     if (sLogger.isActivated()) {
       sLogger.debug(e.getMessage());
     }
     removeSession();
     mListener.handleUploadError(FileSharingError.MEDIA_UPLOAD_FAILED);
   } catch (FileAccessException e) {
     sLogger.error("Failed to initiate session for HTTP uploadId ".concat(mUploadId), e);
     removeSession();
     mListener.handleUploadError(FileSharingError.MEDIA_UPLOAD_FAILED);
   } catch (PayloadException e) {
     sLogger.error("Failed to initiate session for HTTP uploadId ".concat(mUploadId), e);
     removeSession();
     mListener.handleUploadError(FileSharingError.MEDIA_UPLOAD_FAILED);
   } catch (NetworkException e) {
     if (sLogger.isActivated()) {
       sLogger.debug(e.getMessage());
     }
     removeSession();
     mListener.handleUploadError(FileSharingError.MEDIA_UPLOAD_FAILED);
   } catch (RuntimeException e) {
     /*
      * Intentionally catch runtime exceptions as else it will abruptly end the thread and
      * eventually bring the whole system down, which is not intended.
      */
     sLogger.error("Failed to initiate session for HTTP uploadId ".concat(mUploadId), e);
     removeSession();
     mListener.handleUploadError(FileSharingError.MEDIA_UPLOAD_FAILED);
   }
 }
コード例 #2
0
ファイル: FileUploadSession.java プロジェクト: herike/rcsjta
 @Override
 public void onHttpTransferNotAllowedToSend() {
   removeSession();
   mListener.handleUploadNotAllowedToSend();
 }