@Override @Path("/instances/{instanceId}") @PUT @Produces(MediaType.APPLICATION_JSON) public Response updateInstance(@PathParam("instanceId") String instanceId, Instance instance) { boolean success = StorageManager .INSTANCE .getBackgroundKnowledgeStorage() .updateInstance(instance); if (success) return ok(Notifications.success("Instance successfully updated.")); else return ok(Notifications.error("Could not update instance. ")); }
@Path("/{elementUri}/jsonld") @GET @Produces(MediaType.TEXT_PLAIN) @Override public String getAsJsonLd(@PathParam("elementUri") String elementUri) { try { return toJsonLd(getPipelineElementRdfStorage().getSEPAById(elementUri)); } catch (URISyntaxException e) { return toJson(constructErrorMessage(Notifications.create(NotificationType.UNKNOWN_ERROR, e.getMessage()))); } }
public Message parseAndAddEndpointItem(String uri, String username, boolean publicElement) { try { uri = URLDecoder.decode(uri, "UTF-8"); String payload = parseURIContent(uri, null); return Operations.verifyAndAddElement(payload, username, publicElement); } catch (Exception e) { e.printStackTrace(); return Notifications.error(NotificationType.PARSE_ERROR, e.getMessage()); } }
@DELETE @Path("/{pipelineId}") @Produces(MediaType.APPLICATION_JSON) @GsonWithIds public Response removeOwn(@PathParam("username") String username, @PathParam("pipelineId") String elementUri) { getPipelineStorage().deletePipeline(elementUri); return statusMessage(Notifications.success("Pipeline deleted")); }
public Message parseAndAddEndpointItem(String uri, String username, boolean publicElement) { try { uri = URLDecoder.decode(uri, "UTF-8"); String payload = parseURIContent(uri, null); return Operations.verifyAndAddElement(payload, username, publicElement); } catch (Exception e) { e.printStackTrace(); return Notifications.error(NotificationType.PARSE_ERROR, e.getMessage()); } }
@PUT @Path("/{pipelineId}") @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response overwritePipeline(@PathParam("username") String username, org.streampipes.model.client.pipeline.Pipeline pipeline) { getPipelineStorage().updatePipeline(pipeline); return statusMessage(Notifications.success("Pipeline modified")); }
@Override @Path("/types/{typeId}") @DELETE @Produces(MediaType.APPLICATION_JSON) public Response deleteType(@PathParam("typeId") String typeId) { boolean success = StorageManager.INSTANCE.getBackgroundKnowledgeStorage().deleteResource(typeId); if (success) return ok(Notifications.success("Concept successfully deleted.")); else return ok(Notifications.error("Could not delete concept. ")); }
@POST @Path("/batch") @Produces(MediaType.APPLICATION_JSON) public Response addBatch(@PathParam("username") String username, @FormParam("uri") String uri, @FormParam("publicElement") boolean publicElement) { try { uri = URLDecoder.decode(uri, "UTF-8"); JsonElement element = new JsonParser().parse(parseURIContent(uri, "application/json")); List<Message> messages = new ArrayList<>(); if (element.isJsonArray()) { for (JsonElement jsonObj : element.getAsJsonArray()) { messages.add(verifyAndAddElement(jsonObj.getAsString(), username, publicElement)); } } return ok(messages); } catch (Exception e) { e.printStackTrace(); return statusMessage(Notifications.error(NotificationType.PARSE_ERROR)); } }
@DELETE @Path("/{streamId}/streams/{runningInstanceId}") @Produces(MediaType.APPLICATION_JSON) public Response detach(@PathParam("streamId") String elementId, @PathParam("runningInstanceId") String runningInstanceId, @PathParam("username") String username) { String responseMessage = "Instance of set id: " + elementId + " with instance id: "+ runningInstanceId + " successfully started"; String newUrl = Utils.addUserNameToApi(ConnectContainerConfig.INSTANCE.getConnectContainerWorkerUrl(), username); try { this.sourcesManagement.detachAdapter(newUrl, elementId, runningInstanceId); } catch (AdapterException e) { logger.error("Could not set set id "+ elementId + " with instance id: "+ runningInstanceId, e); return fail(); } return ok(Notifications.success(responseMessage)); }
@DELETE @Path("/own/{elementUri}") @RequiresAuthentication @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response removeOwn(@PathParam("username") String username, @PathParam("elementUri") String elementUri) { try { getUserService().deleteOwnSepa(username, elementUri); getPipelineElementRdfStorage().deleteSEPA(getPipelineElementRdfStorage().getSEPAById(elementUri)); } catch (URISyntaxException e) { return constructErrorMessage(Notifications.create(NotificationType.STORAGE_ERROR, e.getMessage())); } return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification()); }
@DELETE @Path("/{categoryId}") @Produces(MediaType.APPLICATION_JSON) public Response removeCategory(@PathParam("username") String username, @PathParam("categoryId") String categoryId) { boolean success = getPipelineCategoryStorage() .deletePipelineCategory(categoryId); if (success) return ok(Notifications.success("Category successfully deleted. ")); else return ok(Notifications.error("Could not delete category.")); }
@POST @Produces(MediaType.APPLICATION_JSON) public Response addElement(@PathParam("username") String username, @FormParam("uri") String uri, @FormParam("publicElement") boolean publicElement) { if (!authorized(username)) { return ok(Notifications.error(NotificationType.UNAUTHORIZED)); } return ok(verifyAndAddElement(uri, username, publicElement)); }
private Message addRdfEndpoints() { RdfEndpointStorageImpl rdfEndpointStorage = new RdfEndpointStorageImpl(); initRdfEndpointPorts .forEach(p -> rdfEndpointStorage .addRdfEndpoint(new RdfEndpoint(initRdfEndpointHost + p))); return Notifications.success("Creating RDF endpoints..."); }
@Path("{id}/jsonld") @GET @Produces(MediaType.TEXT_PLAIN) public Response getActionAsJsonLd(@PathParam("id") String elementId) { IPipelineElementDescriptionStorage requestor = getPipelineElementRdfStorage(); elementId = decode(elementId); try { if (requestor.getSEPAById(elementId) != null) { return ok(toJsonLd(requestor.getSEPAById(elementId))); } else if (requestor.getSEPById(elementId) != null) { return ok(toJsonLd(requestor.getSEPById(elementId))); } else if (requestor.getSECById(elementId) != null) { return ok(toJsonLd(requestor.getSECById(elementId))); } else { return ok(Notifications.create(NotificationType.UNKNOWN_ERROR)); } } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } } }
@Override @Path("/properties/{propertyId}") @DELETE @Produces(MediaType.APPLICATION_JSON) public Response deleteProperty(@PathParam("propertyId") String propertyId) { boolean success = StorageManager.INSTANCE.getBackgroundKnowledgeStorage().deleteResource(propertyId); if (success) return ok(Notifications.success("Property successfully deleted.")); else return ok(Notifications.error("Could not delete property. ")); }
@Override @POST @Produces(MediaType.APPLICATION_JSON) public Response getRuntimeInfo(SpDataStream spDataStream) { // TODO currently only supported for data streams. For data sets, a dummy pipeline needs to be generated to get runtime values. try { return ok(Operations.getRuntimeInfo(spDataStream)); } catch (SpRuntimeException e) { return statusMessage(Notifications.error("Could not get runtime data")); } } }
private Message addRdfEndpoints() { RdfEndpointStorageImpl rdfEndpointStorage = new RdfEndpointStorageImpl(); initRdfEndpointPorts .forEach(p -> rdfEndpointStorage .addRdfEndpoint(new RdfEndpoint(initRdfEndpointHost + p))); return Notifications.success("Creating RDF endpoints..."); }
@Override @Path("/instances/{instanceId}") @DELETE @Produces(MediaType.APPLICATION_JSON) public Response deleteInstance(@PathParam("instanceId") String instanceId) { boolean success = StorageManager.INSTANCE.getBackgroundKnowledgeStorage().deleteResource(instanceId); if (success) return ok(Notifications.success("Instance successfully deleted.")); else return ok(Notifications.error("Could not delete instance. ")); }
@Path("/properties/{propertyId}") @GET @Produces(MediaType.APPLICATION_JSON) @Override public Response getProperty(@PathParam("propertyId") String propertyId) { try { return ok(StorageManager.INSTANCE.getBackgroundKnowledgeStorage().getProperty(propertyId)); } catch (QueryEvaluationException | RepositoryException | MalformedQueryException e) { return ok(Notifications.error("Could not load details")); } }
@POST @Path("/favorites") @RequiresAuthentication @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response addFavorite(@PathParam("username") String username, @FormParam("uri") String elementUri) { getUserService().addSourceAsFavorite(username, decode(elementUri)); return statusMessage(Notifications.success(NotificationType.OPERATION_SUCCESS)); }