use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class PlanStoreResource method updateQueryPlan.
@PUT
@Path("/{plan_name}")
public GenericWebResponse updateQueryPlan(@PathParam("plan_name") String planName, String queryPlanBeanJson) {
try {
QueryPlanBean queryPlanBean = new ObjectMapper().readValue(queryPlanBeanJson, QueryPlanBean.class);
// Updating the plan in the plan store
planStore.updatePlan(planName, queryPlanBean.getDescription(), mapper.writeValueAsString(queryPlanBean.getQueryPlan()));
} catch (IOException | TexeraException e) {
throw new TexeraWebException(e.getMessage());
}
return new GenericWebResponse(0, "Success");
}
use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class KeywordDictionaryResource method uploadDictionary.
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public GenericWebResponse uploadDictionary(@Session HttpSession session, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("size") String sizeString, @FormDataParam("description") String description) {
UInteger userID = UserResource.getUser(session).getUserID();
String dictName = fileDetail.getFileName();
String separator = ",";
long size = parseStringToUInteger(sizeString).longValue();
Pair<Integer, String> validationResult = validateDictionary(dictName, userID, size);
if (validationResult.getLeft() != 0) {
return new GenericWebResponse(validationResult.getLeft(), validationResult.getRight());
}
String content = readFileContent(uploadedInputStream);
List<String> itemList = convertStringToList(content, separator);
byte[] contentByteArray = convertListToByteArray(itemList);
int count = insertDictionaryToDataBase(dictName, contentByteArray, description, userID);
throwErrorWhenNotOne("Error occurred while inserting dictionary to database", count);
return GenericWebResponse.generateSuccessResponse();
}
use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class UserFileResource method validateUserFile.
@POST
@Path("/validate")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public GenericWebResponse validateUserFile(@Session HttpSession session, @FormDataParam("name") String fileName) {
UInteger userID = UserResource.getUser(session).getUserID();
Pair<Boolean, String> validationResult = validateFileName(fileName, userID);
return new GenericWebResponse(validationResult.getLeft() ? 0 : 1, validationResult.getRight());
}
use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class UserFileResource method deleteUserFile.
@DELETE
@Path("/delete/{fileID}")
public GenericWebResponse deleteUserFile(@PathParam("fileID") String fileID, @Session HttpSession session) {
UInteger userID = UserResource.getUser(session).getUserID();
UInteger fileIdUInteger = parseStringToUInteger(fileID);
Record1<String> result = deleteInDatabase(fileIdUInteger, userID);
if (result == null)
return new GenericWebResponse(1, "The file does not exist");
String filePath = result.get(FILE.PATH);
FileManager.getInstance().deleteFile(Paths.get(filePath));
return GenericWebResponse.generateSuccessResponse();
}
use of edu.uci.ics.texera.web.response.GenericWebResponse in project textdb by TextDB.
the class PlanStoreResource method addQueryPlan.
@POST
public GenericWebResponse addQueryPlan(String queryPlanBeanJson) {
try {
QueryPlanBean queryPlanBean = new ObjectMapper().readValue(queryPlanBeanJson, QueryPlanBean.class);
// Adding the query plan to the PlanStore
planStore.addPlan(queryPlanBean.getName(), queryPlanBean.getDescription(), mapper.writeValueAsString(queryPlanBean.getQueryPlan()));
} catch (TexeraException e) {
throw new TexeraWebException(e.getMessage());
} catch (IOException e) {
throw new TexeraWebException(e.getMessage());
}
return new GenericWebResponse(0, "Success");
}
Aggregations