Program: 38145
Project: 38145
Buggy source:
/** 
 * Method used to create command objects together with CommandFactory.
 * @param json the JSON part of the request as a string.
 * @param uri the URI found in the request line of the request..
 * @param cmdt the assumed command type of the JSON object.
 * @return an executable Command object of the correct type.
 */
private Command createCommand(String json,String uri,String uuid,CommandType cmdt){
  if (RestfulSizes.getSize(cmdt) != calculateURISize(uri)) {
    return null;
  }
  Command newCommand=null;
  String parsedURI=parseRequestURI(uri);
  String username=Authenticate.getUsernameByID(uuid);
  String[] rest;
switch (cmdt) {
case DELETE_ANNOTATION_VALUE_COMMAND:
    rest=uri.split("String_Node_Str");
  newCommand=cmdFactory.createDeleteAnnotationValueCommand(rest[3],rest[4]);
break;
case LOGIN_COMMAND:
newCommand=cmdFactory.createLoginCommand(json);
break;
case LOGOUT_COMMAND:
newCommand=cmdFactory.createLogoutCommand(username);
break;
case GET_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createGetExperimentCommand(parsedURI);
break;
case ADD_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createAddExperimentCommand(json);
break;
case UPDATE_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createUpdateExperimentCommand(json,parsedURI);
break;
case DELETE_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createDeleteExperimentCommand(parsedURI);
break;
case GET_FILE_FROM_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createGetFileFromExperimentCommand(parsedURI);
break;
case ADD_FILE_TO_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createAddFileToExperimentCommand(json);
break;
case UPDATE_FILE_IN_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createUpdateFileInExperimentCommand(json,parsedURI);
break;
case DELETE_FILE_FROM_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createDeleteFileFromExperimentCommand(parsedURI);
break;
case SEARCH_FOR_EXPERIMENTS_COMMAND:
newCommand=cmdFactory.createSearchForExperimentCommand(parsedURI);
break;
case DELETE_USER_COMMAND:
newCommand=cmdFactory.createDeleteUserCommand(parsedURI);
break;
case PROCESS_COMMAND:
newCommand=cmdFactory.createProcessCommand(json,username,parsedURI);
break;
case GET_PROCESS_STATUS_COMMAND:
newCommand=cmdFactory.createGetProcessStatusCommand(workPool);
break;
case GET_ANNOTATION_INFORMATION_COMMAND:
newCommand=cmdFactory.createGetAnnotationInformationCommand(json);
break;
case ADD_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createAddAnnotationFieldCommand(parsedURI);
break;
case ADD_ANNOTATION_VALUE_COMMAND:
newCommand=cmdFactory.createAddAnnotationValueCommand(json);
break;
case RENAME_ANNOTATION_VALUE_COMMAND:
newCommand=cmdFactory.creatRenameAnnotationValueCommand(json);
break;
case RENAME_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createEditAnnotationFieldCommand(json);
break;
case REMOVE_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createRemoveAnnotationFieldCommand(parsedURI);
break;
case GET_ANNOTATION_PRIVILEGES_COMMAND:
newCommand=cmdFactory.createGetAnnotationPrivilegesCommand(json);
break;
case UPDATE_ANNOTATION_PRIVILEGES_COMMAND:
newCommand=cmdFactory.createUpdateAnnotationPrivilegesCommand(json,parsedURI);
break;
case ADD_GENOME_RELEASE_COMMAND:
newCommand=cmdFactory.createAddGenomeReleaseCommand(json);
break;
case DELETE_GENOME_RELEASE_COMMAND:
rest=uri.split("String_Node_Str");
newCommand=cmdFactory.createDeleteGenomeReleaseCommand(rest[2],rest[3]);
break;
case GET_ALL_GENOME_RELEASE_COMMAND:
newCommand=cmdFactory.createGetAllGenomeReleasesCommand();
break;
case GET_GENOME_RELEASE_SPECIES_COMMAND:
newCommand=cmdFactory.createGetGenomeReleasesSpeciesCommand(parsedURI);
break;
case CREATE_USER_COMMAND:
newCommand=cmdFactory.createCreateUserCommand(json);
break;
case IS_TOKEN_VALID_COMMAND:
newCommand=cmdFactory.createIsTokenValidCommand(uuid);
break;
}
return newCommand;
}

Fixed version (ground truth):
/** 
 * Method used to create command objects together with CommandFactory.
 * @param json the JSON part of the request as a string.
 * @param uri the URI found in the request line of the request..
 * @param cmdt the assumed command type of the JSON object.
 * @return an executable Command object of the correct type.
 */
private Command createCommand(String json,String uri,String uuid,CommandType cmdt){
  if (RestfulSizes.getSize(cmdt) != calculateURISize(uri)) {
    return null;
  }
  Command newCommand=null;
  String parsedURI=parseRequestURI(uri);
  String username=Authenticate.getUsernameByID(uuid);
  String[] rest;
switch (cmdt) {
case DELETE_ANNOTATION_VALUE_COMMAND:
    rest=uri.split("String_Node_Str");
  newCommand=cmdFactory.createDeleteAnnotationValueCommand(rest[3],rest[4]);
break;
case LOGIN_COMMAND:
newCommand=cmdFactory.createLoginCommand(json);
break;
case LOGOUT_COMMAND:
newCommand=cmdFactory.createLogoutCommand(username);
break;
case GET_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createGetExperimentCommand(parsedURI);
break;
case ADD_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createAddExperimentCommand(json);
break;
case UPDATE_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createUpdateExperimentCommand(json,parsedURI);
break;
case DELETE_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createDeleteExperimentCommand(parsedURI);
break;
case GET_FILE_FROM_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createGetFileFromExperimentCommand(parsedURI);
break;
case ADD_FILE_TO_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createAddFileToExperimentCommand(json);
break;
case UPDATE_FILE_IN_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createUpdateFileInExperimentCommand(json,parsedURI);
break;
case DELETE_FILE_FROM_EXPERIMENT_COMMAND:
newCommand=cmdFactory.createDeleteFileFromExperimentCommand(parsedURI);
break;
case SEARCH_FOR_EXPERIMENTS_COMMAND:
newCommand=cmdFactory.createSearchForExperimentCommand(parsedURI);
break;
case DELETE_USER_COMMAND:
newCommand=cmdFactory.createDeleteUserCommand(parsedURI);
break;
case PROCESS_COMMAND:
newCommand=cmdFactory.createProcessCommand(json,username,parsedURI);
break;
case GET_PROCESS_STATUS_COMMAND:
newCommand=cmdFactory.createGetProcessStatusCommand(workPool);
break;
case GET_ANNOTATION_INFORMATION_COMMAND:
newCommand=cmdFactory.createGetAnnotationInformationCommand(json);
break;
case ADD_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createAddAnnotationFieldCommand(json);
break;
case ADD_ANNOTATION_VALUE_COMMAND:
newCommand=cmdFactory.createAddAnnotationValueCommand(json);
break;
case RENAME_ANNOTATION_VALUE_COMMAND:
newCommand=cmdFactory.creatRenameAnnotationValueCommand(json);
break;
case RENAME_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createEditAnnotationFieldCommand(json);
break;
case REMOVE_ANNOTATION_FIELD_COMMAND:
newCommand=cmdFactory.createRemoveAnnotationFieldCommand(parsedURI);
break;
case GET_ANNOTATION_PRIVILEGES_COMMAND:
newCommand=cmdFactory.createGetAnnotationPrivilegesCommand(json);
break;
case UPDATE_ANNOTATION_PRIVILEGES_COMMAND:
newCommand=cmdFactory.createUpdateAnnotationPrivilegesCommand(json,parsedURI);
break;
case ADD_GENOME_RELEASE_COMMAND:
newCommand=cmdFactory.createAddGenomeReleaseCommand(json);
break;
case DELETE_GENOME_RELEASE_COMMAND:
rest=uri.split("String_Node_Str");
newCommand=cmdFactory.createDeleteGenomeReleaseCommand(rest[2],rest[3]);
break;
case GET_ALL_GENOME_RELEASE_COMMAND:
newCommand=cmdFactory.createGetAllGenomeReleasesCommand();
break;
case GET_GENOME_RELEASE_SPECIES_COMMAND:
newCommand=cmdFactory.createGetGenomeReleasesSpeciesCommand(parsedURI);
break;
case CREATE_USER_COMMAND:
newCommand=cmdFactory.createCreateUserCommand(json);
break;
case IS_TOKEN_VALID_COMMAND:
newCommand=cmdFactory.createIsTokenValidCommand(uuid);
break;
}
return newCommand;
}