Package com.stimulus.archiva.exception

Examples of com.stimulus.archiva.exception.MessageStoreException


             in = new FileInputStream(source).getChannel();
             out = new FileOutputStream(dest).getChannel();
             in.transferTo( 0, in.size(), out);
           
        } catch (Exception e) {
            throw new MessageStoreException("failed to copy email {src='"+source+"=',dest='"+dest+"'",e,logger);
        } finally {
             if (in != null) try { in.close(); } catch (Exception e) {};
             if (out != null) try { out.close(); } catch (Exception e) {};
        }
    }
View Full Code Here


      logger.debug("backupMessage()");
      File noArchiveFile = getNoArchiveFile();
      logger.warn("copying email to no archive queue {dest='"+noArchiveFile.getAbsolutePath()+"'}");
      boolean renamed = file.renameTo(noArchiveFile);
      if (!renamed) {
        throw new MessageStoreException("failed to copy message to noarchive queue",logger);
      }
    }
View Full Code Here

      FileOutputStream fos = null;
      try {
        fos = new FileOutputStream(noArchiveFile);
        email.writeTo(fos);
      } catch (Exception e) {
        throw new MessageStoreException("failed to copy message to noarchive queue:"+e.getMessage(),e,logger);
      } finally {
        try { fos.close(); } catch (Exception e) {}
      }
    }
View Full Code Here

     * Copy a message to a error directory if the message cannot be indexed
     * @param emailID The email ID
     */ 
    public void backupMessage(EmailID emailID) throws MessageStoreException {
        if (emailID==null || emailID.getVolume()==null || emailID.getUniqueID()==null)
            throw new MessageStoreException("assertion failure: null emailID, volume or uniqueId",logger);
        logger.debug("backupMessage() {"+emailID+"'");
        copyEmail(getExistingFile(emailID.getVolume(),emailID.getUniqueID(),messageFileExtension),getNoIndexFile(emailID));  
    }
View Full Code Here

     * @param decrypt Should decrypt message
     * @return An inputstream containing the message
     */ 
   public InputStream getRawMessageInputStream(File messageFile, boolean decompress, boolean decryptthrows IOException,MessageStoreException {
       if (messageFile==null )
           throw new MessageStoreException("assertion failure: null messageFileName",logger);

       InputStream is = new BufferedInputStream(new FileInputStream(messageFile));
       Cipher dcipher = null;
       if(decrypt) {
           try {
             
               dcipher = Cipher.getInstance(key.getAlgorithm());
               dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
         } catch (Exception e) {
               throw new MessageStoreException("failed to initialize cipher. cause:",e,logger);
           }
           is = new CipherInputStream(is,dcipher);
       }

       if(decompress)
View Full Code Here

     * @return An outputstream directed to the message
     */ 
  
   public OutputStream getRawMessageOutputStream(File messageFile,boolean compress, boolean encrypt) throws IOException,MessageStoreException {
       if (messageFile==null)
           throw new MessageStoreException("assertion failure: null messageFileName",logger);

       OutputStream os = new BufferedOutputStream(new FileOutputStream(messageFile));
       Cipher ecipher = null;
       if (encrypt) {
           try {
               ecipher = Cipher.getInstance(key.getAlgorithm());
               ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
           } catch (Exception e) {
                logger.fatal("Please ensure you have the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files installed.");
                logger.fatal("Visit http://java.sun.com2/javase/downloads/index.jsp to download them.");
                throw new MessageStoreException("failed to initalize cipher. Cause:",e,logger);
           }
           os = new CipherOutputStream(os,ecipher);
       }


View Full Code Here

            while ((c = bis.read()) != -1) {
              os.write(c);
            }
    } catch (Throwable ex) {
      StreamUtil.emptyStream(is);
      throw new MessageStoreException("failed to write corrupted email to quarantine:"+ex.getMessage(),ex,logger);
    } finally {
          try {
          if (os != null) os.close();
          if (is != null) is.close();
        } catch (Exception e) {}
View Full Code Here

    logger.debug("getAttachmentFilePath() {"+volume+",hash='"+hash+"'}");
    File attachFile = getFileFromHashValue(volume, hash,attachmentFileExtension);
    if (!attachFile.exists()) {
      attachFile = getLegacyFileFromHashValue(volume,hash,3,attachmentFileExtension);
      if (!attachFile.exists()) {
        throw new MessageStoreException("attachment does not exist {attachFile='"+attachFile.getAbsolutePath()+"'}",logger,ChainedException.Level.DEBUG);
      }
    }
    return attachFile;
  }
View Full Code Here

      DigestOutputStream dos = new DigestOutputStream(fos,sha);
      message.writeTo(dos);
     
        byte[] digest = sha.digest();
        if (digest==null) {
          throw new MessageStoreException("failed to generate email digest. digest is null.",logger,ChainedException.Level.DEBUG);
        }
        return digest;
    } catch (Exception e) {
      if (file.exists()) {
         boolean deleted = file.delete();
           if (!deleted) {
             try {
               file.renameTo(File.createTempFile("ma", "tmp"));
               Config.getFileSystem().getTempFiles().markForDeletion(file);
             } catch (Exception e3) {}
              }
      }
      throw new MessageStoreException("failed to write email {filename='"+file.getAbsolutePath()+"'",e,logger);
    } finally {
      try { if (fos!=null) fos.close(); } catch (Exception e) { logger.error("failed to close email file:"+e.getMessage()); }
    }
    /*
    try {
View Full Code Here

             key = SecretKeyFactory.getInstance(algorithm).generateSecret(keySpec);
          
             paramSpec = new PBEParameterSpec(salt, iterationCount);

         } catch (java.security.NoSuchAlgorithmException e)  {
             throw new MessageStoreException("failed to locate desired encryption algorithm {algorithm='"+algorithm+"'",logger);
         } catch (Exception e) {
             throw new MessageStoreException(e.toString(),e,logger);
         }
   }
View Full Code Here

TOP

Related Classes of com.stimulus.archiva.exception.MessageStoreException

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.