Complete XDAEMON GROUPFLAG subcommand.
authorcli
Sun Sep 11 14:19:19 2011 +0200 (2011-09-11)
changeset 47e118b4d60029
parent 46 28870db3b9fd
child 48 b78e77619152
Complete XDAEMON GROUPFLAG subcommand.
src/org/sonews/daemon/command/XDaemonCommand.java
src/org/sonews/storage/Group.java
     1.1 --- a/src/org/sonews/daemon/command/XDaemonCommand.java	Sat Sep 10 20:20:19 2011 +0200
     1.2 +++ b/src/org/sonews/daemon/command/XDaemonCommand.java	Sun Sep 11 14:19:19 2011 +0200
     1.3 @@ -132,23 +132,24 @@
     1.4  				String flagName = commands[4];
     1.5  				if(commands[3].equalsIgnoreCase("SET")) {
     1.6  					if(flagName.equals("MAILINGLIST")) {
     1.7 -
     1.8 +						group.setFlag(Channel.MAILINGLIST);
     1.9  					} else if(flagName.equals("DELETED")) {
    1.10 -
    1.11 +						group.setFlag(Channel.DELETED);
    1.12  					} else if(flagName.equals("READONLY")) {
    1.13 -
    1.14 +						group.setFlag(Channel.READONLY);
    1.15  					}
    1.16  				} else if(commands[3].equalsIgnoreCase("UNSET")) {
    1.17  					if(flagName.equals("MAILINGLIST")) {
    1.18 -
    1.19 +						group.unsetFlag(Channel.MAILINGLIST);
    1.20  					} else if(flagName.equals("DELETED")) {
    1.21 -
    1.22 +						group.unsetFlag(Channel.DELETED);
    1.23  					} else if(flagName.equals("READONLY")) {
    1.24 -
    1.25 +						group.unsetFlag(Channel.READONLY);
    1.26  					}
    1.27  				} else {
    1.28  					conn.println("500 invalid command usage");
    1.29  				}
    1.30 +				StorageManager.current().update(group);
    1.31  			} else if (commands.length == 4 && commands[1].equalsIgnoreCase("SET")) {
    1.32  				String key = commands[2];
    1.33  				String val = commands[3];
     2.1 --- a/src/org/sonews/storage/Group.java	Sat Sep 10 20:20:19 2011 +0200
     2.2 +++ b/src/org/sonews/storage/Group.java	Sun Sep 11 14:19:19 2011 +0200
     2.3 @@ -27,9 +27,28 @@
     2.4   * @author Christian Lins
     2.5   * @since sonews/0.5.0
     2.6   */
     2.7 -// TODO: This class should not be public!
     2.8  public class Group extends Channel {
     2.9  
    2.10 +	/**
    2.11 +	 * If this flag is set the Group is no real newsgroup but a mailing list
    2.12 +	 * mirror. In that case every posting and receiving mails must go through
    2.13 +	 * the mailing list gateway.
    2.14 +	 */
    2.15 +	public static final int MAILINGLIST = 0x1;
    2.16 +
    2.17 +	/**
    2.18 +	 * If this flag is set the Group is marked as readonly and the posting
    2.19 +	 * is prohibited. This can be useful for groups that are synced only in
    2.20 +	 * one direction.
    2.21 +	 */
    2.22 +	public static final int READONLY = 0x2;
    2.23 +
    2.24 +	/**
    2.25 +	 * If this flag is set the Group is marked as deleted and must not occur
    2.26 +	 * in any output. The deletion is done lazily by a low priority daemon.
    2.27 +	 */
    2.28 +	public static final int DELETED = 0x80;
    2.29 +
    2.30  	private long id = 0;
    2.31  	private int flags = -1;
    2.32  	private String name = null;
    2.33 @@ -47,8 +66,10 @@
    2.34  	}
    2.35  
    2.36  	/**
    2.37 +	 * Constructor.
    2.38  	 * @param name
    2.39  	 * @param id
    2.40 +	 * @param flags
    2.41  	 */
    2.42  	public Group(final String name, final long id, final int flags) {
    2.43  		this.id = id;
    2.44 @@ -99,7 +120,6 @@
    2.45  	 */
    2.46  	public long getInternalID() {
    2.47  		assert id > 0;
    2.48 -
    2.49  		return id;
    2.50  	}
    2.51  
    2.52 @@ -133,6 +153,10 @@
    2.53  		this.flags |= flag;
    2.54  	}
    2.55  
    2.56 +	public void unsetFlag(final int flag) {
    2.57 +		this.flags &= ~flag;
    2.58 +	}
    2.59 +
    2.60  	public void setName(final String name) {
    2.61  		this.name = name;
    2.62  	}