CPD Results

The following document contains the results of PMD's CPD 3.9.

Duplications

FileProjectLine
org/apache/james/transport/mailets/RemoteDelivery.javaApache JAMES Server Mailets function278
org/apache/james/transport/mailets/Retry.javaApache JAMES Server Mailets function243
    public void init() throws MessagingException {
        // Set isDebug flag.
        isDebug = (getInitParameter("debug") == null) ? false : new Boolean(getInitParameter("debug")).booleanValue();

        // Create list of Delay Times.
        ArrayList delayTimesList = new ArrayList();
        try {
            if (getInitParameter("delayTime") != null) {
                delayTimeMatcher = new Perl5Matcher();
                String delayTimesParm = getInitParameter("delayTime");

                // Split on commas
                StringTokenizer st = new StringTokenizer (delayTimesParm,",");
                while (st.hasMoreTokens()) {
                    String delayTime = st.nextToken();
                    delayTimesList.add (new Delay(delayTime));
                }
            } else {
                // Use default delayTime.
                delayTimesList.add(new Delay());
            }
        } catch (Exception e) {
            log("Invalid delayTime setting: " + getInitParameter("delayTime"));
        }

        try {
            // Get No. of Max Retries.
            if (getInitParameter("maxRetries") != null) {
                maxRetries = Integer.parseInt(getInitParameter("maxRetries"));
            }
    
            // Check consistency of 'maxRetries' with delayTimesList attempts.
            int totalAttempts = calcTotalAttempts(delayTimesList);
    
            // If inconsistency found, fix it.
            if (totalAttempts > maxRetries) {
                log("Total number of delayTime attempts exceeds maxRetries specified. "
                        + " Increasing maxRetries from "
                        + maxRetries
                        + " to "
                        + totalAttempts);
                maxRetries = totalAttempts;
            } else {
                int extra = maxRetries - totalAttempts;
                if (extra != 0) {
                    log("maxRetries is larger than total number of attempts specified.  "
                            + "Increasing last delayTime with "
                            + extra
                            + " attempts ");
    
                    // Add extra attempts to the last delayTime.
                    if (delayTimesList.size() != 0) {
                        // Get the last delayTime.
                        Delay delay = (Delay) delayTimesList.get(delayTimesList
                                .size() - 1);
    
                        // Increase no. of attempts.
                        delay.setAttempts(delay.getAttempts() + extra);
                        log("Delay of " + delay.getDelayTime()
                                + " msecs is now attempted: " + delay.getAttempts()
                                + " times");
                    } else {
                        throw new MessagingException(
                                "No delaytimes, cannot continue");
                    }
                }
            }
            delayTimes = expandDelays(delayTimesList);
        } catch (Exception e) {
            log("Invalid maxRetries setting: " + getInitParameter("maxRetries"));
        }

        ServiceManager compMgr = (ServiceManager) getMailetContext()
                .getAttribute(Constants.AVALON_COMPONENT_MANAGER);

FileProjectLine
org/apache/james/vut/JDBCVirtualUserTable.javaApache JAMES Server Avalon User function179
org/apache/james/domain/JDBCDomainList.javaApache JAMES Server Core function167
            } catch (Exception e) {
                getLogger().fatalError(e.getMessage(), e);
                throw e;
            }

            if (getLogger().isDebugEnabled()) {
                logBuffer =
                    new StringBuffer(128)
                            .append("Reading SQL resources from file: ")
                            .append(sqlFileName)
                            .append(", section ")
                            .append(this.getClass().getName())
                            .append(".");
                getLogger().debug(logBuffer.toString());
            }

            // Build the statement parameters
            Map sqlParameters = new HashMap();
            if (tableName != null) {
                sqlParameters.put("table", tableName);
            }
            
            sqlQueries = new SqlResources();
            sqlQueries.init(sqlFile, this.getClass().getName(),
                            conn, sqlParameters);

            // Check if the required table exists. If not, create it.
            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 (!(theJDBCUtil.tableExists(dbMetaData, tableName))) {
           
                // Users table doesn't exist - create it.
                createStatement =
                    conn.prepareStatement(sqlQueries.getSqlString("createTable", true));
                createStatement.execute();

                if (getLogger().isInfoEnabled()) {
                    logBuffer =
                        new StringBuffer(64)
                                .append("JdbcVirtalUserTable: Created table '")
                                .append(tableName)
                                .append("'.");
                    getLogger().info(logBuffer.toString());
                }
            }

          
        } finally {
            theJDBCUtil.closeJDBCStatement(createStatement);
            theJDBCUtil.closeJDBCConnection(conn);
        }
    }
    
    /**
     * The JDBCUtil helper class
     */
    private final JDBCUtil theJDBCUtil = new JDBCUtil() {
        protected void delegatedLog(String logString) {
            getLogger().debug("JDBCVirtualUserTable: " + logString);
        }
    };

    public void setDataSourceComponent(DataSourceComponent dataSourceComponent) {
        this.dataSourceComponent = dataSourceComponent;
    }
    

    public void setFileSystem(FileSystem fileSystem) {
        this.fileSystem = fileSystem;
    }

FileProjectLine
org/apache/james/domain/AbstractDomainList.javaApache JAMES Server Core function82
org/apache/james/impl/vut/AbstractVirtualUserTable.javaApache JAMES Server User Library374
                    getLogger().info("Handling mail for: " + i.next());
                }
            }  
            return domains;
        } else {
            return null;
        }
    }

    /**
     * Return a List which holds all ipAddress of the domains in the given List
     * 
     * @param domains List of domains
     * @return domainIP List of ipaddress for domains
     */
    private static List getDomainsIP(List domains,DNSService dns,Logger log) {
        List domainIP = new ArrayList();
        if (domains.size() > 0 ) {
            for (int i = 0; i < domains.size(); i++) {
                List domList = getDomainIP(domains.get(i).toString(),dns,log);
                
                for(int i2 = 0; i2 < domList.size();i2++) {
                    if(domainIP.contains(domList.get(i2)) == false) {
                        domainIP.add(domList.get(i2));
                    }
                }
            }
        }
        return domainIP;    
    }
    
    /**
     * @see #getDomainsIP(List, DNSService, Logger)
     */
    private static List getDomainIP(String domain, DNSService dns, Logger log) {
        List domainIP = new ArrayList();
        try {
            InetAddress[]  addrs = dns.getAllByName(domain);
            for (int j = 0; j < addrs.length ; j++) {
                String ip = addrs[j].getHostAddress();
                if (domainIP.contains(ip) == false) {
                    domainIP.add(ip);
                }
            }
        } catch (UnknownHostException e) {
            log.error("Cannot get IP address(es) for " + domain);
        }
        return domainIP;
    }

    /**
     * @see org.apache.james.api.vut.management.VirtualUserTableManagement#getUserDomainMappings(java.lang.String, java.lang.String)
     */
    public Collection getUserDomainMappings(String user, String domain) {

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function465
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function588
            out.println("Removing from the white list of " + (new MailAddress(senderUser, senderHost)) + " ...");
            out.println();
            
            MimeMessage message = mail.getMessage() ;
            
            Object content= message.getContent();
            
            if (message.getContentType().startsWith("text/plain")
            && content instanceof String) {
                StringTokenizer st = new StringTokenizer((String) content, " \t\n\r\f,;:<>");
                while (st.hasMoreTokens()) {
                    ResultSet selectRS = null;
                    try {
                        MailAddress recipientMailAddress;
                        try {
                            recipientMailAddress = new MailAddress(st.nextToken());
                        }
                        catch (javax.mail.internet.ParseException pe) {
                            continue;
                        }
                        String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
                        String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
                        
                        if (getMailetContext().isLocalServer(recipientHost)) {
                            // not a remote recipient, so skip
                            continue;
                        }
                        
                        if (conn == null) {
                            conn = datasource.getConnection();
                        }
                        
                        if (selectStmt == null) {
                            selectStmt = conn.prepareStatement(selectByPK);
                        }
                        selectStmt.setString(1, senderUser);
                        selectStmt.setString(2, senderHost);
                        selectStmt.setString(3, recipientUser);
                        selectStmt.setString(4, recipientHost);
                        selectRS = selectStmt.executeQuery();
                        if (!selectRS.next()) {

FileProjectLine
org/apache/james/vut/JDBCVirtualUserTable.javaApache JAMES Server Avalon User function523
org/apache/james/domain/JDBCDomainList.javaApache JAMES Server Core function257
                    if(domains.contains(domains) == false) {
                        domains.add(domain);
                    }
                }
            } finally {
                theJDBCUtil.closeJDBCResultSet(mappingRS);
            }
            
        } catch (SQLException sqle) {
            getLogger().error("Error accessing database", sqle);
        } finally {
            theJDBCUtil.closeJDBCStatement(mappingStmt);
            theJDBCUtil.closeJDBCConnection(conn);
        }
        if (domains.size() == 0) {
            return null;
        } else {
            return domains;
        }
    }

    /**
     * @see org.apache.james.api.domainlist.DomainList#containsDomain(java.lang.String)
     */
    public boolean containsDomain(String domain) {
        Connection conn = null;
        PreparedStatement mappingStmt = null;
        
        try {
            conn = dataSourceComponent.getConnection();
            mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("selectDomain", true));

            ResultSet mappingRS = null;
            try {
                mappingStmt.setString(1, domain);
                mappingRS = mappingStmt.executeQuery();
                if (mappingRS.next()) {
                    return true;
                }
            } finally {
                theJDBCUtil.closeJDBCResultSet(mappingRS);
            }
            
        } catch (SQLException sqle) {
            getLogger().error("Error accessing database", sqle);
        } finally {
            theJDBCUtil.closeJDBCStatement(mappingStmt);
            theJDBCUtil.closeJDBCConnection(conn);
        }
        return false;
    }

FileProjectLine
org/apache/james/vut/JDBCVirtualUserTable.javaApache JAMES Server Avalon User function135
org/apache/james/domain/JDBCDomainList.javaApache JAMES Server Core function122
        if (getLogger().isDebugEnabled()) {
            StringBuffer logBuffer =
                new StringBuffer(128)
                        .append("Parsed URL: table = '")
                        .append(tableName)
                        .append("'");
            getLogger().debug(logBuffer.toString());
        }
    
        sqlFileName = arg0.getChild("sqlFile").getValue();
        
        Configuration autoConf = arg0.getChild("autodetect");
        if (autoConf != null) {
            setAutoDetect(autoConf.getValueAsBoolean(true));    
        }
        
        Configuration autoIPConf = arg0.getChild("autodetectIP");
        if (autoConf != null) {
            setAutoDetectIP(autoIPConf.getValueAsBoolean(true));    
        }
    }
    
    /**
     * @see org.apache.avalon.framework.activity.Initializable#initialize()
     */
    public void initialize() throws Exception {
    
        setDataSourceComponent((DataSourceComponent) datasources.select(dataSourceName));
    
        StringBuffer logBuffer = null;
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(this.getClass().getName() + ".initialize()");
        }

        // Test the connection to the database, by getting the DatabaseMetaData.
        Connection conn = dataSourceComponent.getConnection();
        PreparedStatement createStatement = null;

        try {
            // Initialise the sql strings.

            InputStream sqlFile = null;
            try {
                sqlFile = fileSystem.getResource(sqlFileName);

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function218
org/apache/james/transport/matchers/IsInWhiteList.javaApache JAMES Server Mailets function118
        if (repositoryPath != null) {
            log("repositoryPath: " + repositoryPath);
        }
        else {
            throw new MessagingException("repositoryPath is null");
        }

        ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);

        try {
            // Get the DataSourceSelector block
            DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
            // Get the data-source required.
            int stindex =   repositoryPath.indexOf("://") + 3;
            String datasourceName = repositoryPath.substring(stindex);
            datasource = (DataSourceComponent) datasources.select(datasourceName);
        } catch (Exception e) {
            throw new MessagingException("Can't get datasource", e);
        }

         try {
            // Get the UsersRepository
            localusers = (UsersRepository)serviceManager.lookup(UsersRepository.ROLE);
        } catch (Exception e) {
            throw new MessagingException("Can't get the local users repository", e);
        }

        try {
            initSqlQueries(datasource.getConnection(), getMailetContext());
        } catch (Exception e) {
            throw new MessagingException("Exception initializing queries", e);
        }        
        
        selectByPK = sqlQueries.getSqlString("selectByPK", true);

FileProjectLine
org/apache/james/transport/mailets/RemoteDelivery.javaApache JAMES Server Mailets function512
org/apache/james/transport/mailets/Retry.javaApache JAMES Server Mailets function421
        return delayTimes[retryCount];
    }


    /**
     * This class is used to hold a delay time and its corresponding number of
     * retries.
     **/
    private class Delay {
        private int attempts = 1;

        private long delayTime = DEFAULT_DELAY_TIME;

        /**
         * This constructor expects Strings of the form
         * "[attempt\*]delaytime[unit]".
         * <p>
         * The optional attempt is the number of tries this delay should be used
         * (default = 1). The unit, if present, must be one of
         * (msec,sec,minute,hour,day). The default value of unit is 'msec'.
         * <p>
         * The constructor multiplies the delaytime by the relevant multiplier
         * for the unit, so the delayTime instance variable is always in msec.
         * 
         * @param initString
         *            the string to initialize this Delay object from
         **/
        public Delay(String initString) throws MessagingException {
            // Default unit value to 'msec'.
            String unit = "msec";

            if (delayTimeMatcher.matches(initString, PATTERN)) {
                MatchResult res = delayTimeMatcher.getMatch();

                // The capturing groups will now hold:
                // at 1: attempts * (if present)
                // at 2: delaytime
                // at 3: unit (if present)
                if (res.group(1) != null && !res.group(1).equals("")) {
                    // We have an attempt *
                    String attemptMatch = res.group(1);

                    // Strip the * and whitespace.
                    attemptMatch = attemptMatch.substring(0,
                            attemptMatch.length() - 1).trim();
                    attempts = Integer.parseInt(attemptMatch);
                }

                delayTime = Long.parseLong(res.group(2));

                if (!res.group(3).equals("")) {
                    // We have a value for 'unit'.
                    unit = res.group(3).toLowerCase(Locale.US);
                }
            } else {
                throw new MessagingException(initString + " does not match "
                        + PATTERN_STRING);
            }

FileProjectLine
org/apache/james/pop3server/POP3Handler.javaApache JAMES Server POP3 function189
org/apache/james/smtpserver/SMTPHandler.javaApache JAMES Server SMTP function207
        String responseString = clearResponseBuffer();
        helper.writeLoggedFlushedResponse(responseString);

        //the core in-protocol handling logic
        //run all the connection handlers, if it fast fails, end the session
        //parse the command command, look up for the list of command handlers
        //Execute each of the command handlers. If any command handlers writes
        //response then, End the subsequent command handler processing and
        //start parsing new command. Once the message is received, run all
        //the message handlers. The message handlers can either terminate
        //message or terminate session

        //At the beginning
        //mode = command_mode
        //once the commandHandler writes response, the mode is changed to RESPONSE_MODE.
        //This will cause to skip the subsequent command handlers configured for that command.
        //For instance:
        //There are 2 commandhandlers MailAddressChecker and MailCmdHandler for
        //MAIL command. If MailAddressChecker validation of the MAIL FROM
        //address is successful, the MailCmdHandlers will be executed.
        //Incase it fails, it has to write response. Once we write response
        //there is no need to execute the MailCmdHandler.
        //Next, Once MAIL message is received the DataCmdHandler and any other
        //equivalent commandHandler will call setMail method. this will change
        //he mode to MAIL_RECEIVED_MODE. This mode will trigger the message
        //handlers to be execute. Message handlers can abort message. In that case,
        //message will not spooled.

        //Session started - RUN all connect handlers
        List connectHandlers = handlerChain.getConnectHandlers();
        if(connectHandlers != null) {
            int count = connectHandlers.size();
            for(int i = 0; i < count; i++) {
                ((ConnectHandler)connectHandlers.get(i)).onConnect(this);
                if(sessionEnded) {
                    break;
                }
            }
        }

        helper.getWatchdog().start();
        while(!sessionEnded) {
          //Reset the current command values
          curCommandName = null;
          curCommandArgument = null;
          mode = COMMAND_MODE;

          //parse the command
          String cmdString =  readCommandLine();
          if (cmdString == null) {
              break;
          }
          int spaceIndex = cmdString.indexOf(" ");
          if (spaceIndex > 0) {
              curCommandName = cmdString.substring(0, spaceIndex);
              curCommandArgument = cmdString.substring(spaceIndex + 1);
          } else {
              curCommandName = cmdString;
          }
          curCommandName = curCommandName.toUpperCase(Locale.US);

FileProjectLine
org/apache/james/api/vut/management/VirtualUserTableManagementMBean.javaApache JAMES Server User API47
org/apache/james/api/vut/management/VirtualUserTableManagementService.javaApache JAMES Server User API45
    public boolean addRegexMapping(String virtualUserTable, String user, String domain, String regex) throws VirtualUserTableManagementException;
    
    /**
     * Remove regex mapping
     * 
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param regex the regex.
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean removeRegexMapping(String virtualUserTable, String user,String domain, String regex) throws VirtualUserTableManagementException;
    
    /***
     * Add address mapping
     * 
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param address 
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean addAddressMapping(String virtualUserTable, String user, String domain, String address) throws VirtualUserTableManagementException;
    
    /**
     * Remove address mapping
     *
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param address 
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean removeAddressMapping(String virtualUserTable, String user,String domain, String address) throws VirtualUserTableManagementException;
    
    /**
     * Add error mapping
     *
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param error
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean addErrorMapping(String virtualUserTable, String user, String domain, String error) throws VirtualUserTableManagementException;

    /**
     * Remove error mapping
     *
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param error
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean removeErrorMapping(String virtualUserTable, String user,String domain, String error) throws VirtualUserTableManagementException;
    
    /**
     * Return the explicit mapping stored for the given user and domain. Return null
     * if no mapping was found
     *
     * @param virtualUserTable The virtualUserTable     
     * @param user the username
     * @param domain the domain
     * @return the collection which holds the mappings. 
     * @throws VirtualUserTableManagementException  get thrown if an invalid use or domain was given
     */
    public Collection getUserDomainMappings(String virtualUserTable, String user, String domain) throws VirtualUserTableManagementException;
    
    /**
    * Try to identify the right method based on the prefix of the mapping and add it.
    *
    * @param virtualUserTable The virtualUserTable 
    * @param user the username. Null if no username should be used
    * @param domain the domain. Null if no domain should be used
    * @param mapping the mapping.
    * @return true if successfully
    * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
    */
    public boolean addMapping(String virtualUserTable, String user, String domain, String mapping) throws VirtualUserTableManagementException;
    
    /**
     * Try to identify the right method based on the prefix of the mapping and remove it.
     *
     * @param virtualUserTable The virtualUserTable 
     * @param user the username. Null if no username should be used
     * @param domain the domain. Null if no domain should be used
     * @param mapping the mapping.
     * @return true if successfully
     * @throws VirtualUserTableManagementException get thrown if an invalid argument was given
     */
    public boolean removeMapping(String virtualUserTable, String user, String domain, String mapping) throws VirtualUserTableManagementException;

FileProjectLine
org/apache/james/transport/mailets/AbstractRedirect.javaApache JAMES Server Mailets function400
org/apache/james/transport/mailets/Redirect.javaApache JAMES Server Mailets function335
        String addressList = getInitParameter("recipients",getInitParameter("to"));
                                 
        // if nothing was specified, return <CODE>null</CODE> meaning no change
        if (addressList == null) {
            return null;
        }

        try {
            InternetAddress[] iaarray = InternetAddress.parse(addressList, false);
            for (int i = 0; i < iaarray.length; i++) {
                String addressString = iaarray[i].getAddress();
                MailAddress specialAddress = getSpecialAddress(addressString,
                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});
                if (specialAddress != null) {
                    newRecipients.add(specialAddress);
                } else {
                    newRecipients.add(new MailAddress(iaarray[i]));
                }
            }
        } catch (Exception e) {
            throw new MessagingException("Exception thrown in getRecipients() parsing: " + addressList, e);
        }
        if (newRecipients.size() == 0) {
            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
        }

        return newRecipients;
    }

    /**
     * @return the <CODE>to</CODE> init parameter
     * or the postmaster address
     * or <CODE>SpecialAddress.SENDER</CODE>
     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
     * or <CODE>SpecialAddress.UNALTERED</CODE>
     * or the <CODE>recipients</CODE> init parameter if missing
     * or <CODE>null</CODE> if also the latter is missing
     */
    protected InternetAddress[] getTo() throws MessagingException {

FileProjectLine
org/apache/james/transport/mailets/Forward.javaApache JAMES Server Mailets function120
org/apache/james/transport/mailets/Redirect.javaApache JAMES Server Mailets function340
        }

        try {
            InternetAddress[] iaarray = InternetAddress.parse(addressList, false);
            for (int i = 0; i < iaarray.length; i++) {
                String addressString = iaarray[i].getAddress();
                MailAddress specialAddress = getSpecialAddress(addressString,
                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});
                if (specialAddress != null) {
                    newRecipients.add(specialAddress);
                } else {
                    newRecipients.add(new MailAddress(iaarray[i]));
                }
            }
        } catch (Exception e) {
            throw new MessagingException("Exception thrown in getRecipients() parsing: " + addressList, e);
        }
        if (newRecipients.size() == 0) {
            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
        }

        return newRecipients;
    }

    /**
     * @return the <CODE>to</CODE> init parameter
     * or the postmaster address
     * or <CODE>SpecialAddress.SENDER</CODE>
     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
     * or <CODE>SpecialAddress.UNALTERED</CODE>
     * or the <CODE>recipients</CODE> init parameter if missing
     * or <CODE>null</CODE> if also the latter is missing
     */
    protected InternetAddress[] getTo() throws MessagingException {

FileProjectLine
org/apache/james/pop3server/ListCmdHandler.javaApache JAMES Server POP3 function100
org/apache/james/pop3server/UidlCmdHandler.javaApache JAMES Server POP3 function76
                                    .append(mc.getName());
                        session.writeResponse(responseBuffer.toString());
                    } else {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
                                    .append(POP3Handler.ERR_RESPONSE)
                                    .append(" Message (")
                                    .append(num)
                                    .append(") already deleted.");
                        session.writeResponse(responseBuffer.toString());
                    }
                } catch (IndexOutOfBoundsException npe) {
                    StringBuffer responseBuffer =
                        new StringBuffer(64)
                                .append(POP3Handler.ERR_RESPONSE)
                                .append(" Message (")
                                .append(num)
                                .append(") does not exist.");
                    session.writeResponse(responseBuffer.toString());
                } catch (NumberFormatException nfe) {
                    StringBuffer responseBuffer =
                        new StringBuffer(64)
                                .append(POP3Handler.ERR_RESPONSE)
                                .append(" ")
                                .append(argument)
                                .append(" is not a valid number");
                    session.writeResponse(responseBuffer.toString());
                }

FileProjectLine
org/apache/james/util/bayesian/BayesianAnalyzer.javaApache JAMES Server Common Utilities372
org/apache/james/util/bayesian/BayesianAnalyzer.javaApache JAMES Server Common Utilities424
        String token;
        String header = "";
        
        //Build a Map of tokens encountered.
        while ((token = nextToken(stream)) != null) {
            boolean endingLine = false;
            if (token.length() > 0 && token.charAt(token.length() - 1) == '\n') {
                endingLine = true;
                token = token.substring(0, token.length() - 1);
            }
            
            if (token.length() > 0 && header.length() + token.length() < 90 && !allDigits(token)) {
                if (token.equals("From:")
                || token.equals("Return-Path:")
                || token.equals("Subject:")
                || token.equals("To:")
                ) {
                    header = token;
                    if (!endingLine) {
                        continue;
                    }
                }
                
                token = header + token;

FileProjectLine
org/apache/james/pop3server/POP3HandlerChain.javaApache JAMES Server POP3 function175
org/apache/james/smtpserver/SMTPHandlerChain.javaApache JAMES Server SMTP function314
    }

    /**
     * Add it to map (key as command name, value is an array list of commandhandlers)
     *
     * @param commandName the command name which will be key
     * @param cmdHandler The commandhandler object
     */
    private void addToMap(String commandName, CommandHandler cmdHandler) {
        ArrayList handlers = (ArrayList)commandHandlerMap.get(commandName);
        if(handlers == null) {
            handlers = new ArrayList();
            commandHandlerMap.put(commandName, handlers);
        }
        handlers.add(cmdHandler);
    }

    /**
     * Returns all the configured commandhandlers for the specified command
     *
     * @param command the command name which will be key
     * @return List of commandhandlers
     */
    List getCommandHandlers(String command) {
        if (command == null) {
            return null;
        }
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Lookup command handler for command: " + command);
        }
        List handlers =  (List)commandHandlerMap.get(command);
        if(handlers == null) {
            handlers = (List)commandHandlerMap.get(UnknownCmdHandler.UNKNOWN_COMMAND);
        }

        return handlers;
    }

    /**
     * Returns all the configured message handlers
     *
     * @return List of message handlers
     */
    List getMessageHandlers() {
        return messageHandlers;
    }

    /**
     * Returns all the configured connect handlers
     *
     * @return List of connect handlers
     */
    List getConnectHandlers() {
        return connectHandlers;
    }

}

FileProjectLine
org/apache/james/nntpserver/NNTPHandler.javaApache JAMES Server NNTP function768
org/apache/james/nntpserver/NNTPHandler.javaApache JAMES Server NNTP function899
                            .append("221 0 ")
                            .append(param);
                helper.writeLoggedFlushedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                helper.writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        helper.writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    helper.writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("221 ")

FileProjectLine
org/apache/james/transport/mailets/AbstractRedirect.javaApache JAMES Server Mailets function405
org/apache/james/transport/mailets/Forward.javaApache JAMES Server Mailets function120
        }

        try {
            InternetAddress[] iaarray = InternetAddress.parse(addressList, false);
            for (int i = 0; i < iaarray.length; i++) {
                String addressString = iaarray[i].getAddress();
                MailAddress specialAddress = getSpecialAddress(addressString,
                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});
                if (specialAddress != null) {
                    newRecipients.add(specialAddress);
                } else {
                    newRecipients.add(new MailAddress(iaarray[i]));
                }
            }
        } catch (Exception e) {
            throw new MessagingException("Exception thrown in getRecipients() parsing: " + addressList, e);
        }
        if (newRecipients.size() == 0) {
            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
        }

        return newRecipients;
    }

    /**
     * @return null
     */
    protected InternetAddress[] getTo() throws MessagingException {

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function743
org/apache/james/transport/matchers/IsInWhiteList.javaApache JAMES Server Mailets function226
            theJDBCUtil.closeJDBCConnection(conn);
        }
    }

    /** Gets the main name of a local customer, handling alias */
    private String getPrimaryName(String originalUsername) {
        String username;
        try {
            username = localusers.getRealName(originalUsername);
            JamesUser user = (JamesUser) localusers.getUserByName(username);
            if (user.getAliasing()) {
                username = user.getAlias();
            }
        }
        catch (Exception e) {
            username = originalUsername;
        }
        return username;
    }
    
    /**
     * Initializes the sql query environment from the SqlResources file.
     * Will look for conf/sqlResources.xml.
     * Will <I>not</I> create the database resources, if missing
     * (this task is done, if needed, in the {@link WhiteListManager}
     * initialization routine).
     * @param conn The connection for accessing the database
     * @param mailetContext The current mailet context,
     * for finding the conf/sqlResources.xml file
     * @throws Exception If any error occurs
     */
    private void initSqlQueries(Connection conn, org.apache.mailet.MailetContext mailetContext) throws Exception {
        try {
            if (conn.getAutoCommit()) {
                conn.setAutoCommit(false);
            }
            
            this.sqlFile = new File((String) mailetContext.getAttribute("confDir"), "sqlResources.xml").getCanonicalFile();
            sqlQueries.init(this.sqlFile, "WhiteList" , conn, getSqlParameters());

FileProjectLine
org/apache/james/util/bayesian/JDBCBayesianAnalyzer.javaApache JAMES Server Common Utilities393
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function793
        dbUpdated = createTable(conn, "whiteListTableName", "createWhiteListTable");
        
        //Commit our changes if necessary.
        if (conn != null && dbUpdated && !conn.getAutoCommit()) {
            conn.commit();
            dbUpdated = false;
        }
            
    }
    
    private boolean createTable(Connection conn, String tableNameSqlStringName, String createSqlStringName) throws SQLException {
        String tableName = sqlQueries.getSqlString(tableNameSqlStringName, true);
        
        DatabaseMetaData dbMetaData = conn.getMetaData();

        // Try UPPER, lower, and MixedCase, to see if the table is there.
        if (theJDBCUtil.tableExists(dbMetaData, tableName)) {
            return false;
        }
        
        PreparedStatement createStatement = null;
        
        try {
            createStatement =
                    conn.prepareStatement(sqlQueries.getSqlString(createSqlStringName, true));
            createStatement.execute();
            
            StringBuffer logBuffer = null;
            logBuffer =
                    new StringBuffer(64)
                    .append("Created table '")
                    .append(tableName)
                    .append("' using sqlResources string '")
                    .append(createSqlStringName)
                    .append("'.");

FileProjectLine
org/apache/james/transport/mailets/AbstractRedirect.javaApache JAMES Server Mailets function480
org/apache/james/transport/mailets/Redirect.javaApache JAMES Server Mailets function375
        String addressList = getInitParameter("to",getInitParameter("recipients"));

        // if nothing was specified, return null meaning no change
        if (addressList == null) {
            return null;
        }

        try {
            iaarray = InternetAddress.parse(addressList, false);
            for(int i = 0; i < iaarray.length; ++i) {
                String addressString = iaarray[i].getAddress();
                MailAddress specialAddress = getSpecialAddress(addressString,
                                                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});
                if (specialAddress != null) {
                    iaarray[i] = specialAddress.toInternetAddress();
                }
            }
        } catch (Exception e) {
            throw new MessagingException("Exception thrown in getTo() parsing: " + addressList, e);
        }
        if (iaarray.length == 0) {
            throw new MessagingException("Failed to initialize \"to\" list; empty <to> init parameter found.");
        }

        return iaarray;
    }

    /**
     * @return the <CODE>reversePath</CODE> init parameter 
     * or the postmaster address
     * or <CODE>SpecialAddress.SENDER</CODE>
     * or <CODE>SpecialAddress.NULL</CODE>
     * or <CODE>null</CODE> if missing
     */
    protected MailAddress getReversePath() throws MessagingException {

FileProjectLine
org/apache/james/nntpserver/NNTPHandler.javaApache JAMES Server NNTP function770
org/apache/james/nntpserver/NNTPHandler.javaApache JAMES Server NNTP function969
                helper.writeLoggedResponse(respBuffer.toString());
            }
        } else {
            int newArticleNumber = currentArticleNumber;
            if ( group == null ) {
                helper.writeLoggedFlushedResponse("412 no newsgroup selected");
                return;
            } else {
                if ( param == null ) {
                    if ( currentArticleNumber < 0 ) {
                        helper.writeLoggedFlushedResponse("420 no current article selected");
                        return;
                    } else {
                        article = group.getArticle(currentArticleNumber);
                    }
                }
                else {
                    newArticleNumber = Integer.parseInt(param);
                    article = group.getArticle(newArticleNumber);
                }
                if ( article == null ) {
                    helper.writeLoggedFlushedResponse("423 no such article number in this group");
                    return;
                } else {
                    currentArticleNumber = newArticleNumber;
                    String articleID = article.getUniqueID();
                    if (articleID == null) {
                        articleID = "<0>";
                    }
                    StringBuffer respBuffer =
                        new StringBuffer(128)
                                .append("220 ")

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function528
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function651
                    log("Removal request issued by " + senderMailAddress);
                }
                //Commit our changes if necessary.
                if (conn != null && dbUpdated && !conn.getAutoCommit()) {
                    conn.commit() ;
                    dbUpdated = false;
                }
            }
            else {
                out.println("The message must be plain - no action");
            }
            
            out.println();
            out.println("Finished");
            
            sendReplyFromPostmaster(mail, sout.toString());
            
        } catch (SQLException sqle) {
            out.println("Error accessing the database");
            sendReplyFromPostmaster(mail, sout.toString());
            throw new MessagingException("Error accessing the database", sqle);
        } catch (IOException ioe) {
            out.println("Error getting message content");
            sendReplyFromPostmaster(mail, sout.toString());
            throw new MessagingException("Error getting message content", ioe);
        } finally {
            theJDBCUtil.closeJDBCStatement(selectStmt);
            theJDBCUtil.closeJDBCStatement(deleteStmt);

FileProjectLine
org/apache/james/vut/JDBCVirtualUserTable.javaApache JAMES Server Avalon User function170
org/apache/james/mailrepository/JDBCMailRepository.javaApache JAMES Server Core function298
        Connection conn = datasource.getConnection();
        PreparedStatement createStatement = null;

        try {
            // Initialise the sql strings.

            InputStream sqlFile = null;
            try {
                sqlFile = fileSystem.getResource(sqlFileName);
            } catch (Exception e) {
                getLogger().fatalError(e.getMessage(), e);
                throw e;
            }

            if (getLogger().isDebugEnabled()) {
                logBuffer =
                    new StringBuffer(128)
                            .append("Reading SQL resources from file: ")
                            .append(sqlFileName)
                            .append(", section ")
                            .append(this.getClass().getName())
                            .append(".");
                getLogger().debug(logBuffer.toString());
            }

            // Build the statement parameters
            Map sqlParameters = new HashMap();
            if (tableName != null) {
                sqlParameters.put("table", tableName);
            }

FileProjectLine
org/apache/james/transport/mailets/BayesianAnalysis.javaApache JAMES Server Mailets function230
org/apache/james/transport/mailets/BayesianAnalysisFeeder.javaApache JAMES Server Mailets function189
        initDb();
        
    }
    
    private void initDb() throws MessagingException {
        
        try {
            ServiceManager serviceManager = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
            
            // Get the DataSourceSelector block
            DataSourceSelector datasources = (DataSourceSelector) serviceManager.lookup(DataSourceSelector.ROLE);
            
            // Get the data-source required.
            int stindex =   repositoryPath.indexOf("://") + 3;
            
            String datasourceName = repositoryPath.substring(stindex);
            
            datasource = (DataSourceComponent) datasources.select(datasourceName);
        } catch (Exception e) {
            throw new MessagingException("Can't get datasource", e);
        }
        
        try {
            analyzer.initSqlQueries(datasource.getConnection(), getMailetContext().getAttribute("confDir") + "/sqlResources.xml");
        } catch (Exception e) {
            throw new MessagingException("Exception initializing queries", e);
        }        

FileProjectLine
org/apache/james/transport/mailets/AbstractRedirect.javaApache JAMES Server Mailets function1031
org/apache/james/transport/mailets/DSNBounce.javaApache JAMES Server Mailets function217
            setRecipients(newMail, getRecipients(originalMail), originalMail);
            setTo(newMail, getTo(originalMail), originalMail);
            setSubjectPrefix(newMail, getSubjectPrefix(originalMail), originalMail);
            if(newMail.getMessage().getHeader(RFC2822Headers.DATE) == null) {
                newMail.getMessage().setHeader(RFC2822Headers.DATE,rfc822DateFormat.format(new Date()));
            }
            setReplyTo(newMail, getReplyTo(originalMail), originalMail);
            setReversePath(newMail, getReversePath(originalMail), originalMail);
            setSender(newMail, getSender(originalMail), originalMail);
            setIsReply(newMail, isReply(originalMail), originalMail);
    
            newMail.getMessage().saveChanges();

FileProjectLine
org/apache/james/util/XMLResources.javaApache JAMES Server Common Utilities142
org/apache/james/util/sql/SqlResources.javaApache JAMES Server Common Utilities184
                        .append(sqlDefsSection)
                        .append("\' does not exist.");
            throw new RuntimeException(exceptionBuffer.toString());
        }

        // Get parameters defined within the file as defaults,
        // and use supplied parameters as overrides.
        Map parameters = new HashMap();
        // First read from the <params> element, if it exists.
        Element parametersElement = 
            (Element)(sectionElement.getElementsByTagName("parameters").item(0));
        if ( parametersElement != null ) {
            NamedNodeMap params = parametersElement.getAttributes();
            int paramCount = params.getLength();
            for (int i = 0; i < paramCount; i++ ) {
                Attr param = (Attr)params.item(i);
                String paramName = param.getName();
                String paramValue = param.getValue();
                parameters.put(paramName, paramValue);
            }
        }
        // Then copy in the parameters supplied with the call.
        parameters.putAll(configParameters);

        // 2 maps - one for storing default statements,
        // the other for statements with a "db" attribute matching this 
        // connection.
        Map defaultSqlStatements = new HashMap();

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function333
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function485
                        String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
                        String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
                        
                        if (getMailetContext().isLocalServer(recipientHost)) {
                            // not a remote recipient, so skip
                            continue;
                        }
                        
                        if (conn == null) {
                            conn = datasource.getConnection();
                        }
                        
                        if (selectStmt == null) {
                            selectStmt = conn.prepareStatement(selectByPK);
                        }
                        selectStmt.setString(1, senderUser);
                        selectStmt.setString(2, senderHost);
                        selectStmt.setString(3, recipientUser);
                        selectStmt.setString(4, recipientHost);
                        selectRS = selectStmt.executeQuery();
                        if (selectRS.next()) {

FileProjectLine
org/apache/james/pop3server/RetrCmdHandler.javaApache JAMES Server POP3 function74
org/apache/james/pop3server/TopCmdHandler.javaApache JAMES Server POP3 function102
                        writeMessageContentTo(mc.getMessage(),nouts,lines);
                        nouts.flush();
                        edouts.checkCRLFTerminator();
                        edouts.flush();
                    } finally {
                        session.writeResponse(".");
                    }
                } else {
                    StringBuffer responseBuffer =
                        new StringBuffer(64)
                                .append(POP3Handler.ERR_RESPONSE)
                                .append(" Message (")
                                .append(num)
                                .append(") already deleted.");
                    responseString = responseBuffer.toString();
                    session.writeResponse(responseString);
                }
            } catch (IOException ioe) {
                responseString = POP3Handler.ERR_RESPONSE + " Error while retrieving message.";
                session.writeResponse(responseString);
            } catch (MessagingException me) {
                responseString = POP3Handler.ERR_RESPONSE + " Error while retrieving message.";
                session.writeResponse(responseString);
            } catch (IndexOutOfBoundsException iob) {
                StringBuffer exceptionBuffer =

FileProjectLine
org/apache/james/pop3server/POP3HandlerChain.javaApache JAMES Server POP3 function149
org/apache/james/smtpserver/SMTPHandlerChain.javaApache JAMES Server SMTP function127
            }
        }

        // the size must be greater than 1 because we added UnknownCmdHandler to
        // the map

        if (commandHandlerMap.size() < 2) {
            if (getLogger().isErrorEnabled()) {
                getLogger().error("No commandhandlers configured");
            }
            throw new ConfigurationException("No commandhandlers configured");
        } else {
            boolean found = true;
            for (int i = 0; i < mandatoryCommands.length; i++) {
                if (!commandHandlerMap.containsKey(mandatoryCommands[i])) {
                    if (getLogger().isErrorEnabled()) {
                        getLogger().error(
                                "No commandhandlers configured for the command:"
                                        + mandatoryCommands[i]);
                    }
                    found = false;
                    break;
                }
            }

            if (!found) {
                throw new ConfigurationException(
                        "No commandhandlers configured for mandatory commands");
            }

FileProjectLine
org/apache/james/transport/mailets/JDBCAlias.javaApache JAMES Server Mailets function89
org/apache/james/transport/mailets/JDBCVirtualUserTable.javaApache JAMES Server Mailets function128
        try {
            ServiceManager componentManager = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
            // Get the DataSourceSelector service
            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 (!(theJDBCUtil.tableExists(dbMetaData, tableName))) {
                StringBuffer exceptionBuffer =
                                              new StringBuffer(128)
                                              .append("Could not find table '")
                                              .append(tableName)
                                              .append("' in datasource '")
                                              .append(datasourceName)
                                              .append("'");
                throw new MailetException(exceptionBuffer.toString());
            }

FileProjectLine
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function333
org/apache/james/transport/mailets/WhiteListManager.javaApache JAMES Server Mailets function608
                        String recipientUser = recipientMailAddress.getUser().toLowerCase(Locale.US);
                        String recipientHost = recipientMailAddress.getHost().toLowerCase(Locale.US);
                        
                        if (getMailetContext().isLocalServer(recipientHost)) {
                            // not a remote recipient, so skip
                            continue;
                        }
                        
                        if (conn == null) {
                            conn = datasource.getConnection();
                        }
                        
                        if (selectStmt == null) {
                            selectStmt = conn.prepareStatement(selectByPK);
                        }
                        selectStmt.setString(1, senderUser);
                        selectStmt.setString(2, senderHost);
                        selectStmt.setString(3, recipientUser);
                        selectStmt.setString(4, recipientHost);
                        selectRS = selectStmt.executeQuery();
                        if (!selectRS.next()) {

FileProjectLine
org/apache/james/mailrepository/JDBCMailRepository.javaApache JAMES Server Core function523
org/apache/james/mailrepository/JDBCMailRepository.javaApache JAMES Server Core function627
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ObjectOutputStream oos = new ObjectOutputStream(baos);
                        try {
                            if (mc instanceof MailImpl) {
                            oos.writeObject(((MailImpl)mc).getAttributesRaw());
                            } else {
                                HashMap temp = new HashMap();
                                for (Iterator i = mc.getAttributeNames(); i.hasNext(); ) {
                                    String hashKey = (String) i.next();
                                    temp.put(hashKey,mc.getAttribute(hashKey));
                                }
                                oos.writeObject(temp);
                            }
                            oos.flush();
                            ByteArrayInputStream attrInputStream =
                                new ByteArrayInputStream(baos.toByteArray());

FileProjectLine
org/apache/james/util/bayesian/JDBCBayesianAnalyzer.javaApache JAMES Server Common Utilities399
org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.javaApache JAMES Server SMTP function619
        }
    }

    /**
     * Create the table if not exists.
     * 
     * @param conn
     *            The connection
     * @param tableNameSqlStringName
     *            The tableSqlname
     * @param createSqlStringName
     *            The createSqlname
     * @return true or false
     * @throws SQLException
     */
    private boolean createTable(Connection conn, String tableNameSqlStringName,
    String createSqlStringName) throws SQLException {
        String tableName = sqlQueries.getSqlString(tableNameSqlStringName, true);

        DatabaseMetaData dbMetaData = conn.getMetaData();

        // Try UPPER, lower, and MixedCase, to see if the table is there.
        if (theJDBCUtil.tableExists(dbMetaData, tableName)) {
            return false;
        }

        PreparedStatement createStatement = null;

        try {
            createStatement = conn.prepareStatement(sqlQueries.getSqlString(createSqlStringName, true));
            createStatement.execute();

            StringBuffer logBuffer = null;
            logBuffer = new StringBuffer(64).append("Created table '").append(tableName)
            .append("' using sqlResources string '")
            .append(createSqlStringName).append("'.");

FileProjectLine
org/apache/james/smtpserver/core/DataCmdHandler.javaApache JAMES Server SMTP function153
org/apache/james/smtpserver/core/SendMailHandler.javaApache JAMES Server SMTP function100
                   StringBuffer errorBuffer =
                     new StringBuffer(256)
                         .append("Rejected message from ")
                         .append(session.getState().get(SMTPSession.SENDER).toString())
                         .append(" from host ")
                         .append(session.getRemoteHost())
                         .append(" (")
                         .append(session.getRemoteIPAddress())
                         .append(") exceeding system maximum message size of ")
                         .append(session.getConfigurationData().getMaxMessageSize());
                   getLogger().error(errorBuffer.toString());
              } else {
                   responseString = "451 "+DSNStatus.getStatus(DSNStatus.TRANSIENT,DSNStatus.UNDEFINED_STATUS)+" Error processing message.";

FileProjectLine
org/apache/james/domain/JDBCDomainList.javaApache JAMES Server Core function167
org/apache/james/mailrepository/JDBCMailRepository.javaApache JAMES Server Core function307
            } catch (Exception e) {
                getLogger().fatalError(e.getMessage(), e);
                throw e;
            }

            if (getLogger().isDebugEnabled()) {
                logBuffer =
                    new StringBuffer(128)
                            .append("Reading SQL resources from file: ")
                            .append(sqlFileName)
                            .append(", section ")
                            .append(this.getClass().getName())
                            .append(".");
                getLogger().debug(logBuffer.toString());
            }

            // Build the statement parameters
            Map sqlParameters = new HashMap();
            if (tableName != null) {
                sqlParameters.put("table", tableName);
            }

FileProjectLine
org/apache/james/util/XMLResources.javaApache JAMES Server Common Utilities278
org/apache/james/util/sql/SqlResources.javaApache JAMES Server Common Utilities346
    private String substituteSubString( String input, 
                                        String find,
                                        String replace )
    {
        int find_length = find.length();
        int replace_length = replace.length();

        StringBuffer output = new StringBuffer(input);
        int index = input.indexOf(find);
        int outputOffset = 0;

        while ( index > -1 ) {
            output.replace(index + outputOffset, index + outputOffset + find_length, replace);
            outputOffset = outputOffset + (replace_length - find_length);

            index = input.indexOf(find, index + find_length);
        }

        String result = output.toString();
        return result;
    }

    /**
     * Returns a named SQL string for the specified connection,
     * replacing parameters with the values set.
     * 
     * @param name   the name of the SQL resource required.
     * @return the requested resource
     */
    public String getSqlString(String name)

FileProjectLine
org/apache/james/mailrepository/AbstractMailRepository.javaApache JAMES Server Core function112
org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.javaApache JAMES Server Core function253
        if (getLock().lock(key)) {
            if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
                StringBuffer debugBuffer = new StringBuffer(256).append(
                        "Locked ").append(key).append(" for ").append(
                        Thread.currentThread().getName()).append(" @ ").append(
                        new java.util.Date(System.currentTimeMillis()));
                getLogger().debug(debugBuffer.toString());
            }
            return true;
        } else {
            return false;
        }
    }

    /**
     * Releases a lock on a message identified by a key
     * 
     * @param key
     *            the key of the message to be unlocked
     * 
     * @return true if successfully released the lock, false otherwise
     */
    public boolean unlock(String key) {

FileProjectLine
org/apache/james/mailrepository/AbstractMailRepository.javaApache JAMES Server Core function90
org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.javaApache JAMES Server Core function276
        if (getLock().unlock(key)) {
            if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
                StringBuffer debugBuffer = new StringBuffer(256).append(
                        "Unlocked ").append(key).append(" for ").append(
                        Thread.currentThread().getName()).append(" @ ").append(
                        new java.util.Date(System.currentTimeMillis()));
                getLogger().debug(debugBuffer.toString());
            }
            return true;
        } else {
            return false;
        }
    }

    /**
     * Removes a specified message
     * 
     * @param mail
     *            the message to be removed from the repository
     * @throws MessagingException
     */
    public void remove(Mail mail) throws MessagingException {

FileProjectLine
org/apache/james/transport/mailets/CommandListservManager.javaApache JAMES Server Mailets function416
org/apache/james/transport/mailets/CommandListservProcessor.javaApache JAMES Server Mailets function452
    }

    /**
     * Retrieves a data field, potentially defined by a super class.
     * @return null if not found, the object otherwise
     */
    protected static Object getField(Object instance, String name) throws IllegalAccessException {
        Class clazz = instance.getClass();
        Field[] fields;
        while (clazz != null) {
            fields = clazz.getDeclaredFields();
            for (int index = 0; index < fields.length; index++) {
                Field field = fields[index];
                if (field.getName().equals(name)) {
                    field.setAccessible(true);
                    return field.get(instance);
                }
            }
            clazz = clazz.getSuperclass();
        }

        return null;
    }