Author: [email protected]
Date: Tue Nov 22 13:52:53 2011
New Revision: 1743
Log:
Added logging and fixed the 500 error upon posting the form in (some) IE9
versions. The latter was caused by adding the form tag as descendant of the p
tag, which is not valid HTML.
Modified:
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/osgi/Activator.java
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/service/SurveyRESTServiceImpl.java
sandbox/ivol/ntlm/src/main/resources/jsp/survey.jsp
Modified:
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/osgi/Activator.java
==============================================================================
--- sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/osgi/Activator.java
(original)
+++ sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/osgi/Activator.java
Tue Nov 22 13:52:53 2011
@@ -85,7 +85,8 @@
createComponent()
.setInterface(RESTService.class.getName(), null)
.setImplementation(SurveyRESTServiceImpl.class)
-
.add(createServiceDependency().setService(SurveyStorageProvider.class).setRequired(true)));
+
.add(createServiceDependency().setService(SurveyStorageProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
// Register the Survey ColumnFamilies in Cassandra
manager.add(createComponent()
Modified:
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/service/SurveyRESTServiceImpl.java
==============================================================================
---
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/service/SurveyRESTServiceImpl.java
(original)
+++
sandbox/ivol/ntlm/src/main/java/org/amdatu/auth/ntlm/service/SurveyRESTServiceImpl.java
Tue Nov 22 13:52:53 2011
@@ -21,6 +21,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -40,6 +41,7 @@
import org.amdatu.auth.ntlm.domain.SubmittedSurvey;
import org.amdatu.auth.ntlm.domain.Survey;
import org.amdatu.web.rest.jaxrs.RESTService;
+import org.osgi.service.log.LogService;
/**
* Implementation of a survey REST service.
@@ -58,6 +60,7 @@
NO_CACHE_CONTROL.setNoCache(true);
}
private volatile SurveyStorageProvider m_surveyStore;
+ private volatile LogService m_logService;
private boolean isAuthorized(@Context final HttpServletRequest request) {
NtlmPasswordAuthentication session =
@@ -118,15 +121,14 @@
@SuppressWarnings("rawtypes")
@POST
@Consumes("application/x-www-form-urlencoded")
- public void addSurvey(@Context final HttpServletRequest request) {
+ public void addSurvey(@Context final HttpServletRequest request,
@FormParam("surveyId") final String surveyId) {
// Get the username from NTLM authentication
+ Map parameters = request.getParameterMap();
NtlmPasswordAuthentication session =
(NtlmPasswordAuthentication)
request.getSession().getAttribute("NtlmHttpAuth");
String userName = session.getUsername();
if (userName != null && !"".equals(userName)) {
try {
- Map parameters = request.getParameterMap();
- String surveyId = ((String[]) parameters.get("surveyId"))[0];
List<Answer> answers = new ArrayList<Answer>();
for (Object key : parameters.keySet()) {
if (!"surveyId".equals(key.toString())) {
@@ -139,6 +141,7 @@
m_surveyStore.submitAnswers(surveyId, answers, userName);
}
catch (Exception e) {
+ m_logService.log(LogService.LOG_ERROR, "An error occurred
while posting results for survey '" + surveyId + "'", e);
throw new WebApplicationException(e,
Response.Status.INTERNAL_SERVER_ERROR);
}
}
@@ -157,6 +160,7 @@
}
}
catch (Exception e) {
+ m_logService.log(LogService.LOG_ERROR, "An error occurred while
retrieving results for survey '" + surveyId + "'", e);
throw new WebApplicationException(e,
Response.Status.INTERNAL_SERVER_ERROR);
}
}
@@ -170,6 +174,7 @@
return Response.ok(survey).cacheControl(NO_CACHE_CONTROL).build();
}
catch (Exception e) {
+ m_logService.log(LogService.LOG_ERROR, "An error occurred while
retrieving questions for survey '" + surveyId + "'", e);
throw new WebApplicationException(e,
Response.Status.INTERNAL_SERVER_ERROR);
}
}
Modified: sandbox/ivol/ntlm/src/main/resources/jsp/survey.jsp
==============================================================================
--- sandbox/ivol/ntlm/src/main/resources/jsp/survey.jsp (original)
+++ sandbox/ivol/ntlm/src/main/resources/jsp/survey.jsp Tue Nov 22 13:52:53 2011
@@ -53,11 +53,10 @@
<div class="rightbox">
<h3>Online enquete Ondernemingsraad - Oktober 2011</h3>
- <p>
- <form id="form" action="/rest/survey" method="POST">
- <div id="survey"></div>
- </form>
- </p>
+
+ <form id="form" action="/rest/survey" method="POST">
+ <div id="survey"></div>
+ </form>
</div>
</body>
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits