diff options
author | Morgan E. Cook | 2016-10-12 21:22:51 +0000 |
---|---|---|
committer | Morgan E. Cook | 2016-10-13 19:32:44 +0000 |
commit | 931bd9d908196907979a636296112772aa7e2725 (patch) | |
tree | c07c27b16d96b00012d6118047acec2632abfd39 /plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch | |
parent | 2b523ff97a34059a6cb625bf255cd1d2ee28a97f (diff) | |
download | org.eclipse.osee-0.24.2.v201610181545_REL.tar.gz org.eclipse.osee-0.24.2.v201610181545_REL.tar.xz org.eclipse.osee-0.24.2.v201610181545_REL.zip |
bug[ats_ATS317936]: Fix users able to edit baseline branches0.24.2.v201610181545_REL
Change-Id: Iead30965f2c1216c42c9d8b749542987a6511596
Signed-off-by: Morgan E. Cook <Morgan.e.cook@boeing.com>
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch')
2 files changed, 24 insertions, 1 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)); |