Add HSQLDB stubs and reformat some source files.
authorcli
Mon, 06 Jun 2011 20:12:21 +0200
changeset 427f84f4de2893
parent 41 11402b568081
child 43 7d0e65712a95
Add HSQLDB stubs and reformat some source files.
AUTHORS
SConstruct
debian/control
makedeb
src/org/sonews/Main.java
src/org/sonews/daemon/command/PostCommand.java
src/org/sonews/storage/Channel.java
src/org/sonews/storage/Group.java
src/org/sonews/storage/Storage.java
src/org/sonews/storage/StorageManager.java
src/org/sonews/storage/StorageProvider.java
src/org/sonews/storage/impl/HSQLDB.java
src/org/sonews/storage/impl/HSQLDBProvider.java
src/org/sonews/storage/impl/JDBCDatabaseProvider.java
src/org/sonews/util/io/ArticleInputStream.java
     1.1 --- a/AUTHORS	Wed May 04 18:34:21 2011 +0200
     1.2 +++ b/AUTHORS	Mon Jun 06 20:12:21 2011 +0200
     1.3 @@ -6,11 +6,12 @@
     1.4  the Free Software community are mentioned here:
     1.5  
     1.6  sonews News Server
     1.7 --------------------
     1.8 +------------------
     1.9 +Copyright (c) 2011 by Christian Lins <christian@lins.me>
    1.10 +
    1.11  Copyright (c) 2009, 2010 by
    1.12 -
    1.13 -Christian Lins <christian.lins@fh-osnabrueck.de>
    1.14 -Bernd Eilers <bernd.eilers@sun.com>
    1.15 +  Christian Lins <christian.lins@fh-osnabrueck.de>
    1.16 +  Bernd Eilers <bernd.eilers@sun.com>
    1.17  
    1.18  
    1.19  sonews based partly upon
     2.1 --- a/SConstruct	Wed May 04 18:34:21 2011 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,16 +0,0 @@
     2.4 -# This file is used to build and automatically test sonews
     2.5 -
     2.6 -import os
     2.7 -env = Environment()
     2.8 -
     2.9 -env['ENV']['LANG'] = 'en_GB.UTF-8'
    2.10 -env['JAVACFLAGS']    = '-source 1.6 -target 1.6'
    2.11 -env['JAVACLASSPATH'] = '/usr/share/java/junit4.jar:/usr/share/java/glassfish-mail.jar:/usr/share/java/servlet-api-2.5.jar:/usr/share/java/jchart2d.jar:classes'
    2.12 -
    2.13 -# Build Java classes
    2.14 -classes = env.Java(target='classes', source=['org/sonews/'])
    2.15 -test_classes   = env.Java(target='classes', source=['test'])
    2.16 -
    2.17 -# Setting dependencies
    2.18 -Depends(test_classes, classes)
    2.19 -
     3.1 --- a/debian/control	Wed May 04 18:34:21 2011 +0200
     3.2 +++ b/debian/control	Mon Jun 06 20:12:21 2011 +0200
     3.3 @@ -9,9 +9,8 @@
     3.4  
     3.5  Package: sonews-server
     3.6  Architecture: all
     3.7 -Depends: openjdk-6-jre-headless | openjdk-6-jre | sun-java6-jre | cacao | jamvm, glassfish-mail, libmysql-java
     3.8 -Suggests: sonews-web, libpg-java, mysql-server, libjchart2d-java
     3.9 +Depends: openjdk-6-jre-headless | openjdk-6-jre | sun-java6-jre, glassfish-mail, libhsqldb-java
    3.10 +Suggests: sonews-web, libpg-java, mysql-server, libmysql-java, libjchart2d-java
    3.11  Description: Usenet news server
    3.12   sonews is a modern Usenet server providing newsgroups via NNTP.
    3.13   A relational database backend is used to store the news data.
    3.14 - The sonews-web providers a configuration web interface.
     4.1 --- a/makedeb	Wed May 04 18:34:21 2011 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,36 +0,0 @@
     4.4 -#!/bin/bash -x
     4.5 -PACKAGE_ROOT=sonews
     4.6 -
     4.7 -# Compile classes 
     4.8 -scons
     4.9 -
    4.10 -# Create JAR files; this cannot be done with SCons,
    4.11 -# because Scons looses inner classes.
    4.12 -jar -cf sonews.jar -C classes/ org/
    4.13 -jar -ufe sonews.jar org.sonews.Main
    4.14 -jar -cf test.jar -C classes/ test/ 
    4.15 -jar -ufe test.jar test.TestBench
    4.16 -jar -cf sonews-helpers.jar helpers/
    4.17 -
    4.18 -# Create faked root for packaging
    4.19 -sudo rm -r $PACKAGE_ROOT/
    4.20 -mkdir -p $PACKAGE_ROOT/usr/share/java
    4.21 -mkdir -p $PACKAGE_ROOT/usr/bin
    4.22 -mkdir -p $PACKAGE_ROOT/etc/sonews
    4.23 -mkdir -p $PACKAGE_ROOT/usr/share/doc/sonews/
    4.24 -cp -r DEBIAN $PACKAGE_ROOT/
    4.25 -cp helpers/sonews $PACKAGE_ROOT/usr/bin/sonews
    4.26 -cp helpers/sonews.conf.sample $PACKAGE_ROOT/etc/sonews/sonews.conf
    4.27 -cp helpers/copyright $PACKAGE_ROOT/usr/share/doc/sonews/
    4.28 -cp sonews*.jar $PACKAGE_ROOT/usr/share/java/
    4.29 -
    4.30 -sudo chown root:root -R $PACKAGE_ROOT/
    4.31 -
    4.32 -dpkg-deb --build $PACKAGE_ROOT
    4.33 -
    4.34 -# Cleanup
    4.35 -sudo rm -r $PACKAGE_ROOT
    4.36 -rm -r classes/
    4.37 -
    4.38 -# Check debs
    4.39 -lintian sonews.deb
     5.1 --- a/src/org/sonews/Main.java	Wed May 04 18:34:21 2011 +0200
     5.2 +++ b/src/org/sonews/Main.java	Mon Jun 06 20:12:21 2011 +0200
     5.3 @@ -15,7 +15,6 @@
     5.4   *   You should have received a copy of the GNU General Public License
     5.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     5.6   */
     5.7 -
     5.8  package org.sonews;
     5.9  
    5.10  import java.sql.Driver;
    5.11 @@ -42,8 +41,7 @@
    5.12   * @author Christian Lins
    5.13   * @since sonews/0.5.0
    5.14   */
    5.15 -public final class Main
    5.16 -{
    5.17 +public final class Main {
    5.18  
    5.19  	/** Version information of the sonews daemon */
    5.20  	public static final String VERSION = "sonews/1.1.0";
    5.21 @@ -54,8 +52,7 @@
    5.22  	 * @param args
    5.23  	 * @throws Exception
    5.24  	 */
    5.25 -	public static void main(String[] args) throws Exception
    5.26 -	{
    5.27 +	public static void main(String[] args) throws Exception {
    5.28  		System.out.println(VERSION);
    5.29  		Thread.currentThread().setName("Mainthread");
    5.30  
    5.31 @@ -106,7 +103,7 @@
    5.32  		// a working JDBCDatabase connection.
    5.33  		try {
    5.34  			StorageProvider sprov =
    5.35 -				StorageManager.loadProvider("org.sonews.storage.impl.JDBCDatabaseProvider");
    5.36 +					StorageManager.loadProvider("org.sonews.storage.impl.JDBCDatabaseProvider");
    5.37  			StorageManager.enableProvider(sprov);
    5.38  
    5.39  			// Make sure some elementary groups are existing
    5.40 @@ -118,7 +115,7 @@
    5.41  			ex.printStackTrace();
    5.42  			System.err.println("Database initialization failed with " + ex.toString());
    5.43  			System.err.println("Make sure you have specified the correct database"
    5.44 -				+ " settings in sonews.conf!");
    5.45 +					+ " settings in sonews.conf!");
    5.46  			return;
    5.47  		}
    5.48  
    5.49 @@ -154,13 +151,11 @@
    5.50  		daemon.join();
    5.51  	}
    5.52  
    5.53 -	private static void printArguments()
    5.54 -	{
    5.55 +	private static void printArguments() {
    5.56  		String usage = Resource.getAsString("helpers/usage", true);
    5.57  		System.out.println(usage);
    5.58  	}
    5.59  
    5.60 -	private Main()
    5.61 -	{
    5.62 +	private Main() {
    5.63  	}
    5.64  }
     6.1 --- a/src/org/sonews/daemon/command/PostCommand.java	Wed May 04 18:34:21 2011 +0200
     6.2 +++ b/src/org/sonews/daemon/command/PostCommand.java	Mon Jun 06 20:12:21 2011 +0200
     6.3 @@ -15,7 +15,6 @@
     6.4   *   You should have received a copy of the GNU General Public License
     6.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     6.6   */
     6.7 -
     6.8  package org.sonews.daemon.command;
     6.9  
    6.10  import java.io.IOException;
    6.11 @@ -45,40 +44,35 @@
    6.12   * @author Christian Lins
    6.13   * @since sonews/0.5.0
    6.14   */
    6.15 -public class PostCommand implements Command
    6.16 -{
    6.17 +public class PostCommand implements Command {
    6.18  
    6.19  	private final Article article = new Article();
    6.20  	private int lineCount = 0;
    6.21  	private long bodySize = 0;
    6.22  	private InternetHeaders headers = null;
    6.23  	private long maxBodySize =
    6.24 -		Config.inst().get(Config.ARTICLE_MAXSIZE, 128) * 1024L; // Size in bytes
    6.25 +			Config.inst().get(Config.ARTICLE_MAXSIZE, 128) * 1024L; // Size in bytes
    6.26  	private PostState state = PostState.WaitForLineOne;
    6.27  	private final ByteArrayOutputStream bufBody = new ByteArrayOutputStream();
    6.28  	private final StringBuilder strHead = new StringBuilder();
    6.29  
    6.30  	@Override
    6.31 -	public String[] getSupportedCommandStrings()
    6.32 -	{
    6.33 -		return new String[] {"POST"};
    6.34 +	public String[] getSupportedCommandStrings() {
    6.35 +		return new String[]{"POST"};
    6.36  	}
    6.37  
    6.38  	@Override
    6.39 -	public boolean hasFinished()
    6.40 -	{
    6.41 +	public boolean hasFinished() {
    6.42  		return this.state == PostState.Finished;
    6.43  	}
    6.44  
    6.45  	@Override
    6.46 -	public String impliedCapability()
    6.47 -	{
    6.48 +	public String impliedCapability() {
    6.49  		return null;
    6.50  	}
    6.51  
    6.52  	@Override
    6.53 -	public boolean isStateful()
    6.54 -	{
    6.55 +	public boolean isStateful() {
    6.56  		return true;
    6.57  	}
    6.58  
    6.59 @@ -90,8 +84,7 @@
    6.60  	 */
    6.61  	@Override // TODO: Refactor this method to reduce complexity!
    6.62  	public void processLine(NNTPConnection conn, String line, byte[] raw)
    6.63 -		throws IOException, StorageBackendException
    6.64 -	{
    6.65 +			throws IOException, StorageBackendException {
    6.66  		switch (state) {
    6.67  			case WaitForLineOne: {
    6.68  				if (line.equalsIgnoreCase("POST")) {
    6.69 @@ -113,7 +106,7 @@
    6.70  					try {
    6.71  						// Parse the header using the InternetHeader class from JavaMail API
    6.72  						headers = new InternetHeaders(
    6.73 -							new ByteArrayInputStream(strHead.toString().trim().getBytes(conn.getCurrentCharset())));
    6.74 +								new ByteArrayInputStream(strHead.toString().trim().getBytes(conn.getCurrentCharset())));
    6.75  
    6.76  						// add the header entries for the article
    6.77  						article.setHeaders(headers);
    6.78 @@ -181,8 +174,7 @@
    6.79  	 * @param article
    6.80  	 */
    6.81  	private void controlMessage(NNTPConnection conn, Article article)
    6.82 -		throws IOException
    6.83 -	{
    6.84 +			throws IOException {
    6.85  		String[] ctrl = article.getHeader(Headers.CONTROL)[0].split(" ");
    6.86  		if (ctrl.length == 2) // "cancel <mid>"
    6.87  		{
    6.88 @@ -203,8 +195,7 @@
    6.89  	}
    6.90  
    6.91  	private void supersedeMessage(NNTPConnection conn, Article article)
    6.92 -		throws IOException
    6.93 -	{
    6.94 +			throws IOException {
    6.95  		try {
    6.96  			String oldMsg = article.getHeader(Headers.SUPERSEDES)[0];
    6.97  			StorageManager.current().delete(oldMsg);
    6.98 @@ -217,8 +208,7 @@
    6.99  	}
   6.100  
   6.101  	private void postArticle(NNTPConnection conn, Article article)
   6.102 -		throws IOException
   6.103 -	{
   6.104 +			throws IOException {
   6.105  		if (article.getHeader(Headers.CONTROL)[0].length() > 0) {
   6.106  			controlMessage(conn, article);
   6.107  		} else if (article.getHeader(Headers.SUPERSEDES)[0].length() > 0) {
   6.108 @@ -253,7 +243,7 @@
   6.109  
   6.110  								// Log this posting to statistics
   6.111  								Stats.getInstance().mailPosted(
   6.112 -									article.getHeader(Headers.NEWSGROUPS)[0]);
   6.113 +										article.getHeader(Headers.NEWSGROUPS)[0]);
   6.114  							}
   6.115  							success = true;
   6.116  						}
     7.1 --- a/src/org/sonews/storage/Channel.java	Wed May 04 18:34:21 2011 +0200
     7.2 +++ b/src/org/sonews/storage/Channel.java	Mon Jun 06 20:12:21 2011 +0200
     7.3 @@ -15,7 +15,6 @@
     7.4   *   You should have received a copy of the GNU General Public License
     7.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     7.6   */
     7.7 -
     7.8  package org.sonews.storage;
     7.9  
    7.10  import java.util.ArrayList;
    7.11 @@ -30,8 +29,7 @@
    7.12   * @author Christian Lins
    7.13   * @since sonews/1.0
    7.14   */
    7.15 -public abstract class Channel
    7.16 -{
    7.17 +public abstract class Channel {
    7.18  
    7.19  	/**
    7.20  	 * If this flag is set the Group is no real newsgroup but a mailing list
    7.21 @@ -39,22 +37,19 @@
    7.22  	 * the mailing list gateway.
    7.23  	 */
    7.24  	public static final int MAILINGLIST = 0x1;
    7.25 -
    7.26  	/**
    7.27  	 * If this flag is set the Group is marked as readonly and the posting
    7.28  	 * is prohibited. This can be useful for groups that are synced only in
    7.29  	 * one direction.
    7.30  	 */
    7.31  	public static final int READONLY = 0x2;
    7.32 -
    7.33  	/**
    7.34  	 * If this flag is set the Group is marked as deleted and must not occur
    7.35  	 * in any output. The deletion is done lazily by a low priority daemon.
    7.36  	 */
    7.37  	public static final int DELETED = 0x80;
    7.38  
    7.39 -	public static List<Channel> getAll()
    7.40 -	{
    7.41 +	public static List<Channel> getAll() {
    7.42  		List<Channel> all = new ArrayList<Channel>();
    7.43  
    7.44  		/*List<Channel> agroups = AggregatedGroup.getAll();
    7.45 @@ -72,36 +67,35 @@
    7.46  	}
    7.47  
    7.48  	public static Channel getByName(String name)
    7.49 -		throws StorageBackendException
    7.50 -	{
    7.51 +			throws StorageBackendException {
    7.52  		return StorageManager.current().getGroup(name);
    7.53  	}
    7.54  
    7.55  	public abstract Article getArticle(long idx)
    7.56 -		throws StorageBackendException;
    7.57 +			throws StorageBackendException;
    7.58  
    7.59  	public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
    7.60 -		final long first, final long last)
    7.61 -		throws StorageBackendException;
    7.62 +			final long first, final long last)
    7.63 +			throws StorageBackendException;
    7.64  
    7.65  	public abstract List<Long> getArticleNumbers()
    7.66 -		throws StorageBackendException;
    7.67 +			throws StorageBackendException;
    7.68  
    7.69  	public abstract long getFirstArticleNumber()
    7.70 -		throws StorageBackendException;
    7.71 +			throws StorageBackendException;
    7.72  
    7.73  	public abstract long getIndexOf(Article art)
    7.74 -		throws StorageBackendException;
    7.75 +			throws StorageBackendException;
    7.76  
    7.77  	public abstract long getInternalID();
    7.78  
    7.79  	public abstract long getLastArticleNumber()
    7.80 -		throws StorageBackendException;
    7.81 +			throws StorageBackendException;
    7.82  
    7.83  	public abstract String getName();
    7.84  
    7.85  	public abstract long getPostingsCount()
    7.86 -		throws StorageBackendException;
    7.87 +			throws StorageBackendException;
    7.88  
    7.89  	public abstract boolean isDeleted();
    7.90  
     8.1 --- a/src/org/sonews/storage/Group.java	Wed May 04 18:34:21 2011 +0200
     8.2 +++ b/src/org/sonews/storage/Group.java	Mon Jun 06 20:12:21 2011 +0200
     8.3 @@ -15,7 +15,6 @@
     8.4   *   You should have received a copy of the GNU General Public License
     8.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     8.6   */
     8.7 -
     8.8  package org.sonews.storage;
     8.9  
    8.10  import java.sql.SQLException;
    8.11 @@ -29,8 +28,7 @@
    8.12   * @since sonews/0.5.0
    8.13   */
    8.14  // TODO: This class should not be public!
    8.15 -public class Group extends Channel
    8.16 -{
    8.17 +public class Group extends Channel {
    8.18  
    8.19  	private long id = 0;
    8.20  	private int flags = -1;
    8.21 @@ -39,8 +37,7 @@
    8.22  	/**
    8.23  	 * @return List of all groups this server handles.
    8.24  	 */
    8.25 -	public static List<Channel> getAll()
    8.26 -	{
    8.27 +	public static List<Channel> getAll() {
    8.28  		try {
    8.29  			return StorageManager.current().getGroups();
    8.30  		} catch (StorageBackendException ex) {
    8.31 @@ -53,16 +50,14 @@
    8.32  	 * @param name
    8.33  	 * @param id
    8.34  	 */
    8.35 -	public Group(final String name, final long id, final int flags)
    8.36 -	{
    8.37 +	public Group(final String name, final long id, final int flags) {
    8.38  		this.id = id;
    8.39  		this.flags = flags;
    8.40  		this.name = name;
    8.41  	}
    8.42  
    8.43  	@Override
    8.44 -	public boolean equals(Object obj)
    8.45 -	{
    8.46 +	public boolean equals(Object obj) {
    8.47  		if (obj instanceof Group) {
    8.48  			return ((Group) obj).id == this.id;
    8.49  		} else {
    8.50 @@ -71,73 +66,61 @@
    8.51  	}
    8.52  
    8.53  	public Article getArticle(long idx)
    8.54 -		throws StorageBackendException
    8.55 -	{
    8.56 +			throws StorageBackendException {
    8.57  		return StorageManager.current().getArticle(idx, this.id);
    8.58  	}
    8.59  
    8.60  	public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
    8.61 -		throws StorageBackendException
    8.62 -	{
    8.63 +			throws StorageBackendException {
    8.64  		return StorageManager.current().getArticleHeads(this, first, last);
    8.65  	}
    8.66  
    8.67  	public List<Long> getArticleNumbers()
    8.68 -		throws StorageBackendException
    8.69 -	{
    8.70 +			throws StorageBackendException {
    8.71  		return StorageManager.current().getArticleNumbers(id);
    8.72  	}
    8.73  
    8.74  	public long getFirstArticleNumber()
    8.75 -		throws StorageBackendException
    8.76 -	{
    8.77 +			throws StorageBackendException {
    8.78  		return StorageManager.current().getFirstArticleNumber(this);
    8.79  	}
    8.80  
    8.81 -	public int getFlags()
    8.82 -	{
    8.83 +	public int getFlags() {
    8.84  		return this.flags;
    8.85  	}
    8.86  
    8.87  	public long getIndexOf(Article art)
    8.88 -		throws StorageBackendException
    8.89 -	{
    8.90 +			throws StorageBackendException {
    8.91  		return StorageManager.current().getArticleIndex(art, this);
    8.92  	}
    8.93  
    8.94  	/**
    8.95  	 * Returns the group id.
    8.96  	 */
    8.97 -	public long getInternalID()
    8.98 -	{
    8.99 +	public long getInternalID() {
   8.100  		assert id > 0;
   8.101  
   8.102  		return id;
   8.103  	}
   8.104  
   8.105 -	public boolean isDeleted()
   8.106 -	{
   8.107 +	public boolean isDeleted() {
   8.108  		return (this.flags & DELETED) != 0;
   8.109  	}
   8.110  
   8.111 -	public boolean isMailingList()
   8.112 -	{
   8.113 +	public boolean isMailingList() {
   8.114  		return (this.flags & MAILINGLIST) != 0;
   8.115  	}
   8.116  
   8.117 -	public boolean isWriteable()
   8.118 -	{
   8.119 +	public boolean isWriteable() {
   8.120  		return true;
   8.121  	}
   8.122  
   8.123  	public long getLastArticleNumber()
   8.124 -		throws StorageBackendException
   8.125 -	{
   8.126 +			throws StorageBackendException {
   8.127  		return StorageManager.current().getLastArticleNumber(this);
   8.128  	}
   8.129  
   8.130 -	public String getName()
   8.131 -	{
   8.132 +	public String getName() {
   8.133  		return name;
   8.134  	}
   8.135  
   8.136 @@ -146,13 +129,11 @@
   8.137  	 * in the JDBCDatabase.
   8.138  	 * @param flag
   8.139  	 */
   8.140 -	public void setFlag(final int flag)
   8.141 -	{
   8.142 +	public void setFlag(final int flag) {
   8.143  		this.flags |= flag;
   8.144  	}
   8.145  
   8.146 -	public void setName(final String name)
   8.147 -	{
   8.148 +	public void setName(final String name) {
   8.149  		this.name = name;
   8.150  	}
   8.151  
   8.152 @@ -161,8 +142,7 @@
   8.153  	 * @throws java.sql.SQLException
   8.154  	 */
   8.155  	public long getPostingsCount()
   8.156 -		throws StorageBackendException
   8.157 -	{
   8.158 +			throws StorageBackendException {
   8.159  		return StorageManager.current().getPostingsCount(this.name);
   8.160  	}
   8.161  
   8.162 @@ -170,8 +150,7 @@
   8.163  	 * Updates flags and name in the backend.
   8.164  	 */
   8.165  	public void update()
   8.166 -		throws StorageBackendException
   8.167 -	{
   8.168 +			throws StorageBackendException {
   8.169  		StorageManager.current().update(this);
   8.170  	}
   8.171  }
     9.1 --- a/src/org/sonews/storage/Storage.java	Wed May 04 18:34:21 2011 +0200
     9.2 +++ b/src/org/sonews/storage/Storage.java	Mon Jun 06 20:12:21 2011 +0200
     9.3 @@ -15,7 +15,6 @@
     9.4   *   You should have received a copy of the GNU General Public License
     9.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     9.6   */
     9.7 -
     9.8  package org.sonews.storage;
     9.9  
    9.10  import java.util.List;
    9.11 @@ -27,8 +26,7 @@
    9.12   * @author Christian Lins
    9.13   * @since sonews/1.0
    9.14   */
    9.15 -public interface Storage
    9.16 -{
    9.17 +public interface Storage {
    9.18  
    9.19  	/**
    9.20  	 * Stores the given Article in the storage.
    9.21 @@ -36,60 +34,60 @@
    9.22  	 * @throws StorageBackendException
    9.23  	 */
    9.24  	void addArticle(Article art)
    9.25 -		throws StorageBackendException;
    9.26 +			throws StorageBackendException;
    9.27  
    9.28  	void addEvent(long timestamp, int type, long groupID)
    9.29 -		throws StorageBackendException;
    9.30 +			throws StorageBackendException;
    9.31  
    9.32  	void addGroup(String groupname, int flags)
    9.33 -		throws StorageBackendException;
    9.34 +			throws StorageBackendException;
    9.35  
    9.36  	int countArticles()
    9.37 -		throws StorageBackendException;
    9.38 +			throws StorageBackendException;
    9.39  
    9.40  	int countGroups()
    9.41 -		throws StorageBackendException;
    9.42 +			throws StorageBackendException;
    9.43  
    9.44  	void delete(String messageID)
    9.45 -		throws StorageBackendException;
    9.46 +			throws StorageBackendException;
    9.47  
    9.48  	Article getArticle(String messageID)
    9.49 -		throws StorageBackendException;
    9.50 +			throws StorageBackendException;
    9.51  
    9.52  	Article getArticle(long articleIndex, long groupID)
    9.53 -		throws StorageBackendException;
    9.54 +			throws StorageBackendException;
    9.55  
    9.56  	List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
    9.57 -		throws StorageBackendException;
    9.58 +			throws StorageBackendException;
    9.59  
    9.60  	List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end,
    9.61 -		String header, String pattern)
    9.62 -		throws StorageBackendException;
    9.63 +			String header, String pattern)
    9.64 +			throws StorageBackendException;
    9.65  
    9.66  	long getArticleIndex(Article art, Group group)
    9.67 -		throws StorageBackendException;
    9.68 +			throws StorageBackendException;
    9.69  
    9.70  	List<Long> getArticleNumbers(long groupID)
    9.71 -		throws StorageBackendException;
    9.72 +			throws StorageBackendException;
    9.73  
    9.74  	String getConfigValue(String key)
    9.75 -		throws StorageBackendException;
    9.76 +			throws StorageBackendException;
    9.77  
    9.78  	int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
    9.79 -		Channel channel)
    9.80 -		throws StorageBackendException;
    9.81 +			Channel channel)
    9.82 +			throws StorageBackendException;
    9.83  
    9.84  	double getEventsPerHour(int key, long gid)
    9.85 -		throws StorageBackendException;
    9.86 +			throws StorageBackendException;
    9.87  
    9.88  	int getFirstArticleNumber(Group group)
    9.89 -		throws StorageBackendException;
    9.90 +			throws StorageBackendException;
    9.91  
    9.92  	Group getGroup(String name)
    9.93 -		throws StorageBackendException;
    9.94 +			throws StorageBackendException;
    9.95  
    9.96  	List<Channel> getGroups()
    9.97 -		throws StorageBackendException;
    9.98 +			throws StorageBackendException;
    9.99  
   9.100  	/**
   9.101  	 * Retrieves the collection of groupnames that are associated with the
   9.102 @@ -99,10 +97,10 @@
   9.103  	 * @throws StorageBackendException
   9.104  	 */
   9.105  	List<String> getGroupsForList(String listAddress)
   9.106 -		throws StorageBackendException;
   9.107 +			throws StorageBackendException;
   9.108  
   9.109  	int getLastArticleNumber(Group group)
   9.110 -		throws StorageBackendException;
   9.111 +			throws StorageBackendException;
   9.112  
   9.113  	/**
   9.114  	 * Returns a list of email addresses that are related to the given
   9.115 @@ -112,28 +110,28 @@
   9.116  	 * @throws StorageBackendException
   9.117  	 */
   9.118  	List<String> getListsForGroup(String groupname)
   9.119 -		throws StorageBackendException;
   9.120 +			throws StorageBackendException;
   9.121  
   9.122  	String getOldestArticle()
   9.123 -		throws StorageBackendException;
   9.124 +			throws StorageBackendException;
   9.125  
   9.126  	int getPostingsCount(String groupname)
   9.127 -		throws StorageBackendException;
   9.128 +			throws StorageBackendException;
   9.129  
   9.130  	List<Subscription> getSubscriptions(int type)
   9.131 -		throws StorageBackendException;
   9.132 +			throws StorageBackendException;
   9.133  
   9.134  	boolean isArticleExisting(String messageID)
   9.135 -		throws StorageBackendException;
   9.136 +			throws StorageBackendException;
   9.137  
   9.138  	boolean isGroupExisting(String groupname)
   9.139 -		throws StorageBackendException;
   9.140 +			throws StorageBackendException;
   9.141  
   9.142  	void purgeGroup(Group group)
   9.143 -		throws StorageBackendException;
   9.144 +			throws StorageBackendException;
   9.145  
   9.146  	void setConfigValue(String key, String value)
   9.147 -		throws StorageBackendException;
   9.148 +			throws StorageBackendException;
   9.149  
   9.150  	/**
   9.151  	 * Updates headers and channel references of the given article.
   9.152 @@ -142,8 +140,8 @@
   9.153  	 * @throws StorageBackendException
   9.154  	 */
   9.155  	boolean update(Article article)
   9.156 -		throws StorageBackendException;
   9.157 +			throws StorageBackendException;
   9.158  
   9.159  	boolean update(Group group)
   9.160 -		throws StorageBackendException;
   9.161 +			throws StorageBackendException;
   9.162  }
    10.1 --- a/src/org/sonews/storage/StorageManager.java	Wed May 04 18:34:21 2011 +0200
    10.2 +++ b/src/org/sonews/storage/StorageManager.java	Mon Jun 06 20:12:21 2011 +0200
    10.3 @@ -15,22 +15,19 @@
    10.4   *   You should have received a copy of the GNU General Public License
    10.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    10.6   */
    10.7 -
    10.8  package org.sonews.storage;
    10.9  
   10.10  /**
   10.11 - *
   10.12 + * Provides access to a storage backend.
   10.13   * @author Christian Lins
   10.14   * @since sonews/1.0
   10.15   */
   10.16 -public final class StorageManager
   10.17 -{
   10.18 +public final class StorageManager {
   10.19  
   10.20  	private static StorageProvider provider;
   10.21  
   10.22  	public static Storage current()
   10.23 -		throws StorageBackendException
   10.24 -	{
   10.25 +			throws StorageBackendException {
   10.26  		synchronized (StorageManager.class) {
   10.27  			if (provider == null) {
   10.28  				return null;
   10.29 @@ -40,8 +37,7 @@
   10.30  		}
   10.31  	}
   10.32  
   10.33 -	public static StorageProvider loadProvider(String pluginClassName)
   10.34 -	{
   10.35 +	public static StorageProvider loadProvider(String pluginClassName) {
   10.36  		try {
   10.37  			Class<?> clazz = Class.forName(pluginClassName);
   10.38  			Object inst = clazz.newInstance();
   10.39 @@ -56,8 +52,7 @@
   10.40  	 * Sets the current storage provider.
   10.41  	 * @param provider
   10.42  	 */
   10.43 -	public static void enableProvider(StorageProvider provider)
   10.44 -	{
   10.45 +	public static void enableProvider(StorageProvider provider) {
   10.46  		synchronized (StorageManager.class) {
   10.47  			if (StorageManager.provider != null) {
   10.48  				disableProvider();
   10.49 @@ -69,8 +64,7 @@
   10.50  	/**
   10.51  	 * Disables the current provider.
   10.52  	 */
   10.53 -	public static void disableProvider()
   10.54 -	{
   10.55 +	public static void disableProvider() {
   10.56  		synchronized (StorageManager.class) {
   10.57  			provider = null;
   10.58  		}
    11.1 --- a/src/org/sonews/storage/StorageProvider.java	Wed May 04 18:34:21 2011 +0200
    11.2 +++ b/src/org/sonews/storage/StorageProvider.java	Mon Jun 06 20:12:21 2011 +0200
    11.3 @@ -15,7 +15,6 @@
    11.4   *   You should have received a copy of the GNU General Public License
    11.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    11.6   */
    11.7 -
    11.8  package org.sonews.storage;
    11.9  
   11.10  /**
   11.11 @@ -23,8 +22,7 @@
   11.12   * @author Christian Lins
   11.13   * @since sonews/1.0
   11.14   */
   11.15 -public interface StorageProvider
   11.16 -{
   11.17 +public interface StorageProvider {
   11.18  
   11.19  	public boolean isSupported(String uri);
   11.20  
   11.21 @@ -35,5 +33,5 @@
   11.22  	 * @return The reference to the associated Storage.
   11.23  	 */
   11.24  	public Storage storage(Thread thread)
   11.25 -		throws StorageBackendException;
   11.26 +			throws StorageBackendException;
   11.27  }
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/org/sonews/storage/impl/HSQLDB.java	Mon Jun 06 20:12:21 2011 +0200
    12.3 @@ -0,0 +1,157 @@
    12.4 +/*
    12.5 + *   SONEWS News Server
    12.6 + *   see AUTHORS for the list of contributors
    12.7 + *
    12.8 + *   This program is free software: you can redistribute it and/or modify
    12.9 + *   it under the terms of the GNU General Public License as published by
   12.10 + *   the Free Software Foundation, either version 3 of the License, or
   12.11 + *   (at your option) any later version.
   12.12 + *
   12.13 + *   This program is distributed in the hope that it will be useful,
   12.14 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.16 + *   GNU General Public License for more details.
   12.17 + *
   12.18 + *   You should have received a copy of the GNU General Public License
   12.19 + *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   12.20 + */
   12.21 +package org.sonews.storage.impl;
   12.22 +
   12.23 +import java.util.List;
   12.24 +import org.sonews.feed.Subscription;
   12.25 +import org.sonews.storage.Article;
   12.26 +import org.sonews.storage.ArticleHead;
   12.27 +import org.sonews.storage.Channel;
   12.28 +import org.sonews.storage.Group;
   12.29 +import org.sonews.storage.Storage;
   12.30 +import org.sonews.storage.StorageBackendException;
   12.31 +import org.sonews.util.Pair;
   12.32 +
   12.33 +/**
   12.34 + *
   12.35 + * @author Christian Lins
   12.36 + * @since sonews/1.1
   12.37 + */
   12.38 +public class HSQLDB implements Storage {
   12.39 +
   12.40 +	public void addArticle(Article art) throws StorageBackendException {
   12.41 +		throw new UnsupportedOperationException("Not supported yet.");
   12.42 +	}
   12.43 +
   12.44 +	public void addEvent(long timestamp, int type, long groupID) throws StorageBackendException {
   12.45 +		throw new UnsupportedOperationException("Not supported yet.");
   12.46 +	}
   12.47 +
   12.48 +	public void addGroup(String groupname, int flags) throws StorageBackendException {
   12.49 +		throw new UnsupportedOperationException("Not supported yet.");
   12.50 +	}
   12.51 +
   12.52 +	public int countArticles() throws StorageBackendException {
   12.53 +		throw new UnsupportedOperationException("Not supported yet.");
   12.54 +	}
   12.55 +
   12.56 +	public int countGroups() throws StorageBackendException {
   12.57 +		throw new UnsupportedOperationException("Not supported yet.");
   12.58 +	}
   12.59 +
   12.60 +	public void delete(String messageID) throws StorageBackendException {
   12.61 +		throw new UnsupportedOperationException("Not supported yet.");
   12.62 +	}
   12.63 +
   12.64 +	public Article getArticle(String messageID) throws StorageBackendException {
   12.65 +		throw new UnsupportedOperationException("Not supported yet.");
   12.66 +	}
   12.67 +
   12.68 +	public Article getArticle(long articleIndex, long groupID) throws StorageBackendException {
   12.69 +		throw new UnsupportedOperationException("Not supported yet.");
   12.70 +	}
   12.71 +
   12.72 +	public List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end, String header, String pattern) throws StorageBackendException {
   12.73 +		throw new UnsupportedOperationException("Not supported yet.");
   12.74 +	}
   12.75 +
   12.76 +	public List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last) throws StorageBackendException {
   12.77 +		throw new UnsupportedOperationException("Not supported yet.");
   12.78 +	}
   12.79 +
   12.80 +	public long getArticleIndex(Article art, Group group) throws StorageBackendException {
   12.81 +		throw new UnsupportedOperationException("Not supported yet.");
   12.82 +	}
   12.83 +
   12.84 +	public List<Long> getArticleNumbers(long groupID) throws StorageBackendException {
   12.85 +		throw new UnsupportedOperationException("Not supported yet.");
   12.86 +	}
   12.87 +
   12.88 +	public String getConfigValue(String key) throws StorageBackendException {
   12.89 +		throw new UnsupportedOperationException("Not supported yet.");
   12.90 +	}
   12.91 +
   12.92 +	public int getEventsCount(int eventType, long startTimestamp, long endTimestamp, Channel channel) throws StorageBackendException {
   12.93 +		throw new UnsupportedOperationException("Not supported yet.");
   12.94 +	}
   12.95 +
   12.96 +	public double getEventsPerHour(int key, long gid) throws StorageBackendException {
   12.97 +		throw new UnsupportedOperationException("Not supported yet.");
   12.98 +	}
   12.99 +
  12.100 +	public int getFirstArticleNumber(Group group) throws StorageBackendException {
  12.101 +		throw new UnsupportedOperationException("Not supported yet.");
  12.102 +	}
  12.103 +
  12.104 +	public Group getGroup(String name) throws StorageBackendException {
  12.105 +		throw new UnsupportedOperationException("Not supported yet.");
  12.106 +	}
  12.107 +
  12.108 +	public List<Channel> getGroups() throws StorageBackendException {
  12.109 +		throw new UnsupportedOperationException("Not supported yet.");
  12.110 +	}
  12.111 +
  12.112 +	public List<String> getGroupsForList(String listAddress) throws StorageBackendException {
  12.113 +		throw new UnsupportedOperationException("Not supported yet.");
  12.114 +	}
  12.115 +
  12.116 +	public int getLastArticleNumber(Group group) throws StorageBackendException {
  12.117 +		throw new UnsupportedOperationException("Not supported yet.");
  12.118 +	}
  12.119 +
  12.120 +	public List<String> getListsForGroup(String groupname) throws StorageBackendException {
  12.121 +		throw new UnsupportedOperationException("Not supported yet.");
  12.122 +	}
  12.123 +
  12.124 +	public String getOldestArticle() throws StorageBackendException {
  12.125 +		throw new UnsupportedOperationException("Not supported yet.");
  12.126 +	}
  12.127 +
  12.128 +	public int getPostingsCount(String groupname) throws StorageBackendException {
  12.129 +		throw new UnsupportedOperationException("Not supported yet.");
  12.130 +	}
  12.131 +
  12.132 +	public List<Subscription> getSubscriptions(int type) throws StorageBackendException {
  12.133 +		throw new UnsupportedOperationException("Not supported yet.");
  12.134 +	}
  12.135 +
  12.136 +	public boolean isArticleExisting(String messageID) throws StorageBackendException {
  12.137 +		throw new UnsupportedOperationException("Not supported yet.");
  12.138 +	}
  12.139 +
  12.140 +	public boolean isGroupExisting(String groupname) throws StorageBackendException {
  12.141 +		throw new UnsupportedOperationException("Not supported yet.");
  12.142 +	}
  12.143 +
  12.144 +	public void purgeGroup(Group group) throws StorageBackendException {
  12.145 +		throw new UnsupportedOperationException("Not supported yet.");
  12.146 +	}
  12.147 +
  12.148 +	public void setConfigValue(String key, String value) throws StorageBackendException {
  12.149 +		throw new UnsupportedOperationException("Not supported yet.");
  12.150 +	}
  12.151 +
  12.152 +	public boolean update(Article article) throws StorageBackendException {
  12.153 +		throw new UnsupportedOperationException("Not supported yet.");
  12.154 +	}
  12.155 +
  12.156 +	public boolean update(Group group) throws StorageBackendException {
  12.157 +		throw new UnsupportedOperationException("Not supported yet.");
  12.158 +	}
  12.159 +
  12.160 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/org/sonews/storage/impl/HSQLDBProvider.java	Mon Jun 06 20:12:21 2011 +0200
    13.3 @@ -0,0 +1,39 @@
    13.4 +/*
    13.5 + *   SONEWS News Server
    13.6 + *   see AUTHORS for the list of contributors
    13.7 + *
    13.8 + *   This program is free software: you can redistribute it and/or modify
    13.9 + *   it under the terms of the GNU General Public License as published by
   13.10 + *   the Free Software Foundation, either version 3 of the License, or
   13.11 + *   (at your option) any later version.
   13.12 + *
   13.13 + *   This program is distributed in the hope that it will be useful,
   13.14 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.16 + *   GNU General Public License for more details.
   13.17 + *
   13.18 + *   You should have received a copy of the GNU General Public License
   13.19 + *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   13.20 + */
   13.21 +package org.sonews.storage.impl;
   13.22 +
   13.23 +import org.sonews.storage.Storage;
   13.24 +import org.sonews.storage.StorageBackendException;
   13.25 +import org.sonews.storage.StorageProvider;
   13.26 +
   13.27 +/**
   13.28 + *
   13.29 + * @author Christian Lins
   13.30 + * @since sonews/1.1
   13.31 + */
   13.32 +public class HSQLDBProvider implements StorageProvider {
   13.33 +
   13.34 +	public boolean isSupported(String uri) {
   13.35 +		throw new UnsupportedOperationException("Not supported yet.");
   13.36 +	}
   13.37 +
   13.38 +	public Storage storage(Thread thread) throws StorageBackendException {
   13.39 +		throw new UnsupportedOperationException("Not supported yet.");
   13.40 +	}
   13.41 +
   13.42 +}
    14.1 --- a/src/org/sonews/storage/impl/JDBCDatabaseProvider.java	Wed May 04 18:34:21 2011 +0200
    14.2 +++ b/src/org/sonews/storage/impl/JDBCDatabaseProvider.java	Mon Jun 06 20:12:21 2011 +0200
    14.3 @@ -15,7 +15,6 @@
    14.4   *   You should have received a copy of the GNU General Public License
    14.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    14.6   */
    14.7 -
    14.8  package org.sonews.storage.impl;
    14.9  
   14.10  import java.sql.SQLException;
   14.11 @@ -30,21 +29,18 @@
   14.12   * @author Christian Lins
   14.13   * @since sonews/1.0
   14.14   */
   14.15 -public class JDBCDatabaseProvider implements StorageProvider
   14.16 -{
   14.17 +public class JDBCDatabaseProvider implements StorageProvider {
   14.18  
   14.19  	protected static final Map<Thread, JDBCDatabase> instances = new ConcurrentHashMap<Thread, JDBCDatabase>();
   14.20  
   14.21  	@Override
   14.22 -	public boolean isSupported(String uri)
   14.23 -	{
   14.24 +	public boolean isSupported(String uri) {
   14.25  		throw new UnsupportedOperationException("Not supported yet.");
   14.26  	}
   14.27  
   14.28  	@Override
   14.29  	public Storage storage(Thread thread)
   14.30 -		throws StorageBackendException
   14.31 -	{
   14.32 +			throws StorageBackendException {
   14.33  		try {
   14.34  			if (!instances.containsKey(Thread.currentThread())) {
   14.35  				JDBCDatabase db = new JDBCDatabase();
    15.1 --- a/src/org/sonews/util/io/ArticleInputStream.java	Wed May 04 18:34:21 2011 +0200
    15.2 +++ b/src/org/sonews/util/io/ArticleInputStream.java	Mon Jun 06 20:12:21 2011 +0200
    15.3 @@ -15,7 +15,6 @@
    15.4   *   You should have received a copy of the GNU General Public License
    15.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15.6   */
    15.7 -
    15.8  package org.sonews.util.io;
    15.9  
   15.10  import java.io.ByteArrayOutputStream;
   15.11 @@ -29,15 +28,13 @@
   15.12   * @author Christian Lins
   15.13   * @since sonews/0.5.0
   15.14   */
   15.15 -public class ArticleInputStream extends InputStream
   15.16 -{
   15.17 +public class ArticleInputStream extends InputStream {
   15.18  
   15.19  	private byte[] buf;
   15.20  	private int pos = 0;
   15.21  
   15.22  	public ArticleInputStream(final Article art)
   15.23 -		throws IOException, UnsupportedEncodingException
   15.24 -	{
   15.25 +			throws IOException, UnsupportedEncodingException {
   15.26  		final ByteArrayOutputStream out = new ByteArrayOutputStream();
   15.27  		out.write(art.getHeaderSource().getBytes("UTF-8"));
   15.28  		out.write("\r\n\r\n".getBytes());
   15.29 @@ -56,8 +53,7 @@
   15.30  	 * @return The byte read, or -1 if end of stream
   15.31  	 */
   15.32  	@Override
   15.33 -	public synchronized int read()
   15.34 -	{
   15.35 +	public synchronized int read() {
   15.36  		if (pos < buf.length) {
   15.37  			return ((int) buf[pos++]) & 0xFF;
   15.38  		} else {