protected void postUploadTask(CallingContext cc) throws ODKExternalServiceException { // upload data to external service if (!fsc.getExternalServicePublicationOption() .equals(ExternalServicePublicationOption.STREAM_ONLY)) { UploadSubmissions uploadTask = (UploadSubmissions) cc.getBean(BeanDefs.UPLOAD_TASK_BEAN); CallingContext ccDaemon = ContextFactory.duplicateContext(cc); ccDaemon.setAsDaemon(true); uploadTask.createFormUploadTask(fsc, true, ccDaemon); } }
/** * Handler for HTTP Get request to create xform upload page * * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { CallingContext cc = ContextFactory.getCallingContext(this, req); cc.setAsDaemon(true); logger.info("GAE servlet for CSV generation begins"); // get parameter final String formId = getParameter(req, ServletConsts.FORM_ID); if (formId == null) { logger.error("Missing " + ServletConsts.FORM_ID + " key"); errorMissingKeyParam(resp); return; } final String persistentResultsString = getParameter(req, ServletConsts.PERSISTENT_RESULTS_KEY); if (persistentResultsString == null) { logger.error("Missing " + ServletConsts.PERSISTENT_RESULTS_KEY + " key"); errorBadParam(resp); return; } SubmissionKey persistentResultsKey = new SubmissionKey(persistentResultsString); final String attemptCountString = getParameter(req, ServletConsts.ATTEMPT_COUNT); if (attemptCountString == null) { logger.error("Missing " + ServletConsts.ATTEMPT_COUNT + " key"); errorBadParam(resp); return; } Long attemptCount = 1L; try { attemptCount = Long.valueOf(attemptCountString); } catch (Exception e) { logger.error( "Invalid " + ServletConsts.ATTEMPT_COUNT + " value: " + attemptCountString + " exception: " + e.toString()); errorBadParam(resp); return; } IForm form = null; try { form = FormFactory.retrieveFormByFormId(formId, cc); } catch (ODKFormNotFoundException e) { logger.error("Unable to retrieve formId: " + formId + " exception: " + e.toString()); e.printStackTrace(); odkIdNotFoundError(resp); return; } catch (ODKOverQuotaException e) { logger.error("Unable to retrieve formId: " + formId + " exception: " + e.toString()); e.printStackTrace(); quotaExceededError(resp); return; } catch (ODKDatastoreException e) { logger.error("Unable to retrieve formId: " + formId + " exception: " + e.toString()); e.printStackTrace(); datastoreError(resp); return; } if (!form.hasValidFormDefinition()) { logger.error("Unable to retrieve formId: " + formId + " invalid form definition"); errorRetreivingData(resp); return; // ill-formed definition } CsvWorkerImpl impl = new CsvWorkerImpl(form, persistentResultsKey, attemptCount, cc); impl.generateCsv(); }