Package org.apache.mailet

Examples of org.apache.mailet.MailetException


* @author  Federico Barbieri <scoobie@pop.systemy.it>
*/
public class ExceptionThrowingMailet extends GenericMailet {

    public void service(Mail mail) throws MessagingException {
        throw new MailetException("General protection fault");
    }
View Full Code Here


        String tableName = datasourceName.substring(pos + 1);
        datasourceName = datasourceName.substring(0, pos);

        Connection conn = null;
        if (getInitParameter("source_column") == null) {
            throw new MailetException("source_column not specified for JDBCAlias");
        }
        if (getInitParameter("target_column") == null) {
            throw new MailetException("target_column not specified for JDBCAlias");
        }
        try {
            ComponentManager componentManager = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
            // Get the DataSourceSelector block
            DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
            // Get the data-source required.
            datasource = (DataSourceComponent)datasources.select(datasourceName);

            conn = datasource.getConnection();

            // Check if the required table exists. If not, complain.
            DatabaseMetaData dbMetaData = conn.getMetaData();
            // Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo.
            // Try UPPER, lower, and MixedCase, to see if the table is there.
            if (! ( tableExists(dbMetaData, tableName) ||
                    tableExists(dbMetaData, tableName.toUpperCase()) ||
                    tableExists(dbMetaData, tableName.toLowerCase()) ))  {
                throw new MailetException("Could not find table '" + tableName + "' in datasource '" + datasourceName + "'");
            }

            //Build the query
            query = "SELECT " + getInitParameter("target_column")
                    + " FROM " + tableName + " WHERE "
View Full Code Here

            StringBuffer exceptionBuffer =
                new StringBuffer(128)
                        .append("Could not load matcher (")
                        .append(matchName)
                        .append(")");
            throw new MailetException(exceptionBuffer.toString(), e);
        }
    }
View Full Code Here

            StringBuffer exceptionBuffer =
                new StringBuffer(128)
                        .append("Could not load mailet (")
                        .append(mailetName)
                        .append(")");
            throw new MailetException(exceptionBuffer.toString(), e);
        }
    }
View Full Code Here

       
        try {
            FlowedMessageUtils.flowMessage(mail.getMessage(), optionFlowedDelsp, optionWidth);
           
        } catch (MessagingException e) {
            throw new MailetException("Could not wrap message", e);
           
        } catch (IOException e) {
            throw new MailetException("Could not wrap message", e);
        }
       
    }
View Full Code Here

     * @return an array containing Pattern and Substitution of the input stream
     * @throws MailetException
     */
    protected static PatternBean getPattern(String line) throws MailetException {
        String[] pieces = StringUtils.split(line, "/");
        if (pieces.length < 3) throw new MailetException("Invalid expression: " + line);
        int options = 0;
        //if (pieces[2].indexOf('x') >= 0) options += Pattern.EXTENDED;
        if (pieces[2].indexOf('i') >= 0) options += Pattern.CASE_INSENSITIVE;
        if (pieces[2].indexOf('m') >= 0) options += Pattern.MULTILINE;
        if (pieces[2].indexOf('s') >= 0) options += Pattern.DOTALL;
View Full Code Here

        return new PatternBean (Pattern.compile(pieces[0], options), pieces[1] , flags);
    }
   
    protected static PatternList getPatternsFromString(String pattern) throws MailetException {
        pattern = pattern.trim();
        if (pattern.length() < 2 && !pattern.startsWith("/") && !pattern.endsWith("/")) throw new MailetException("Invalid parameter value: " + PARAMETER_NAME_SUBJECT_PATTERN);
        pattern = pattern.substring(1, pattern.length() - 1);
        String[] patternArray = StringUtils.split(pattern, "/,/");
       
        PatternList patternList= new PatternList();
        for (String aPatternArray : patternArray) {
View Full Code Here

       
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.length() > 0 && !line.startsWith("#")) {
                if (line.length() < 2 && !line.startsWith("/") && !line.endsWith("/")) throw new MailetException("Invalid expression: " + line);
                PatternBean o = getPattern(line.substring(1, line.length() - 1));
                patternList.getPatterns().add(o.getPatterns());
                patternList.getSubstitutions().add(o.getSubstitutions());
                patternList.getFlags().add(o.getFlag());
            }
View Full Code Here

            rConfig.bodyFlags = bodyFlagsList.toArray(new Integer[bodyFlagsList.size()]);
           
            return rConfig;
           
        } catch (FileNotFoundException e) {
            throw new MailetException("Failed initialization", e);
           
        } catch (MailetException e) {
            throw new MailetException("Failed initialization", e);
           
        } catch (IOException e) {
            throw new MailetException("Failed initialization", e);
           
        }
    }
View Full Code Here

            }
           
            if (mod) mail.getMessage().saveChanges();
           
        } catch (MessagingException e) {
            throw new MailetException("Error in replace", e);
           
        } catch (IOException e) {
            throw new MailetException("Error in replace", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.mailet.MailetException

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.