else if (right == -READ)
freeReading = false;
else if (right == -WRITE)
freeWriting = false;
else
throw new RequestException("Invalid right value: " + right);
} else {
// Setting a specific user right:
Integer currentRight = (Integer) clients.get(user);
if (right == READ) {
if (currentRight != null && currentRight.intValue() == WRITE)
clients.put(user, new Integer(READWRITE));
else
clients.put(user, new Integer(READ));
} else if (right == WRITE) {
if (currentRight != null && currentRight.intValue() == READ)
clients.put(user, new Integer(READWRITE));
else
clients.put(user, new Integer(WRITE));
} else if (right == -READ) {
if (currentRight != null && currentRight.intValue() == READWRITE)
clients.put(user, new Integer(WRITE));
else if (currentRight != null && currentRight.intValue() == READ)
clients.remove(user);
} else if (right == -WRITE) {
if (currentRight != null && currentRight.intValue() == READWRITE)
clients.put(user, new Integer(READ));
else if (currentRight != null && currentRight.intValue() == WRITE)
clients.remove(user);
} else
throw new RequestException("Invalid right value: " + right);
}
}