public Notification getNotification() { return new Notification(type.title(), type.description()); }
@Path("/logout") @GET @GsonWithIds @Override public Response doLogout() { Subject subject = SecurityUtils.getSubject(); subject.logout(); return ok(new SuccessMessage(NotificationType.LOGOUT_SUCCESS.uiNotification())); }
public static Notification create(NotificationType type) { return new Notification(type.name(), type.description()); }
@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()); }
@DELETE @Path("/own/{elementUri}") @RequiresAuthentication @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response removeOwn(@PathParam("username") String username, @PathParam("elementUri") String elementUri) { try { IPipelineElementDescriptionStorage requestor = getPipelineElementRdfStorage(); getUserService().deleteOwnAction(username, elementUri); requestor.deleteSEC(requestor.getSECById(elementUri)); } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description(), e.getMessage())); } return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification()); }
public Notification getNotification() { return new Notification(type.title(), type.description()); }
@DELETE @Path("/own/{elementUri}") @RequiresAuthentication @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response removeOwn(@PathParam("username") String username, @PathParam("elementUri") String elementUri) { try { getUserService().deleteOwnSource(username, elementUri); getPipelineElementRdfStorage().deleteSEC(getPipelineElementRdfStorage().getSECById(elementUri)); } catch (URISyntaxException e) { return constructErrorMessage(new Notification(NotificationType.STORAGE_ERROR.title(), NotificationType.STORAGE_ERROR.description(), e.getMessage())); } return constructSuccessMessage(NotificationType.STORAGE_SUCCESS.uiNotification()); }
public static Notification create(NotificationType type, String info) { return new Notification(type.name(), type.description(), info); }
private Message successMessage() { List<Notification> notifications = collectNotifications(); notifications.add(NotificationType.STORAGE_SUCCESS.uiNotification()); return new SuccessMessage(elementDescription.getName(), notifications); }
@Path("/{elementUri}/jsonld") @GET @Produces(MediaType.TEXT_PLAIN) @Override public String getAsJsonLd(@PathParam("elementUri") String elementUri) { try { return toJsonLd(getPipelineElementRdfStorage().getSECById(elementUri)); } catch (URISyntaxException e) { return toJson(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()); }
public static ErrorMessage error(NotificationType type, String info) { return new ErrorMessage(new Notification(type.name(), type.description(), info)); } }
private Message successMessage() { List<Notification> notifications = collectNotifications(); notifications.add(NotificationType.STORAGE_SUCCESS.uiNotification()); return new SuccessMessage(elementDescription.getName(), notifications); }
@Path("/recommend") @POST @Produces(MediaType.APPLICATION_JSON) @GsonWithIds public Response recommend(@PathParam("username") String email, org.streampipes.model.client.pipeline.Pipeline pipeline) { try { return ok(Operations.findRecommendedElements(email, pipeline)); } catch (JsonSyntaxException e) { return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } catch (NoSuitableSepasAvailableException e) { return constructErrorMessage(new Notification(NotificationType.NO_SEPA_FOUND.title(), NotificationType.NO_SEPA_FOUND.description(), e.getMessage())); } catch (Exception e) { e.printStackTrace(); return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } }
public static SuccessMessage success(NotificationType type, String info) { return new SuccessMessage(new Notification(type.name(), type.description(), info)); }
@POST @Produces(MediaType.APPLICATION_JSON) @Override public Response addVirtualSensor(@PathParam("username") String username, String virtualSensorDescription) { org.streampipes.model.client.VirtualSensor vs = Utils.getGson().fromJson(virtualSensorDescription, org.streampipes.model.client.VirtualSensor.class); //vs.setPipelineId(UUID.randomUUID().toString()); vs.setCreatedBy(username); getPipelineStorage().storeVirtualSensor(username, vs); return constructSuccessMessage(NotificationType.VIRTUAL_SENSOR_STORAGE_SUCCESS.uiNotification()); }
@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())); } }
public static SuccessMessage success(NotificationType type) { return new SuccessMessage(new Notification(type.name(), type.description())); }
@Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @GsonWithIds @POST @Override @Path("/login") public Response doLogin(ShiroAuthenticationRequest token) { try { ShiroAuthenticationResponse authResponse = login(token); return ok(authResponse); } catch (AuthenticationException e) { return ok(new ErrorMessage(NotificationType.LOGIN_FAILED.uiNotification())); } }
public Response stopPipeline(String pipelineId) { try { Pipeline pipeline = getPipelineStorage().getPipeline(pipelineId); PipelineOperationStatus status = Operations.stopPipeline(pipeline); return ok(status); } catch (Exception e) { e.printStackTrace(); return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage())); } }