Commit cd5a090f8b88e4b2c7c224a5b88151d74869e40f

Authored by Ronan
1 parent 03081ec9

Correcting SessionFilter and SkillEndPoint

skilldr-rs/src/main/java/eu/totoandco/filter/SessionFilter.java
... ... @@ -25,7 +25,6 @@ import javax.servlet.ServletException;
25 25 import javax.servlet.ServletRequest;
26 26 import javax.servlet.ServletResponse;
27 27 import javax.servlet.http.HttpServletRequest;
28   -import javax.ws.rs.core.Context;
29 28  
30 29 import eu.totoandco.exception.ExceptionLevel;
31 30 import eu.totoandco.exception.MessageCarrier;
... ... @@ -39,14 +38,13 @@ import eu.totoandco.rs.EndPoint;
39 38 * @author Ronan Presle (ronan.presle@ttmail.eu)
40 39 */
41 40 public class SessionFilter extends EndPoint implements Filter{
42   - @Context HttpServletRequest request;
43 41 /**
44 42 * This method is called whenever the urlpattern configured is called
45 43 */
46 44 @Override
47 45 public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) throws IOException, ServletException {
48   - //HttpServletRequest request = (HttpServletRequest) req;
49   - if (this.request.getSession(false) == null || this.request.getSession(false).getAttribute(USERSESSION) == null) {
  46 + HttpServletRequest request = (HttpServletRequest) req;
  47 + if (request.getSession(false) == null || request.getSession(false).getAttribute(USERSESSION) == null) {
50 48 throw new RestException(MessageCarrier
51 49 .message(MessageText.DISCONNECTED_USER)
52 50 .level(ExceptionLevel.DISCONNECTED).build());
... ...
skilldr-rs/src/main/java/eu/totoandco/rs/SkillEndPoint.java
... ... @@ -85,7 +85,7 @@ public class SkillEndPoint extends EndPoint {
85 85 * @return a UserSkill object containg all data
86 86 */
87 87 @POST
88   - @Path("/p/userSkill")
  88 + @Path("/userSkill")
89 89 public UserSkill addUserSkill(@FormParam("idSkill") int idSkill, @FormParam("period") int period,
90 90 @FormParam("idExperienceType") int idExperienceType,
91 91 @Context HttpServletRequest request) {
... ... @@ -93,7 +93,7 @@ public class SkillEndPoint extends EndPoint {
93 93 RestParameterCheck.checkNotNegativeOrZero(period);
94 94 RestParameterCheck.checkNotNegativeOrZero(idExperienceType);
95 95 return skillManager.addUserSkill(
96   - ((User) request.getAttribute(USERSESSION)).getId(),idSkill, period,
  96 + ((User) request.getSession(false).getAttribute(USERSESSION)).getId(),idSkill, period,
97 97 idExperienceType);
98 98 }
99 99  
... ... @@ -113,7 +113,7 @@ public class SkillEndPoint extends EndPoint {
113 113 RestParameterCheck.checkNotNegativeOrZero(idSkill);
114 114 RestParameterCheck.checkNotNegativeOrZero(period);
115 115 RestParameterCheck.checkNotNegativeOrZero(idExperienceType);
116   - return skillManager.updateUserSkill(((User) request.getAttribute(USERSESSION)).getId(), idSkill, period, idExperienceType);
  116 + return skillManager.updateUserSkill(((User) request.getSession(false).getAttribute(USERSESSION)).getId(), idSkill, period, idExperienceType);
117 117 }
118 118  
119 119 /**
... ... @@ -127,7 +127,7 @@ public class SkillEndPoint extends EndPoint {
127 127 @Context HttpServletRequest request) {
128 128 RestParameterCheck.checkNotNegativeOrZero(idSkill);
129 129 skillManager.removeUserSkill(
130   - ((User) request.getAttribute(USERSESSION)).getId(), idSkill);
  130 + ((User) request.getSession(false).getAttribute(USERSESSION)).getId(), idSkill);
131 131 }
132 132  
133 133 /**
... ...