use of io.lumeer.api.model.AllowedPermissions in project engine by Lumeer.
the class LumeerBridge method removeDocumentsInView.
@SuppressWarnings("unused")
public void removeDocumentsInView(final String viewId) {
try {
final View view = task.getDaoContextSnapshot().getViewDao().getViewById(viewId);
final Query query = view.getQuery().getFirstStem(0, Task.MAX_VIEW_DOCUMENTS);
final Language language = Language.fromString(task.getCurrentLocale());
final Set<RoleType> roles = PermissionUtils.getUserRolesInResource(task.getDaoContextSnapshot().getOrganization(), task.getDaoContextSnapshot().getProject(), view, task.getInitiator(), task.getGroups());
final AllowedPermissions permissions = new AllowedPermissions(roles);
final List<Document> documents = DocumentUtils.getDocuments(task.getDaoContextSnapshot(), query, task.getInitiator(), language, permissions, task.getTimeZone());
documents.stream().filter(d -> task.getDaoContextSnapshot().increaseDeletionCounter() <= Task.MAX_CREATED_AND_DELETED_DOCUMENTS_AND_LINKS).forEach(d -> operations.add(new DocumentRemovalOperation(d)));
} catch (Exception e) {
cause = e;
throw e;
}
}
use of io.lumeer.api.model.AllowedPermissions in project engine by Lumeer.
the class LumeerBridge method readView.
@SuppressWarnings("unused")
public List<DocumentBridge> readView(final String viewId) {
try {
final View view = task.getDaoContextSnapshot().getViewDao().getViewById(viewId);
final Query query = view.getQuery().getFirstStem(0, Task.MAX_VIEW_DOCUMENTS);
final Language language = Language.fromString(task.getCurrentLocale());
final Set<RoleType> roles = PermissionUtils.getUserRolesInResource(task.getDaoContextSnapshot().getOrganization(), task.getDaoContextSnapshot().getProject(), view, task.getInitiator(), task.getGroups());
final AllowedPermissions permissions = new AllowedPermissions(roles);
final List<Document> documents = DocumentUtils.getDocuments(task.getDaoContextSnapshot(), query, task.getInitiator(), language, permissions, task.getTimeZone());
return documents.stream().map(DocumentBridge::new).collect(toList());
} catch (Exception e) {
cause = e;
throw e;
}
}
use of io.lumeer.api.model.AllowedPermissions in project engine by Lumeer.
the class DocumentMatcher method initializePermissions.
private void initializePermissions() {
Set<RoleType> thisCollectionRoles = PermissionUtils.getUserRolesInResource(this.organization, this.project, this.thisCollection, this.ruleTask.getInitiator(), this.ruleTask.getGroups());
Set<RoleType> thatCollectionRoles = PermissionUtils.getUserRolesInResource(this.organization, this.project, this.thatCollection, this.ruleTask.getInitiator(), this.ruleTask.getGroups());
AllowedPermissions thisCollectionPermissions = new AllowedPermissions(thisCollectionRoles);
AllowedPermissions thatCollectionPermissions = new AllowedPermissions(thatCollectionRoles);
AllowedPermissions linkTypePermission = AllowedPermissions.merge(thisCollectionPermissions, thatCollectionPermissions);
collectionPermissions = Map.of(thisCollection.getId(), thisCollectionPermissions, thatCollection.getId(), thatCollectionPermissions);
linkTypePermissions = Map.of(linkType.getId(), linkTypePermission);
}
Aggregations