Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-09-19 18:37:58 +0000
committerRyan D. Brooks2016-09-28 14:43:45 +0000
commit42ece4ecb4adfc4594b61bec32cb25a202ca1cf9 (patch)
treeb5165065c7eb83546199ff59d231913fc43f39c7
parent87795aa3485d9cad68b334f9e9ebdd9913315809 (diff)
downloadorg.eclipse.osee-42ece4ecb4adfc4594b61bec32cb25a202ca1cf9.tar.gz
org.eclipse.osee-42ece4ecb4adfc4594b61bec32cb25a202ca1cf9.tar.xz
org.eclipse.osee-42ece4ecb4adfc4594b61bec32cb25a202ca1cf9.zip
refactor: Use HasBranch with AccessObject
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsConfigurationsService.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceClientImpl.java2
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessObject.java5
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java162
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/ArtifactAccessObject.java53
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java34
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserAdmin.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserManager.java11
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/UserAdminImpl.java15
9 files changed, 137 insertions, 154 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsConfigurationsService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsConfigurationsService.java
index 5eb772960a..94b583010f 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsConfigurationsService.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsConfigurationsService.java
@@ -70,7 +70,7 @@ public class AtsConfigurationsService implements IAtsConfigurationProvider {
public ArtifactToken loadUser(IAtsUser user) {
ArtifactToken userArt = null;
try {
- userArt = UserManager.getUserByArtId(user.getId().intValue());
+ userArt = UserManager.getUserByArtId(user.getId());
if (userArt == null) {
userArt = ArtifactQuery.getArtifactFromId(user.getId(), AtsUtilCore.getAtsBranch());
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceClientImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceClientImpl.java
index 4b65927bce..164d972924 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceClientImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceClientImpl.java
@@ -133,7 +133,7 @@ public class AtsUserServiceClientImpl extends AbstractAtsUserService implements
@Override
public IAtsUser getUserById(long accountId) {
- return getUserFromOseeUser(UserManager.getUserByArtId((int) accountId));
+ return getUserFromOseeUser(UserManager.getUserByArtId(accountId));
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessObject.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessObject.java
index 02288a2083..0929b2ebd9 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessObject.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessObject.java
@@ -13,19 +13,18 @@ package org.eclipse.osee.framework.access;
import org.eclipse.osee.framework.access.internal.data.ArtifactAccessObject;
import org.eclipse.osee.framework.access.internal.data.BranchAccessObject;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.HasBranch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
/**
* @author Jeff C. Phillips
*/
-public abstract class AccessObject {
+public abstract class AccessObject implements HasBranch {
public abstract void removeFromCache();
public abstract void removeFromDatabase(int subjectId) throws OseeCoreException;
- public abstract long getBranchId();
-
public static AccessObject getAccessObject(Object object) throws OseeCoreException {
if (object instanceof Artifact) {
return ArtifactAccessObject.getArtifactAccessObject((Artifact) object);
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
index 96296cec0a..ba7fb043fd 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
@@ -33,8 +33,9 @@ import org.eclipse.osee.framework.access.AccessControlData;
import org.eclipse.osee.framework.access.AccessObject;
import org.eclipse.osee.framework.access.internal.data.ArtifactAccessObject;
import org.eclipse.osee.framework.access.internal.data.BranchAccessObject;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
@@ -109,18 +110,15 @@ public class AccessControlService implements IAccessControlService {
private final String DELETE_BRANCH_ACL_FROM_BRANCH = "DELETE FROM OSEE_BRANCH_ACL WHERE branch_id =?";
private final String USER_GROUP_MEMBERS =
- "SELECT b_art_id FROM osee_relation_link WHERE a_art_id =? AND rel_link_type_id =? ORDER BY b_art_id";
+ "SELECT b_art_id FROM osee_relation_link WHERE a_art_id = ? AND rel_link_type_id = ? ORDER BY b_art_id";
- private final DoubleKeyHashMap<Integer, AccessObject, PermissionEnum> accessControlListCache =
- new DoubleKeyHashMap<Integer, AccessObject, PermissionEnum>();
- private final HashCollection<AccessObject, Integer> objectToSubjectCache =
- new HashCollection<AccessObject, Integer>(true); // <subjectId, groupId>
- private final HashCollection<Integer, Integer> subjectToGroupCache = new HashCollection<>(true); // <groupId, subjectId>
- private final HashCollection<Integer, Integer> groupToSubjectsCache = new HashCollection<>(true); // <artId, branchUuid>
+ private final DoubleKeyHashMap<Long, AccessObject, PermissionEnum> accessControlListCache = new DoubleKeyHashMap<>();
+ private final HashCollection<AccessObject, ArtifactId> objectToSubjectCache = new HashCollection<>(true);
+ private final HashCollection<Long, ArtifactId> subjectToGroupCache = new HashCollection<>(true); // <subjectId, groupId>
+ private final HashCollection<Long, ArtifactId> groupToSubjectsCache = new HashCollection<>(true); // <groupId, subjectId>
// branch_id, art_id, subject_id
- private final CompositeKeyHashMap<Long, Integer, Integer> artifactLockCache =
- new CompositeKeyHashMap<Long, Integer, Integer>();
+ private final CompositeKeyHashMap<BranchId, Long, ArtifactId> artifactLockCache = new CompositeKeyHashMap<>();
private final HashCollection<Integer, PermissionEnum> subjectToPermissionCache =
new HashCollection<Integer, PermissionEnum>(true);
@@ -209,16 +207,16 @@ public class AccessControlService implements IAccessControlService {
private void populateBranchAccessControlList() throws OseeCoreException {
ensurePopulated();
Consumer<JdbcStatement> consumer = stmt -> {
- Integer subjectId = stmt.getInt("privilege_entity_id");
- Long branchUuid = stmt.getLong("branch_id");
- Long subjectArtifactTypeId = stmt.getLong("art_type_id");
+ ArtifactId subjectId = ArtifactId.valueOf(stmt.getLong("privilege_entity_id"));
+ BranchId branch = BranchId.valueOf(stmt.getLong("branch_id"));
+ ArtifactTypeId subjectArtifactTypeId = ArtifactTypeId.valueOf(stmt.getLong("art_type_id"));
PermissionEnum permission = PermissionEnum.getPermission(stmt.getInt("permission_id"));
- BranchAccessObject branchAccessObject = BranchAccessObject.getBranchAccessObject(branchUuid);
+ BranchAccessObject branchAccessObject = BranchAccessObject.getBranchAccessObject(branch);
- accessControlListCache.put(subjectId, branchAccessObject, permission);
+ accessControlListCache.put(subjectId.getId(), branchAccessObject, permission);
objectToSubjectCache.put(branchAccessObject, subjectId);
- ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
+ ArtifactType subjectArtifactType = getArtifactTypeCache().get(subjectArtifactTypeId);
if (subjectArtifactType != null && subjectArtifactType.inheritsFrom(CoreArtifactTypes.UserGroup)) {
populateGroupMembers(subjectId);
}
@@ -230,19 +228,18 @@ public class AccessControlService implements IAccessControlService {
ensurePopulated();
Consumer<JdbcStatement> consumer = stmt -> {
- Integer subjectId = stmt.getInt("privilege_entity_id");
- Integer objectId = stmt.getInt("art_id");
- Long branchUuid = stmt.getLong("branch_id");
+ ArtifactId subjectId = ArtifactId.valueOf(stmt.getLong("privilege_entity_id"));
+ ArtifactId objectId = ArtifactId.valueOf(stmt.getLong("art_id"));
+ BranchId branch = BranchId.valueOf(stmt.getLong("branch_id"));
Long subjectArtifactTypeId = stmt.getLong("art_type_id");
PermissionEnum permission = PermissionEnum.getPermission(stmt.getInt("permission_id"));
if (permission != null) {
if (permission.equals(PermissionEnum.LOCK)) {
- artifactLockCache.put(branchUuid, objectId, subjectId);
+ artifactLockCache.put(branch, objectId.getId(), subjectId);
} else {
- AccessObject accessObject =
- ArtifactAccessObject.getArtifactAccessObject(objectId, TokenFactory.createBranch(branchUuid));
- cacheAccessObject(objectId, subjectId, permission, accessObject);
+ AccessObject accessObject = ArtifactAccessObject.getArtifactAccessObject(objectId, branch);
+ cacheAccessObject(subjectId, permission, accessObject);
ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
if (subjectArtifactType != null && subjectArtifactType.inheritsFrom(CoreArtifactTypes.UserGroup)) {
@@ -255,14 +252,14 @@ public class AccessControlService implements IAccessControlService {
getJdbcClient().runQuery(consumer, GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST);
}
- private void populateGroupMembers(Integer groupId) throws OseeCoreException {
+ private void populateGroupMembers(ArtifactId groupId) throws OseeCoreException {
ensurePopulated();
- if (!groupToSubjectsCache.containsKey(groupId)) {
+ if (!groupToSubjectsCache.containsKey(groupId.getId())) {
getJdbcClient().runQuery(stmt -> {
- Integer groupMember = stmt.getInt("b_art_id");
- subjectToGroupCache.put(groupMember, groupId);
- groupToSubjectsCache.put(groupId, groupMember);
- }, USER_GROUP_MEMBERS, groupId, CoreRelationTypes.Users_User.getGuid());
+ ArtifactId groupMember = ArtifactId.valueOf(stmt.getLong("b_art_id"));
+ subjectToGroupCache.put(groupMember.getId(), groupId);
+ groupToSubjectsCache.put(groupId.getId(), groupMember);
+ }, USER_GROUP_MEMBERS, groupId, CoreRelationTypes.Users_User);
}
}
@@ -398,18 +395,17 @@ public class AccessControlService implements IAccessControlService {
return PermissionEnum.FULLACCESS;
}
- Integer artId = artifact.getArtId();
+ Long artId = artifact.getId();
BranchId branch = artifact.getBranch();
- Long branchUuid = branch.getUuid();
// accessObject = accessObjectCache.get(artId, branchUuid);
- accessObject = ArtifactAccessObject.getArtifactAccessObjectFromCache(artId, branch);
+ accessObject = ArtifactAccessObject.getArtifactAccessObjectFromCache(artifact);
- if (artifactLockCache.containsKey(branchUuid, artId)) {
+ if (artifactLockCache.containsKey(branch, artId)) {
- int lockOwnerId = artifactLockCache.get(branchUuid, artId);
+ ArtifactId lockOwnerId = artifactLockCache.get(branch, artId);
// this object is locked under a different branch
- if (lockOwnerId != subject.getArtId()) {
+ if (subject.notEqual(lockOwnerId)) {
userPermission = PermissionEnum.LOCK;
}
}
@@ -425,16 +421,15 @@ public class AccessControlService implements IAccessControlService {
private PermissionEnum acquirePermissionRank(IBasicArtifact<?> subject, AccessObject accessObject) {
ensurePopulated();
PermissionEnum userPermission = PermissionEnum.FULLACCESS;
- int subjectId = subject.getArtId();
- userPermission = accessControlListCache.get(subjectId, accessObject);
+ userPermission = accessControlListCache.get(subject.getId(), accessObject);
if (userPermission == null) {
userPermission = PermissionEnum.FULLACCESS;
}
- if (subjectToGroupCache.containsKey(subjectId)) {
- for (int groupPermissionId : subjectToGroupCache.getValues(subjectId)) {
- PermissionEnum groupPermission = accessControlListCache.get(groupPermissionId, accessObject);
+ if (subjectToGroupCache.containsKey(subject.getId())) {
+ for (ArtifactId groupPermissionId : subjectToGroupCache.getValues(subject.getId())) {
+ PermissionEnum groupPermission = accessControlListCache.get(groupPermissionId.getId(), accessObject);
if (groupPermission != null) {
if (groupPermission.getRank() > userPermission.getRank()) {
@@ -455,9 +450,9 @@ public class AccessControlService implements IAccessControlService {
ensurePopulated();
AccessObject accessObject = getAccessObject(object);
- boolean newAccessControlData = !accessControlListCache.containsKey(subject.getArtId(), accessObject);
+ boolean newAccessControlData = !accessControlListCache.containsKey(subject.getId(), accessObject);
- if (newAccessControlData || permission != accessControlListCache.get(subject.getArtId(), accessObject)) {
+ if (newAccessControlData || permission != accessControlListCache.get(subject.getId(), accessObject)) {
AccessControlData data = new AccessControlData(subject, accessObject, permission, newAccessControlData);
persistPermission(data);
}
@@ -502,26 +497,26 @@ public class AccessControlService implements IAccessControlService {
if (data.isBirth()) {
getJdbcClient().runPreparedUpdate(INSERT_INTO_ARTIFACT_ACL, artifactAccessObject.getArtId(),
- data.getPermission().getPermId(), data.getSubject().getArtId(), artifactAccessObject.getBranchId());
+ data.getPermission().getPermId(), data.getSubject().getArtId(), artifactAccessObject.getBranch());
} else {
getJdbcClient().runPreparedUpdate(UPDATE_ARTIFACT_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), artifactAccessObject.getArtId(), artifactAccessObject.getBranchId());
+ data.getSubject().getArtId(), artifactAccessObject.getArtId(), artifactAccessObject.getBranch());
}
event.addArtifact(artifactAccessObject.getArtId());
if (recurse) {
- Artifact artifact = ArtifactQuery.getArtifactFromId(artifactAccessObject.getArtId(),
- TokenFactory.createBranch(artifactAccessObject.getBranchId()));
+ Artifact artifact =
+ ArtifactQuery.getArtifactFromId(artifactAccessObject.getArtId(), artifactAccessObject.getBranch());
for (Artifact child : artifact.getChildren()) {
AccessControlData childAccessControlData = null;
AccessObject childAccessObject = getAccessObject(child);
if (objectToSubjectCache.containsKey(childAccessObject)) {
- Collection<Integer> subjectIds = objectToSubjectCache.getValues(childAccessObject);
+ Collection<ArtifactId> subjectIds = objectToSubjectCache.getValues(childAccessObject);
- for (int subjectId : subjectIds) {
- if (subjectId == subject.getArtId()) {
+ for (ArtifactId subjectId : subjectIds) {
+ if (subjectId.equals(subject)) {
childAccessControlData =
new AccessControlData(subject, childAccessObject, permission, false);
break;
@@ -550,10 +545,10 @@ public class AccessControlService implements IAccessControlService {
try {
if (data.isBirth()) {
getJdbcClient().runPreparedUpdate(INSERT_INTO_BRANCH_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), branchAccessObject.getBranchId());
+ data.getSubject().getArtId(), branchAccessObject.getBranch());
} else {
getJdbcClient().runPreparedUpdate(UPDATE_BRANCH_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), branchAccessObject.getBranchId());
+ data.getSubject().getArtId(), branchAccessObject.getBranch());
}
} catch (OseeCoreException ex) {
OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
@@ -564,14 +559,14 @@ public class AccessControlService implements IAccessControlService {
private void cacheAccessControlData(AccessControlData data) throws OseeCoreException {
ensurePopulated();
AccessObject accessObject = data.getObject();
- int subjectId = data.getSubject().getArtId();
PermissionEnum permission = data.getPermission();
+ ArtifactId subject = data.getSubject();
if (!permission.equals(PermissionEnum.LOCK)) {
- accessControlListCache.put(subjectId, accessObject, permission);
- objectToSubjectCache.put(accessObject, subjectId);
+ accessControlListCache.put(data.getSubject().getId(), accessObject, permission);
+ objectToSubjectCache.put(accessObject, subject);
- populateGroupMembers(subjectId);
+ populateGroupMembers(subject);
}
}
@@ -598,14 +593,14 @@ public class AccessControlService implements IAccessControlService {
ensurePopulated();
List<AccessControlData> datas = new LinkedList<>();
- Collection<Integer> subjects = objectToSubjectCache.getValues(accessObject);
+ Collection<ArtifactId> subjects = objectToSubjectCache.getValues(accessObject);
if (subjects == null) {
return datas;
}
- for (int subjectId : subjects) {
+ for (ArtifactId subjectId : subjects) {
Artifact subject = ArtifactQuery.getArtifactFromId(subjectId, CoreBranches.COMMON);
- PermissionEnum permissionEnum = accessControlListCache.get(subjectId, accessObject);
+ PermissionEnum permissionEnum = accessControlListCache.get(subjectId.getId(), accessObject);
AccessControlData accessControlData =
new AccessControlData(subject, accessObject, permissionEnum, false, false);
if (accessObject instanceof ArtifactAccessObject) {
@@ -621,10 +616,7 @@ public class AccessControlService implements IAccessControlService {
}
private PermissionEnum getBranchPermission(IBasicArtifact<?> subject, Object object) throws OseeCoreException {
- long branchUuid = ((AccessObject) object).getBranchId();
- BranchId branch = TokenFactory.createBranch(branchUuid);
-
- return getBranchPermission(subject, branch);
+ return getBranchPermission(subject, ((AccessObject) object).getBranch());
}
public void removeAccessControlDataIf(boolean removeFromDb, AccessControlData data) throws OseeCoreException {
@@ -657,18 +649,18 @@ public class AccessControlService implements IAccessControlService {
}
AccessObject accessObject = data.getObject();
- Integer subjectId = data.getSubject().getArtId();
+ ArtifactId subject = data.getSubject();
- accessControlListCache.remove(subjectId, accessObject);
- objectToSubjectCache.removeValue(accessObject, subjectId);
- Collection<Integer> members = groupToSubjectsCache.getValues(subjectId);
+ accessControlListCache.remove(data.getSubject().getId(), accessObject);
+ objectToSubjectCache.removeValue(accessObject, subject);
+ Collection<ArtifactId> members = groupToSubjectsCache.getValues(subject.getId());
if (members != null) {
- for (Integer member : members) {
- subjectToGroupCache.removeValue(member, subjectId);
+ for (ArtifactId member : members) {
+ subjectToGroupCache.removeValue(member.getId(), subject);
}
}
- groupToSubjectsCache.removeValues(subjectId);
+ groupToSubjectsCache.removeValues(subject.getId());
if (!objectToSubjectCache.containsKey(accessObject)) {
accessObject.removeFromCache();
}
@@ -678,8 +670,8 @@ public class AccessControlService implements IAccessControlService {
return AccessObject.getAccessObject(object);
}
- private void cacheAccessObject(Integer objectId, Integer subjectId, PermissionEnum permission, AccessObject accessObject) {
- accessControlListCache.put(subjectId, accessObject, permission);
+ private void cacheAccessObject(ArtifactId subjectId, PermissionEnum permission, AccessObject accessObject) {
+ accessControlListCache.put(subjectId.getId(), accessObject, permission);
objectToSubjectCache.put(accessObject, subjectId);
}
@@ -692,15 +684,14 @@ public class AccessControlService implements IAccessControlService {
event.setLocked(true);
Set<Artifact> lockedArts = new HashSet<>();
for (Artifact object : objects) {
- Integer objectArtId = object.getArtId();
- Integer subjectArtId = subject.getArtId();
- Long objectBranchId = object.getBranchId();
+ Long objectArtId = object.getId();
+ BranchId objectBranch = object.getBranch();
- if (!artifactLockCache.containsKey(objectBranchId, objectArtId)) {
+ if (!artifactLockCache.containsKey(objectBranch, objectArtId)) {
AccessObject accessObject = getAccessObject(object);
AccessControlData data = new AccessControlData(subject, accessObject, PermissionEnum.LOCK, true);
persistPermission(data);
- artifactLockCache.put(objectBranchId, objectArtId, subjectArtId);
+ artifactLockCache.put(objectBranch, objectArtId, subject);
event.addArtifact(object.getUuid());
lockedArts.add(object);
}
@@ -719,13 +710,13 @@ public class AccessControlService implements IAccessControlService {
event.setLocked(false);
Set<Artifact> lockedArts = new HashSet<>();
for (Artifact object : objects) {
- Integer objectArtId = object.getArtId();
- Long branchUuid = object.getBranchId();
+ Long objectArtId = object.getId();
+ BranchId branch = object.getBranch();
- if (artifactLockCache.containsKey(branchUuid, objectArtId) && canUnlockObject(object, subject)) {
+ if (artifactLockCache.containsKey(branch, objectArtId) && canUnlockObject(object, subject)) {
AccessObject accessObject = getAccessObject(object);
removeAccessControlDataIf(true, new AccessControlData(subject, accessObject, PermissionEnum.LOCK, false));
- artifactLockCache.removeAndGet(branchUuid, objectArtId);
+ artifactLockCache.removeAndGet(branch, objectArtId);
event.addArtifact(object.getUuid());
lockedArts.add(object);
}
@@ -757,13 +748,13 @@ public class AccessControlService implements IAccessControlService {
return false;
}
- return artifactLockCache.containsKey(object.getBranchId(), object.getArtId());
+ return artifactLockCache.containsKey(object.getBranch(), object.getId());
}
public boolean canUnlockObject(Artifact object, Artifact subject) throws OseeCoreException {
ensurePopulated();
- Integer subjectId = artifactLockCache.get(object.getBranchId(), object.getArtId());
- return subjectId != null && subjectId.intValue() == subject.getArtId();
+ ArtifactId subjectId = artifactLockCache.get(object.getBranch(), object.getId());
+ return subject.equals(subjectId);
}
public Artifact getSubjectFromLockedObject(Object object) throws OseeCoreException {
@@ -772,7 +763,7 @@ public class AccessControlService implements IAccessControlService {
if (object instanceof Artifact) {
Artifact art = (Artifact) object;
- Integer subjectArtId = artifactLockCache.get(art.getBranchId(), art.getArtId());
+ ArtifactId subjectArtId = artifactLockCache.get(art.getBranch(), art.getId());
if (subjectArtId != null) {
subject = UserManager.getUserByArtId(subjectArtId);
@@ -790,8 +781,7 @@ public class AccessControlService implements IAccessControlService {
}
if (hasLock(object)) {
- long branchUuid = object.getBranchId();
- hasAccess = artifactLockCache.get(branchUuid, object.getArtId()) == UserManager.getUser().getArtId();
+ hasAccess = artifactLockCache.get(object.getBranch(), object.getId()).equals(UserManager.getUser());
}
return hasAccess;
}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/ArtifactAccessObject.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/ArtifactAccessObject.java
index bc9a1386a7..3a52a77a22 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/ArtifactAccessObject.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/ArtifactAccessObject.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.access.internal.data;
import org.eclipse.osee.framework.access.AccessObject;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.type.DoubleKeyHashMap;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -22,70 +23,60 @@ import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
*/
public class ArtifactAccessObject extends AccessObject {
- private final Integer artId;
- private final Long branchUuid;
- private static final DoubleKeyHashMap<Integer, Long, ArtifactAccessObject> cache =
- new DoubleKeyHashMap<Integer, Long, ArtifactAccessObject>();
+ private final ArtifactId artId;
+ private final BranchId branch;
+ private static final DoubleKeyHashMap<Long, BranchId, ArtifactAccessObject> cache = new DoubleKeyHashMap<>();
- public ArtifactAccessObject(Integer artId, Long branchUuid) {
- super();
+ public ArtifactAccessObject(ArtifactId artId, BranchId branch) {
this.artId = artId;
- this.branchUuid = branchUuid;
+ this.branch = branch;
}
@Override
public int hashCode() {
int result = 17;
- result = 31 * result + artId;
- result = 31 * result + branchUuid.hashCode();
+ result = 31 * result + artId.hashCode();
+ result = 31 * result + branch.hashCode();
return result;
}
- public Integer getArtId() {
+ public ArtifactId getArtId() {
return artId;
}
@Override
- public long getBranchId() {
- return branchUuid;
+ public BranchId getBranch() {
+ return branch;
}
@Override
public void removeFromCache() {
- cache.remove(artId, branchUuid);
+ cache.remove(artId.getId(), branch);
}
@Override
public void removeFromDatabase(int subjectId) throws OseeCoreException {
final String DELETE_ARTIFACT_ACL =
"DELETE FROM OSEE_ARTIFACT_ACL WHERE privilege_entity_id = ? AND art_id =? AND branch_id =?";
- ConnectionHandler.runPreparedUpdate(DELETE_ARTIFACT_ACL, subjectId, artId, branchUuid);
+ ConnectionHandler.runPreparedUpdate(DELETE_ARTIFACT_ACL, subjectId, artId, branch);
}
public static ArtifactAccessObject getArtifactAccessObject(Artifact artifact) throws OseeCoreException {
- Integer artId = artifact.getArtId();
- BranchId branchUuid = artifact.getBranch();
- return getArtifactAccessObject(artId, branchUuid);
+ return getArtifactAccessObject(artifact, artifact.getBranch());
}
- public static ArtifactAccessObject getArtifactAccessObject(Integer artId, BranchId branch) throws OseeCoreException {
- long branchUuid = branch.getUuid();
- ArtifactAccessObject accessObject = cache.get(artId, branchUuid);
+ public static ArtifactAccessObject getArtifactAccessObject(ArtifactId artifact, BranchId branch) throws OseeCoreException {
+ ArtifactAccessObject accessObject = cache.get(artifact.getId(), branch);
if (accessObject == null) {
- accessObject = new ArtifactAccessObject(artId, branchUuid);
- cache.put(artId, branchUuid, accessObject);
+ accessObject = new ArtifactAccessObject(artifact, branch);
+ cache.put(artifact.getId(), branch, accessObject);
}
return accessObject;
}
- public static AccessObject getArtifactAccessObjectFromCache(Artifact art) throws OseeCoreException {
- return getArtifactAccessObjectFromCache(art.getArtId(), art.getBranch());
- }
-
- public static AccessObject getArtifactAccessObjectFromCache(Integer artId2, BranchId branch) throws OseeCoreException {
- long branchUuid2 = branch.getUuid();
- return cache.get(artId2, branchUuid2);
+ public static AccessObject getArtifactAccessObjectFromCache(Artifact artifact) throws OseeCoreException {
+ return cache.get(artifact.getId(), artifact.getBranch());
}
@Override
@@ -94,6 +85,6 @@ public class ArtifactAccessObject extends AccessObject {
return false;
}
ArtifactAccessObject ao = (ArtifactAccessObject) obj;
- return ao.artId.equals(this.artId) && ao.branchUuid.equals(this.branchUuid);
+ return ao.artId.equals(this.artId) && ao.branch.equals(this.branch);
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java
index ba67b1bcf6..c45834e596 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java
@@ -21,53 +21,49 @@ import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
* @author Jeff C. Phillips
*/
public class BranchAccessObject extends AccessObject {
- private final Long branchUuid;
- private static final Map<Long, BranchAccessObject> cache = new HashMap<>();
+ private final BranchId branch;
+ private static final Map<BranchId, BranchAccessObject> cache = new HashMap<>();
@Override
public int hashCode() {
int result = 17;
- result = 31 * result + branchUuid.hashCode();
+ result = 31 * result + branch.hashCode();
return result;
}
- public BranchAccessObject(long branchUuid) {
- this.branchUuid = branchUuid;
+ public BranchAccessObject(BranchId branch) {
+ this.branch = branch;
}
@Override
- public long getBranchId() {
- return branchUuid;
+ public BranchId getBranch() {
+ return branch;
}
@Override
public void removeFromCache() {
- cache.remove(branchUuid);
+ cache.remove(branch);
}
@Override
public void removeFromDatabase(int subjectId) throws OseeCoreException {
final String DELETE_BRANCH_ACL = "DELETE FROM OSEE_BRANCH_ACL WHERE privilege_entity_id = ? AND branch_id =?";
- ConnectionHandler.runPreparedUpdate(DELETE_BRANCH_ACL, subjectId, branchUuid);
+ ConnectionHandler.runPreparedUpdate(DELETE_BRANCH_ACL, subjectId, branch);
}
public static BranchAccessObject getBranchAccessObject(BranchId branch) throws OseeCoreException {
- return getBranchAccessObject(branch.getId());
- }
-
- public static BranchAccessObject getBranchAccessObject(long branchUuid) {
BranchAccessObject branchAccessObject;
- if (cache.containsKey(branchUuid)) {
- branchAccessObject = cache.get(branchUuid);
+ if (cache.containsKey(branch)) {
+ branchAccessObject = cache.get(branch);
} else {
- branchAccessObject = new BranchAccessObject(branchUuid);
- cache.put(branchUuid, branchAccessObject);
+ branchAccessObject = new BranchAccessObject(branch);
+ cache.put(branch, branchAccessObject);
}
return branchAccessObject;
}
public static BranchAccessObject getBranchAccessObjectFromCache(BranchId branch) throws OseeCoreException {
- return cache.get(branch.getUuid());
+ return cache.get(branch);
}
@Override
@@ -75,6 +71,6 @@ public class BranchAccessObject extends AccessObject {
if (!(obj instanceof BranchAccessObject)) {
return false;
}
- return branchUuid.equals(((BranchAccessObject) obj).branchUuid);
+ return branch.equals(((BranchAccessObject) obj).branch);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserAdmin.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserAdmin.java
index 8ea09521d7..abb429d544 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserAdmin.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserAdmin.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.skynet.core;
import java.util.List;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.IUserToken;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
@@ -42,11 +43,11 @@ public interface UserAdmin {
User getUser(IUserToken user) throws OseeCoreException;
- String getSafeUserNameById(int userArtifactId);
+ String getSafeUserNameById(ArtifactId userArtifactId);
- String getUserNameById(int userArtifactId) throws OseeCoreException;
+ String getUserNameById(ArtifactId userArtifactId) throws OseeCoreException;
- User getUserByArtId(int userArtifactId) throws OseeCoreException;
+ User getUserByArtId(ArtifactId userArtifactId) throws OseeCoreException;
User createUser(IUserToken userToken, String comment) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserManager.java
index 679f486c23..f8db4feab9 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/UserManager.java
@@ -17,6 +17,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.logging.Level;
import org.eclipse.osee.cache.admin.CacheAdmin;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.IUserToken;
import org.eclipse.osee.framework.core.exception.UserNotInDatabase;
import org.eclipse.osee.framework.jdk.core.type.LazyObject;
@@ -133,20 +134,24 @@ public final class UserManager {
String name;
if (userAdmin != null) {
- name = userAdmin.getSafeUserNameById(userArtifactId);
+ name = userAdmin.getSafeUserNameById(ArtifactId.valueOf(userArtifactId));
} else {
name = String.format("Unable resolve user by artId[%s] since userAdmin was unavailable", userArtifactId);
}
return name;
}
- public static User getUserByArtId(int userArtifactId) throws OseeCoreException {
+ public static User getUserByArtId(ArtifactId userArtifactId) throws OseeCoreException {
return getUserAdmin().getUserByArtId(userArtifactId);
}
+ public static User getUserByArtId(long userArtifactId) throws OseeCoreException {
+ return getUserAdmin().getUserByArtId(ArtifactId.valueOf(userArtifactId));
+ }
+
/**
* This is not the preferred way to get a user. Most likely getUserByUserId() or getUserByArtId() should be used
- *
+ *
* @return the first user found with the given name
*/
public static User getUserByName(String name) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/UserAdminImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/UserAdminImpl.java
index 0e6ffa6a72..9ab9c1de2a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/UserAdminImpl.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/UserAdminImpl.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.osee.cache.admin.Cache;
import org.eclipse.osee.cache.admin.CacheAdmin;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.IUserToken;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.exception.UserDataStoreException;
@@ -211,7 +212,7 @@ public class UserAdminImpl implements UserAdmin {
/**
* This is not the preferred way to get a user. Most likely getUserByUserId() or getUserByArtId() should be used
- *
+ *
* @return the first user found with the given name
*/
@Override
@@ -249,7 +250,7 @@ public class UserAdminImpl implements UserAdmin {
}
@Override
- public String getUserNameById(int userArtifactId) throws OseeCoreException {
+ public String getUserNameById(ArtifactId userArtifactId) throws OseeCoreException {
User user = getUserByArtId(userArtifactId);
if (user == null) {
throw new UserNotInDatabase("Unable to find user with artId[%s]", userArtifactId);
@@ -259,7 +260,7 @@ public class UserAdminImpl implements UserAdmin {
}
@Override
- public String getSafeUserNameById(int userArtifactId) {
+ public String getSafeUserNameById(ArtifactId userArtifactId) {
String name;
try {
name = getUserNameById(userArtifactId);
@@ -270,9 +271,9 @@ public class UserAdminImpl implements UserAdmin {
}
@Override
- public User getUserByArtId(int userArtifactId) throws OseeCoreException {
+ public User getUserByArtId(ArtifactId userArtifactId) throws OseeCoreException {
User toReturn = null;
- if (userArtifactId <= 0) {
+ if (userArtifactId.isInvalid()) {
toReturn = getUser(SystemUser.OseeSystem);
} else {
// check cached users first
@@ -284,10 +285,10 @@ public class UserAdminImpl implements UserAdmin {
return toReturn;
}
- private User checkIterableForId(Iterable<User> users, int id) {
+ private User checkIterableForId(Iterable<User> users, ArtifactId id) {
User toReturn = null;
for (User tempUser : users) {
- if (id == tempUser.getArtId()) {
+ if (id.equals(Long.valueOf(tempUser.getArtId()))) {
toReturn = tempUser;
break;
}

Back to the top