@POST @Path("/storeTwitter") @Consumes(MediaType.APPLICATION_JSON) @Produces("text/plain") public Response storeTwitter(UserTwitterTokens tokens) { DaoUserTwitterTokens daoTwitter = new DaoUserTwitterTokens(); if (daoTwitter.storeTwitterTokens(tokens) == DATA_SUCCESSFULLY_STORED) { return Response.status(Response.Status.OK).entity(MONGO_SUCCESS_MSG).build(); } return Response.status(ERROR_STORING_DATA).entity(MONGO_ERROR_MSG).build(); }
@POST @Path("/deleteTwitter") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) public Response deleteTwitter(MultivaluedMap<String, String> formParams) { DaoUserTwitterTokens daoTwitter = new DaoUserTwitterTokens(); int code = daoTwitter.deleteTwitterTokens(formParams.getFirst("AsociatedWorflowId")); if (code == NOT_FOUND_IN_DATABASE) { return Response.status(NOT_FOUND_IN_DATABASE).entity(MONGO_NOTFOUND_ID).build(); } else if (code == DATA_SUCCESSFULLY_DELETED) { return Response.status(DATA_SUCCESSFULLY_DELETED).entity(MONGO_SUCCESS_MSG).build(); } else { return Response.status(ERROR_DELETING_DATA).entity(MONGO_ERROR_MSG).build(); } }
@POST @Path("/getTwitter") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) public Response getTwitter(MultivaluedMap<String, String> formParams) { DaoUserTwitterTokens daoTwitter = new DaoUserTwitterTokens(); UserTwitterTokens tokens = null; tokens = daoTwitter.getTwitterTokens(formParams.getFirst("AsociatedWorflowId")); if (tokens != null) { return Response.status(Response.Status.OK).entity(tokens).build(); } return Response.status(NOT_FOUND_IN_DATABASE).entity(MONGO_NOTFOUND_ID).build(); }