@Path("/{elementUri}") @GET @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response getElement(@PathParam("username") String username, @PathParam("elementUri") String elementUri) { // TODO Access rights try { return ok(new DataSourceDescription(getPipelineElementRdfStorage().getSEPById(elementUri))); } catch (URISyntaxException e) { return statusMessage(Notifications.error(NotificationType.UNKNOWN_ERROR, e.getMessage())); } }
@Path("/sources/{sourceId}") @GET @GsonWithIds @Produces(MediaType.APPLICATION_JSON) public Response getSourceDetails(@PathParam("sourceId") String sepaId, @QueryParam("keepIds") boolean keepIds) { try { DataSourceDescription sepaDescription = new DataSourceDescription(StorageManager.INSTANCE.getStorageAPI().getSEPById(sepaId)); return ok(sepaDescription); } catch (URISyntaxException e) { return ok(Notifications.error("Error")); } }
@Path("/{sourceId}/streams") @GET @Produces(MediaType.APPLICATION_JSON) @GsonWithIds public Response getStreamsBySource(@PathParam("username") String username, @PathParam("sourceId") String sourceId) { try { return ok(new DataSourceDescription(getPipelineElementRdfStorage().getSEPById(sourceId))); } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.URIOFFLINE.title(), NotificationType.URIOFFLINE.description(), e.getMessage())); } catch (Exception e) { return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } }
@Path("/delete") @POST @Produces(MediaType.APPLICATION_JSON) public Response deleteElement(@PathParam("username") String username, @FormParam("uri") String uri) { // URI myUri = uri.getBaseUri(); // String id = myUri.toString() + "v2/adapter/all/" + elementId; UserService userService = getUserService(); IPipelineElementDescriptionStorage requestor = getPipelineElementRdfStorage(); logger.info("User " + username + " deletes element with URI: " + uri + " from triplestore"); try { if (requestor.getSEPById(uri) != null) { requestor.deleteSEP(requestor.getSEPById(uri)); userService.deleteOwnSource(username, uri); } else return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description())); } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description())); } return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification()); }
public SepStoppedMonitoringPipelineBuilder(String sepUri, String streamUri) throws URISyntaxException { this.outputTopic = OUTPUT_TOPIC; this.streamUri = streamUri; DataSourceDescription desc = StorageManager.INSTANCE.getStorageAPI().getSEPById(sepUri); this.stream = StorageManager.INSTANCE.getStorageAPI().getEventStreamById(streamUri); this.dataSourceDescription = desc; this.streamStoppedDataProcessorDescription = getStreamStoppedEpa(); this.kafkaDataSinkDescription = getKafkaPublisherEc(); }
public SepStoppedMonitoringPipelineBuilder(String sepUri, String streamUri) throws URISyntaxException { this.outputTopic = OUTPUT_TOPIC; this.streamUri = streamUri; DataSourceDescription desc = StorageManager.INSTANCE.getStorageAPI().getSEPById(sepUri); this.stream = StorageManager.INSTANCE.getStorageAPI().getEventStreamById(streamUri); this.dataSourceDescription = desc; this.streamStoppedDataProcessorDescription = getStreamStoppedEpa(); this.kafkaDataSinkDescription = getKafkaPublisherEc(); }
@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())); } } }
@Path("/{id}") @DELETE @Produces(MediaType.APPLICATION_JSON) public Response deleteElement(@PathParam("username") String username, @PathParam("id") String elementId) { UserService userService = getUserService(); IPipelineElementDescriptionStorage requestor = getPipelineElementRdfStorage(); try { if (requestor.getSEPAById(elementId) != null) { requestor.deleteSEPA(requestor.getSEPAById(elementId)); userService.deleteOwnSepa(username, elementId); } else if (requestor.getSEPById(elementId) != null) { requestor.deleteSEP(requestor.getSEPById(elementId)); userService.deleteOwnSource(username, elementId); } else if (requestor.getSECById(elementId) != null) { requestor.deleteSEC(requestor.getSECById(elementId)); userService.deleteOwnAction(username, elementId); } else { return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description())); } } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description())); } return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification()); }