use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherAdapterIT method linkTypeCollectionsLostOrGainedTest.
@Test
public void linkTypeCollectionsLostOrGainedTest() {
String aCollection = createCollection("A", EMPTY_ROLES, EMPTY_ROLES).getId();
String bCollection = createCollection("B", EMPTY_ROLES, EMPTY_ROLES).getId();
String cCollection = createCollection("C", EMPTY_ROLES, EMPTY_ROLES).getId();
String aLinkTypeId = createLinkType("A", Arrays.asList(aCollection, bCollection), Set.of(), Set.of()).getId();
String bLinkTypeId = createLinkType("B", Arrays.asList(bCollection, cCollection), Set.of(), Set.of()).getId();
LinkType linkType = linkTypeDao.getLinkType(bLinkTypeId);
LinkType linkTypeWithRead = updateLinkTypeRoles(bLinkTypeId, Set.of(), Set.of(new Role(RoleType.Read)));
// check gained
List<Event> events = pusherAdapter.checkLinkTypePermissionsChange(organization, project, otherUser, linkType, linkTypeWithRead);
assertThat(events).hasSize(2);
assertThat(events).extracting("name").containsOnly("Collection:update");
assertThat(events).extracting("data").extracting("object").extracting("id").containsOnly(bCollection, cCollection);
// check lost
events = pusherAdapter.checkLinkTypePermissionsChange(organization, project, otherUser, linkTypeWithRead, linkType);
assertThat(events).hasSize(3);
assertThat(events).extracting("name").containsOnly("LinkType:remove", "Collection:remove");
assertThat(events).extracting("data").extracting("id").containsOnly(bLinkTypeId, bCollection, cCollection);
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherAdapterIT method viewLinkTypesLostOrGainedTest.
@Test
public void viewLinkTypesLostOrGainedTest() {
String aCollection = createCollection("A", EMPTY_ROLES, EMPTY_ROLES).getId();
String bCollection = createCollection("B", READ_ROLES, EMPTY_ROLES).getId();
String cCollection = createCollection("C", READ_ROLES, EMPTY_ROLES).getId();
String aLinkType = createLinkType("A", Arrays.asList(aCollection, bCollection), EMPTY_ROLES, EMPTY_ROLES).getId();
String bLinkType = createLinkType("B", Arrays.asList(bCollection, cCollection), EMPTY_ROLES, READ_ROLES).getId();
View view = createView("V1", new Query(Arrays.asList(new QueryStem(aCollection, Collections.singletonList(aLinkType)), new QueryStem(bCollection, Collections.singletonList(bLinkType)))), EMPTY_ROLES, EMPTY_ROLES);
View viewWithUser = updateViewRoles(view.getId(), READ_ROLES, EMPTY_ROLES);
View viewWithGroup = updateViewRoles(view.getId(), EMPTY_ROLES, READ_ROLES);
// check gained by user roles
List<Event> events = pusherAdapter.checkViewPermissionsChange(organization, project, otherUser, view, viewWithUser);
assertThat(events).hasSize(2);
assertThat(events).extracting("name").containsOnly("Collection:update", "LinkType:update");
assertThat(events).extracting("data").extracting("object").extracting("id").containsOnly(aCollection, aLinkType);
// check gained by group roles
events = pusherAdapter.checkViewPermissionsChange(organization, project, otherUser, view, viewWithGroup);
assertThat(events).hasSize(2);
assertThat(events).extracting("name").containsOnly("Collection:update", "LinkType:update");
assertThat(events).extracting("data").extracting("object").extracting("id").containsOnly(aCollection, aLinkType);
// check lost by user roles
events = pusherAdapter.checkViewPermissionsChange(organization, project, otherUser, viewWithUser, view);
assertThat(events).hasSize(3);
assertThat(events).extracting("name").containsOnly("View:remove", "Collection:remove", "LinkType:remove");
assertThat(events).extracting("data").extracting("id").containsOnly(view.getId(), aCollection, aLinkType);
// check lost by group roles
events = pusherAdapter.checkViewPermissionsChange(organization, project, otherUser, viewWithGroup, view);
assertThat(events).hasSize(3);
assertThat(events).extracting("name").containsOnly("View:remove", "Collection:remove", "LinkType:remove");
assertThat(events).extracting("data").extracting("id").containsOnly(view.getId(), aCollection, aLinkType);
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherAdapterIT method collectionLinkTypesLostOrGainedTest.
@Test
public void collectionLinkTypesLostOrGainedTest() {
String aCollection = createCollection("A", READ_ROLES, EMPTY_ROLES).getId();
String bCollection = createCollection("B", EMPTY_ROLES, EMPTY_ROLES).getId();
String cCollection = createCollection("C", READ_ROLES, EMPTY_ROLES).getId();
String aLinkType = createLinkType("A", Arrays.asList(aCollection, bCollection)).getId();
String bLinkType = createLinkType("B", Arrays.asList(bCollection, cCollection)).getId();
Collection collection = collectionDao.getCollectionById(bCollection);
Collection collectionWithRead = updateCollectionRoles(bCollection, EMPTY_ROLES, READ_ROLES);
// check gained
List<Event> events = pusherAdapter.checkCollectionsPermissionsChange(organization, project, otherUser, collection, collectionWithRead);
assertThat(events).hasSize(2);
assertThat(events).extracting("name").containsOnly("LinkType:update");
assertThat(events).extracting("data").extracting("object").extracting("id").containsOnly(aLinkType, bLinkType);
// check lost
events = pusherAdapter.checkCollectionsPermissionsChange(organization, project, otherUser, collectionWithRead, collection);
assertThat(events).hasSize(3);
assertThat(events).extracting("name").containsOnly("Collection:remove", "LinkType:remove");
assertThat(events).extracting("data").extracting("id").containsOnly(bCollection, aLinkType, bLinkType);
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method createRemoveGroupNotification.
public void createRemoveGroupNotification(@Observes final RemoveGroup removeGroup) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(removeGroup.getOrganizationId());
ResourceId resourceId = new ResourceId(getAppId(), removeGroup.getGroup().getId(), organization.getId());
String className = removeGroup.getGroup().getClass().getSimpleName();
Set<String> users = permissionAdapter.getOrganizationUsersByRole(organization, RoleType.UserConfig);
List<Event> events = users.stream().map(userId -> createEventForRemove(className, resourceId, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method createRemoveUserNotification.
public void createRemoveUserNotification(@Observes final RemoveUser removeUser) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(removeUser.getOrganizationId());
ResourceId resourceId = new ResourceId(getAppId(), removeUser.getUser().getId(), organization.getId());
String className = removeUser.getUser().getClass().getSimpleName();
Set<String> users = resourceAdapter.getOrganizationReaders(organization);
List<Event> events = users.stream().map(userId -> createEventForRemove(className, resourceId, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations