Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn.f.cook2012-03-26 15:11:06 -0400
committerRoberto E. Escobar2012-03-26 15:11:06 -0400
commit0c1106db928fe3931b9c13762939acfdcc3abcf9 (patch)
tree646f33f51227a5611baea15476bd5e7c341ee782
parent9f161ede85626e51263c2e8f3a230516500a8b32 (diff)
downloadorg.eclipse.osee-0c1106db928fe3931b9c13762939acfdcc3abcf9.tar.gz
org.eclipse.osee-0c1106db928fe3931b9c13762939acfdcc3abcf9.tar.xz
org.eclipse.osee-0c1106db928fe3931b9c13762939acfdcc3abcf9.zip
bug: Fix sporadic AccessPolicyImpl unit test failure
AccessPolicyImpl methods that check for permissions (see list below) will not check permissions if system is in DBInit mode. When in DBinit mode permissions are wide open. Methods modified: - hasBranchPermission - hasAttributeTypePermission - hasArtifactPermission - hasArtifactTypePermission - hasArtifactRelationPermission
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java95
1 files changed, 65 insertions, 30 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java
index b52882abf7..c465a3fc16 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.skynet.core.internal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
+import org.eclipse.osee.framework.core.client.OseeClientProperties;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
@@ -89,9 +90,14 @@ public class AccessPolicyImpl implements AccessPolicy {
public PermissionStatus hasBranchPermission(IOseeBranch branch, PermissionEnum permission, Level level) throws OseeCoreException {
User currentUser = getCurrentUser();
AccessDataQuery query = getAccessService().getAccessData(currentUser, java.util.Collections.singleton(branch));
- PermissionStatus permissionStatus = new PermissionStatus();
- query.branchMatches(permission, branch, permissionStatus);
- printErrorMessage(currentUser, java.util.Collections.singleton(branch), permissionStatus, level);
+ PermissionStatus permissionStatus = null;
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ query.branchMatches(permission, branch, permissionStatus);
+ printErrorMessage(currentUser, java.util.Collections.singleton(branch), permissionStatus, level);
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
+ }
return permissionStatus;
}
@@ -103,17 +109,23 @@ public class AccessPolicyImpl implements AccessPolicy {
public PermissionStatus hasAttributeTypePermission(Collection<? extends IBasicArtifact<?>> artifacts, IAttributeType attributeType, PermissionEnum permission, Level level) throws OseeCoreException {
User currentUser = getCurrentUser();
AccessDataQuery query = getAccessService().getAccessData(currentUser, artifacts);
- PermissionStatus permissionStatus = new PermissionStatus();
- if (artifacts != null) {
- for (IBasicArtifact<?> artifact : artifacts) {
- query.attributeTypeMatches(permission, artifact, attributeType, permissionStatus);
+ PermissionStatus permissionStatus = null;
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ if (artifacts != null) {
+ for (IBasicArtifact<?> artifact : artifacts) {
+ query.attributeTypeMatches(permission, artifact, attributeType, permissionStatus);
- if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) {
- break;
+ if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) {
+ break;
+ }
}
}
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
}
+
return permissionStatus;
}
@@ -121,20 +133,27 @@ public class AccessPolicyImpl implements AccessPolicy {
public PermissionStatus hasArtifactPermission(Collection<? extends IBasicArtifact<?>> artifacts, PermissionEnum permission, Level level) throws OseeCoreException {
User currentUser = getCurrentUser();
AccessDataQuery query = getAccessService().getAccessData(currentUser, artifacts);
- PermissionStatus permissionStatus = new PermissionStatus();
- if (artifacts != null) {
- for (IBasicArtifact<?> artifact : artifacts) {
- if (artifact instanceof Artifact) {
- Artifact fullArtifact = ((Artifact) artifact).getFullArtifact();
- if (fullArtifact.isInDb()) {
- query.artifactMatches(permission, artifact, permissionStatus);
+
+ PermissionStatus permissionStatus = null;
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ if (artifacts != null) {
+ for (IBasicArtifact<?> artifact : artifacts) {
+ if (artifact instanceof Artifact) {
+ Artifact fullArtifact = ((Artifact) artifact).getFullArtifact();
+ if (fullArtifact.isInDb()) {
+ query.artifactMatches(permission, artifact, permissionStatus);
+ }
+ }
+ if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) {
+ break;
}
- }
- if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) {
- break;
}
}
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
}
+
return permissionStatus;
}
@@ -142,17 +161,23 @@ public class AccessPolicyImpl implements AccessPolicy {
public PermissionStatus hasArtifactTypePermission(IOseeBranch branch, Collection<? extends IArtifactType> artifactTypes, PermissionEnum permission, Level level) throws OseeCoreException {
User currentUser = getCurrentUser();
AccessDataQuery query = getAccessService().getAccessData(currentUser, java.util.Collections.singleton(branch));
- PermissionStatus permissionStatus = new PermissionStatus();
- if (artifactTypes != null) {
- for (IArtifactType artifactType : artifactTypes) {
- query.branchArtifactTypeMatches(permission, branch, artifactType, permissionStatus);
+ PermissionStatus permissionStatus = null;
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ if (artifactTypes != null) {
+ for (IArtifactType artifactType : artifactTypes) {
+ query.branchArtifactTypeMatches(permission, branch, artifactType, permissionStatus);
- if (printErrorMessage(currentUser, artifactTypes, permissionStatus, level)) {
- break;
+ if (printErrorMessage(currentUser, artifactTypes, permissionStatus, level)) {
+ break;
+ }
}
}
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
}
+
return permissionStatus;
}
@@ -191,13 +216,23 @@ public class AccessPolicyImpl implements AccessPolicy {
private PermissionStatus hasArtifactRelationPermission(Collection<? extends IBasicArtifact<?>> artifacts, Collection<? extends IRelationTypeSide> relationTypeSides, PermissionEnum permission, Level level) throws OseeCoreException {
AccessDataQuery query = getAccessService().getAccessData(getCurrentUser(), artifacts);
- PermissionStatus status = new PermissionStatus();
- for (IBasicArtifact<?> artifact : artifacts) {
- for (IRelationTypeSide relationTypeSide : relationTypeSides) {
- query.relationTypeMatches(permission, artifact, relationTypeSide, status);
+ PermissionStatus permissionStatus = null;
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ if (!OseeClientProperties.isInDbInit()) {
+ permissionStatus = new PermissionStatus();
+ for (IBasicArtifact<?> artifact : artifacts) {
+ for (IRelationTypeSide relationTypeSide : relationTypeSides) {
+ query.relationTypeMatches(permission, artifact, relationTypeSide, permissionStatus);
+ }
+ }
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
}
+ } else {
+ permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled");
}
- return status;
+ return permissionStatus;
}
}

Back to the top