Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2016-08-16 19:14:50 -0400
committerAngel Avila2017-02-17 15:10:56 -0500
commitcb9a11d684a9c64c8742ea72e3f00533db9483a7 (patch)
treee67e2790e70079c49ee99938cb3ecb7f352546c4
parenta1abe91311c70688b0d8e1e4f31b4e176a150122 (diff)
downloadorg.eclipse.osee-cb9a11d684a9c64c8742ea72e3f00533db9483a7.tar.gz
org.eclipse.osee-cb9a11d684a9c64c8742ea72e3f00533db9483a7.tar.xz
org.eclipse.osee-cb9a11d684a9c64c8742ea72e3f00533db9483a7.zip
refinement: Handle exceptions gracefully on Dispo Import
-rw-r--r--plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DiscrepancyParserTest.java20
-rw-r--r--plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DispoItemDataCopierTest.java11
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DiscrepancyParser.java15
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/TmoImporter.java27
4 files changed, 51 insertions, 22 deletions
diff --git a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DiscrepancyParserTest.java b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DiscrepancyParserTest.java
index a40782f221f..18cc3df969c 100644
--- a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DiscrepancyParserTest.java
+++ b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DiscrepancyParserTest.java
@@ -19,6 +19,8 @@ import java.util.Map;
import org.eclipse.osee.disposition.model.Discrepancy;
import org.eclipse.osee.disposition.model.DispoItemData;
import org.eclipse.osee.disposition.rest.internal.importer.DiscrepancyParser;
+import org.eclipse.osee.disposition.rest.internal.importer.DiscrepancyParser.MutableString;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.junit.Assert;
import org.junit.Test;
@@ -41,21 +43,24 @@ public class DiscrepancyParserTest {
public void testNewImport() throws Exception {
DispoItemData dispoItem = new DispoItemData();
- boolean stoppedParsing = false;
+ MutableBoolean stoppedParsing = new MutableBoolean(false);
+ MutableBoolean isException = new MutableBoolean(false);
+ MutableString exMessage = new MutableString();
String name = "sampleTmo.tmo";
URL resource = getClass().getResource("sampleTmo.tmo");
InputStream stream = null;
try {
stream = new BufferedInputStream(resource.openStream());
- stoppedParsing = DiscrepancyParser.buildItemFromFile(dispoItem, name, stream, false, new Date(0));
+ DiscrepancyParser.buildItemFromFile(dispoItem, name, stream, false, new Date(0), stoppedParsing, isException,
+ exMessage);
} finally {
Lib.close(stream);
}
int actualLength = dispoItem.getDiscrepanciesList().size();
Assert.assertEquals(6, actualLength);
- Assert.assertFalse(stoppedParsing);
+ Assert.assertFalse(stoppedParsing.getValue());
Map<String, Discrepancy> discrepanciesList = dispoItem.getDiscrepanciesList();
Collection<Discrepancy> values = discrepanciesList.values();
@@ -95,21 +100,24 @@ public class DiscrepancyParserTest {
public void testNewImportStringLocations() throws Exception {
DispoItemData dispoItem = new DispoItemData();
- boolean stoppedParsing = false;
+ MutableBoolean stoppedParsing = new MutableBoolean(false);
+ MutableBoolean isException = new MutableBoolean(false);
+ MutableString exMessage = new MutableString();
String name = "sampleTmoStrings.tmo";
URL resource = getClass().getResource(name);
InputStream stream = null;
try {
stream = new BufferedInputStream(resource.openStream());
- stoppedParsing = DiscrepancyParser.buildItemFromFile(dispoItem, name, stream, false, new Date(0));
+ DiscrepancyParser.buildItemFromFile(dispoItem, name, stream, false, new Date(0), stoppedParsing, isException,
+ exMessage);
} finally {
Lib.close(stream);
}
int actualLength = dispoItem.getDiscrepanciesList().size();
Assert.assertEquals(6, actualLength);
- Assert.assertFalse(stoppedParsing);
+ Assert.assertFalse(stoppedParsing.getValue());
Map<String, Discrepancy> discrepanciesList = dispoItem.getDiscrepanciesList();
Collection<Discrepancy> values = discrepanciesList.values();
diff --git a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DispoItemDataCopierTest.java b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DispoItemDataCopierTest.java
index 1166c999d29..efa2442e97b 100644
--- a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DispoItemDataCopierTest.java
+++ b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/importer/DispoItemDataCopierTest.java
@@ -27,7 +27,9 @@ import org.eclipse.osee.disposition.model.OperationReport;
import org.eclipse.osee.disposition.rest.integration.util.DispositionIntegrationRule;
import org.eclipse.osee.disposition.rest.internal.DispoConnector;
import org.eclipse.osee.disposition.rest.internal.importer.DiscrepancyParser;
+import org.eclipse.osee.disposition.rest.internal.importer.DiscrepancyParser.MutableString;
import org.eclipse.osee.disposition.rest.internal.importer.DispoItemDataCopier;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.orcs.db.mock.OsgiService;
@@ -53,6 +55,9 @@ public class DispoItemDataCopierTest {
@Test
public void testCopyItemData() throws Exception {
+ MutableBoolean stoppedParsing = new MutableBoolean(false);
+ MutableBoolean isException = new MutableBoolean(false);
+ MutableString exMessage = new MutableString();
DispoItemData oldItemTemp = new DispoItemData();
String name = "sampleTmo.tmo";
@@ -60,7 +65,8 @@ public class DispoItemDataCopierTest {
InputStream stream = null;
try {
stream = new BufferedInputStream(resource.openStream());
- DiscrepancyParser.buildItemFromFile(oldItemTemp, name, stream, true, new Date());
+ DiscrepancyParser.buildItemFromFile(oldItemTemp, name, stream, true, new Date(), stoppedParsing, isException,
+ exMessage);
} finally {
Lib.close(stream);
}
@@ -90,7 +96,8 @@ public class DispoItemDataCopierTest {
InputStream stream2 = null;
try {
stream2 = new BufferedInputStream(resource2.openStream());
- DiscrepancyParser.buildItemFromFile(itemFromNewVersion, name2, stream2, false, oldItemTemp.getLastUpdate());
+ DiscrepancyParser.buildItemFromFile(itemFromNewVersion, name2, stream2, false, oldItemTemp.getLastUpdate(),
+ stoppedParsing, isException, exMessage);
} finally {
Lib.close(stream2);
}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DiscrepancyParser.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DiscrepancyParser.java
index 4e33efbb0e5..e19f254f50f 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DiscrepancyParser.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DiscrepancyParser.java
@@ -62,7 +62,7 @@ public class DiscrepancyParser {
}
}
- public static boolean buildItemFromFile(DispoItemData dispoItem, String resourceName, InputStream inputStream, final boolean isNewImport, final Date lastUpdate) throws Exception {
+ public static void buildItemFromFile(DispoItemData dispoItem, String resourceName, InputStream inputStream, final boolean isNewImport, final Date lastUpdate, MutableBoolean isSameFile, MutableBoolean isException, MutableString exMessage) throws Exception {
final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
final MutableBoolean isWithinTestPointElement = new MutableBoolean(false);
final MutableString location = new MutableString();
@@ -72,7 +72,6 @@ public class DiscrepancyParser {
final Map<String, Discrepancy> discrepancies = new HashMap<String, Discrepancy>();
final MutableDate scriptRunDate = new MutableDate();
final MutableDate firstTestPointDate = new MutableDate();
- final MutableBoolean stoppedParsing = new MutableBoolean(false);
final MutableString version = new MutableString();
final MutableString totalPoints = new MutableString();
final MutableBoolean firstTestPointResultFound = new MutableBoolean(false);
@@ -263,13 +262,17 @@ public class DiscrepancyParser {
}
} catch (Exception ex) {
if (ex.getMessage().equals("Stopped Parsing")) {
- stoppedParsing.setValue(true);
+ exMessage.setValue("Old File");
+ isSameFile.setValue(true);
+ return;
} else {
- throw ex;
+ isException.setValue(true);
+ exMessage.setValue(ex.getMessage());
+ return;
}
}
- if (!stoppedParsing.getValue()) {
+ if (!isSameFile.getValue()) {
dispoItem.setName(resourceName);
if (abortedFlag.getValue() == null || totalPoints.getValue() == null) {
@@ -313,8 +316,6 @@ public class DiscrepancyParser {
}
dispoItem.setLastUpdate(scriptRunDate.getValue());
}
-
- return stoppedParsing.getValue();
}
private static Discrepancy createAdditionalDiscrepancy(String id, String message) {
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/TmoImporter.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/TmoImporter.java
index e40109b3903..9cfcb1ebd8a 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/TmoImporter.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/TmoImporter.java
@@ -24,10 +24,13 @@ import java.util.regex.Pattern;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoItemData;
+import org.eclipse.osee.disposition.model.DispoSummarySeverity;
import org.eclipse.osee.disposition.model.OperationReport;
import org.eclipse.osee.disposition.rest.DispoImporterApi;
import org.eclipse.osee.disposition.rest.internal.DispoDataFactory;
+import org.eclipse.osee.disposition.rest.internal.importer.DiscrepancyParser.MutableString;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.logger.Log;
@@ -109,16 +112,20 @@ public class TmoImporter implements DispoImporterApi {
try {
inputStream = new FileInputStream(file);
String sanitizedFileName = file.getName().replaceAll("\\..*", "");
-
DispoItemData itemToBuild = new DispoItemData();
+ MutableString message = new MutableString();
+ MutableBoolean isSameFile = new MutableBoolean(false);
+ MutableBoolean isExeptioned = new MutableBoolean(false);
// We already have an item with this name so we now have to check the dates in the parsing
if (exisitingItems.containsKey(sanitizedFileName)) {
DispoItem oldItem = exisitingItems.get(sanitizedFileName);
Date lastUpdate = oldItem.getLastUpdate();
- boolean wasSameFile = DiscrepancyParser.buildItemFromFile(itemToBuild, sanitizedFileName, inputStream,
- false, lastUpdate);
- if (!wasSameFile) {
+ DiscrepancyParser.buildItemFromFile(itemToBuild, sanitizedFileName, inputStream, false, lastUpdate,
+ isSameFile, isExeptioned, message);
+ if (isExeptioned.getValue()) {
+ operationReport.addEntry(sanitizedFileName, message.getValue(), DispoSummarySeverity.ERROR);
+ } else if (!isSameFile.getValue()) {
// Copy Id to tell callee that this is not a new Item
itemToBuild.setGuid(oldItem.getGuid());
itemToBuild.setAnnotationsList(new ArrayList<DispoAnnotationData>());
@@ -131,9 +138,15 @@ public class TmoImporter implements DispoImporterApi {
fromThread.add(itemToBuild);
}
} else {
- DiscrepancyParser.buildItemFromFile(itemToBuild, sanitizedFileName, inputStream, true, new Date());
- dataFactory.initDispoItem(itemToBuild);
- fromThread.add(itemToBuild);
+ DiscrepancyParser.buildItemFromFile(itemToBuild, sanitizedFileName, inputStream, true, new Date(),
+ isSameFile, isExeptioned, message);
+ if (isExeptioned.getValue()) {
+ operationReport.addEntry(sanitizedFileName, message.getValue(), DispoSummarySeverity.ERROR);
+ } else {
+ dataFactory.initDispoItem(itemToBuild);
+ fromThread.add(itemToBuild);
+ }
+
}
} finally {
Lib.close(inputStream);

Back to the top