diff options
author | donald.g.dunne | 2014-05-29 18:40:54 +0000 |
---|---|---|
committer | Donald Dunne | 2014-06-17 05:33:58 +0000 |
commit | 4975c977d4505d902e7b9b4829502ecc1b8613d6 (patch) | |
tree | 1ef6f02fae7fd21cd5b3ad8d90a280d86989840b /plugins/org.eclipse.osee.ats.impl | |
parent | 33553f2a403fe872b42ab6b65c37ca060e793454 (diff) | |
download | org.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
Change-Id: I02cf7e50ea4e4a5a70b3c3795e994cd1b8658d90
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.java | 29 |
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; + } } |