diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse')
3 files changed, 25 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java index 52b2179132b..6c78e693196 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osee.ats.demo.api.DemoUsers; import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -26,6 +27,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable; import org.eclipse.osee.framework.plugin.core.util.Jobs; +import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; @@ -67,6 +69,8 @@ public class BranchCreationHandler extends CommandHandler { BranchId branch = parentTransactionId.getBranch(); if (branch.equals(CoreBranches.SYSTEM_ROOT)) { BranchManager.createTopLevelBranch(dialog.getEntry()); + AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, + PermissionEnum.FULLACCESS); } else { if (dialog.isChecked()) { BranchManager.createWorkingBranchFromTx(parentTransactionId, dialog.getEntry(), null); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java index 83a7b6ad0a3..b31b7fb5d17 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java @@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; @@ -57,14 +58,32 @@ public abstract class GeneralBranchHandler extends CommandHandler { Iterator<IOseeBranch> iterator = selectedBranches.iterator(); List<BranchId> hasChildren = new LinkedList<>(); + List<BranchId> hasNoPermission = new LinkedList<>(); while (iterator.hasNext()) { BranchId branch = iterator.next(); - if (BranchManager.hasChildren(branch)) { + boolean removed = false; + if (!AccessControlManager.hasPermission(branch, PermissionEnum.WRITE)) { iterator.remove(); + hasNoPermission.add(branch); + removed = true; + } + if (BranchManager.hasChildren(branch)) { + if (!removed) { + iterator.remove(); + } hasChildren.add(branch); } } + if (!hasNoPermission.isEmpty()) { + StringBuilder noPermission = new StringBuilder(); + noPermission.append(String.format( + "User does not have permission on the following branches and cannot be %sd:\n", type.dialogType)); + noPermission.append(String.format("%s", hasNoPermission.toString())); + + MessageDialog.openError(Displays.getActiveShell(), type.dialogTitle, noPermission.toString()); + } + if (!hasChildren.isEmpty()) { StringBuilder children = new StringBuilder(); children.append(String.format("The following branches have children and cannot be %sd:\n", type.dialogType)); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java index 6ca4dfaf38a..f96f0e45a65 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java @@ -115,7 +115,7 @@ public class GlobalMenu { } if (purgeMenuItem != null) { purgeMenuItem.setEnabled( - !artifacts.isEmpty() && permiss.isHasArtifacts() && AccessControlManager.isOseeAdmin()); + !artifacts.isEmpty() && permiss.isHasArtifacts() && permiss.isWritePermission() && AccessControlManager.isOseeAdmin()); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); |