Search in sources :

Example 6 with GenericWebResponse

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());
}
Also used : UInteger(org.jooq.types.UInteger) UInteger(org.jooq.types.UInteger) GenericWebResponse(edu.uci.ics.texera.web.response.GenericWebResponse)

Example 7 with GenericWebResponse

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();
}
Also used : UInteger(org.jooq.types.UInteger) GenericWebResponse(edu.uci.ics.texera.web.response.GenericWebResponse)

Aggregations

GenericWebResponse (edu.uci.ics.texera.web.response.GenericWebResponse)7 UInteger (org.jooq.types.UInteger)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)2 TexeraWebException (edu.uci.ics.texera.web.TexeraWebException)2 QueryPlanBean (edu.uci.ics.texera.web.response.planstore.QueryPlanBean)2 IOException (java.io.IOException)2