use of org.akaza.openclinica.web.pform.EnketoCredentials in project OpenClinica by OpenClinica.
the class ParticipantFormServlet method processRequest.
@Override
protected void processRequest() throws Exception {
String crf_oid = request.getParameter(CRF_ID);
String formURL = null;
// Build Enketo URL for CRF version.
if (currentStudy.getStudyParameterConfig().getParticipantPortal().equals("enabled")) {
EnketoCredentials credentials = getCredentials();
EnketoAPI enketo = new EnketoAPI(credentials);
formURL = enketo.getFormPreviewURL(crf_oid);
if (!formURL.equals("")) {
response.sendRedirect(formURL);
} else {
if (credentials.getServerUrl() == null) {
addPageMessage(respage.getString("pform_preview_missing_url"));
} else {
if ((credentials.getApiKey() != null) && (credentials.getOcInstanceUrl() != null)) {
addPageMessage(respage.getString("pform_preview_forbidden"));
} else {
addPageMessage(respage.getString("participate_not_available"));
}
}
forwardPage(Page.MENU_SERVLET);
}
}
}
use of org.akaza.openclinica.web.pform.EnketoCredentials in project OpenClinica by OpenClinica.
the class ParticipantFormServlet method getCredentials.
private EnketoCredentials getCredentials() throws Exception {
EnketoCredentials credentials = null;
Map<String, EnketoCredentials> credentialsMap = (Map<String, EnketoCredentials>) session.getAttribute("EnketoCredentialsMap");
if (credentialsMap == null) {
credentialsMap = new HashMap<String, EnketoCredentials>();
credentials = EnketoCredentials.getInstance(currentStudy.getOid());
credentialsMap.put(currentStudy.getOid(), credentials);
session.setAttribute("EnketoCredentialsMap", credentialsMap);
} else if (credentialsMap.get(currentStudy.getOid()) == null) {
credentials = EnketoCredentials.getInstance(currentStudy.getOid());
credentialsMap.put(currentStudy.getOid(), credentials);
} else
credentials = credentialsMap.get(currentStudy.getOid());
return credentials;
}
Aggregations