| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <html> |
| <head> |
| <title>James Server - CPD Results</title> |
| <style type="text/css" media="all"> |
| @import url("./css/maven-base.css"); |
| @import url("./css/maven-theme.css"); |
| @import url("./css/site.css"); |
| </style> |
| <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" /> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
| </head> |
| <body class="composite"> |
| <div id="banner"> |
| <a href="http://james.apache.org/index.html" id="bannerLeft"> |
| |
| <img src="images/james-server-logo.gif" alt="" /> |
| |
| </a> |
| <a href="http://www.apache.org/index.html" id="bannerRight"> |
| |
| <img src="images/asf-logo-reduced.gif" alt="" /> |
| |
| </a> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="breadcrumbs"> |
| |
| |
| |
| |
| |
| |
| |
| <div class="xleft"> |
| Last Published: 05/28/2009 |
| </div> |
| <div class="xright"> <a href="../../index.html">JAMES Project</a> |
| | |
| <a href="../../server/index.html">Server</a> |
| | |
| <a href="../../mailet/index.html">Mailets</a> |
| | |
| <a href="../../jspf/index.html">jSPF</a> |
| | |
| <a href="../../mime4j/index.html">Mime4J</a> |
| | |
| <a href="../../jsieve/index.html">JSieve</a> |
| | |
| <a href="../../postage/index.html">Postage</a> |
| |
| |
| |
| |
| |
| |
| |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="leftColumn"> |
| <div id="navcolumn"> |
| |
| |
| |
| |
| |
| |
| |
| <h5>James Server</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="../index.html">Overview</a> |
| </li> |
| |
| <li class="none"> |
| <a href="../design_objectives.html">Objectives</a> |
| </li> |
| |
| |
| |
| |
| |
| <li class="expanded"> |
| <a href="../FAQ.html">James FAQ</a> |
| <ul> |
| |
| <li class="none"> |
| <a href="../james_and_sendmail.html">James and Sendmail</a> |
| </li> |
| </ul> |
| </li> |
| |
| <li class="none"> |
| <a href="http://wiki.apache.org/james">Wiki</a> |
| </li> |
| |
| <li class="none"> |
| <a href="../rfclist.html">Useful RFCs</a> |
| </li> |
| </ul> |
| <h5>Overview</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="index.html">Introduction</a> |
| </li> |
| |
| <li class="none"> |
| <a href="release-notes.html">Release Notes</a> |
| </li> |
| |
| <li class="none"> |
| <a href="jira-report.html">Changes</a> |
| </li> |
| </ul> |
| <h5>Concepts</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="summary.html">Summary</a> |
| </li> |
| |
| <li class="none"> |
| <a href="spoolmanager.html">SpoolManager</a> |
| </li> |
| |
| <li class="none"> |
| <a href="repositories.html">Repositories</a> |
| </li> |
| |
| <li class="none"> |
| <a href="mailet_api.html">The Mailet API</a> |
| </li> |
| </ul> |
| <h5>How to...</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="build_instructions.html">Build James</a> |
| </li> |
| |
| <li class="none"> |
| <a href="installation_instructions.html">Install James</a> |
| </li> |
| </ul> |
| <h5>Mailets</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/index.html">Overview</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/api/index.html">API</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/base/index.html">Basic Toolkit</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/crypto/index.html">Crypto</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/standard/index.html">Sieve</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/maven-mailetdocs-plugin/index.html">MailetDocs</a> |
| </li> |
| |
| <li class="none"> |
| <a href="james-server-mailets-function/mailet-report.html">Server</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://james.apache.org/mailet/standard/index.html">Standard</a> |
| </li> |
| </ul> |
| <h5>Configuration</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="dns_configuration.html">DNS Server</a> |
| </li> |
| |
| <li class="none"> |
| <a href="pop3_configuration.html">POP3 Server</a> |
| </li> |
| |
| <li class="none"> |
| <a href="smtp_configuration.html">SMTP Server</a> |
| </li> |
| |
| <li class="none"> |
| <a href="nntp_configuration.html">NNTP Server</a> |
| </li> |
| |
| <li class="none"> |
| <a href="fetchmail_configuration.html">FetchMail</a> |
| </li> |
| |
| <li class="none"> |
| <a href="remotemanager_configuration.html">RemoteManager</a> |
| </li> |
| |
| <li class="none"> |
| <a href="spoolmanager_configuration.html">SpoolManager</a> |
| </li> |
| |
| <li class="none"> |
| <a href="serverwide_configuration.html">Server-wide</a> |
| </li> |
| |
| <li class="none"> |
| <a href="adding_users.html">Adding Users</a> |
| </li> |
| |
| <li class="none"> |
| <a href="provided_matchers.html">Provided Matchers</a> |
| </li> |
| |
| <li class="none"> |
| <a href="provided_mailets.html">Provided Mailets</a> |
| </li> |
| </ul> |
| <h5>Common Configurations</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="smtp_auth.html">Using SMTP AUTH</a> |
| </li> |
| |
| <li class="none"> |
| <a href="using_database.html">Using a Database with James</a> |
| </li> |
| |
| <li class="none"> |
| <a href="usingTLS.html">Using TLS/SSL</a> |
| </li> |
| |
| <li class="none"> |
| <a href="mailing_lists.html">Creating Mailing Lists</a> |
| </li> |
| </ul> |
| <h5>Customization</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="custom_matcher.html">How to write a custom Matcher</a> |
| </li> |
| |
| <li class="none"> |
| <a href="custom_mailet.html">How to write a custom Mailet</a> |
| </li> |
| </ul> |
| <h5>Project Documentation</h5> |
| <ul> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="collapsed"> |
| <a href="project-info.html">Project Information</a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="expanded"> |
| <a href="project-reports.html">Project Reports</a> |
| <ul> |
| |
| <li class="none"> |
| <strong>CPD Report</strong> |
| </li> |
| |
| <li class="none"> |
| <a href="apidocs/index.html">JavaDocs</a> |
| </li> |
| |
| <li class="none"> |
| <a href="jira-report.html">JIRA Report</a> |
| </li> |
| |
| <li class="none"> |
| <a href="mailet-report.html">Mailet Reference</a> |
| </li> |
| |
| <li class="none"> |
| <a href="pmd.html">PMD Report</a> |
| </li> |
| |
| <li class="none"> |
| <a href="xref/index.html">Source Xref</a> |
| </li> |
| |
| <li class="none"> |
| <a href="testapidocs/index.html">Test JavaDocs</a> |
| </li> |
| |
| <li class="none"> |
| <a href="xref-test/index.html">Test Source Xref</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <h5>Project</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="http://issues.apache.org/jira/browse/JAMES">Bug Database</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://svn.apache.org/viewvc/james/server/">Source Code</a> |
| </li> |
| |
| <li class="none"> |
| <a href="../todo.html">TODO</a> |
| </li> |
| </ul> |
| <h5>Downloads</h5> |
| <ul> |
| |
| <li class="none"> |
| <a href="../../download.cgi">Stable releases</a> |
| </li> |
| |
| <li class="none"> |
| <a href="../../downloadunstable.cgi">Unstable releases</a> |
| </li> |
| |
| <li class="none"> |
| <a href="http://people.apache.org/builds/james/nightly/">Nightly builds</a> |
| </li> |
| </ul> |
| <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy"> |
| <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img> |
| </a> |
| |
| |
| |
| |
| |
| |
| |
| </div> |
| </div> |
| <div id="bodyColumn"> |
| <div id="contentBox"> |
| <div class="section"><h2>CPD Results</h2><p>The following document contains the results of PMD's <a href="http://pmd.sourceforge.net/cpd.html">CPD</a> 3.9.</p></div><div class="section"><h2>Duplications</h2><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/RemoteDelivery.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/RemoteDelivery.html#278">278</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Retry.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Retry.html#243">243</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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);</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/vut/JDBCVirtualUserTable.java</td><td>Apache JAMES Server Avalon User function</td><td><a href="./xref/org/apache/james/vut/JDBCVirtualUserTable.html#179">179</a></td></tr><tr class="a"><td>org/apache/james/domain/JDBCDomainList.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/domain/JDBCDomainList.html#167">167</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } 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; |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/domain/AbstractDomainList.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/domain/AbstractDomainList.html#82">82</a></td></tr><tr class="a"><td>org/apache/james/impl/vut/AbstractVirtualUserTable.java</td><td>Apache JAMES Server User Library</td><td><a href="./xref/org/apache/james/impl/vut/AbstractVirtualUserTable.html#374">374</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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) {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#465">465</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#588">588</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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()) {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/vut/JDBCVirtualUserTable.java</td><td>Apache JAMES Server Avalon User function</td><td><a href="./xref/org/apache/james/vut/JDBCVirtualUserTable.html#523">523</a></td></tr><tr class="a"><td>org/apache/james/domain/JDBCDomainList.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/domain/JDBCDomainList.html#257">257</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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; |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/vut/JDBCVirtualUserTable.java</td><td>Apache JAMES Server Avalon User function</td><td><a href="./xref/org/apache/james/vut/JDBCVirtualUserTable.html#135">135</a></td></tr><tr class="a"><td>org/apache/james/domain/JDBCDomainList.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/domain/JDBCDomainList.html#122">122</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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);</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#218">218</a></td></tr><tr class="a"><td>org/apache/james/transport/matchers/IsInWhiteList.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/matchers/IsInWhiteList.html#118">118</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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);</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/RemoteDelivery.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/RemoteDelivery.html#512">512</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Retry.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Retry.html#421">421</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/pop3server/POP3Handler.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/POP3Handler.html#189">189</a></td></tr><tr class="a"><td>org/apache/james/smtpserver/SMTPHandler.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/SMTPHandler.html#207">207</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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);</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/api/vut/management/VirtualUserTableManagementMBean.java</td><td>Apache JAMES Server User API</td><td><a href="./xref/org/apache/james/api/vut/management/VirtualUserTableManagementMBean.html#47">47</a></td></tr><tr class="a"><td>org/apache/james/api/vut/management/VirtualUserTableManagementService.java</td><td>Apache JAMES Server User API</td><td><a href="./xref/org/apache/james/api/vut/management/VirtualUserTableManagementService.html#45">45</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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;</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/AbstractRedirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/AbstractRedirect.html#400">400</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Redirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Redirect.html#335">335</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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 {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/Forward.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Forward.html#120">120</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Redirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Redirect.html#340">340</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| |
| 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 {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/pop3server/ListCmdHandler.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/ListCmdHandler.html#100">100</a></td></tr><tr class="a"><td>org/apache/james/pop3server/UidlCmdHandler.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/UidlCmdHandler.html#76">76</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> .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()); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/util/bayesian/BayesianAnalyzer.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/bayesian/BayesianAnalyzer.html#372">372</a></td></tr><tr class="a"><td>org/apache/james/util/bayesian/BayesianAnalyzer.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/bayesian/BayesianAnalyzer.html#424">424</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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;</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/pop3server/POP3HandlerChain.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/POP3HandlerChain.html#175">175</a></td></tr><tr class="a"><td>org/apache/james/smtpserver/SMTPHandlerChain.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/SMTPHandlerChain.html#314">314</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| |
| /** |
| * 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; |
| } |
| |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/nntpserver/NNTPHandler.java</td><td>Apache JAMES Server NNTP function</td><td><a href="./xref/org/apache/james/nntpserver/NNTPHandler.html#768">768</a></td></tr><tr class="a"><td>org/apache/james/nntpserver/NNTPHandler.java</td><td>Apache JAMES Server NNTP function</td><td><a href="./xref/org/apache/james/nntpserver/NNTPHandler.html#899">899</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> .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 ")</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/AbstractRedirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/AbstractRedirect.html#405">405</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Forward.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Forward.html#120">120</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| |
| 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 {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#743">743</a></td></tr><tr class="a"><td>org/apache/james/transport/matchers/IsInWhiteList.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/matchers/IsInWhiteList.html#226">226</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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());</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.html#393">393</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#793">793</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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("'.");</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/AbstractRedirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/AbstractRedirect.html#480">480</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/Redirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/Redirect.html#375">375</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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 {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/nntpserver/NNTPHandler.java</td><td>Apache JAMES Server NNTP function</td><td><a href="./xref/org/apache/james/nntpserver/NNTPHandler.html#770">770</a></td></tr><tr class="a"><td>org/apache/james/nntpserver/NNTPHandler.java</td><td>Apache JAMES Server NNTP function</td><td><a href="./xref/org/apache/james/nntpserver/NNTPHandler.html#969">969</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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 ")</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#528">528</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#651">651</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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);</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/vut/JDBCVirtualUserTable.java</td><td>Apache JAMES Server Avalon User function</td><td><a href="./xref/org/apache/james/vut/JDBCVirtualUserTable.html#170">170</a></td></tr><tr class="a"><td>org/apache/james/mailrepository/JDBCMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/JDBCMailRepository.html#298">298</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/BayesianAnalysis.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/BayesianAnalysis.html#230">230</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/BayesianAnalysisFeeder.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/BayesianAnalysisFeeder.html#189">189</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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); |
| } </pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/AbstractRedirect.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/AbstractRedirect.html#1031">1031</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/DSNBounce.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/DSNBounce.html#217">217</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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();</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/util/XMLResources.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/XMLResources.html#142">142</a></td></tr><tr class="a"><td>org/apache/james/util/sql/SqlResources.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/sql/SqlResources.html#184">184</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> .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();</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#333">333</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#485">485</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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()) {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/pop3server/RetrCmdHandler.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/RetrCmdHandler.html#74">74</a></td></tr><tr class="a"><td>org/apache/james/pop3server/TopCmdHandler.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/TopCmdHandler.html#102">102</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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 =</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/pop3server/POP3HandlerChain.java</td><td>Apache JAMES Server POP3 function</td><td><a href="./xref/org/apache/james/pop3server/POP3HandlerChain.html#149">149</a></td></tr><tr class="a"><td>org/apache/james/smtpserver/SMTPHandlerChain.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/SMTPHandlerChain.html#127">127</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| } |
| |
| // 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"); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/JDBCAlias.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/JDBCAlias.html#89">89</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/JDBCVirtualUserTable.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/JDBCVirtualUserTable.html#128">128</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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()); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#333">333</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/WhiteListManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/WhiteListManager.html#608">608</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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()) {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/mailrepository/JDBCMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/JDBCMailRepository.html#523">523</a></td></tr><tr class="a"><td>org/apache/james/mailrepository/JDBCMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/JDBCMailRepository.html#627">627</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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());</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.html#399">399</a></td></tr><tr class="a"><td>org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.html#619">619</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| } |
| |
| /** |
| * 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("'.");</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/smtpserver/core/DataCmdHandler.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/core/DataCmdHandler.html#153">153</a></td></tr><tr class="a"><td>org/apache/james/smtpserver/core/SendMailHandler.java</td><td>Apache JAMES Server SMTP function</td><td><a href="./xref/org/apache/james/smtpserver/core/SendMailHandler.html#100">100</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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.";</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/domain/JDBCDomainList.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/domain/JDBCDomainList.html#167">167</a></td></tr><tr class="a"><td>org/apache/james/mailrepository/JDBCMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/JDBCMailRepository.html#307">307</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } 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); |
| }</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/util/XMLResources.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/XMLResources.html#278">278</a></td></tr><tr class="a"><td>org/apache/james/util/sql/SqlResources.java</td><td>Apache JAMES Server Common Utilities</td><td><a href="./xref/org/apache/james/util/sql/SqlResources.html#346">346</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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)</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/mailrepository/AbstractMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/AbstractMailRepository.html#112">112</a></td></tr><tr class="a"><td>org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.html#253">253</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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) {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/mailrepository/AbstractMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/AbstractMailRepository.html#90">90</a></td></tr><tr class="a"><td>org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.java</td><td>Apache JAMES Server Core function</td><td><a href="./xref/org/apache/james/mailrepository/javamail/AbstractJavamailStoreMailRepository.html#276">276</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> 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 {</pre></div></td></tr><table class="bodyTable"></p><p><table class="bodyTable"><tr class="a"><th>File</th><th>Project</th><th>Line</th></tr><tr class="b"><td>org/apache/james/transport/mailets/CommandListservManager.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/CommandListservManager.html#416">416</a></td></tr><tr class="a"><td>org/apache/james/transport/mailets/CommandListservProcessor.java</td><td>Apache JAMES Server Mailets function</td><td><a href="./xref/org/apache/james/transport/mailets/CommandListservProcessor.html#452">452</a></td></tr><tr class="b"><td colspan='3'><div class="source"><pre> } |
| |
| /** |
| * 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; |
| }</pre></div></td></tr><table class="bodyTable"></p></div> |
| </div> |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| <div id="footer"> |
| <div class="xright">© |
| 2002-2009 |
| |
| The Apache Software Foundation |
| |
| |
| |
| |
| |
| |
| |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> |
| </script> |
| <script type="text/javascript"> |
| _uacct = "UA-1384591-1"; |
| urchinTracker(); |
| </script> |
| </body> |
| </html> |