Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-07-21 19:37:04 -0400
committerRyan D. Brooks2017-07-26 17:29:25 -0400
commita92454247674346caea2d097897584282dc5e8aa (patch)
treeca4e5f0d0e2ac5104f96417788e0fc2cf9f8f5e4
parent52cc33b7a8d0d173526d44676daeb0cdef797d1d (diff)
downloadorg.eclipse.osee-a92454247674346caea2d097897584282dc5e8aa.tar.gz
org.eclipse.osee-a92454247674346caea2d097897584282dc5e8aa.tar.xz
org.eclipse.osee-a92454247674346caea2d097897584282dc5e8aa.zip
refactor: Use ArtifactId with ATS admin
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/AtsConfigurations.java16
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsUtilClient.java11
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/AbstractAtsUserService.java13
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkflowManagerCore.java20
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java2
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsUserServiceServerImpl.java4
7 files changed, 24 insertions, 44 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/AtsConfigurations.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/AtsConfigurations.java
index 6e88ac20ce..8e172d8bec 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/AtsConfigurations.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/AtsConfigurations.java
@@ -21,8 +21,8 @@ import org.eclipse.osee.ats.api.user.AtsUser;
import org.eclipse.osee.ats.api.util.ColorColumns;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionStringProvider;
import org.eclipse.osee.ats.api.workdef.WorkDefData;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Donald G. Dunne
@@ -34,7 +34,7 @@ public class AtsConfigurations implements IAtsWorkDefinitionStringProvider {
private AtsViews views = new AtsViews();
private ColorColumns colorColumns = new ColorColumns();
List<AtsUser> users = new ArrayList<>();
- List<Long> atsAdmins = new ArrayList<>();
+ List<ArtifactId> atsAdmins = new ArrayList<>();
Long topActionableItem;
Long topTeamDefinition;
List<JaxVersion> versions = new ArrayList<>();
@@ -89,20 +89,12 @@ public class AtsConfigurations implements IAtsWorkDefinitionStringProvider {
}
@JsonIgnore
- public List<Long> getAtsAdmins() {
+ public List<ArtifactId> getAtsAdmins() {
return atsAdmins;
}
public void setAtsAdminsStr(String atsAdmins) {
- parseStringOfLongs(this.atsAdmins, atsAdmins);
- }
-
- private void parseStringOfLongs(List<Long> uuids, String strOfLongs) {
- if (Strings.isValid(strOfLongs)) {
- for (String uuid : strOfLongs.split(",")) {
- uuids.add(Long.valueOf(uuid));
- }
- }
+ this.atsAdmins = Collections.fromString(atsAdmins, ArtifactId::valueOf);
}
@Override
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
index 4fb18c1e6b..6f3b010899 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
@@ -39,6 +39,8 @@ public interface IAtsUserService {
Collection<IAtsUser> getUsersByUserIds(Collection<String> userIds) throws OseeCoreException;
+ boolean isAtsAdmin();
+
boolean isAtsAdmin(IAtsUser user);
List<IAtsUser> getUsers(Active active);
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsUtilClient.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsUtilClient.java
index d19ba02b95..ebd9345136 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsUtilClient.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsUtilClient.java
@@ -121,16 +121,7 @@ public class AtsUtilClient {
}
public static boolean isAtsAdmin() {
- if (atsAdmin == null) {
- try {
- atsAdmin = AtsClientService.get().getConfigurations().getAtsAdmins().contains(
- AtsClientService.get().getUserService().getCurrentUser().getId());
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- atsAdmin = false;
- }
- }
- return atsAdmin;
+ return AtsClientService.get().getUserService().isAtsAdmin();
}
public static String getAtsId(Artifact art) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/AbstractAtsUserService.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/AbstractAtsUserService.java
index b7d0f3c2f8..c6dc3e58f4 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/AbstractAtsUserService.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/users/AbstractAtsUserService.java
@@ -136,13 +136,9 @@ public abstract class AbstractAtsUserService implements IAtsUserService {
}
@Override
- public abstract String getCurrentUserId();
-
- @Override
- public abstract boolean isAtsAdmin(IAtsUser user);
-
- @Override
- public abstract List<? extends IAtsUser> getUsers();
+ public boolean isAtsAdmin() {
+ return isAtsAdmin(getCurrentUser());
+ }
@Override
public List<IAtsUser> getUsers(Active active) {
@@ -170,5 +166,4 @@ public abstract class AbstractAtsUserService implements IAtsUserService {
public void releaseUser() {
currentUser = null;
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkflowManagerCore.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkflowManagerCore.java
index 48df02e340..75f6801410 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkflowManagerCore.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/WorkflowManagerCore.java
@@ -27,7 +27,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
public class WorkflowManagerCore {
public static boolean isEditable(IAtsUser user, IAtsWorkItem workItem, IAtsStateDefinition stateDef, boolean privilegedEditEnabled, IAtsUserService userService) throws OseeCoreException {
- return isEditable(workItem, stateDef, privilegedEditEnabled, user, userService.isAtsAdmin(user));
+ return isEditable(workItem, stateDef, privilegedEditEnabled, user, userService.isAtsAdmin());
}
public static boolean isEditable(IAtsWorkItem workItem, IAtsStateDefinition stateDef, boolean privilegedEditEnabled, IAtsUser currentUser, boolean isAtsAdmin) throws OseeCoreException {
@@ -41,15 +41,15 @@ public class WorkflowManagerCore {
// and one of these
//
// page is define to allow anyone to edit
- (workItem.getStateDefinition().hasRule(RuleDefinitionOption.AllowEditToAll.name()) ||
- // team definition has allowed anyone to edit
- teamDefHasRule(workItem, RuleDefinitionOption.AllowEditToAll) ||
- // privileged edit mode is on
- privilegedEditEnabled ||
- // current user is assigned
- workItem.getAssignees().contains(currentUser) ||
- // current user is ats admin
- isAtsAdmin);
+ (workItem.getStateDefinition().hasRule(RuleDefinitionOption.AllowEditToAll.name()) ||
+ // team definition has allowed anyone to edit
+ teamDefHasRule(workItem, RuleDefinitionOption.AllowEditToAll) ||
+ // privileged edit mode is on
+ privilegedEditEnabled ||
+ // current user is assigned
+ workItem.getAssignees().contains(currentUser) ||
+ // current user is ats admin
+ isAtsAdmin);
}
protected boolean teamDefHasRule(IAtsWorkItem workItem, RuleDefinitionOption option) {
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
index 0df3d836b7..85f21336e3 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
@@ -132,7 +132,7 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi {
AtsArtifactToken.AtsAdmin).getResults().getAtMostOneOrNull();
if (atsAdminArt != null) {
for (ArtifactReadable member : atsAdminArt.getRelated(CoreRelationTypes.Users_User)) {
- configs.getAtsAdmins().add(member.getId());
+ configs.getAtsAdmins().add(member);
}
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsUserServiceServerImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsUserServiceServerImpl.java
index 91d3967eae..49fcb879e9 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsUserServiceServerImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsUserServiceServerImpl.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.ats.rest.internal.config;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -25,8 +27,6 @@ import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
/**
* @author Donald G. Dunne

Back to the top