Search in sources :

Example 1 with PermissionAdapter

use of io.lumeer.core.adapter.PermissionAdapter in project engine by Lumeer.

the class AuditFacade method init.

@PostConstruct
public void init() {
    constraintManager = ConstraintManager.getInstance(configurationProducer);
    pusherClient = pusherHelperFacade.getPusherClient();
    auditAdapter = new AuditAdapter(auditDao);
    documentAdapter = new DocumentAdapter(resourceCommentDao, favoriteItemDao);
    linkInstanceAdapter = new LinkInstanceAdapter(resourceCommentDao);
    PermissionAdapter permissionAdapter = new PermissionAdapter(userDao, groupDao, viewDao, linkTypeDao, collectionDao);
    resourceAdapter = new ResourceAdapter(permissionAdapter, collectionDao, linkTypeDao, viewDao, userDao);
    collectionAdapter = new CollectionAdapter(collectionDao, favoriteItemDao, documentDao);
    linkTypeAdapter = new LinkTypeAdapter(linkTypeDao, linkInstanceDao);
    pusherAdapter = new PusherAdapter(requestDataKeeper.getAppId(), getFacadeAdapter(), resourceAdapter, permissionAdapter, viewDao, linkTypeDao, collectionDao);
}
Also used : LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) AuditAdapter(io.lumeer.core.adapter.AuditAdapter) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) PostConstruct(javax.annotation.PostConstruct)

Example 2 with PermissionAdapter

use of io.lumeer.core.adapter.PermissionAdapter in project engine by Lumeer.

the class AbstractContextualTask method initialize.

@Override
public ContextualTask initialize(final User initiator, final DaoContextSnapshot daoContextSnapshot, final PusherClient pusherClient, final LumeerS3Client lumeerS3Client, final RequestDataKeeper requestDataKeeper, final ConstraintManager constraintManager, DefaultConfigurationProducer.DeployEnvironment environment, final int recursionDepth) {
    this.initiator = initiator;
    this.daoContextSnapshot = daoContextSnapshot;
    this.pusherClient = pusherClient;
    this.lumeerS3Client = lumeerS3Client;
    this.requestDataKeeper = requestDataKeeper;
    this.constraintManager = constraintManager;
    this.environment = environment;
    this.timeZone = requestDataKeeper.getTimezone();
    this.recursionDepth = recursionDepth;
    collectionAdapter = new CollectionAdapter(daoContextSnapshot.getCollectionDao(), daoContextSnapshot.getFavoriteItemDao(), daoContextSnapshot.getDocumentDao());
    permissionAdapter = new PermissionAdapter(daoContextSnapshot.getUserDao(), daoContextSnapshot.getGroupDao(), daoContextSnapshot.getViewDao(), daoContextSnapshot.getLinkTypeDao(), daoContextSnapshot.getCollectionDao());
    resourceAdapter = new ResourceAdapter(permissionAdapter, daoContextSnapshot.getCollectionDao(), daoContextSnapshot.getLinkTypeDao(), daoContextSnapshot.getViewDao(), daoContextSnapshot.getUserDao());
    viewAdapter = new ViewAdapter(resourceAdapter, daoContextSnapshot.getFavoriteItemDao());
    documentAdapter = new DocumentAdapter(daoContextSnapshot.getResourceCommentDao(), daoContextSnapshot.getFavoriteItemDao());
    linkTypeAdapter = new LinkTypeAdapter(daoContextSnapshot.getLinkTypeDao(), daoContextSnapshot.getLinkInstanceDao());
    linkInstanceAdapter = new LinkInstanceAdapter(daoContextSnapshot.getResourceCommentDao());
    pusherAdapter = new PusherAdapter(getAppId(), new FacadeAdapter(permissionAdapter), resourceAdapter, permissionAdapter, daoContextSnapshot.getViewDao(), daoContextSnapshot.getLinkTypeDao(), daoContextSnapshot.getCollectionDao());
    fileAttachmentAdapter = new FileAttachmentAdapter(getLumeerS3Client(), daoContextSnapshot.getFileAttachmentDao(), environment.name());
    return this;
}
Also used : LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) FileAttachmentAdapter(io.lumeer.core.adapter.FileAttachmentAdapter) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) FacadeAdapter(io.lumeer.core.adapter.FacadeAdapter) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) ViewAdapter(io.lumeer.core.adapter.ViewAdapter) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter)

Example 3 with PermissionAdapter

use of io.lumeer.core.adapter.PermissionAdapter in project engine by Lumeer.

the class PermissionsChecker method init.

@PostConstruct
public void init() {
    collectionAdapter = new CollectionAdapter(collectionDao, favoriteItemDao, documentDao);
    permissionAdapter = new PermissionAdapter(userDao, groupDao, viewDao, linkTypeDao, collectionDao);
}
Also used : CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) PostConstruct(javax.annotation.PostConstruct)

Example 4 with PermissionAdapter

use of io.lumeer.core.adapter.PermissionAdapter in project engine by Lumeer.

the class DelayedActionProcessor method checkActionResourceExistsAndFillData.

private Collection checkActionResourceExistsAndFillData(final DelayedAction action, final User receiver) {
    final String organizationId = action.getData().getString(DelayedAction.DATA_ORGANIZATION_ID);
    final String projectId = action.getData().getString(DelayedAction.DATA_PROJECT_ID);
    final String collectionId = action.getData().getString(DelayedAction.DATA_COLLECTION_ID);
    final String documentId = action.getData().getString(DelayedAction.DATA_DOCUMENT_ID);
    try {
        if (organizationId != null) {
            final DataStorage userDataStorage = getDataStorage(organizationId);
            final Organization organization = organizations.computeIfAbsent(organizationId, id -> organizationDao.getOrganizationById(organizationId));
            action.getData().append(DelayedAction.DATA_ORGANIZATION_NAME, organization.getName());
            action.getData().append(DelayedAction.DATA_ORGANIZATION_CODE, organization.getCode());
            action.getData().append(DelayedAction.DATA_ORGANIZATION_ICON, organization.getIcon());
            action.getData().append(DelayedAction.DATA_ORGANIZATION_COLOR, organization.getColor());
            final DaoContextSnapshot organizationDaoSnapshot = organizationDaoSnapshots.computeIfAbsent(organizationId, id -> getDaoContextSnapshot(userDataStorage, new Workspace(organization, null)));
            if (projectId != null) {
                final Project project = projects.computeIfAbsent(projectId, id -> organizationDaoSnapshot.getProjectDao().getProjectById(projectId));
                action.getData().append(DelayedAction.DATA_PROJECT_NAME, project.getName());
                action.getData().append(DelayedAction.DATA_PROJECT_CODE, project.getCode());
                action.getData().append(DelayedAction.DATA_PROJECT_ICON, project.getIcon());
                action.getData().append(DelayedAction.DATA_PROJECT_COLOR, project.getColor());
                final String projectKey = organizationId + ":" + projectId;
                final DaoContextSnapshot projectDaoSnapshot = projectDaoSnapshots.computeIfAbsent(projectKey, key -> getDaoContextSnapshot(userDataStorage, new Workspace(organization, project)));
                final PermissionAdapter permissionAdapter = permissionAdapters.computeIfAbsent(projectKey, key -> new PermissionAdapter(projectDaoSnapshot.getUserDao(), projectDaoSnapshot.getGroupDao(), projectDaoSnapshot.getViewDao(), projectDaoSnapshot.getLinkTypeDao(), projectDaoSnapshot.getCollectionDao()));
                if (receiver != null && !permissionAdapter.canReadWorkspace(organization, project, receiver.getId())) {
                    return null;
                }
                if (collectionId != null) {
                    final Collection collection = collections.computeIfAbsent(collectionId, id -> projectDaoSnapshot.getCollectionDao().getCollectionById(collectionId));
                    action.getData().append(DelayedAction.DATA_COLLECTION_NAME, collection.getName());
                    action.getData().append(DelayedAction.DATA_COLLECTION_ICON, collection.getIcon());
                    action.getData().append(DelayedAction.DATA_COLLECTION_COLOR, collection.getColor());
                    if (documentId != null) {
                        final Document document = projectDaoSnapshot.getDocumentDao().getDocumentById(documentId);
                        document.setData(projectDaoSnapshot.getDataDao().getData(collectionId, documentId));
                        if (receiver != null && !permissionAdapter.canReadDocument(organization, project, document, collection, receiver.getId())) {
                            return null;
                        }
                        return collection;
                    }
                }
            }
        }
    } catch (ResourceNotFoundException e) {
        return null;
    }
    return null;
}
Also used : DataStorage(io.lumeer.engine.api.data.DataStorage) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) Collection(io.lumeer.api.model.Collection) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException) DaoContextSnapshot(io.lumeer.storage.api.dao.context.DaoContextSnapshot) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter)

Aggregations

PermissionAdapter (io.lumeer.core.adapter.PermissionAdapter)4 CollectionAdapter (io.lumeer.core.adapter.CollectionAdapter)3 DocumentAdapter (io.lumeer.core.adapter.DocumentAdapter)2 LinkInstanceAdapter (io.lumeer.core.adapter.LinkInstanceAdapter)2 LinkTypeAdapter (io.lumeer.core.adapter.LinkTypeAdapter)2 PusherAdapter (io.lumeer.core.adapter.PusherAdapter)2 ResourceAdapter (io.lumeer.core.adapter.ResourceAdapter)2 PostConstruct (javax.annotation.PostConstruct)2 Collection (io.lumeer.api.model.Collection)1 Document (io.lumeer.api.model.Document)1 Organization (io.lumeer.api.model.Organization)1 Project (io.lumeer.api.model.Project)1 AuditAdapter (io.lumeer.core.adapter.AuditAdapter)1 FacadeAdapter (io.lumeer.core.adapter.FacadeAdapter)1 FileAttachmentAdapter (io.lumeer.core.adapter.FileAttachmentAdapter)1 ViewAdapter (io.lumeer.core.adapter.ViewAdapter)1 DataDocument (io.lumeer.engine.api.data.DataDocument)1 DataStorage (io.lumeer.engine.api.data.DataStorage)1 DaoContextSnapshot (io.lumeer.storage.api.dao.context.DaoContextSnapshot)1 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)1