/** * Responds to the request to pull an artifact from a connector * When successful, this action creates the appropriate job and returns it. * * @param parameters The request parameters * @return The response */ private HttpResponse onMessagePullFromConnector(Map<String, String[]> parameters) { String[] ids = parameters.get("id"); if (ids == null || ids.length == 0) return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Expected an id parameter"); JobExecutionService executor = ServiceUtils.getService(JobExecutionService.class); if (executor == null) return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Could not find the job execution service"); Job job = new PullArtifactJob(ids[0]); executor.schedule(job); return new HttpResponse(HttpURLConnection.HTTP_OK, HttpConstants.MIME_JSON, job.serializedJSON()); }
/** * Responds to the request to push an artifact to a connector * When successful, this action creates the appropriate job and returns it. * * @param parameters The request parameters * @return The response */ private HttpResponse onMessagePushToConnector(Map<String, String[]> parameters) { String[] ids = parameters.get("id"); if (ids == null || ids.length == 0) return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Expected an id parameter"); String[] artifacts = parameters.get("artifact"); if (artifacts == null || artifacts.length == 0) return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Expected an artifact parameter"); JobExecutionService executor = ServiceUtils.getService(JobExecutionService.class); if (executor == null) return new HttpResponse(HttpURLConnection.HTTP_BAD_REQUEST, HttpConstants.MIME_TEXT_PLAIN, "Could not find the job execution service"); Job job = new PushArtifactJob(ids[0], artifacts[0]); executor.schedule(job); return new HttpResponse(HttpURLConnection.HTTP_OK, HttpConstants.MIME_JSON, job.serializedJSON()); } }