Search in sources :

Example 1 with EnketoCredentials

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);
        }
    }
}
Also used : EnketoAPI(org.akaza.openclinica.web.pform.EnketoAPI) EnketoCredentials(org.akaza.openclinica.web.pform.EnketoCredentials)

Example 2 with EnketoCredentials

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;
}
Also used : EnketoCredentials(org.akaza.openclinica.web.pform.EnketoCredentials) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

EnketoCredentials (org.akaza.openclinica.web.pform.EnketoCredentials)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EnketoAPI (org.akaza.openclinica.web.pform.EnketoAPI)1