Search in sources :

Example 11 with RBACRole

use of de.catma.rbac.RBACRole in project catma by forTEXT.

the class GitProjectHandler method getCollections.

public List<AnnotationCollection> getCollections(TagLibrary tagLibrary, ProgressListener progressListener) {
    ArrayList<AnnotationCollection> collections = new ArrayList<>();
    try (ILocalGitRepositoryManager localRepoManager = this.localGitRepositoryManager) {
        try {
            localRepoManager.open(projectId, GitProjectManager.getProjectRootRepositoryName(projectId));
            Path collectionDirPath = Paths.get(localRepoManager.getRepositoryWorkTree().toURI()).resolve(ANNOTATION_COLLECTION_SUBMODULES_DIRECTORY_NAME);
            if (!collectionDirPath.toFile().exists()) {
                return collections;
            }
            List<Path> paths = localRepoManager.getSubmodulePaths().stream().filter(path -> path != null && path.startsWith(ANNOTATION_COLLECTION_SUBMODULES_DIRECTORY_NAME)).map(path -> Paths.get(localRepoManager.getRepositoryWorkTree().toURI()).resolve(ANNOTATION_COLLECTION_SUBMODULES_DIRECTORY_NAME).resolve(path)).collect(Collectors.toList());
            localRepoManager.detach();
            GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(localRepoManager, this.remoteGitServerManager, this.credentialsProvider);
            for (Path collectionPath : paths) {
                String collectionId = collectionPath.getFileName().toString();
                RBACRole resourceRole = rolesPerResource.get(collectionId);
                if ((resourceRole != null) && hasPermission(resourceRole, RBACPermission.COLLECTION_READ)) {
                    try {
                        collections.add(gitMarkupCollectionHandler.getCollection(projectId, collectionId, tagLibrary, progressListener, hasPermission(resourceRole, RBACPermission.COLLECTION_WRITE), (tagsetId) -> {
                            RBACRole tagsetResourceRole = rolesPerResource.get(tagsetId);
                            return ((tagsetResourceRole != null) && hasPermission(tagsetResourceRole, RBACPermission.TAGSET_READ));
                        }));
                    } catch (Exception e) {
                        logger.log(Level.SEVERE, String.format("error loading Collection reference %1$s for project %2$s", collectionPath, projectId), e);
                    }
                }
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, String.format("error loading Collection references for project %1$s", projectId), e);
        }
    }
    return collections;
}
Also used : Path(java.nio.file.Path) ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) Reply(de.catma.document.comment.Reply) java.util(java.util) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) Status(org.eclipse.jgit.api.Status) RBACRole(de.catma.rbac.RBACRole) User(de.catma.user.User) Level(java.util.logging.Level) IRemoteGitManagerRestricted(de.catma.repository.git.interfaces.IRemoteGitManagerRestricted) Comment(de.catma.document.comment.Comment) Member(de.catma.user.Member) Pair(de.catma.util.Pair) IDGenerator(de.catma.util.IDGenerator) RBACSubject(de.catma.rbac.RBACSubject) CommitInfo(de.catma.project.CommitInfo) Nonnull(javax.annotation.Nonnull) Path(java.nio.file.Path) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) ProgressListener(de.catma.backgroundservice.ProgressListener) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Files(java.nio.file.Files) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) TermInfo(de.catma.indexer.TermInfo) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider) FileUtils(org.apache.commons.io.FileUtils) Constants(org.eclipse.jgit.lib.Constants) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) SourceDocumentInfo(de.catma.document.source.SourceDocumentInfo) File(java.io.File) TagReference(de.catma.document.annotation.TagReference) de.catma.project.conflict(de.catma.project.conflict) de.catma.tag(de.catma.tag) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException) Paths(java.nio.file.Paths) MergeResult(org.eclipse.jgit.api.MergeResult) JGitRepoManager(de.catma.repository.git.managers.JGitRepoManager) ContentInfoSet(de.catma.document.source.ContentInfoSet) RBACPermission(de.catma.rbac.RBACPermission) FilenameUtils(org.apache.commons.io.FilenameUtils) StatusPrinter(de.catma.repository.git.managers.StatusPrinter) InputStream(java.io.InputStream) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) RBACRole(de.catma.rbac.RBACRole) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException)

Example 12 with RBACRole

use of de.catma.rbac.RBACRole in project catma by forTEXT.

the class JoinProjectDialog method initComponents.

private void initComponents() {
    setWidth("30%");
    setHeight("90%");
    center();
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();
    Label lDescription = new Label("Please enter your invitation code to find and join a Project");
    lDescription.addStyleName("label-with-word-wrap");
    content.addComponent(lDescription);
    tfCode = new TextField("Code");
    tfCode.setWidth("100%");
    tfCode.setDescription("Enter your invitation code here");
    content.addComponent(tfCode);
    content.setExpandRatio(tfCode, 0.3f);
    tfName = new TextField("Name");
    tfName.setWidth("100%");
    tfName.setReadOnly(true);
    tfName.setVisible(false);
    content.addComponent(tfName);
    cbRole = new ComboBox<RBACRole>("Role", Lists.newArrayList(RBACRole.values()));
    cbRole.setWidth("100%");
    cbRole.setItemCaptionGenerator(RBACRole::getRoleName);
    cbRole.setEmptySelectionAllowed(false);
    cbRole.setReadOnly(true);
    cbRole.setVisible(false);
    content.addComponent(cbRole);
    taDescription = new TextArea("Description");
    taDescription.setWidth("100%");
    taDescription.setHeight("100%");
    taDescription.setVisible(false);
    content.addComponent(taDescription);
    content.setExpandRatio(taDescription, 1f);
    HorizontalLayout buttonPanel = new HorizontalLayout();
    buttonPanel.setWidth("100%");
    btnJoin = new Button("Join");
    btnCancel = new Button("Cancel");
    btnJoin.setEnabled(false);
    buttonPanel.addComponent(btnJoin);
    buttonPanel.addComponent(btnCancel);
    buttonPanel.setExpandRatio(btnJoin, 1f);
    buttonPanel.setComponentAlignment(btnJoin, Alignment.BOTTOM_RIGHT);
    buttonPanel.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
    content.addComponent(buttonPanel);
    setContent(content);
}
Also used : RBACRole(de.catma.rbac.RBACRole) TextArea(com.vaadin.ui.TextArea) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

RBACRole (de.catma.rbac.RBACRole)12 IOException (java.io.IOException)6 User (de.catma.user.User)5 Collectors (java.util.stream.Collectors)5 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)4 Comment (de.catma.document.comment.Comment)4 Reply (de.catma.document.comment.Reply)4 CATMAPropertyKey (de.catma.properties.CATMAPropertyKey)4 RBACPermission (de.catma.rbac.RBACPermission)4 ILocalGitRepositoryManager (de.catma.repository.git.interfaces.ILocalGitRepositoryManager)4 IRemoteGitManagerRestricted (de.catma.repository.git.interfaces.IRemoteGitManagerRestricted)4 Member (de.catma.user.Member)4 IDGenerator (de.catma.util.IDGenerator)4 Level (java.util.logging.Level)4 Logger (java.util.logging.Logger)4 Label (com.vaadin.ui.Label)3 List (java.util.List)3 EventBus (com.google.common.eventbus.EventBus)2 MarginInfo (com.vaadin.shared.ui.MarginInfo)2 Alignment (com.vaadin.ui.Alignment)2