summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-05-03 15:03:19 (EDT)
committerRyan D. Brooks2011-05-03 15:03:19 (EDT)
commitc68a5c5ad6083409ce94aba7e9705a22fff4acb0 (patch)
treea15e4420f335d2ae36ea91730e7af4852c2666fd
parent1feb2d1e6a2bcdb8877550cac3b7b04ca232e69b (diff)
downloadorg.eclipse.osee-c68a5c5ad6083409ce94aba7e9705a22fff4acb0.zip
org.eclipse.osee-c68a5c5ad6083409ce94aba7e9705a22fff4acb0.tar.gz
org.eclipse.osee-c68a5c5ad6083409ce94aba7e9705a22fff4acb0.tar.bz2
bug[bgz_346890]: ArtifactExplorer: check artifact READ permission to copy
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/accessProviders/ArtifactAccessProvider.java11
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java39
4 files changed, 37 insertions, 19 deletions
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 d249ee8..9708baf 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
@@ -997,7 +997,6 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent
private void performCopy() throws OseeCoreException {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
List<Artifact> artifactTransferData = new ArrayList<Artifact>();
- List<String> textTransferData = new ArrayList<String>();
Artifact artifact;
if (selection != null && !selection.isEmpty()) {
@@ -1006,11 +1005,10 @@ public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEvent
artifact = (Artifact) object;
artifactTransferData.add(artifact);
- textTransferData.add(artifact.getName());
}
}
artifactClipboard.setArtifactsToClipboard(new ArtifactAccessProvider(),
- SkynetGuiPlugin.getInstance().getPolicyHandlerService(), artifactTransferData, textTransferData);
+ SkynetGuiPlugin.getInstance().getPolicyHandlerService(), artifactTransferData);
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/accessProviders/ArtifactAccessProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/accessProviders/ArtifactAccessProvider.java
index 71a2100..be8075d 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/accessProviders/ArtifactAccessProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/accessProviders/ArtifactAccessProvider.java
@@ -5,6 +5,8 @@
*/
package org.eclipse.osee.framework.ui.skynet.accessProviders;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@@ -23,15 +25,16 @@ public class ArtifactAccessProvider {
}
public List<Artifact> getArtifactsWithPermission(IAccessPolicyHandlerService accessService, PermissionEnum permission, List<Artifact> artifacts) throws OseeCoreException {
- Iterator<Artifact> artIterator = artifacts.iterator();
+ ArrayList<Artifact> toReturn = new ArrayList<Artifact>(artifacts);
+ Iterator<Artifact> artIterator = toReturn.iterator();
// Remove Artifact that do not have write permission.
while (artIterator.hasNext()) {
- artIterator.next();
- if (!accessService.hasArtifactPermission(artifacts, permission, Level.WARNING).matched()) {
+ Artifact cur = artIterator.next();
+ if (!accessService.hasArtifactPermission(Collections.singleton(cur), permission, Level.WARNING).matched()) {
artIterator.remove();
}
}
- return artifacts;
+ return toReturn;
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java
index 8ab6985..f6a3094 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java
@@ -77,7 +77,7 @@ public class CopyHandler extends AbstractHandler {
} else if (!names.isEmpty() && !artifacts.isEmpty()) {
try {
clipboard.setArtifactsToClipboard(new ArtifactAccessProvider(),
- SkynetGuiPlugin.getInstance().getPolicyHandlerService(), artifacts, names);
+ SkynetGuiPlugin.getInstance().getPolicyHandlerService(), artifacts);
} catch (OseeCoreException ex) {
throw new ExecutionException(ex.getLocalizedMessage());
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java
index f41f6b5..71e7b70 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.util;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
@@ -22,6 +24,7 @@ import org.eclipse.osee.framework.ui.skynet.HTMLTransferFormatter;
import org.eclipse.osee.framework.ui.skynet.accessProviders.ArtifactAccessProvider;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer;
import org.eclipse.osee.framework.ui.skynet.artifact.IAccessPolicyHandlerService;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.HTMLTransfer;
import org.eclipse.swt.dnd.TextTransfer;
@@ -40,7 +43,7 @@ public class ArtifactClipboard {
this.viewId = viewId;
}
- public void setArtifactsToClipboard(ArtifactAccessProvider artifactAccessProvider, IAccessPolicyHandlerService policyHandlerService, List<Artifact> artifactTransferData, List<String> textTransferData) throws OseeCoreException {
+ public void setArtifactsToClipboard(ArtifactAccessProvider artifactAccessProvider, IAccessPolicyHandlerService policyHandlerService, List<Artifact> artifactTransferData) throws OseeCoreException {
if (artifactTransferData == null) {
throw new IllegalArgumentException("Artifacts can not be null for artifact copy.");
}
@@ -48,20 +51,34 @@ public class ArtifactClipboard {
throw new IllegalArgumentException("Artifacts can not be empty.");
}
+ List<Artifact> authFailedList = new ArrayList<Artifact>(artifactTransferData);
List<Artifact> authorizedArtifacts =
- artifactAccessProvider.getArtifactsWithPermission(policyHandlerService, PermissionEnum.WRITE,
+ artifactAccessProvider.getArtifactsWithPermission(policyHandlerService, PermissionEnum.READ,
artifactTransferData);
- Artifact[] artifacts = authorizedArtifacts.toArray(new Artifact[authorizedArtifacts.size()]);
+ authFailedList.removeAll(authorizedArtifacts);
+
+ if (authorizedArtifacts.size() > 0) {
+ ArrayList<String> textTransferData = new ArrayList<String>();
+ for (Artifact cur : authorizedArtifacts) {
+ textTransferData.add(cur.getName());
+ }
+ Artifact[] artifacts = authorizedArtifacts.toArray(new Artifact[authorizedArtifacts.size()]);
+ clipboard.setContents(
+ new Object[] {
+ new ArtifactData(artifacts, STATUS, viewId),
+ HTMLTransferFormatter.getHtml(artifacts),
+ Collections.toString(textTransferData, null, ", ", null)},
+ new Transfer[] {ArtifactTransfer.getInstance(), HTMLTransfer.getInstance(), TextTransfer.getInstance()});
+ }
+ if (authFailedList.size() > 0) {
+ String failed = Collections.toString(", ", authFailedList) + ".";
+ MessageDialog.openError(
+ Displays.getActiveShell(),
+ "Copy Error",
+ "Access control has restricted this action. The following artifacts were not copied to the clipboard: " + failed);
+ }
- clipboard.setContents(
- new Object[] {
- new ArtifactData(artifacts, STATUS, viewId),
- HTMLTransferFormatter.getHtml(artifacts),
- Collections.toString(textTransferData, null, ", ", null)}, new Transfer[] {
- ArtifactTransfer.getInstance(),
- HTMLTransfer.getInstance(),
- TextTransfer.getInstance()});
}
public void setTextToClipboard(Collection<String> textTransferData) {