Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2014-05-29 18:40:54 +0000
committerDonald Dunne2014-06-17 05:33:58 +0000
commit4975c977d4505d902e7b9b4829502ecc1b8613d6 (patch)
tree1ef6f02fae7fd21cd5b3ad8d90a280d86989840b /plugins/org.eclipse.osee.ats.impl
parent33553f2a403fe872b42ab6b65c37ca060e793454 (diff)
downloadorg.eclipse.osee-4975c977d4505d902e7b9b4829502ecc1b8613d6.tar.gz
org.eclipse.osee-4975c977d4505d902e7b9b4829502ecc1b8613d6.tar.xz
org.eclipse.osee-4975c977d4505d902e7b9b4829502ecc1b8613d6.zip
feature[ats_ATS34674]: Revert to Common for ATS if no access to config branch
Diffstat (limited to 'plugins/org.eclipse.osee.ats.impl')
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
index 665dd5f928e..8597ff625e6 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
@@ -18,6 +18,8 @@ import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.core.users.AbstractAtsUserService;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.impl.internal.util.AtsUtilServer;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.Active;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
@@ -26,6 +28,7 @@ import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -47,11 +50,19 @@ public class AtsUserServiceImpl extends AbstractAtsUserService {
System.out.println("ATS - AtsUserService started");
}
+ @Override
+ public String getCurrentUserId() throws OseeCoreException {
+ if (currentUserId == null) {
+ currentUserId = SystemUser.OseeSystem.getUserId();
+ }
+ return currentUserId;
+ }
+
// TODO Replace this once server has user account
@Override
public IAtsUser getCurrentUser() throws OseeCoreException {
if (currentUser == null) {
- currentUser = getUserById(SystemUser.OseeSystem.getUserId());
+ currentUser = getUserById(getCurrentUserId());
}
return currentUser;
}
@@ -138,4 +149,20 @@ public class AtsUserServiceImpl extends AbstractAtsUserService {
}
}
+ @Override
+ public boolean currentUserHasAccessToAtsBranch(Long branchUuid) {
+ boolean hasPermission = false;
+ IOseeBranch configAtsBranch = TokenFactory.createBranch(branchUuid, "ATS Branch");
+ if (!orcsApi.getQueryFactory(null).branchQuery().andIds(configAtsBranch).getResults().isEmpty()) {
+ String userId = getCurrentUserId();
+ if (Strings.isValid(userId) && !userId.equals(SystemUser.Guest.getUserId())) {
+ ResultSet<ArtifactReadable> results =
+ orcsApi.getQueryFactory(AtsUtilServer.getApplicationContext()).fromBranch(AtsUtilCore.getAtsBranch()).andIsOfType(
+ CoreArtifactTypes.User).and(CoreAttributeTypes.UserId,
+ org.eclipse.osee.framework.core.enums.Operator.EQUAL, userId).getResults();
+ hasPermission = (results.size() == 1);
+ }
+ }
+ return hasPermission;
+ }
}

Back to the top