src/org/sonews/daemon/command/ListCommand.java
changeset 120 bb1c8a7b774c
parent 48 b78e77619152
     1.1 --- a/src/org/sonews/daemon/command/ListCommand.java	Sun Sep 11 15:05:04 2011 +0200
     1.2 +++ b/src/org/sonews/daemon/command/ListCommand.java	Wed Dec 31 12:07:40 2014 +0100
     1.3 @@ -15,7 +15,6 @@
     1.4   *   You should have received a copy of the GNU General Public License
     1.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     1.6   */
     1.7 -
     1.8  package org.sonews.daemon.command;
     1.9  
    1.10  import java.io.IOException;
    1.11 @@ -34,37 +33,31 @@
    1.12   * @author Dennis Schwerdel
    1.13   * @since n3tpd/0.1
    1.14   */
    1.15 -public class ListCommand implements Command
    1.16 -{
    1.17 +public class ListCommand implements Command {
    1.18  
    1.19  	@Override
    1.20 -	public String[] getSupportedCommandStrings()
    1.21 -	{
    1.22 -		return new String[] {"LIST"};
    1.23 +	public String[] getSupportedCommandStrings() {
    1.24 +		return new String[]{"LIST"};
    1.25  	}
    1.26  
    1.27  	@Override
    1.28 -	public boolean hasFinished()
    1.29 -	{
    1.30 +	public boolean hasFinished() {
    1.31  		return true;
    1.32  	}
    1.33  
    1.34  	@Override
    1.35 -	public String impliedCapability()
    1.36 -	{
    1.37 +	public String impliedCapability() {
    1.38  		return null;
    1.39  	}
    1.40  
    1.41  	@Override
    1.42 -	public boolean isStateful()
    1.43 -	{
    1.44 +	public boolean isStateful() {
    1.45  		return false;
    1.46  	}
    1.47  
    1.48  	@Override
    1.49  	public void processLine(NNTPConnection conn, final String line, byte[] raw)
    1.50 -		throws IOException, StorageBackendException
    1.51 -	{
    1.52 +			throws IOException, StorageBackendException {
    1.53  		final String[] command = line.split(" ");
    1.54  
    1.55  		if (command.length >= 2) {
    1.56 @@ -90,7 +83,7 @@
    1.57  				conn.println(".");
    1.58  			} else if (command[1].equalsIgnoreCase("ACTIVE")) {
    1.59  				String pattern = command.length == 2
    1.60 -					? null : command[2].replace("*", "\\w*");
    1.61 +						? null : command[2].replace("*", "\\w*");
    1.62  				printGroupInfo(conn, pattern);
    1.63  			} else {
    1.64  				conn.println("500 unknown argument to LIST command");
    1.65 @@ -101,21 +94,20 @@
    1.66  	}
    1.67  
    1.68  	private void printGroupInfo(NNTPConnection conn, String pattern)
    1.69 -		throws IOException, StorageBackendException
    1.70 -	{
    1.71 +			throws IOException, StorageBackendException {
    1.72  		final List<Group> groups = Group.getAll();
    1.73  		if (groups != null) {
    1.74  			conn.println("215 list of newsgroups follows");
    1.75  			for (Group g : groups) {
    1.76  				try {
    1.77  					Matcher matcher = pattern == null
    1.78 -						? null : Pattern.compile(pattern).matcher(g.getName());
    1.79 +							? null : Pattern.compile(pattern).matcher(g.getName());
    1.80  					if (!g.isDeleted()
    1.81 -						&& (matcher == null || matcher.find())) {
    1.82 +							&& (matcher == null || matcher.find())) {
    1.83  						String writeable = g.isWriteable() ? " y" : " n";
    1.84  						// Indeed first the higher article number then the lower
    1.85  						conn.println(g.getName() + " " + g.getLastArticleNumber() + " "
    1.86 -							+ g.getFirstArticleNumber() + writeable);
    1.87 +								+ g.getFirstArticleNumber() + writeable);
    1.88  					}
    1.89  				} catch (PatternSyntaxException ex) {
    1.90  					Log.get().info(ex.toString());