Add partially working blocking and deletion (for both client and server)
Additionally had to refactor several classes "a little bit". (Whenever one bug seemed fixed, another one appeared...)
This commit is contained in:
@ -17,14 +17,14 @@ public final class GroupCreation extends Event<String> {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* @param value the name of this group at creation time
|
||||
* @param name the name of this group at creation time
|
||||
* @param initialMemberIDs the IDs of all {@link User}s that should be group
|
||||
* members from the beginning on (excluding the creator
|
||||
* of this group)
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public GroupCreation(String value, Set<Long> initialMemberIDs) {
|
||||
super(value);
|
||||
public GroupCreation(String name, Set<Long> initialMemberIDs) {
|
||||
super(name);
|
||||
this.initialMemberIDs = initialMemberIDs != null ? initialMemberIDs : new HashSet<>();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package envoy.event;
|
||||
|
||||
import envoy.data.Group;
|
||||
|
||||
/**
|
||||
* Used to communicate with a client that his request to create a group might
|
||||
* have been rejected as it might be disabled on his current server.
|
||||
@ -7,15 +9,23 @@ package envoy.event;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public class GroupCreationResult extends Event<Boolean> {
|
||||
public class GroupCreationResult extends Event<Group> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new {@code GroupCreationResult}.
|
||||
* Creates a new {@code GroupCreationResult} that implies the failure of this
|
||||
* {@link GroupCreationResult}.
|
||||
*
|
||||
* @param success whether the GroupCreation sent before was successful
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public GroupCreationResult(boolean success) { super(success); }
|
||||
public GroupCreationResult() { super(null); }
|
||||
|
||||
/**
|
||||
* Creates a new {@code GroupCreationResult}.
|
||||
*
|
||||
* @param resultGroup the group the server created
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public GroupCreationResult(Group resultGroup) { super(resultGroup); }
|
||||
}
|
||||
|
@ -33,13 +33,12 @@ public final class GroupResize extends Event<User> {
|
||||
*/
|
||||
public GroupResize(User user, Group group, ElementOperation operation) {
|
||||
super(user);
|
||||
this.operation = operation;
|
||||
if (group.getContacts().contains(user)) {
|
||||
if (operation.equals(ADD))
|
||||
throw new IllegalArgumentException(String.format("Cannot add %s to %s!", user, group));
|
||||
} else if (operation.equals(REMOVE))
|
||||
throw new IllegalArgumentException(String.format("Cannot remove %s from %s!", user, group));
|
||||
groupID = group.getID();
|
||||
this.operation = operation;
|
||||
final var contained = group.getContacts().contains(user);
|
||||
if (contained && operation.equals(ADD))
|
||||
throw new IllegalArgumentException(String.format("Cannot add %s to %s!", user, group));
|
||||
else if (operation.equals(REMOVE) && !contained) throw new IllegalArgumentException(String.format("Cannot remove %s from %s!", user, group));
|
||||
groupID = group.getID();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,5 +71,5 @@ public final class GroupResize extends Event<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("GroupResize[userid=%d,groupid=%d,operation=%s]", get(), groupID, operation); }
|
||||
public String toString() { return String.format("GroupResize[user=%s,groupid=%d,operation=%s]", get(), groupID, operation); }
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import envoy.event.Event.Valueless;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.3-beta
|
||||
*/
|
||||
public class ContactDeletionSinceLastLogin extends Valueless {
|
||||
public class ContactsChangedSinceLastLogin extends Valueless {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -1,35 +1,38 @@
|
||||
package envoy.event.contact;
|
||||
|
||||
import envoy.data.Contact;
|
||||
import envoy.data.User;
|
||||
import envoy.event.*;
|
||||
|
||||
/**
|
||||
* Signifies the modification of a contact list.
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
* @since Envoy Common v0.3-beta
|
||||
*/
|
||||
public final class ContactOperation extends Event<Contact> {
|
||||
public final class UserOperation extends Event<User> {
|
||||
|
||||
private final ElementOperation operationType;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ContactOperation}.
|
||||
* Initializes a {@link UserOperation}.
|
||||
*
|
||||
* @param contact the user on which the operation is performed
|
||||
* @param operationType the type of operation to perform
|
||||
* @since Envoy Common v0.2-alpha
|
||||
* @since Envoy Common v0.3-beta
|
||||
*/
|
||||
public ContactOperation(Contact contact, ElementOperation operationType) {
|
||||
public UserOperation(User contact, ElementOperation operationType) {
|
||||
super(contact);
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of operation to perform
|
||||
* @since Envoy Common v0.2-alpha
|
||||
* @since Envoy Common v0.3-beta
|
||||
*/
|
||||
public ElementOperation getOperationType() { return operationType; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("%s[contact=%s, operation=%s]", UserOperation.class.getSimpleName(), value, operationType); }
|
||||
}
|
Reference in New Issue
Block a user