summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-04-25 19:52:21 (EDT)
committer Ryan D. Brooks2011-04-25 19:52:21 (EDT)
commit024838ff7fbadffe9e54fb685280af704e560c40 (patch)
treee0aa779d36b23d6699258e2622dc09980b28a1e9
parente9a520c0377091b1072f8574cc3a3eb7bd54e88c (diff)
downloadorg.eclipse.osee-024838ff7fbadffe9e54fb685280af704e560c40.zip
org.eclipse.osee-024838ff7fbadffe9e54fb685280af704e560c40.tar.gz
org.eclipse.osee-024838ff7fbadffe9e54fb685280af704e560c40.tar.bz2
bug[bgz_343781]: Check permissions for ArtifactExplorer new child
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/artifact/ArtifactPromptChangeTest.java6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java11
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java49
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/IAccessPolicyHandlerService.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/AccessPolicyHandlerServiceImpl.java10
5 files changed, 59 insertions, 19 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/artifact/ArtifactPromptChangeTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/artifact/ArtifactPromptChangeTest.java
index e5888e4..12835b7 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/artifact/ArtifactPromptChangeTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/artifact/ArtifactPromptChangeTest.java
@@ -85,6 +85,12 @@ public class ArtifactPromptChangeTest {
public IAccessControlService getAccessService() {
return null;
}
+
+ @Override
+ public PermissionStatus hasArtifactRelatablePermission(Collection<? extends IBasicArtifact<?>> artifacts, Collection<? extends IRelationTypeSide> relationTypeSides, PermissionEnum permission, Level level) throws OseeCoreException {
+ return new PermissionStatus();
+ }
+
}
private static class MockPromptFactory implements IPromptFactory {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
index ea8d2a0..d249ee8 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
@@ -614,17 +614,16 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent
@Override
public void widgetSelected(SelectionEvent e) {
try {
- ArtifactTypeFilteredTreeEntryDialog dialog = getDialog();
Artifact parent = getParent();
IAccessPolicyHandlerService policy = SkynetGuiPlugin.getInstance().getPolicyHandlerService();
PermissionStatus status =
- policy.hasRelationSidePermission(
+ policy.hasArtifactRelatablePermission(Collections.singleton(parent),
java.util.Collections.singleton(CoreRelationTypes.Default_Hierarchical__Child),
PermissionEnum.WRITE, Level.FINE);
-
if (status.matched()) {
+ ArtifactTypeFilteredTreeEntryDialog dialog = getDialog();
if (dialog.open() == Window.OK) {
IArtifactType type = dialog.getSelection();
String name = dialog.getEntryValue();
@@ -639,6 +638,11 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent
treeViewer.refresh();
treeViewer.refresh(false);
}
+ } else {
+ MessageDialog.openError(
+ AWorkbench.getActiveShell(),
+ "New Child Error",
+ "Access control has restricted this action. The current user does not have sufficient permission to create relations on this artifact.");
}
} catch (Exception ex) {
OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
@@ -1496,4 +1500,5 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent
}
return null;
}
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
index b755abd..b6a7dd0 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
@@ -11,12 +11,16 @@
package org.eclipse.osee.framework.ui.skynet;
import java.io.File;
+import java.util.Collections;
+import java.util.logging.Level;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.access.PermissionStatus;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -26,6 +30,7 @@ import org.eclipse.osee.framework.ui.plugin.util.Wizards;
import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportWizard;
import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImporter;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer;
+import org.eclipse.osee.framework.ui.skynet.artifact.IAccessPolicyHandlerService;
import org.eclipse.osee.framework.ui.skynet.update.InterArtifactExplorerDropHandler;
import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
import org.eclipse.swt.dnd.DND;
@@ -77,29 +82,42 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop {
}
}
+ private boolean checkArtifactPermissions(Artifact toCheck) {
+ boolean toReturn = false;
+ try {
+ IAccessPolicyHandlerService policy = SkynetGuiPlugin.getInstance().getPolicyHandlerService();
+ PermissionStatus status =
+ policy.hasArtifactRelatablePermission(Collections.singleton(toCheck),
+ Collections.singleton(CoreRelationTypes.Default_Hierarchical__Child), PermissionEnum.WRITE, Level.FINE);
+ toReturn = status.matched();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ return toReturn;
+ }
+
private boolean isValidForArtifactDrop(DropTargetEvent event) {
+ boolean valid = false;
if (ArtifactTransfer.getInstance().isSupportedType(event.currentDataType)) {
- ArtifactData artData = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType);
- if (artData != null) {
-
- Artifact parentArtifact = getSelectedArtifact(event);
- if (parentArtifact != null && artData.getSource().equals(viewId)) {
- Artifact[] artifactsToBeRelated = artData.getArtifacts();
-
- for (Artifact artifact : artifactsToBeRelated) {
- if (parentArtifact.equals(artifact)) {
- return false;
+ Artifact parentArtifact = getSelectedArtifact(event);
+ ArtifactData artData = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType);
+ if (parentArtifact != null && artData.getSource().equals(viewId)) {
+ valid = checkArtifactPermissions(parentArtifact);
+
+ // if valid, check artifacts that are moving
+ if (valid) {
+ Artifact[] toCheck = artData.getArtifacts();
+ for (Artifact art : toCheck) {
+ valid = (art.equals(parentArtifact) ? false : checkArtifactPermissions(art));
+ if (!valid) {
+ break;
}
}
- return true;
}
- } else {
- // only occurs during the drag on some platforms
- return true;
}
}
- return false;
+ return valid;
}
private Artifact getSelectedArtifact(DropTargetEvent event) {
@@ -162,4 +180,5 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop {
}
}
}
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/IAccessPolicyHandlerService.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/IAccessPolicyHandlerService.java
index 16e6814..bb088d1 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/IAccessPolicyHandlerService.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/IAccessPolicyHandlerService.java
@@ -31,5 +31,7 @@ public interface IAccessPolicyHandlerService {
PermissionStatus hasArtifactPermission(Collection<? extends IBasicArtifact<?>> artifacts, PermissionEnum permission, Level level) throws OseeCoreException;
+ PermissionStatus hasArtifactRelatablePermission(Collection<? extends IBasicArtifact<?>> artifacts, Collection<? extends IRelationTypeSide> relationTypeSides, PermissionEnum permission, Level level) throws OseeCoreException;
+
IAccessControlService getAccessService();
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/AccessPolicyHandlerServiceImpl.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/AccessPolicyHandlerServiceImpl.java
index 07734a4..8289084 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/AccessPolicyHandlerServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/AccessPolicyHandlerServiceImpl.java
@@ -87,7 +87,6 @@ public class AccessPolicyHandlerServiceImpl implements IAccessPolicyHandlerServi
if (relationTypeSides != null) {
for (IRelationTypeSide relationTypeSide : relationTypeSides) {
query.relationTypeMatches(permission, relationTypeSide, permissionStatus);
-
if (printErrorMessage(relationTypeSides, permissionStatus, level)) {
break;
}
@@ -129,4 +128,13 @@ public class AccessPolicyHandlerServiceImpl implements IAccessPolicyHandlerServi
public IAccessControlService getAccessService() {
return accessControlService;
}
+
+ @Override
+ public PermissionStatus hasArtifactRelatablePermission(Collection<? extends IBasicArtifact<?>> artifacts, Collection<? extends IRelationTypeSide> relationTypeSides, PermissionEnum permission, Level level) throws OseeCoreException {
+ PermissionStatus status = hasRelationSidePermission(relationTypeSides, permission, level);
+ if (status.matched()) {
+ status = hasArtifactPermission(artifacts, permission, level);
+ }
+ return status;
+ }
}