@Override public HttpResponse handle(SecurityService securityService, HttpApiRequest request) { if (!HttpConstants.METHOD_GET.equals(request.getMethod())) return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method"); if (request.getUri().equals(apiUri + "/metrics")) return onMessageGetMetricList(securityService); if (request.getUri().startsWith(apiUri + "/metrics")) { String rest = request.getUri().substring(apiUri.length() + "/metrics".length() + 1); if (rest.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String metricId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (index < 0) return onMessageGetMetric(securityService, metricId); else if (rest.substring(index).equals("/snapshot")) return onMessageGetMetricValue(securityService, metricId); } return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); }
@Override public HttpResponse handle(SecurityService securityService, HttpApiRequest request) { if (!HttpConstants.METHOD_GET.equals(request.getMethod())) return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method"); if (request.getUri().equals(apiUri + "/archetypes")) { return onGetArchetypes(); } else if (request.getUri().equals(apiUri + "/schemas")) { return onGetSchemas(); } else if (request.getUri().startsWith(apiUri + "/archetypes")) { String rest = URIUtils.decodeComponent(request.getUri().substring(apiUri.length() + "/archetypes".length() + 1)); if (rest.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); return onGetArchetype(rest); } else if (request.getUri().startsWith(apiUri + "/schemas")) { String rest = URIUtils.decodeComponent(request.getUri().substring(apiUri.length() + "/schemas".length() + 1)); if (rest.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); return onGetSchema(rest); } return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); }
if (!rest.startsWith("/")) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); String artifactId = URIUtils.decodeComponent(rest.substring(1)); if (artifactId.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
if (!rest.startsWith("/")) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); String artifactId = URIUtils.decodeComponent(rest.substring(1)); if (artifactId.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
/** * Responds to a request for the policy resource * * @param request The web API request to handle * @return The HTTP response */ private HttpResponse handleRequestPolicy(HttpApiRequest request) { if (request.getUri().equals(apiUri + "/policy")) { if (!HttpConstants.METHOD_GET.equals(request.getMethod())) return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected GET method"); return XSPReplyUtils.toHttpResponse(getPolicy().getConfiguration(), null); } if (request.getUri().startsWith(apiUri + "/policy/actions/")) { String rest = request.getUri().substring(apiUri.length() + "/policy/actions/".length()); String actionId = URIUtils.decodeComponent(rest); if (actionId.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); if (!HttpConstants.METHOD_PUT.equals(request.getMethod())) return new HttpResponse(HttpURLConnection.HTTP_BAD_METHOD, HttpConstants.MIME_TEXT_PLAIN, "Expected PUT method"); String definition = new String(request.getContent(), IOUtils.CHARSET); return XSPReplyUtils.toHttpResponse(getPolicy().setPolicy(actionId, definition), null); } return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); }
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String jobId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (index < 0) { if (!HttpConstants.METHOD_GET.equals(request.getMethod()))
String neighbourId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); return handleNeighbour(request, neighbourId, index > 0 ? rest.substring(index + 1) : "");
String specId = URIUtils.decodeComponent(rest); return XSPReplyUtils.toHttpResponse(getNeighbourInputsFor(neighbourId, specId), null); String specId = URIUtils.decodeComponent(rest); return XSPReplyUtils.toHttpResponse(getNeighbourOutputsFor(neighbourId, specId), null);
String specId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (specId.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
String specId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (specId.isEmpty()) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String connectorId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (index < 0) { switch (request.getMethod()) {
String roleId = URIUtils.decodeComponent(rest.substring(1)); switch (request.getMethod()) { case HttpConstants.METHOD_DELETE:
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String addonId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (index >= 0) return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND);
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String roleId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest);
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String ruleId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest); if (index < 0) { switch (request.getMethod()) {
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String userId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest);
return new HttpResponse(HttpURLConnection.HTTP_NOT_FOUND); int index = rest.indexOf("/"); String groupId = URIUtils.decodeComponent(index > 0 ? rest.substring(0, index) : rest);