Examples of MessageStoreException


Examples of com.stimulus.archiva.exception.MessageStoreException

     */ 
   
    public Email retrieveMessage(EmailID emailID, boolean decompress, boolean decrypt, boolean headersOnly) throws MessageStoreException {

        if (emailID==null || emailID.getVolume()==null || emailID.getUniqueID()==null)
            throw new MessageStoreException("assertion failure: null emailID, volume or uniqueId",logger);

        logger.debug("retrieveMessage() {"+emailID+",retrieveHeadersOnly='" + headersOnly + "', decompress='" + decompress + "',decrypt='"+decrypt+"'}");
      
        String messageFileName = getMessageFileName(emailID);
        InputStream is = null;
        try {

            is = getRawMessageInputStream(emailID, decompress, decrypt);
        }   catch(FileNotFoundException fnfe)
        {
            throw new MessageStoreException("message file not found {filename='" + messageFileName + "'}", fnfe, logger);
        } catch(IOException io)
        {
            try
            {
                if (is!=null)
                    is.close();
            }
            catch(Exception e) { }
            throw new MessageStoreException("failed to retrieve message {filename='" + messageFileName + "'}", io, logger);
        }

        Email message = null;
        try {
            message = new Email(is, headersOnly, emailID);
        } catch(MessagingException me)
        {
            try
            {
                is.close();
            }
            catch(Exception e) { }
            throw new MessageStoreException("failed to decode message {filename='" + messageFileName + "'}", me, logger);
        } finally
        {
            if(is != null)
                try
                {
                    is.close();
                }
                catch(IOException ioe)
                {
                    throw new MessageStoreException("error closing message {file '" + messageFileName + "'}", ioe, logger);
                }

        }

        try
        {
            logger.debug("retrieved message {filename='" + messageFileName + "'," + message+"}");
        }
        catch(Exception e)
        {
            throw new MessageStoreException("retrieved message does not appear to be well formed.", e, logger);
        }
        return message;

    }
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

     * Copy a message to a error directory if the message cannot be indexed
     * @param emailID The email ID
     */ 
    public void copyEmailToNoIndexQueue(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("copyEmailToNoIndexQueue() {"+emailID+"'");
        FileChannel in = null, out = null;
        String messageFileName = getMessageFileName(emailID);
        String indexErrorFileName = getIndexErrorFileName(emailID);
        try {         
             in = new FileInputStream(messageFileName).getChannel();
             out = new FileOutputStream(indexErrorFileName).getChannel();
             in.transferTo( 0, in.size(), out);
           
        } catch (Exception e) {
            throw new MessageStoreException("failed to copy suspect message to noindex queue {src='"+messageFileName+"=',dest='"+indexErrorFileName+"'",logger);
        } finally {
             if (in != null) try { in.close(); } catch (Exception e) {};
             if (out != null) try { out.close(); } catch (Exception e) {};
        }
    }
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

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

       String messageFileName = getMessageFileName(emailID);
       InputStream is = new BufferedInputStream(new FileInputStream(messageFileName));
       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

Examples of com.stimulus.archiva.exception.MessageStoreException

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

       OutputStream os = new BufferedOutputStream(new FileOutputStream(messageFileName));
       Cipher ecipher = null;
       if (encrypt) {
           try {
               ecipher = Cipher.getInstance(key.getAlgorithm());
               ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
           } catch (Exception e) {
                logger.warn("Please ensure you have the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files installed.");
                logger.warn("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

Examples of com.stimulus.archiva.exception.MessageStoreException

             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

Examples of com.stimulus.archiva.exception.MessageStoreException

    * @return The file location message not processed
    */ 
   
    protected File getNoIndexFile(EmailID emailID) throws MessageStoreException {
        if (emailID==null || emailID.getUniqueID()==null)
            throw new MessageStoreException("assertion failure: null emailID or uniqueId",logger);
        String filename = Config.getFileSystem().getNoIndexPath() + File.separatorChar + emailID.getUniqueID() + messageFileExtension;
        logger.debug("getNoIndexFileName() {return='" + filename + "'}");
        return new File(filename);
    }
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

     */ 

    public void prepareStore(Volume volume) throws MessageStoreException {

       if (volume==null)
           throw new MessageStoreException("assertion failure: null volume",logger);

       logger.debug("createMessageStoreDir() {" + volume + "}");

       File storeDir = new File(volume.getPath());
       if(!storeDir.exists())
       {
           logger.info("message store directory does not exist {"+volume+"}");
           boolean success = storeDir.mkdirs();
           if(!success)
               throw new MessageStoreException("failed to create message store directory {" + volume + "}", logger);
           logger.info("created message store directory {" + volume + "}");
       }
    }
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

             boolean makedir = todayDir.mkdirs();
             if(makedir)
                 logger.debug("created message sub-directory {dir='" + directory + "'}");
             else {
               if(!todayDir.exists())
                 throw new MessageStoreException("failed to create directory {dir='" + directory + "'}",logger);
             }
         } else
         {
             logger.debug("directory exists {dir='" + directory + "'}");
         }
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

         logger.fatal("assertion failure. volume is null");
         return false;
       }
     
      if (!isDefaultPassPhraseModified())
           throw new MessageStoreException("failed to archive message. encryption password is not set. {"+emailId+"}",logger);

       File messageFile = getNewFile(emailId.getVolume(),emailId.getUniqueID(),messageFileExtension);
     
       if (messageFile.exists()) {
         logger.debug("no need to archive. message already exists in the store. {"+emailId+"}");
View Full Code Here

Examples of com.stimulus.archiva.exception.MessageStoreException

     * @return An email message
     */ 
   
    public Email retrieveMessage(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("retrieveMessage() {"+emailID+"'}");
    
    
        Email message = null;
        try {
         
           File messageFile = getExistingFile(emailID.getVolume(),emailID.getUniqueID(),messageFileExtension);
           logger.debug("returning input stream {filename='" + messageFile + "'}");
           
           message = new Email(emailID,getRawMessageInputStream(messageFile, true, true));
 
            logger.debug("retrieved message {"+message+"}");
        } catch (java.io.FileNotFoundException fnfe) {
          throw new MessageStoreException("The message is currently not accessible on the storage device.",fnfe,logger);
        } catch(Throwable e) {
            throw new MessageStoreException("Retrieved message does not appear to be well formed.", e, logger, ChainedException.Level.DEBUG);
        }
        return message;

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.