use of de.catma.rbac.RBACRole in project catma by forTEXT.
the class ResourcePermissionView method initData.
private void initData(TreeData<Resource> resourceData, Collection<TagsetDefinition> tagsets) {
try {
permissionGrid.removeAllColumns();
permissionGrid.addColumn(resource -> resource.getIcon(), new HtmlRenderer()).setWidth(70);
permissionGrid.addColumn(resource -> resource.getName()).setWidth(250).setCaption("Resource");
TreeData<Resource> items = new TreeData<Resource>();
for (Resource documentResource : resourceData.getRootItems()) {
Set<Member> documentMembers = project.getResourceMembers(documentResource.getResourceId());
documentMembers.forEach(member -> permissionMatrix.put(documentResource, member, member.getRole()));
items.addItem(null, documentResource);
Collection<Resource> collectionResources = resourceData.getChildren(documentResource);
for (Resource collectionResource : collectionResources) {
Set<Member> collectionMembers = project.getResourceMembers(collectionResource.getResourceId());
collectionMembers.forEach(member -> permissionMatrix.put(collectionResource, member, member.getRole()));
items.addItem(documentResource, collectionResource);
}
}
for (TagsetDefinition tagset : tagsets) {
Set<Member> tagsetMembers = project.getResourceMembers(tagset.getUuid());
TagsetResource tagsetResource = new TagsetResource(tagset, project.getProjectId());
tagsetMembers.forEach(member -> permissionMatrix.put(tagsetResource, member, member.getRole()));
items.addItem(null, tagsetResource);
}
for (Member member : permissionMatrix.columnKeySet()) {
Column<Resource, String> memberColumn = permissionGrid.addColumn(resource -> {
RBACRole role = permissionMatrix.get(resource, member);
return role == null ? "" : role.getRoleName();
}).setWidth(120).setCaption(member.getName()).setDescriptionGenerator(resource -> member.preciseName());
// only reporter and lower can be upgraded for specific resources
if (member.getRole().getAccessLevel() <= RBACRole.REPORTER.getAccessLevel()) {
memberColumn.setEditorBinding(createRoleEditor(member));
} else {
memberColumn.setHidable(true);
memberColumn.setHidden(true);
}
}
permissionDataProvider = new TreeDataProvider<>(items);
permissionGrid.setDataProvider(permissionDataProvider);
permissionGrid.expand(resourceData.getRootItems());
} catch (IOException e) {
errorHandler.showAndLogError("Failed to fetch permissions", e);
}
}
use of de.catma.rbac.RBACRole in project catma by forTEXT.
the class ProjectInvitationDialog method initComponents.
private void initComponents() {
setModal(true);
setWidth("60%");
setHeight("90%");
VerticalLayout content = new VerticalLayout();
content.setSizeFull();
lInvitationCode = new Label("", ContentMode.HTML);
lInvitationCode.setVisible(false);
content.addComponent(lInvitationCode);
cbOwnCollection = new CheckBox("Create one collection per Document and joined User", false);
cbOwnCollection.setValue(false);
content.addComponent(cbOwnCollection);
cbOwnCollection.setEnabled(!documentsForCollectionCreation.isEmpty());
documentGrid = new Grid<>();
documentGrid.setSizeFull();
documentGrid.setRowHeight(45);
documentGrid.setCaption("Documents");
documentGrid.setDataProvider(new ListDataProvider<>(documentsForCollectionCreation));
documentGrid.setSelectionMode(SelectionMode.MULTI);
documentGrid.addColumn(resource -> resource.getIcon(), new HtmlRenderer()).setWidth(100);
Function<Resource, String> buildNameFunction = (resource) -> {
StringBuilder sb = new StringBuilder().append("<div class='documentsgrid__doc'> ").append("<div class='documentsgrid__doc__title'> ").append(resource.getName()).append("</div>");
if (resource.hasDetail()) {
sb.append("<span class='documentsgrid__doc__author'> ").append(resource.getDetail()).append("</span>");
}
sb.append("</div>");
return sb.toString();
};
documentGrid.addColumn(resource -> buildNameFunction.apply(resource), new HtmlRenderer()).setCaption("Name");
// .setExpandRatio(1);
documentGrid.setEnabled(false);
content.addComponent(documentGrid);
content.setExpandRatio(documentGrid, 1f);
roleBox = new ComboBox<RBACRole>("Role", Lists.newArrayList(RBACRole.GUEST, RBACRole.REPORTER, RBACRole.ASSISTANT, RBACRole.MAINTAINER));
roleBox.setWidth("100%");
roleBox.setItemCaptionGenerator(RBACRole::getRoleName);
roleBox.setEmptySelectionAllowed(false);
content.addComponent(roleBox);
joinedUsersConsole = new ListSelect<>("Joined Users", joinedUsers);
joinedUsersConsole.setWidth("100%");
joinedUsersConsole.setCaption("Users");
joinedUsersConsole.setReadOnly(true);
joinedUsersConsole.setVisible(false);
content.addComponent(joinedUsersConsole);
HorizontalLayout buttonPanel = new HorizontalLayout();
buttonPanel.setWidth("100%");
buttonPanel.setMargin(new MarginInfo(true, false));
btnInvite = new Button("Invite");
btnStopInvite = new Button("Stop invitation");
progressIndicator = new ProgressBar();
progressIndicator.setIndeterminate(false);
progressIndicator.setVisible(false);
buttonPanel.addComponent(progressIndicator);
buttonPanel.setExpandRatio(progressIndicator, 0.5f);
buttonPanel.addComponent(btnInvite);
buttonPanel.addComponent(btnStopInvite);
buttonPanel.setComponentAlignment(btnInvite, Alignment.BOTTOM_RIGHT);
buttonPanel.setComponentAlignment(btnStopInvite, Alignment.BOTTOM_RIGHT);
buttonPanel.setExpandRatio(btnInvite, 0.5f);
content.addComponent(buttonPanel);
content.setComponentAlignment(buttonPanel, Alignment.BOTTOM_RIGHT);
setContent(content);
}
use of de.catma.rbac.RBACRole in project catma by forTEXT.
the class GitlabManagerRestricted method getRolesPerResource.
public Map<String, RBACRole> getRolesPerResource(String projectId) throws IOException {
try {
Group group = restrictedGitLabApi.getGroupApi().getGroup(projectId);
Map<String, AccessLevel> permMap = getResourcePermissions(group.getId());
return permMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> RBACRole.forValue(e.getValue().value)));
} catch (GitLabApiException e) {
throw new IOException("Permission retrieval failed!", e);
}
}
use of de.catma.rbac.RBACRole in project catma by forTEXT.
the class AbstractMemberDialog method initComponents.
private void initComponents(String description) {
this.descriptionLabel = new Label(description);
descriptionLabel.setHeight("50px");
cbUsers = new ComboBox<>("Member");
cbUsers.setWidth("100%");
cbUsers.setPageLength(20);
cbUsers.setItemCaptionGenerator(User::preciseName);
cbRole = new ComboBox<RBACRole>("Role", Lists.newArrayList(RBACRole.GUEST, RBACRole.REPORTER, RBACRole.ASSISTANT, RBACRole.MAINTAINER));
cbRole.setWidth("100%");
cbRole.setItemCaptionGenerator(RBACRole::getRoleName);
cbRole.setEmptySelectionAllowed(false);
}
use of de.catma.rbac.RBACRole in project catma by forTEXT.
the class ProjectCard method initData.
private void initData() {
try {
RBACRole projectRole = rbacManager.getRoleOnProject(projectManager.getUser(), projectReference.getProjectId());
// normally done in reload();
rbacEnforcer.enforceConstraints(projectRole);
} catch (IOException e) {
errorLogger.showAndLogError("can't fetch permissions" + projectReference.getName(), e);
}
}
Aggregations