Skip to content

Commit

Permalink
Moooore thread safety and mooore admin limited ressources
Browse files Browse the repository at this point in the history
  • Loading branch information
hannaeko committed Jan 14, 2018
1 parent 90df935 commit 7d4d73b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ public Response getInput(@PathParam("id") String id) {
}

@GET
@Secured
@Path("{id}/outputFile")
@Produces(MediaType.TEXT_PLAIN)
public Response getOutput(@PathParam("id") String id) {
public Response getOutput(@PathParam("id") String id, @Context SecurityContext securityContext) {
if ( ! securityContext.isUserInRole("Admin") )
throw new NotAuthorizedException("");

Exercice exercice = getExercice(Integer.parseInt(id));
Response.ResponseBuilder response = Response.ok(exercice.getOutputFile());
response.header("Content-Disposition", "attachment; filename=\"output_exercice_" + id + ".txt\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import javax.ws.rs.InternalServerErrorException;

public class Serializable {
private static Session session;

public static String saveObject(InitModel object){
session = HibernateUtil.getSessionFactory().openSession();
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = null;

try {
Expand All @@ -30,7 +29,7 @@ public static String saveObject(InitModel object){
}

public static void updateObject(InitModel object, Integer id) {
session = HibernateUtil.getSessionFactory().openSession();
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = null;

try {
Expand Down

0 comments on commit 7d4d73b

Please sign in to comment.