Proper reply on XDAEMON GROUPADD if group already existing (#551).
authorcli
Wed, 26 Aug 2009 10:55:59 +0200
changeset 23e4345a26f81f
parent 22 2541bdb54cb2
child 24 2ff819fa5be1
Proper reply on XDAEMON GROUPADD if group already existing (#551).
org/sonews/daemon/command/XDaemonCommand.java
     1.1 --- a/org/sonews/daemon/command/XDaemonCommand.java	Wed Aug 26 10:47:51 2009 +0200
     1.2 +++ b/org/sonews/daemon/command/XDaemonCommand.java	Wed Aug 26 10:55:59 2009 +0200
     1.3 @@ -66,6 +66,21 @@
     1.4      return false;
     1.5    }
     1.6  
     1.7 +  private void channelAdd(String[] commands, NNTPConnection conn)
     1.8 +    throws IOException, StorageBackendException
     1.9 +  {
    1.10 +    String groupName = commands[2];
    1.11 +    if(StorageManager.current().isGroupExisting(groupName))
    1.12 +    {
    1.13 +      conn.println("400 group " + groupName + " already existing!");
    1.14 +    }
    1.15 +    else
    1.16 +    {
    1.17 +      StorageManager.current().addGroup(groupName, Integer.parseInt(commands[3]));
    1.18 +      conn.println("200 group " + groupName + " created");
    1.19 +    }
    1.20 +  }
    1.21 +
    1.22    // TODO: Refactor this method to reduce complexity!
    1.23    @Override
    1.24    public void processLine(NNTPConnection conn, String line, byte[] raw)
    1.25 @@ -119,8 +134,7 @@
    1.26        }
    1.27        else if(commands.length == 4 && commands[1].equalsIgnoreCase("GROUPADD"))
    1.28        {
    1.29 -        StorageManager.current().addGroup(commands[2], Integer.parseInt(commands[3]));
    1.30 -        conn.println("200 group " + commands[2] + " created");
    1.31 +        channelAdd(commands, conn);
    1.32        }
    1.33        else if(commands.length == 3 && commands[1].equalsIgnoreCase("GROUPDEL"))
    1.34        {