use of org.graylog2.shared.users.UserService in project graylog2-server by Graylog2.
the class ViewOwnerShipToGrantsMigration method upgrade.
public void upgrade() {
viewService.streamAll().forEach(view -> {
final Optional<User> user = view.owner().map(userService::load);
if (user.isPresent() && !user.get().isLocalAdmin()) {
final GRNType grnType = ViewDTO.Type.DASHBOARD.equals(view.type()) ? GRNTypes.DASHBOARD : GRNTypes.SEARCH;
final GRN target = grnType.toGRN(view.id());
ensureGrant(user.get(), target);
}
});
}
use of org.graylog2.shared.users.UserService in project graylog2-server by Graylog2.
the class ViewSharingToGrantsMigration method migrateUsers.
private void migrateUsers(String viewId, Collection<String> userNames) {
final Set<User> users = userNames.stream().map(userService::load).filter(Objects::nonNull).collect(Collectors.toSet());
final GRN target = getTarget(viewId);
LOG.info("Migrate users for view <{}> to grants: {}", target, users.stream().map(u -> u.getId() + "/" + u.getName()).collect(Collectors.toSet()));
for (final User user : users) {
ensureGrant(user, target);
}
}
use of org.graylog2.shared.users.UserService in project graylog2-server by Graylog2.
the class EventDefinitionFacadeTest method setUp.
@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
objectMapper.registerSubtypes(AggregationEventProcessorConfig.class, PersistToStreamsStorageHandler.Config.class, TemplateFieldValueProvider.Config.class, AggregationEventProcessorConfigEntity.class);
stateService = mock(DBEventProcessorStateService.class);
jobDefinitionService = mock(DBJobDefinitionService.class);
jobTriggerService = mock(DBJobTriggerService.class);
jobSchedulerClock = mock(JobSchedulerClock.class);
eventDefinitionService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, entityOwnershipService);
eventDefinitionHandler = new EventDefinitionHandler(eventDefinitionService, jobDefinitionService, jobTriggerService, jobSchedulerClock);
Set<PluginMetaData> pluginMetaData = new HashSet<>();
facade = new EventDefinitionFacade(objectMapper, eventDefinitionHandler, pluginMetaData, jobDefinitionService, eventDefinitionService, userService);
}
Aggregations