Search in sources :

Example 6 with AllowedPermissions

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;
    }
}
Also used : AllowedPermissions(io.lumeer.api.model.AllowedPermissions) SelectedWorkspace(io.lumeer.api.SelectedWorkspace) Arrays(java.util.Arrays) TaskExecutor(io.lumeer.core.task.TaskExecutor) PrintTextOperation(io.lumeer.core.task.executor.operation.PrintTextOperation) CollectionUtil(io.lumeer.api.util.CollectionUtil) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) User(io.lumeer.api.model.User) FileAttachmentData(io.lumeer.core.task.executor.operation.data.FileAttachmentData) Operation(io.lumeer.core.task.executor.operation.Operation) TextPrintRequest(io.lumeer.core.task.executor.request.TextPrintRequest) StringUtils(org.apache.commons.lang3.StringUtils) UserMessageOperation(io.lumeer.core.task.executor.operation.UserMessageOperation) BigDecimal(java.math.BigDecimal) SmtpConfigurationBuilder(io.lumeer.core.task.executor.request.SmtpConfigurationBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceType(io.lumeer.api.model.ResourceType) Map(java.util.Map) AddLinkFileAttachmentOperation(io.lumeer.core.task.executor.operation.AddLinkFileAttachmentOperation) Collectors.toSet(java.util.stream.Collectors.toSet) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) DocumentOperation(io.lumeer.core.task.executor.operation.DocumentOperation) RoleType(io.lumeer.api.model.RoleType) View(io.lumeer.api.model.View) ViewPermissionsOperation(io.lumeer.core.task.executor.operation.ViewPermissionsOperation) DataDocument(io.lumeer.engine.api.data.DataDocument) Value(org.graalvm.polyglot.Value) DummySequenceOperation(io.lumeer.core.task.executor.operation.DummySequenceOperation) Document(io.lumeer.api.model.Document) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) StandardCharsets(java.nio.charset.StandardCharsets) LinkType(io.lumeer.api.model.LinkType) Group(io.lumeer.api.model.Group) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) PrintAttributeOperation(io.lumeer.core.task.executor.operation.PrintAttributeOperation) SendSmtpEmailRequest(io.lumeer.core.task.executor.request.SendSmtpEmailRequest) List(java.util.List) SendEmailOperation(io.lumeer.core.task.executor.operation.SendEmailOperation) EmailSecurityType(io.lumeer.core.util.EmailSecurityType) Optional(java.util.Optional) Attribute(io.lumeer.api.model.Attribute) WithId(io.lumeer.api.model.common.WithId) SendSmtpEmailOperation(io.lumeer.core.task.executor.operation.SendSmtpEmailOperation) ChangesTracker(io.lumeer.core.task.executor.ChangesTracker) LongAdder(java.util.concurrent.atomic.LongAdder) LinkOperation(io.lumeer.core.task.executor.operation.LinkOperation) Engine(com.floreysoft.jmte.Engine) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DocumentCreationOperation(io.lumeer.core.task.executor.operation.DocumentCreationOperation) SendEmailRequest(io.lumeer.core.task.executor.request.SendEmailRequest) HashMap(java.util.HashMap) AllowedPermissions(io.lumeer.api.model.AllowedPermissions) ArrayList(java.util.ArrayList) NavigationOperation(io.lumeer.core.task.executor.operation.NavigationOperation) SearchQueryStem(io.lumeer.storage.api.query.SearchQueryStem) HashSet(java.util.HashSet) Language(io.lumeer.api.model.Language) LinkCreationOperation(io.lumeer.core.task.executor.operation.LinkCreationOperation) PrintRequest(io.lumeer.core.task.executor.request.PrintRequest) DocumentRemovalOperation(io.lumeer.core.task.executor.operation.DocumentRemovalOperation) Query(io.lumeer.api.model.Query) ResourceOperation(io.lumeer.core.task.executor.operation.ResourceOperation) ContextualTask(io.lumeer.core.task.ContextualTask) LinkTypeUtil(io.lumeer.api.util.LinkTypeUtil) Task(io.lumeer.core.task.Task) PermissionUtils(io.lumeer.api.util.PermissionUtils) IOException(java.io.IOException) UserMessageRequest(io.lumeer.core.task.executor.request.UserMessageRequest) NavigationRequest(io.lumeer.core.task.executor.request.NavigationRequest) SmtpConfiguration(io.lumeer.core.task.executor.request.SmtpConfiguration) SearchQuery(io.lumeer.storage.api.query.SearchQuery) AddDocumentFileAttachmentOperation(io.lumeer.core.task.executor.operation.AddDocumentFileAttachmentOperation) DocumentUtils(io.lumeer.core.util.DocumentUtils) FileAttachment(io.lumeer.api.model.FileAttachment) Collectors.toList(java.util.stream.Collectors.toList) ResourceVariable(io.lumeer.api.model.ResourceVariable) PdfCreator(io.lumeer.core.pdf.PdfCreator) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) Query(io.lumeer.api.model.Query) SearchQuery(io.lumeer.storage.api.query.SearchQuery) Language(io.lumeer.api.model.Language) RoleType(io.lumeer.api.model.RoleType) DocumentRemovalOperation(io.lumeer.core.task.executor.operation.DocumentRemovalOperation) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) View(io.lumeer.api.model.View) IOException(java.io.IOException)

Example 7 with AllowedPermissions

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;
    }
}
Also used : AllowedPermissions(io.lumeer.api.model.AllowedPermissions) Query(io.lumeer.api.model.Query) SearchQuery(io.lumeer.storage.api.query.SearchQuery) Language(io.lumeer.api.model.Language) RoleType(io.lumeer.api.model.RoleType) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) View(io.lumeer.api.model.View) IOException(java.io.IOException)

Example 8 with AllowedPermissions

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);
}
Also used : AllowedPermissions(io.lumeer.api.model.AllowedPermissions) RoleType(io.lumeer.api.model.RoleType)

Aggregations

AllowedPermissions (io.lumeer.api.model.AllowedPermissions)8 RoleType (io.lumeer.api.model.RoleType)6 Document (io.lumeer.api.model.Document)5 HashSet (java.util.HashSet)5 Collection (io.lumeer.api.model.Collection)4 LinkType (io.lumeer.api.model.LinkType)4 Query (io.lumeer.api.model.Query)4 User (io.lumeer.api.model.User)4 LinkInstance (io.lumeer.api.model.LinkInstance)3 View (io.lumeer.api.model.View)3 Attribute (io.lumeer.api.model.Attribute)2 FileAttachment (io.lumeer.api.model.FileAttachment)2 Language (io.lumeer.api.model.Language)2 ResourceType (io.lumeer.api.model.ResourceType)2 CollectionUtil (io.lumeer.api.util.CollectionUtil)2 TaskExecutor (io.lumeer.core.task.TaskExecutor)2 DocumentUtils (io.lumeer.core.util.DocumentUtils)2 Tuple (io.lumeer.core.util.Tuple)2 ZonedDateTime (java.time.ZonedDateTime)2 ArrayList (java.util.ArrayList)2