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;
}
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);
}
Aggregations