Code with Finding: |
class ServerInputProcessor {
private void processAddParticipants() throws ConnectionException {
Connection conn = DBManager.getConnection();
String command = participantsError(conn);
if (!command.equals("")) {
sendWithNonce(command);
} else {
String board = currentPath[0];
String region = currentPath[1];
List<String> addables = SocialNetworkAdmin.getAddableParticip(
conn, user, board, region);
List<String> addUsers = null;
String priv = "";
// Validity check
command = "";
boolean validParticip = false;
while (!validParticip) {
command += SocialNetworkAdmin.displayAddableParticip(addables, board);
sendWithNonce(command);
String input = recvWithNonce().toLowerCase();
if (input.equals("cancel")) {
sendWithNonce(CANCEL);
return;
}
// Checking for valid command
boolean validCommand = false;
String value = "";
if (input.matches("^view .+")) {
priv = "view";
validCommand = true;
value = Utils.getValue(input);
} else if (input.matches("^viewpost .+")) {
priv = "viewpost";
validCommand = true;
value = Utils.getValue(input);
} else {
command = INVALID;
}
if (validCommand) {
addUsers = Arrays.asList(value.split(" *, *"));
validParticip = addables.containsAll(addUsers);
if (!validParticip) {
command = "print You do not have permission to add all the " +
"users you specified.;print ;";
}
}
}
// Participants to add are valid
command = "";
for (String u: addUsers) {
command += SocialNetworkRegions.addParticipant(conn, board, region,
u, priv, user);
}
sendWithNonce(command);
}
DBManager.closeConnection(conn);
}
}
|