summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2018-01-04 13:58:14 -0500
committermegumi.telles2018-01-04 13:59:40 -0500
commitc22036ad94963c6e190a79be7a379db437d473b0 (patch)
tree2408cc58f4394e78d1527305f6d3bc0fcf38e780
parent8cdce434d14c654c2240df67df51c6a63b4b0fcb (diff)
downloadorg.eclipse.osee-c22036ad94963c6e190a79be7a379db437d473b0.tar.gz
org.eclipse.osee-c22036ad94963c6e190a79be7a379db437d473b0.tar.xz
org.eclipse.osee-c22036ad94963c6e190a79be7a379db437d473b0.zip
refinement: Add support to find other invalid links0.25.3_REL_2018012519090.25.2.v201801121723-REL0.25.2.v201801051909-NR0.25.2
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java13
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkParser.java22
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/WordMlLinkHandler.java17
3 files changed, 44 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
index 178703af32..3df13c035a 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
@@ -118,11 +118,22 @@ public class FindErroneousEmbeddedLinksBlam extends AbstractBlam {
private void findIncorrectLinks(Artifact artifact, String content, ISheetWriter excelWriter) throws IOException {
Set<String> unknownGuids = new HashSet<>();
- HashCollection<String, MatchRange> links = WordMlLinkHandler.getLinks(content);
+ HashCollection<String, MatchRange> errorMap = new HashCollection<>();
+ HashCollection<String, MatchRange> links = WordMlLinkHandler.getLinks(content, errorMap);
if (!links.isEmpty()) {
unknownGuids.addAll(links.keySet());
}
+ findInvalid(artifact, excelWriter, unknownGuids);
+ unknownGuids.clear();
+ if (!errorMap.isEmpty()) {
+ unknownGuids.addAll(errorMap.keySet());
+ }
+ findInvalid(artifact, excelWriter, unknownGuids);
+
+ }
+
+ private void findInvalid(Artifact artifact, ISheetWriter excelWriter, Set<String> unknownGuids) throws IOException {
Iterator<String> guidIter = unknownGuids.iterator();
while (guidIter.hasNext()) {
// Pointing to itself
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkParser.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkParser.java
index cb2b0232d9..ff4db676ec 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkParser.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkParser.java
@@ -30,20 +30,35 @@ public final class OseeLinkParser {
private static final Matcher PARAMETER_MATCHER = Pattern.compile("([^&]*?)=([^&]*)").matcher("");
private final Map<String, String> parameterMap;
+ private final Map<String, String> errorParamMap;
public OseeLinkParser() {
this.parameterMap = new HashMap<>();
+ this.errorParamMap = new HashMap<>();
}
public void parse(String link) {
parameterMap.clear();
+ errorParamMap.clear();
link = link.replaceAll("&amp;", "&");
boolean wasHandled = parseOldSchoolStyleLinks(link);
+
if (!wasHandled) {
- parseNewStyleRequests(link);
+ wasHandled = parseNewStyleRequests(link);
+ }
+
+ if (!wasHandled) {
+ errorParamMap.put("linkerr", link);
}
}
+ public String getErrLink() {
+ if (errorParamMap != null) {
+ return errorParamMap.get("linkerr");
+ }
+ return null;
+ }
+
public BranchId getId() throws OseeCoreException {
BranchId branchUuid = BranchId.SENTINEL;
if (parameterMap != null) {
@@ -85,7 +100,8 @@ public final class OseeLinkParser {
* Process new style requests are of the following format: http://127.0.0.1:<port>/
* <ProcessType>?key1=value1&key2=value2...&key3=value3
*/
- private void parseNewStyleRequests(String link) {
+ private boolean parseNewStyleRequests(String link) {
+ boolean wasHandled = false;
String noHostStr = link.replaceFirst("^http:\\/\\/(.*?)\\/", "/");
Matcher matcher = LINK_CONTEXT_MATCHER;
matcher.reset(noHostStr);
@@ -94,8 +110,10 @@ public final class OseeLinkParser {
dataMatcher.reset(matcher.group(2));
while (dataMatcher.find()) {
parameterMap.put(dataMatcher.group(1), dataMatcher.group(2));
+ wasHandled = true;
}
}
+ return wasHandled;
}
/**
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/WordMlLinkHandler.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/WordMlLinkHandler.java
index e2705a9f3e..2677b2e3b2 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/WordMlLinkHandler.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/WordMlLinkHandler.java
@@ -102,7 +102,7 @@ public class WordMlLinkHandler {
public static String unlink(LinkType sourceLinkType, Artifact source, String content) throws OseeCoreException {
LinkType linkType = checkLinkType(sourceLinkType);
String modified = content;
- HashCollection<String, MatchRange> matchMap = parseOseeWordMLLinks(content);
+ HashCollection<String, MatchRange> matchMap = parseOseeWordMLLinks(content, new HashCollection<>());
if (!matchMap.isEmpty()) {
modified = modifiedContent(linkType, source, content, matchMap, true, null);
}
@@ -125,7 +125,7 @@ public class WordMlLinkHandler {
LinkType linkType = checkLinkType(destLinkType);
String modified = content;
- HashCollection<String, MatchRange> matchMap = getLinks(content);
+ HashCollection<String, MatchRange> matchMap = getLinks(content, new HashCollection<>());
if (!matchMap.isEmpty()) {
modified = modifiedContent(linkType, source, content, matchMap, false, unknownGuids, presentationType);
unknownGuids.addAll(matchMap.keySet());
@@ -137,9 +137,9 @@ public class WordMlLinkHandler {
return modified;
}
- public static HashCollection<String, MatchRange> getLinks(String content) {
+ public static HashCollection<String, MatchRange> getLinks(String content, HashCollection<String, MatchRange> errorMap) {
// Detect legacy links
- HashCollection<String, MatchRange> matchMap = parseOseeWordMLLinks(content);
+ HashCollection<String, MatchRange> matchMap = parseOseeWordMLLinks(content, errorMap);
// Detect new style link marker
OSEE_LINK_PATTERN.reset(content);
@@ -147,6 +147,8 @@ public class WordMlLinkHandler {
String guid = OSEE_LINK_PATTERN.group(1);
if (Strings.isValid(guid)) {
matchMap.put(guid, new MatchRange(OSEE_LINK_PATTERN.start(), OSEE_LINK_PATTERN.end()));
+ } else {
+ errorMap.put(guid, new MatchRange(WORDML_LINK.start(), WORDML_LINK.end()));
}
}
OSEE_LINK_PATTERN.reset();
@@ -158,7 +160,7 @@ public class WordMlLinkHandler {
*
* @return locations where WordMlLinks were found grouped by GUID
*/
- private static HashCollection<String, MatchRange> parseOseeWordMLLinks(String content) throws OseeCoreException {
+ private static HashCollection<String, MatchRange> parseOseeWordMLLinks(String content, HashCollection<String, MatchRange> errorMap) throws OseeCoreException {
HashCollection<String, MatchRange> matchMap = new HashCollection<>();
OseeLinkParser linkParser = new OseeLinkParser();
WORDML_LINK.reset(content);
@@ -169,6 +171,8 @@ public class WordMlLinkHandler {
String guid = linkParser.getGuid();
if (Strings.isValid(guid)) {
matchMap.put(guid, new MatchRange(WORDML_LINK.start(), WORDML_LINK.end()));
+ } else {
+ errorMap.put(linkParser.getErrLink(), new MatchRange(WORDML_LINK.start(), WORDML_LINK.end()));
}
}
}
@@ -182,6 +186,9 @@ public class WordMlLinkHandler {
String guid = linkParser.getGuid();
if (Strings.isValid(guid)) {
matchMap.put(guid, new MatchRange(HYPERLINK_PATTERN.start(), HYPERLINK_PATTERN.end()));
+ } else {
+ errorMap.put(linkParser.getErrLink(),
+ new MatchRange(HYPERLINK_PATTERN.start(), HYPERLINK_PATTERN.end()));
}
}
}