@Path("/logout") @GET @GsonWithIds @Override public Response doLogout() { Subject subject = SecurityUtils.getSubject(); subject.logout(); return ok(new SuccessMessage(NotificationType.LOGOUT_SUCCESS.uiNotification())); }
private Message successMessage() { List<Notification> notifications = collectNotifications(); notifications.add(NotificationType.STORAGE_SUCCESS.uiNotification()); return new SuccessMessage(elementDescription.getName(), notifications); }
private Message successMessage() { List<Notification> notifications = collectNotifications(); notifications.add(NotificationType.STORAGE_SUCCESS.uiNotification()); return new SuccessMessage(elementDescription.getName(), notifications); }
@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()); }
@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())); } }
@GET @GsonWithIds @Path("/authc") @Override public Response userAuthenticated(@Context HttpServletRequest req) { if (BackendConfig.INSTANCE.isConfigured()) { if (SecurityUtils.getSubject().isAuthenticated()) { ShiroAuthenticationResponse response = ShiroAuthenticationResponseFactory.create(getUserStorage().getUser((String) SecurityUtils.getSubject().getPrincipal())); System.out.println(SecurityUtils.getSubject().getSession().getId().toString()); return ok(response); } } return ok(new ErrorMessage(NotificationType.NOT_LOGGED_IN.uiNotification())); }
@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()); }
@Path("/register") @POST @GsonWithIds @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Override public Response doRegister(RegistrationData data) { Set<Role> roles = new HashSet<>(); roles.add(data.getRole()); if (getUserStorage().emailExists(data.getEmail())) { return ok(Notifications.error("This email address already exists. Please choose another address.")); } else { new UserManagementService().registerUser(data, roles); return ok(new SuccessMessage(NotificationType.REGISTRATION_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()); }
@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()); }
@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 Message verifyAndUpdate(String username) throws SepaParseException { try { this.elementDescription = transform(); } catch (RDFParseException | UnsupportedRDFormatException | RepositoryException | IOException e) { return new ErrorMessage(NotificationType.UNKNOWN_ERROR.uiNotification()); } verify(); if (isVerifiedSuccessfully()) { update(username); return successMessage(); } else return errorMessage(); }
public Message verifyAndUpdate(String username) throws SepaParseException { try { this.elementDescription = transform(); } catch (RDFParseException | UnsupportedRDFormatException | RepositoryException | IOException e) { return new ErrorMessage(NotificationType.UNKNOWN_ERROR.uiNotification()); } verify(); if (isVerifiedSuccessfully()) { update(username); return successMessage(); } else return errorMessage(); }
@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 Message verifyAndAdd(String username, boolean publicElement) throws SepaParseException { try { this.elementDescription = transform(); } catch (RDFParseException | UnsupportedRDFormatException | RepositoryException | IOException e) { return new ErrorMessage(NotificationType.UNKNOWN_ERROR.uiNotification()); } verify(); if (isVerifiedSuccessfully()) { StorageState state = store(username, publicElement); if (state == StorageState.STORED) return successMessage(); else if (state == StorageState.ALREADY_IN_SESAME) return addedToUserSuccessMessage(); else return skippedSuccessMessage(); } else return errorMessage(); }
public Message verifyAndAdd(String username, boolean publicElement) throws SepaParseException { try { this.elementDescription = transform(); } catch (RDFParseException | UnsupportedRDFormatException | RepositoryException | IOException e) { return new ErrorMessage(NotificationType.UNKNOWN_ERROR.uiNotification()); } verify(); if (isVerifiedSuccessfully()) { StorageState state = store(username, publicElement); if (state == StorageState.STORED) return successMessage(); else if (state == StorageState.ALREADY_IN_SESAME) return addedToUserSuccessMessage(); else return skippedSuccessMessage(); } else return errorMessage(); }