Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-05-09 14:54:43 -0400
committerRyan D. Brooks2017-05-11 19:36:30 -0400
commita272e97b57d0a01437e0062d0bf8a3282df1da30 (patch)
treebb6837469679b938ad96d746a566f237ed1a4ab8
parentb37d7a257cef074fef33a24e3b481013603f366d (diff)
downloadorg.eclipse.osee-a272e97b57d0a01437e0062d0bf8a3282df1da30.tar.gz
org.eclipse.osee-a272e97b57d0a01437e0062d0bf8a3282df1da30.tar.xz
org.eclipse.osee-a272e97b57d0a01437e0062d0bf8a3282df1da30.zip
refactor: Utilize Collection.fromString
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java11
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/AtsWorkItemEventHandler.java7
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java27
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/xml/Jaxp.java35
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/action/PurgeTransactionAction.java8
-rw-r--r--plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/OAuthEncryption.java25
-rw-r--r--plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ClientRegistrationEndpoint.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/AuthCodeGrantStorage.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientCredentialStorage.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionUtil.java62
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IndexerEndpointImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java17
14 files changed, 82 insertions, 206 deletions
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
index 96463fe55b..b0cf739b5b 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
@@ -91,17 +91,6 @@ public class AtsObjects {
return Collections.toString(", ", guids);
}
- /**
- * @param semicolon delimited list of uuids
- */
- public static Collection<Long> uuidsToLong(String separator, String uuidsList) {
- List<Long> uuids = new ArrayList<>();
- for (String uuid : uuidsList.split(separator)) {
- uuids.add(Long.valueOf(uuid));
- }
- return uuids;
- }
-
public static Collection<ArtifactId> getArtifacts(Collection<?> objects) {
List<ArtifactId> artifacts = new LinkedList<>();
for (Object object : objects) {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/AtsWorkItemEventHandler.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/AtsWorkItemEventHandler.java
index 5632c5851a..91b0ec8425 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/AtsWorkItemEventHandler.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/AtsWorkItemEventHandler.java
@@ -11,9 +11,9 @@
package org.eclipse.osee.ats.workflow;
import org.eclipse.osee.ats.api.util.AtsTopicEvent;
-import org.eclipse.osee.ats.core.util.AtsObjects;
import org.eclipse.osee.ats.editor.WfeArtifactEventManager;
import org.eclipse.osee.ats.internal.AtsClientService;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
import org.osgi.service.event.Event;
@@ -30,10 +30,9 @@ public class AtsWorkItemEventHandler implements EventHandler {
public void handleEvent(Event event) {
try {
if (event.getTopic().equals(AtsTopicEvent.WORK_ITEM_MODIFIED)) {
- for (Long workItemUuid : AtsObjects.uuidsToLong(";",
- (String) event.getProperty(AtsTopicEvent.WORK_ITEM_UUIDS_KEY))) {
+ String ids = (String) event.getProperty(AtsTopicEvent.WORK_ITEM_UUIDS_KEY);
+ for (Long workItemUuid : Collections.fromString(ids, ";", Long::valueOf)) {
Artifact artifact = ArtifactCache.getActive(workItemUuid, AtsClientService.get().getAtsBranch());
-
if (artifact != null) {
if (WfeArtifactEventManager.isLoaded(artifact)) {
artifact.reloadAttributesAndRelations();
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
index 3f7b37a40b..966de71e9b 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
@@ -18,6 +18,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import java.util.function.Function;
/**
* @author David Diepenbrock
@@ -25,8 +26,29 @@ import java.util.Set;
public class Collections {
public static Object[] EMPTY_ARRAY = new Object[0];
- public static Collection<String> fromString(String string, String seperator) {
- return Arrays.asList(string.split(seperator));
+ public static List<String> fromString(String rawValue, String seperator) {
+ return fromString(rawValue, seperator, Function.identity());
+ }
+
+ public static <R> List<R> fromString(String rawValue, Function<String, R> function) {
+ return fromString(rawValue, ",", function);
+ }
+
+ public static <R> List<R> fromString(String rawValue, String seperator, Function<String, R> function) {
+ List<R> toReturn;
+ if (Strings.isValid(rawValue)) {
+ String[] entries = rawValue.split(seperator);
+ toReturn = new ArrayList<>(entries.length);
+ for (String entry : entries) {
+ String token = entry.trim();
+ if (Strings.isValid(token)) {
+ toReturn.add(function.apply(token));
+ }
+ }
+ } else {
+ toReturn = java.util.Collections.emptyList();
+ }
+ return toReturn;
}
/**
@@ -347,5 +369,4 @@ public class Collections {
}
return result;
}
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/xml/Jaxp.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/xml/Jaxp.java
index ff8f25d2ad..fd4f32a850 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/xml/Jaxp.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/xml/Jaxp.java
@@ -42,6 +42,7 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.w3c.dom.Attr;
@@ -68,7 +69,7 @@ public class Jaxp {
/**
* Obtains a list of all direct descendants of element
- *
+ *
* @param element the element to find the children of
* @return A list of elements that are direct children of element. If no children exist, an empty list is returned.
*/
@@ -86,7 +87,7 @@ public class Jaxp {
/**
* Obtains a list of all direct descendants of element with the matching tag.
- *
+ *
* @param element the element to find the children of
* @param childTagName the tag name for the children
* @return A list of elements that are direct children of element whose tag names match childTagName. If no such
@@ -106,7 +107,7 @@ public class Jaxp {
/**
* Obtains the first child that is a direct descendant of element with the matching tag
- *
+ *
* @param element the element to find the child of
* @param childTagName the tag name for the child
* @return the first child with the given tag one level deep from element, null if no such child exists.
@@ -124,7 +125,7 @@ public class Jaxp {
/**
* Obtains the first child that is a descendant of element with the matching tag
- *
+ *
* @param element the element to find the child of
* @param childTagName the tag name for the child
* @return the first child with the given tag, or null if no such children exist
@@ -143,7 +144,7 @@ public class Jaxp {
/**
* Obtains the character data for the Element. Note this differs from the Node.getTextContext(); call, which returns
* the concatenation of the character data for all children of this Element.
- *
+ *
* @param e The element go get the character data for
* @param trimWhitespace if true, each segment will be trimmed.
* @return All of the character data for the Element e. This means if there are elements separating the character
@@ -178,7 +179,7 @@ public class Jaxp {
/**
* Obtains the character data for the Element. Note this differs from the Node.getTextContext(); call, which returns
* the concatenation of the character data for all children of this Element.
- *
+ *
* @param e The element go get the character data for
* @return All of the character data for the Element e. This means if there are elements separating the character
* data, it will all be concatenated together. Each segment will be trimmed of whitespace, with a single space
@@ -216,7 +217,7 @@ public class Jaxp {
/**
* Obtains a list of Strings of the character data for all elements in the document whose tag name matches.
- *
+ *
* @param document The document to be searched
* @param tagName The tagName for the children whose text we will obtain
* @return An ArrayList<String> of the text for all child nodes matching tagName
@@ -227,7 +228,7 @@ public class Jaxp {
/**
* Obtains a list of Strings of the character data for all descendants of element whose tag name matches.
- *
+ *
* @param document The document to be searched
* @param tagName The tagName for the children whose text we will obtain
* @return An ArrayList<String> of the text for all child nodes matching tagName
@@ -270,7 +271,7 @@ public class Jaxp {
/**
* Searches for all sub-elements found at the path provided.
- *
+ *
* @param element The element underneath which we will search
* @param elementPath The path to follow. For example ["script","configuration","element_i_want"]
* @param firstIsRoot If true, the first item in elementPath must match element. That is, in the above example, e's
@@ -303,7 +304,7 @@ public class Jaxp {
}
private static List<Element> findElementsSinglePath(Element e, String elementPath, boolean firstIsRoot) {
- return findElements(e, Arrays.asList(elementPath.split("/")), firstIsRoot);
+ return findElements(e, Collections.fromString(elementPath, "/"), firstIsRoot);
}
private static List<Element> findElements(Element e, String elementPath, boolean firstIsRoot) {
@@ -327,7 +328,7 @@ public class Jaxp {
/**
* Searches for a sub-element found at the path provided. Each list element indicates the tag name for the next
* sub-element.
- *
+ *
* @param e The element underneath which we will search
* @param elementPath The path to follow. For example ["script","configuration","element_i_want"]
* @return The first element that matches the provided path, beneath the provided element e, or null if no such
@@ -356,7 +357,7 @@ public class Jaxp {
/**
* Searches the Document for the Element found at the '/' delimited path provided. The path should begin with the
* root node of the document.
- *
+ *
* @param d The document to search
* @param elementPath The path to follow. For example "script/configuration/element_i_want"
* @return The first element that matches the provided path, or null if no such element exists.
@@ -381,7 +382,7 @@ public class Jaxp {
/**
* Searches for a sub-element found at the '/' delimited path provided. The path should begin with the first node
* underneath the provided element.
- *
+ *
* @param e The element underneath which we will search
* @param elementPath The path to follow. For example "script/configuration/element_i_want"
* @return The first element that matches the provided path, beneath the provided element e, or null if no such
@@ -468,7 +469,7 @@ public class Jaxp {
/**
* Writes the XML document 'document' to the 'file'.
- *
+ *
* @param document The XML document to output
* @param file Where to put the output
* @throws TransformerException
@@ -479,7 +480,7 @@ public class Jaxp {
/**
* Writes the XML document 'document' to the 'file'.
- *
+ *
* @param document The XML document to output
* @param file Where to put the output
* @param prettyOutput If true, turns on indentation so the output is more easily readable, if False turns
@@ -494,7 +495,7 @@ public class Jaxp {
/**
* Gets the XML document 'document' as a string
- *
+ *
* @param document The XML document to output
* @param file Where to put the output
* @param prettyOutput If true, turns on indentation so the output is more easily readable, if False turns
@@ -510,7 +511,7 @@ public class Jaxp {
/**
* Sends the XML to the output
- *
+ *
* @param node The source XML
* @param output Where the XML is 'printed' to
* @param format The format style to use
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/action/PurgeTransactionAction.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/action/PurgeTransactionAction.java
index 4d9bdc57ee..153b97559a 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/action/PurgeTransactionAction.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/action/PurgeTransactionAction.java
@@ -25,7 +25,6 @@ import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
@@ -96,12 +95,7 @@ public class PurgeTransactionAction extends Action {
EntryDialog dialog = new EntryDialog(NAME, "Enter Transaction(s), comma delimited");
boolean success = false;
if (dialog.open() == 0) {
- for (String transId : dialog.getEntry().split(",")) {
- transId = transId.trim();
- if (Strings.isValid(transId)) {
- transactions.add(TransactionId.valueOf(transId));
- }
- }
+ transactions.addAll(Collections.fromString(dialog.getEntry(), TransactionId::valueOf));
success = !transactions.isEmpty();
}
return success;
diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/OAuthEncryption.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/OAuthEncryption.java
index 7ead0316a8..9e50501019 100644
--- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/OAuthEncryption.java
+++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/OAuthEncryption.java
@@ -11,8 +11,6 @@
package org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.adapters;
import java.security.Key;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -26,6 +24,7 @@ import org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider;
import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
import org.apache.cxf.rs.security.oauth2.utils.crypto.KeyProperties;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.server.session.SessionData;
@@ -167,12 +166,7 @@ public class OAuthEncryption {
}
private static List<String> parseSimpleList(String listStr) {
- String pureStringList = prepareSimpleString(listStr);
- if (pureStringList.isEmpty()) {
- return Collections.emptyList();
- } else {
- return Arrays.asList(pureStringList.split(","));
- }
+ return Collections.fromString(prepareSimpleString(listStr), ",");
}
private static String getStringPart(String str) {
@@ -218,17 +212,10 @@ public class OAuthEncryption {
private static ServerAccessToken recreateAccessToken(OAuthDataProvider provider, String newTokenKey, String[] parts) {
- @SuppressWarnings("serial")
- final ServerAccessToken newToken =
- new ServerAccessToken(provider.getClient(parts[4]), parts[1], newTokenKey == null ? parts[0] : newTokenKey,
- Long.valueOf(parts[2]), Long.valueOf(parts[3])) {
-
- /**
- *
- */
- private static final long serialVersionUID = 7381031812625396582L;
- //
- };
+ final ServerAccessToken newToken = new ServerAccessToken(provider.getClient(parts[4]), parts[1],
+ newTokenKey == null ? parts[0] : newTokenKey, Long.valueOf(parts[2]), Long.valueOf(parts[3])) {
+ private static final long serialVersionUID = 7381031812625396582L;
+ };
newToken.setRefreshToken(getStringPart(parts[5]));
newToken.setGrantType(getStringPart(parts[6]));
diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ClientRegistrationEndpoint.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ClientRegistrationEndpoint.java
index d37f4883b5..3481e2c3c1 100644
--- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ClientRegistrationEndpoint.java
+++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ClientRegistrationEndpoint.java
@@ -25,8 +25,6 @@ import static org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.en
import static org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.endpoints.ClientConstants.CLIENT_REGISTRATION__DECISION_REGISTER;
import static org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.endpoints.ClientConstants.CLIENT_REGISTRATION__IS_CONFIDENTIAL;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -48,8 +46,8 @@ import org.apache.cxf.rs.security.oauth2.common.UserSubject;
import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
import org.apache.cxf.security.SecurityContext;
import org.eclipse.osee.framework.jdk.core.type.OseePrincipal;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.server.internal.security.oauth2.OAuthUtil;
import org.eclipse.osee.logger.Log;
@@ -83,7 +81,7 @@ public class ClientRegistrationEndpoint extends AbstractClientService {
@Path("/complete")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response finishRegistration(@Context UriInfo uriInfo, //
- MultipartBody multiPart) {
+ MultipartBody multiPart) {
SecurityContext securityContext = getAndValidateSecurityContext();
UserSubject userSubject = createUserSubject(securityContext);
@@ -162,18 +160,6 @@ public class ClientRegistrationEndpoint extends AbstractClientService {
}
private List<String> parseMultilined(String rawData) {
- List<String> toReturn = Collections.emptyList();
- if (Strings.isValid(rawData)) {
- toReturn = new ArrayList<>();
- String[] entries = rawData.split("\\s+");
- for (String entry : entries) {
- entry = entry.trim();
- if (Strings.isValid(entry)) {
- toReturn.add(entry);
- }
- }
- }
- return toReturn;
+ return Collections.fromString(rawData, "\\s+");
}
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/AuthCodeGrantStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/AuthCodeGrantStorage.java
index dac36f832e..86e1c2596d 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/AuthCodeGrantStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/AuthCodeGrantStorage.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal.oauth;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.jaxrs.server.database.AbstractDatabaseStorage;
import org.eclipse.osee.jaxrs.server.security.OAuthCodeGrant;
import org.eclipse.osee.jdbc.JdbcClient;
@@ -79,24 +77,10 @@ public class AuthCodeGrantStorage extends AbstractDatabaseStorage<OAuthCodeGrant
deleteItems(DELETE_AUTH_CODE_BY_ID, datas);
}
- private List<String> parseScopes(String scopes) {
- List<String> toReturn = Collections.emptyList();
- if (scopes != null) {
- toReturn = new ArrayList<>();
- String[] scopeValues = scopes.split(SCOPES_SEPARATOR);
- for (String scope : scopeValues) {
- if (Strings.isValid(scope)) {
- toReturn.add(scope);
- }
- }
- }
- return toReturn;
- }
-
private Object asScopesStore(List<String> scopes) {
String scopeData = null;
if (scopes != null && !scopes.isEmpty()) {
- scopeData = org.eclipse.osee.framework.jdk.core.util.Collections.toString(SCOPES_SEPARATOR, scopes);
+ scopeData = Collections.toString(SCOPES_SEPARATOR, scopes);
}
return asVarcharOrNull(scopeData);
}
@@ -112,7 +96,7 @@ public class AuthCodeGrantStorage extends AbstractDatabaseStorage<OAuthCodeGrant
final String redirect_uri = chStmt.getString("redirect_uri");
final String verifier = chStmt.getString("verifier");
final String audience = chStmt.getString("audience");
- final List<String> approvedScopes = parseScopes(chStmt.getString("approved_scopes"));
+ final List<String> approvedScopes = Collections.fromString(chStmt.getString("approved_scopes"), SCOPES_SEPARATOR);
return new OAuthCodeGrant() {
@Override
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientCredentialStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientCredentialStorage.java
index 855476388b..15f256d238 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientCredentialStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientCredentialStorage.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal.oauth;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.jaxrs.server.database.AbstractDatabaseStorage;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcStatement;
@@ -111,7 +109,7 @@ public class ClientCredentialStorage extends AbstractDatabaseStorage<OAuthClient
final String clientSecret = chStmt.getString("client_secret");
final String clientCert = chStmt.getString("client_cert");
- List<String> certs = fromCertString(clientCert);
+ List<String> certs = Collections.fromString(clientCert, ";");
return newCredential(clientId, applicationId, subjectId, clientKey, clientSecret, certs);
}
@@ -119,20 +117,6 @@ public class ClientCredentialStorage extends AbstractDatabaseStorage<OAuthClient
return certs != null ? org.eclipse.osee.framework.jdk.core.util.Collections.toString(";", certs) : null;
}
- private List<String> fromCertString(String certs) {
- List<String> toReturn = null;
- if (Strings.isValid(certs)) {
- toReturn = new ArrayList<>();
- String[] certArray = certs.split(";");
- for (String cert : certArray) {
- toReturn.add(cert);
- }
- } else {
- toReturn = Collections.emptyList();
- }
- return toReturn;
- }
-
public OAuthClientCredential newCredential(final long clientId, final long applicationId, final long subjectId, final String clientKey, final String clientSecret, final List<String> clientCert) {
return new OAuthClientCredential() {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionUtil.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionUtil.java
deleted file mode 100644
index 41868c5ed8..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionUtil.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.transaction;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Callable;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Angel Avila
- */
-public class OrcsTransactionUtil {
-
- public static List<Integer> asIntegerList(String rawValue) {
- List<Integer> toReturn;
- if (Strings.isValid(rawValue)) {
- String[] entries = rawValue.split(",");
- toReturn = new ArrayList<>();
- for (String entry : entries) {
- Integer value = Integer.parseInt(entry.trim());
- toReturn.add(value);
- }
- } else {
- toReturn = Collections.emptyList();
- }
- return toReturn;
- }
-
- public static List<Long> asLongList(String rawValue) {
- List<Long> toReturn;
- if (Strings.isValid(rawValue)) {
- String[] entries = rawValue.split(",");
- toReturn = new ArrayList<>();
- for (String entry : entries) {
- Long value = Long.parseLong(entry.trim());
- toReturn.add(value);
- }
- } else {
- toReturn = Collections.emptyList();
- }
- return toReturn;
- }
-
- public static <T> T executeCallable(Callable<T> callable) {
- try {
- return callable.call();
- } catch (Exception ex) {
- throw OseeCoreException.wrap(ex);
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
index 8847f864e5..4b4a2e4243 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
@@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.model.change.ChangeItem;
import org.eclipse.osee.framework.core.model.change.CompareResults;
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.Collections;
import org.eclipse.osee.framework.jdk.core.util.Compare;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.orcs.KeyValueOps;
@@ -95,12 +96,15 @@ public class TransactionFactoryImpl implements TransactionFactory {
public CompareResults compareTxs(TransactionId txId1, TransactionId txId2) {
TransactionToken sourceTx = getTx(txId1);
TransactionToken destinationTx = getTx(txId2);
- Callable<List<ChangeItem>> callable = orcsBranch.compareBranch(sourceTx, destinationTx);
- List<ChangeItem> changes = OrcsTransactionUtil.executeCallable(callable);
- CompareResults data = new CompareResults();
- data.setChanges(changes);
- return data;
+ try {
+ List<ChangeItem> changes = orcsBranch.compareBranch(sourceTx, destinationTx).call();
+ CompareResults data = new CompareResults();
+ data.setChanges(changes);
+ return data;
+ } catch (Exception ex) {
+ throw OseeCoreException.wrap(ex);
+ }
}
@Override
@@ -128,15 +132,19 @@ public class TransactionFactoryImpl implements TransactionFactory {
@Override
public boolean purgeTxs(String txIds) {
boolean modified = false;
- List<Long> txsToDelete = OrcsTransactionUtil.asLongList(txIds);
+ List<Long> txsToDelete = Collections.fromString(txIds, Long::parseLong);
+
if (!txsToDelete.isEmpty()) {
ResultSet<? extends TransactionId> results =
queryFactory.transactionQuery().andTxIds(txsToDelete).getResults();
if (!results.isEmpty()) {
checkAllTxsFound("Purge Transaction", txsToDelete, results);
List<TransactionId> list = Lists.newArrayList(results);
- Callable<?> op = purgeTransaction(list);
- OrcsTransactionUtil.executeCallable(op);
+ try {
+ purgeTransaction(list).call();
+ } catch (Exception ex) {
+ throw OseeCoreException.wrap(ex);
+ }
modified = true;
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
index 77a466fd41..92e044119f 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
@@ -753,7 +753,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
@Override
public Response purgeTxs(BranchId branch, String txIds) {
boolean modified = false;
- List<Long> txsToDelete = OrcsRestUtil.asLongList(txIds);
+ List<Long> txsToDelete = org.eclipse.osee.framework.jdk.core.util.Collections.fromString(txIds, Long::parseLong);
if (!txsToDelete.isEmpty()) {
ResultSet<? extends TransactionId> results = newTxQuery().andBranch(branch).andTxIds(txsToDelete).getResults();
if (!results.isEmpty()) {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IndexerEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IndexerEndpointImpl.java
index 0bfb87fa7b..de12709603 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IndexerEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IndexerEndpointImpl.java
@@ -19,7 +19,9 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.jaxrs.OseeWebApplicationException;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.BranchReadable;
@@ -53,9 +55,9 @@ public class IndexerEndpointImpl implements IndexerEndpoint {
}
@Override
- public Response indexBranches(String branchUuids, boolean missingItemsOnly) {
- List<Long> ids = OrcsRestUtil.asLongList(branchUuids);
- ResultSet<BranchReadable> results = newBranchQuery().andUuids(ids).getResults();
+ public Response indexBranches(String branchIdsStr, boolean missingItemsOnly) {
+ List<BranchId> branchIds = Collections.fromString(branchIdsStr, BranchId::valueOf);
+ ResultSet<BranchReadable> results = newBranchQuery().andIds(branchIds).getResults();
Callable<Integer> op = getIndexer().indexBranches(Sets.newLinkedHashSet(results), missingItemsOnly);
Integer result = executeCallable(op);
boolean modified = result > 0;
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java
index a6972fba2d..5a13532e79 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java
@@ -11,14 +11,12 @@
package org.eclipse.osee.orcs.rest.internal;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
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.Strings;
import org.eclipse.osee.orcs.data.BranchReadable;
import org.eclipse.osee.orcs.data.TransactionReadable;
import org.eclipse.osee.orcs.rest.model.Branch;
@@ -93,19 +91,4 @@ public final class OrcsRestUtil {
data.setTxType(tx.getTxType());
return data;
}
-
- public static List<Long> asLongList(String rawValue) {
- List<Long> toReturn;
- if (Strings.isValid(rawValue)) {
- String[] entries = rawValue.split(",");
- toReturn = new ArrayList<>();
- for (String entry : entries) {
- Long value = Long.parseLong(entry.trim());
- toReturn.add(value);
- }
- } else {
- toReturn = Collections.emptyList();
- }
- return toReturn;
- }
}

Back to the top