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()); } }
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()); } }
@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)); }
@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")); } } }
@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")); } }
@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.")); }
@Path("/sepas/{sepaId}") @GET @Produces(MediaType.APPLICATION_JSON) @Override public Response getSepa(@PathParam("sepaId") String sepaId, @QueryParam("keepIds") boolean keepIds) { try { DataProcessorDescription dataProcessorDescription = new DataProcessorDescription(StorageManager.INSTANCE.getStorageAPI().getSEPAById(sepaId)); return ok(dataProcessorDescription); } catch (URISyntaxException e) { return ok(Notifications.error("Error")); } }
@GET @Produces(MediaType.APPLICATION_JSON) @Override public Response getUserDetails(@PathParam("email") String email) { org.streampipes.model.client.user.User user = getUser(email); user.setPassword(""); if (user != null) { return ok(user); } else { return statusMessage(Notifications.error("User not found")); } }
@Path("/actions/{actionId}") @GET @Produces(MediaType.APPLICATION_JSON) @Override public Response getAction(@PathParam("actionId") String actionId, @QueryParam("keepIds") boolean keepIds) { try { DataSinkDescription dataSinkDescription = new DataSinkDescription(StorageManager.INSTANCE.getStorageAPI().getSECById(actionId)); return ok(dataSinkDescription); } catch (URISyntaxException e) { return ok(Notifications.error("Error")); } }
@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. ")); }
@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. ")); }
@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. ")); }
@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(statusMessage(Notifications.error(NotificationType.UNKNOWN_ERROR))); } }
@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")); } }
@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. ")); }
@DELETE @Produces(MediaType.APPLICATION_JSON) @Path("/{notificationId}") @Override public Response deleteNotification(@PathParam("notificationId") String notificationId) { boolean success = getNotificationStorage() .deleteNotification(notificationId); if (success) { return ok(Notifications.success("Notification deleted")); } else { return ok(Notifications.error("Could not delete notification")); } }
@POST @Produces(MediaType.APPLICATION_JSON) public Response addCategory(@PathParam("username") String username, org.streampipes.model.client.pipeline.PipelineCategory pipelineCategory) { boolean success = getPipelineCategoryStorage() .addPipelineCategory(pipelineCategory); if (success) return ok(Notifications.success("Category successfully stored. ")); else return ok(Notifications.error("Could not create category.")); }
@Path("/{elementUri}") @GET @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response getElement(@PathParam("username") String username, @PathParam("elementUri") String elementUri) { try { return ok(new DataSinkInvocation(new DataSinkInvocation(getPipelineElementRdfStorage().getSECById(elementUri)))); } catch (URISyntaxException e) { return statusMessage(Notifications.error(NotificationType.UNKNOWN_ERROR, e.getMessage())); } }
@Override public List<Message> install() { try { String encryptedPassword = PasswordUtil.encryptPassword(adminPassword); StorageDispatcher.INSTANCE.getNoSqlStore().getUserStorageAPI().storeUser(new User(adminEmail, encryptedPassword, roles)); return Arrays.asList(Notifications.success(getTitle())); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { e.printStackTrace(); return Arrays.asList(Notifications.error("Could not encrypt password")); } }
@Override public List<Message> install() { try { String encryptedPassword = PasswordUtil.encryptPassword(adminPassword); StorageDispatcher.INSTANCE.getNoSqlStore().getUserStorageAPI().storeUser(new User(adminEmail, encryptedPassword, roles)); return Arrays.asList(Notifications.success(getTitle())); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { e.printStackTrace(); return Arrays.asList(Notifications.error("Could not encrypt password")); } }