use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class KeywordDictionaryResource method validateUserDictionary.
@POST
@Path("/validate")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public GenericWebResponse validateUserDictionary(@Session HttpSession session, @FormDataParam("name") String fileName, @FormDataParam("size") String sizeString) {
UInteger userID = UserResource.getUser(session).getUserID();
long size = parseStringToUInteger(sizeString).longValue();
Pair<Integer, String> validationResult = validateDictionary(fileName, userID, size);
return new GenericWebResponse(validationResult.getLeft(), validationResult.getRight());
}
use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class UserFileResource method uploadFile.
/**
* This method will handle the request to upload a single file.
*/
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public GenericWebResponse uploadFile(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("size") String size, @FormDataParam("description") String description, @Session HttpSession session) {
UInteger userID = UserResource.getUser(session).getUserID();
String fileName = fileDetail.getFileName();
UInteger sizeUInteger = parseStringToUInteger(size);
Pair<Boolean, String> validationResult = validateFileName(fileName, userID);
if (!validationResult.getLeft()) {
return new GenericWebResponse(1, validationResult.getRight());
}
this.handleFileUpload(uploadedInputStream, fileName, description, sizeUInteger, userID);
return GenericWebResponse.generateSuccessResponse();
}
Aggregations