public Notification uiNotification() { return new Notification(title, description); } }
public static ErrorMessage error(String message) { return new ErrorMessage(new Notification(message, "")); }
public static SuccessMessage success(String message) { return new SuccessMessage(new Notification(message, "")); }
public static ErrorMessage error(NotificationType type, String info) { return new ErrorMessage(new Notification(type.name(), type.description(), info)); } }
public static SuccessMessage success(NotificationType type) { return new SuccessMessage(new Notification(type.name(), type.description())); }
public static ErrorMessage error(NotificationType type) { return new ErrorMessage(new Notification(type.name(), type.description())); }
public static SuccessMessage success(NotificationType type, String info) { return new SuccessMessage(new Notification(type.name(), type.description(), info)); }
public static Notification create(NotificationType type) { return new Notification(type.name(), type.description()); }
public static Notification create(NotificationType type, String info) { return new Notification(type.name(), type.description(), info); }
public Notification getNotification() { return new Notification(type.title(), type.description()); }
private Message addedToUserSuccessMessage() { List<Notification> notifications = collectNotifications(); notifications.add(new Notification("Already stored", "Element description already stored, added element to user")); return new SuccessMessage(elementDescription.getName(), notifications); }
public Notification getNotification() { return new Notification(type.title(), type.description()); }
private Message skippedSuccessMessage() { List<Notification> notifications = collectNotifications(); notifications.add(new Notification("Already exists", "This element is already in your list of elements, skipped.")); return new SuccessMessage(elementDescription.getName(), notifications); }
private Message skippedSuccessMessage() { List<Notification> notifications = collectNotifications(); notifications.add(new Notification("Already exists", "This element is already in your list of elements, skipped.")); return new SuccessMessage(elementDescription.getName(), notifications); }
private Message addedToUserSuccessMessage() { List<Notification> notifications = collectNotifications(); notifications.add(new Notification("Already stored", "Element description already stored, added element to user")); 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()))); } }
@POST @Produces(MediaType.APPLICATION_JSON) @GsonWithIds public Response addPipeline(@PathParam("username") String username, org.streampipes.model.client.pipeline.Pipeline pipeline) { String pipelineId = UUID.randomUUID().toString(); pipeline.setPipelineId(pipelineId); pipeline.setRunning(false); pipeline.setCreatedByUser(username); pipeline.setCreatedAt(new Date().getTime()); //userService.addOwnPipeline(username, pipeline); Operations.storePipeline(pipeline); SuccessMessage message = Notifications.success(NotificationType.PIPELINE_STORAGE_SUCCESS); message.addNotification(new Notification("id", pipelineId)); return ok(message); }
@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("/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())); } }
@PUT @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Response updateElement(@PathParam("username") String username, @PathParam("id") String uri) { if (!authorized(username)) { return ok(Notifications.error(NotificationType.UNAUTHORIZED)); } try { uri = URLDecoder.decode(uri, "UTF-8"); String payload = parseURIContent(uri); return ok(Operations.verifyAndUpdateElement(payload, username)); } catch (URISyntaxException | IOException e) { e.printStackTrace(); return constructErrorMessage(new Notification(NotificationType.PARSE_ERROR.title(), NotificationType.PARSE_ERROR.description(), e.getMessage())); } catch (SepaParseException e) { e.printStackTrace(); return constructErrorMessage(new Notification(NotificationType.PARSE_ERROR.title(), NotificationType.PARSE_ERROR.description(), e.getMessage())); } }