Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java72
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessData.java74
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionAccessHandler.java50
4 files changed, 98 insertions, 101 deletions
diff --git a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
index f7ae3966ed..5baa089021 100644
--- a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
@@ -29,4 +29,5 @@ Import-Package: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Eclipse-ExtensibleAPI: true
Export-Package: org.eclipse.osee.framework.access
-Require-Bundle: org.eclipse.osee.framework.skynet.core;bundle-version="0.9.5"
+Require-Bundle: org.eclipse.osee.framework.skynet.core;bundle-version="0.9.5",
+ org.eclipse.osee.framework.core.model
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java
index 300180a971..43e306c5df 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java
@@ -24,40 +24,40 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
public class ObjectAccessProvider implements IAccessProvider {
- private final AccessControlService accessService;
-
- public ObjectAccessProvider(AccessControlService accessService) {
- this.accessService = accessService;
- }
-
- @Override
- public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
- for (Object object : objToCheck) {
- if (object instanceof Artifact) {
- setArtifactAccessData(userArtifact, (Artifact) object, accessData);
- } else if (object instanceof Branch) {
- setBranchAccessData(userArtifact, (Branch) object, accessData);
- } else {
- throw new OseeStateException("Unhandled object type for access control - " + object);
- }
- }
- }
-
- private void setArtifactAccessData(IBasicArtifact<?> userArtifact, Artifact artifact, AccessData accessData) throws OseeCoreException {
- PermissionEnum userPermission = accessService.getArtifactPermission(userArtifact, artifact);
-
- if (userPermission == null || isArtifactReadOnly(artifact)) {
- userPermission = PermissionEnum.READ;
- }
- accessData.add(artifact, new AccessDetail<IBasicArtifact<Artifact>>(artifact, userPermission));
- }
-
- public boolean isArtifactReadOnly(Artifact artifact) {
- return artifact.isDeleted() || artifact.isHistorical() || !artifact.getBranch().isEditable();
- }
-
- private void setBranchAccessData(IBasicArtifact<?> userArtifact, Branch branch, AccessData accessData) throws OseeCoreException {
- PermissionEnum userPermission = accessService.getBranchPermission(userArtifact, branch);
- accessData.add(branch, new AccessDetail<IOseeBranch>(branch, userPermission));
- }
+ private final AccessControlService accessService;
+
+ public ObjectAccessProvider(AccessControlService accessService) {
+ this.accessService = accessService;
+ }
+
+ @Override
+ public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
+ for (Object object : objToCheck) {
+ if (object instanceof Artifact) {
+ setArtifactAccessData(userArtifact, (Artifact) object, accessData);
+ } else if (object instanceof Branch) {
+ setBranchAccessData(userArtifact, (Branch) object, accessData);
+ } else {
+ throw new OseeStateException("Unhandled object type for access control - " + object);
+ }
+ }
+ }
+
+ private void setArtifactAccessData(IBasicArtifact<?> userArtifact, Artifact artifact, AccessData accessData) throws OseeCoreException {
+ PermissionEnum userPermission = accessService.getArtifactPermission(userArtifact, artifact);
+
+ if (userPermission == null || isArtifactReadOnly(artifact)) {
+ userPermission = PermissionEnum.READ;
+ }
+ accessData.add(artifact, new AccessDetail<IBasicArtifact<Artifact>>(artifact, userPermission));
+ }
+
+ public boolean isArtifactReadOnly(Artifact artifact) {
+ return artifact.isDeleted() || artifact.isHistorical() || !artifact.getBranch().isEditable();
+ }
+
+ private void setBranchAccessData(IBasicArtifact<?> userArtifact, Branch branch, AccessData accessData) throws OseeCoreException {
+ PermissionEnum userPermission = accessService.getBranchPermission(userArtifact, branch);
+ accessData.add(branch, new AccessDetail<IOseeBranch>(branch, userPermission));
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessData.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessData.java
index 2ca825a840..8fb004a1d0 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessData.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessData.java
@@ -22,43 +22,39 @@ import org.eclipse.osee.framework.jdk.core.type.Pair;
* @author Jeff C. Phillips
* @author Roberto E. Escobar
*/
-public class AccessData {
-
- private final CompositeKeyHashMap<Object, Object, AccessDetail<?>> accessMap =
- new CompositeKeyHashMap<Object, Object, AccessDetail<?>>();
-
- public AccessData() {
- }
-
- public void add(Object key, AccessDetail<?> data) throws OseeCoreException {
- Conditions.checkNotNull(key, "access key");
- Conditions.checkNotNull(data, "access data");
-
- AccessDetail<?> access = accessMap.get(key, data.getAccessObject());
- if (access == null) {
- accessMap.put(key, data.getAccessObject(), data);
- } else {
- PermissionEnum original = access.getPermission();
- PermissionEnum newPermission = data.getPermission();
- PermissionEnum netPermission = PermissionEnum.getMostRestrictive(original, newPermission);
- access.setPermission(netPermission);
- }
- }
-
- public Collection<AccessDetail<?>> getAccess(Object key) throws OseeCoreException {
- Conditions.checkNotNull(key, "access key");
- // TODO clone each access data object? or Hide Method
- return accessMap.getValues(key);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- for (Entry<Pair<Object, Object>, AccessDetail<?>> entry : accessMap.entrySet()) {
- builder.append(entry.getKey().getFirst());
- builder.append(entry.getValue());
- builder.append(",\n");
- }
- return builder.toString();
- }
+public final class AccessData {
+
+ private final CompositeKeyHashMap<Object, Object, AccessDetail<?>> accessMap =
+ new CompositeKeyHashMap<Object, Object, AccessDetail<?>>();
+
+ public void add(Object key, AccessDetail<?> data) throws OseeCoreException {
+ Conditions.checkNotNull(key, "access key");
+ Conditions.checkNotNull(data, "access data");
+
+ AccessDetail<?> access = accessMap.get(key, data.getAccessObject());
+ if (access == null) {
+ accessMap.put(key, data.getAccessObject(), data);
+ } else {
+ PermissionEnum original = access.getPermission();
+ PermissionEnum newPermission = data.getPermission();
+ PermissionEnum netPermission = PermissionEnum.getMostRestrictive(original, newPermission);
+ access.setPermission(netPermission);
+ }
+ }
+
+ Collection<AccessDetail<?>> getAccess(Object key) throws OseeCoreException {
+ Conditions.checkNotNull(key, "access key");
+ return accessMap.getValues(key);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ for (Entry<Pair<Object, Object>, AccessDetail<?>> entry : accessMap.entrySet()) {
+ builder.append(entry.getKey().getFirst());
+ builder.append(entry.getValue());
+ builder.append(",\n");
+ }
+ return builder.toString();
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionAccessHandler.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionAccessHandler.java
index 30fee81e51..9bbab7c717 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionAccessHandler.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionAccessHandler.java
@@ -24,31 +24,31 @@ import org.eclipse.osee.framework.skynet.core.internal.Activator;
*/
public class SkynetTransactionAccessHandler extends SkynetTransactionHandler {
- public final IAccessControlService service;
+ public final IAccessControlService service;
- public SkynetTransactionAccessHandler(IAccessControlService service) {
- super();
- this.service = service;
- }
+ public SkynetTransactionAccessHandler(IAccessControlService service) {
+ super();
+ this.service = service;
+ }
- @Override
- public IStatus onCheck(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- AccessDataQuery accessData = service.getAccessData(getUserArtifact(), getItemsToPersist());
- if (!accessData.matchesAll(PermissionEnum.WRITE)) {
- //TODO Make access denied message more descriptive
- status =
- new Status(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- String.format(
- "Access Denied - does not have valid permission to edit this artifact\n objects:[%s]\naccessData:[%s]",
- getItemsToPersist(), accessData));
- }
- } catch (OseeCoreException ex) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error during access check", ex);
- }
- return status;
- }
+ @Override
+ public IStatus onCheck(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ AccessDataQuery accessData = service.getAccessData(getUserArtifact(), getItemsToPersist());
+ if (!accessData.matchesAll(getItemsToPersist(), PermissionEnum.WRITE)) {
+ //TODO Make access denied message more descriptive
+ status =
+ new Status(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ String.format(
+ "Access Denied - does not have valid permission to edit this artifact\n objects:[%s]\naccessData:[%s]",
+ getItemsToPersist(), accessData));
+ }
+ } catch (OseeCoreException ex) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error during access check", ex);
+ }
+ return status;
+ }
}

Back to the top