/** * Favorites * */ public void addSepaAsFavorite(String username, String elementId) { if (!checkUser(username)) return; User user = userStorage.getUser(username); user.addPreferredSepa(elementId); userStorage.updateUser(user); }
/** * * @param username * @return True if user exists exactly once, false otherwise */ public boolean checkUser(String username) { return userStorage.checkUser(username); }
public List<String> getAvailableActionUris(String email) { List<String> actions = new ArrayList<>(getOwnActionUris(email)); System.out.println(userStorage.getAllUsers().size()); userStorage .getAllUsers() .stream() .filter(u -> !(u.getEmail().equals(email))) .map(u -> u.getOwnActions().stream().filter(p -> p.isPublicElement()).map(p -> p.getElementId()).collect(Collectors.toList())).forEach(actions::addAll); return actions; }
public List<String> getFavoriteActionUris(String username) { return userStorage.getUser(username).getPreferredActions(); }
@PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Override public Response updateUserDetails(org.streampipes.model.client.user.User user) { if (user != null) { org.streampipes.model.client.user.User existingUser = getUser(user.getEmail()); user.setPassword(existingUser.getPassword()); getUserStorage().updateUser(user); return ok(Notifications.success("User updated")); } else { return statusMessage(Notifications.error("User not found")); } }
@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")); } }
@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())); } }
public List<String> getFavoriteSourceUris(String username) { return userStorage.getUser(username).getPreferredSources(); }
@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")); } }
public void addOwnSource(String username, String elementId, boolean publicElement) { if (!checkUser(username)) return; User user = userStorage.getUser(username); user.addOwnSource(elementId, publicElement); userStorage.updateUser(user); }
public List<String> getFavoriteSepaUris(String email) { return userStorage.getUser(email).getPreferredSepas(); }
public List<Pipeline> getPublicPipelines(String username) { List<Pipeline> pipelines = new ArrayList<>(); userStorage() .getAllUsers() .stream() .map(u -> u.getPipelines().stream().filter(p -> p.isPublicElement()).collect(Collectors.toList())).forEach(pipelines::addAll); return pipelines; }
public Boolean registerUser(RegistrationData data, Set<Role> roles) { org.streampipes.model.client.user.User user = new User(data.getEmail(), data.getPassword(), roles); try { String encryptedPassword = PasswordUtil.encryptPassword(data.getPassword()); user.setPassword(encryptedPassword); StorageDispatcher.INSTANCE.getNoSqlStore().getUserStorageAPI().storeUser(user); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { return false; } return true; }
/** * * @param username * @return True if user exists exactly once, false otherwise */ public boolean checkUser(String username) { return userStorage.checkUser(username); }
public void addOwnAction(String username, String elementId, boolean publicElement) { if (!checkUser(username)) return; User user = userStorage.getUser(username); user.addOwnAction(elementId, publicElement); userStorage.updateUser(user); }
public List<String> getFavoriteActionUris(String username) { return userStorage.getUser(username).getPreferredActions(); }
public List<String> getAvailableActionUris(String email) { List<String> actions = new ArrayList<>(getOwnActionUris(email)); System.out.println(userStorage.getAllUsers().size()); userStorage .getAllUsers() .stream() .filter(u -> !(u.getEmail().equals(email))) .map(u -> u.getOwnActions().stream().filter(p -> p.isPublicElement()).map(p -> p.getElementId()).collect(Collectors.toList())).forEach(actions::addAll); return actions; }
public Boolean registerUser(RegistrationData data, Set<Role> roles) { org.streampipes.model.client.user.User user = new User(data.getEmail(), data.getPassword(), roles); try { String encryptedPassword = PasswordUtil.encryptPassword(data.getPassword()); user.setPassword(encryptedPassword); StorageDispatcher.INSTANCE.getNoSqlStore().getUserStorageAPI().storeUser(user); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { return false; } return true; }
public void addOwnSepa(String username, String elementId, boolean publicElement) { if (!checkUser(username)) return; User user = userStorage.getUser(username); user.addOwnSepa(elementId, publicElement); userStorage.updateUser(user); }
public List<String> getFavoriteSourceUris(String username) { return userStorage.getUser(username).getPreferredSources(); }