summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-08-10 05:43:29 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-08-10 05:43:29 +0000
commit72d2eeb858c510bb2ae39fca46ec392d7d1c37c1 (patch)
tree7bde8e971bc6996a0438b83c4f994d1a776daaa7 /branches/sca-java-1.x/modules
parentde4541fd654973cf0ccdce916e6b9a6b37b933c6 (diff)
Minor format based on Tuscany code style
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@802657 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules')
-rw-r--r--branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/Searcher.java808
1 files changed, 382 insertions, 426 deletions
diff --git a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/Searcher.java b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/Searcher.java
index 0fb1812975..f2701c1f73 100644
--- a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/Searcher.java
+++ b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/Searcher.java
@@ -23,480 +23,436 @@ import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
@Scope("COMPOSITE")
-@Service(interfaces = { ItemCollection.class, LocalItemCollection.class })
+@Service(interfaces = {ItemCollection.class, LocalItemCollection.class})
public class Searcher implements ItemCollection, LocalItemCollection {
+ static char[] characters = {'\u0001'/*  */, '\u0003'/*  */, '\u0004'/*  */,};
+
+ final private static String HTML_NEW_LINE = "<BR/>";
+
+ final private static String PATH_SEPARATOR = "/";
+
+ final private static int MAX_CONTENT_LINE_WIDTH = 300;
+
+ final private static String HIGHLIGHT_START = "<font color='#FF0000'>";
+
+ final private static String HIGHLIGHT_END = "</font>";
+
+ @Reference
+ public ContributionsReader contributionReader;
+
+ @Reference
+ public LocalItemCollection contributionCollection;
+
+ @Reference
+ public DomainSearch domainSearch;
+
+ private int elementCounter;
+
+ public void delete(String key) throws NotFoundException {
+ System.out.println("delete");
+ }
+
+ private static void startIndentation(int size, StringWriter writer) {
+ writer.write("<p style='margin-top:0em;margin-bottom:0em;padding:0em;margin-left:");
+ writer.write(Integer.toString(size));
+ writer.write("em'>");
+
+ }
+
+ private static void endIndentation(StringWriter writer) {
+ writer.write("</p>");
+ }
+
+ public Item get(String key) throws NotFoundException {
+ try {
+ if (key.startsWith("highlight")) {
+ int lastSemicolonIndex = key.lastIndexOf(";");
+ String artifact = key.substring(lastSemicolonIndex + 1);
+ int secondLastSemicolonIndex = key.lastIndexOf(";", lastSemicolonIndex - 1);
+ String contribution = key.substring(secondLastSemicolonIndex + 1, lastSemicolonIndex);
+ String query = key.substring("highlight".length(), secondLastSemicolonIndex);
+
+ return highlightArtifact(contribution, artifact, query);
+
+ } else if (key.startsWith("query")) {
+ return executeQuery(key.substring("query".length()));
+
+ } else {
+ throw new NotFoundException("Invalid operation!");
+ }
+ } catch (Exception t) {
+ if (t instanceof NotFoundException) {
+ throw (NotFoundException)t;
+ }
+ throw new NotFoundException("Internal error!");
+ }
+
+ }
+
+ private Item highlightArtifact(String contribution, String artifact, String query) throws NotFoundException {
+
+ // Item item = this.contributionCollection.get(contribution);
+ //
+ // if (item == null) {
+ // throw new NotFoundException("contribution not found: " +
+ // contribution);
+ // }
+ //
+ // String location = item.getAlternate();
+ //
+ // if (location.endsWith(".jar") || location.endsWith(".zip")) {
+ // location = "jar:" + (location.startsWith("file:") ? "" : "file:") +
+ // location + '!' + (artifact.startsWith("/") ? "" : "/") + artifact;
+ //
+ // } else {
+ // location += (location.endsWith("/") ? "" : "/") + artifact;
+ // }
+ //
+ // try {
+ // Reader reader = new InputStreamReader(new
+ // URL(location).openStream());
+ // StringBuilder sb = new StringBuilder();
+ // int c;
+ //
+ // // TODO: load the chars into an array buffer instead of one
+ // // at a
+ // // time
+ // while ((c = reader.read()) != -1) {
+ // char character = (char) c;
+ //
+ // if (!Character.isIdentifierIgnorable(character)) {
+ // sb.append(character);
+ // }
+ //
+ // }
+ //
+ // String highlightedText =
+ // this.domainSearch.highlight(SearchFields.FILE_CONTENT_FIELD,
+ // sb.toString(), query);
+ // highlightedText =
+ // HighlightingUtil.replaceHighlightMarkupBy(highlightedText,
+ // HIGHLIGHT_START, HIGHLIGHT_END);
+ //
+ // item = new Item();
+ // item.setTitle("Highlighted Artifact");
+ // item.setContents(highlightedText);
+ //
+ // return item;
+ //
+ // } catch (Exception e) {
+ // throw new NotFoundException("Could not highlight artifact: " +
+ // e.getMessage(), e);
+ // }
+
+ return null;
+
+ }
+
+ private Item executeQuery(String query) throws NotFoundException {
+
+ if (!this.domainSearch.indexExists()) {
+ Contribution[] contributions = this.contributionReader.readContributions();
+
+ for (Contribution contribution : contributions) {
+ if (!contribution.getURI().equals(DomainManagerUtil.DEPLOYMENT_CONTRIBUTION_URI)) {
+ this.domainSearch.contributionUpdated(contribution, contribution);
+ }
+ }
+ }
+
+ Result[] results;
+ try {
+ results = this.domainSearch.parseAndSearch(query, true);
+ } catch (Exception e1) {
+ throw new NotFoundException("Exception while searching: " + e1.getMessage(), e1);
+ }
+
+ Item item = new Item();
+ item.setTitle("Results");
+
+ StringWriter sw = new StringWriter();
+ this.elementCounter = 0;
+
+ if (results.length > 0) {
+ for (Result result : results) {
+ try {
+ writeToHTML(0, result, sw);
+ } catch (IOException e) {
+ // ignore result
+ }
+ }
+
+ String contents = HighlightingUtil.replaceHighlightMarkupBy(sw.getBuffer(), HIGHLIGHT_START, HIGHLIGHT_END);
+
+ item.setContents(replaceAll(contents, 40) + "end");
+
+ } else {
+ item.setContents("No results match: <u>" + query + "</u>");
+ }
+
+ System.out.println(item.getContents());
+
+ return item;
+
+ }
+
+ //
+ // private static String replaceAll(CharSequence c) {
+ // StringBuilder sb = new StringBuilder();
+ // // HashSet<Character> set = new HashSet<Character>();
+ // Arrays.sort(characters);
+ // // int start = 0, end = 4;
+ // // char[] chars = new char[end - start];
+ // // System.arraycopy(characters, start, chars, 0, end - start);
+ //
+ // for (int i = 0 ; i < c.length() ; i++) {
+ // char actual = c.charAt(i);
+ //
+ // //if (Arrays.binarySearch(characters, actual) < 0) {
+ //
+ // if (!Character.isIdentifierIgnorable(actual)) {
+ // sb.append(actual);
+ //
+ // } else {
+ // //sb.append('0');
+ // }
+ //
+ // }
+ // //
+ // // System.out.println("set-size: " + set.size());
+ // // for (char character : set) {
+ // // System.out.print(",");
+ // // System.out.print((int) character);
+ // // System.out.print("/*" + character + "*/");
+ // //
+ // // }
+ // //
+ // // System.out.println();
+ //
+ // return sb.toString();
+ //
+ // }
+
+ private static String replaceAll(CharSequence c, int less) {
+ StringBuilder sb = new StringBuilder();
+ // HashSet<Character> set = new HashSet<Character>();
+ Arrays.sort(characters);
+ // int start = 0, end = 4;
+ // char[] chars = new char[end - start];
+ // System.arraycopy(characters, start, chars, 0, end - start);
+
+ for (int i = 0; i < c.length(); i++) {
+ char actual = c.charAt(i);
+
+ // if (Arrays.binarySearch(characters, actual) < 0) {
+
+ // if (actual != '\u000b' && actual != '\u0020' &&
+ // actual != '\u000c' && actual != '\u0009' &&
+ // actual != ')' && actual != '(') {
+
+ if (actual > less || actual == '&'
+ || actual == '#'
+ || actual == '\''
+ || actual == ' '
+ || actual == '%'
+ || actual == ':'
+ || actual == '('
+ || actual == ')'
+ || actual == '"') {
+
+ sb.append(actual);
+
+ } else {
+ // sb.append('0');
+ }
+
+ }
+ //
+ // System.out.println("set-size: " + set.size());
+ // for (char character : set) {
+ // System.out.print(",");
+ // System.out.print((int) character);
+ // System.out.print("/*" + character + "*/");
+ //
+ // }
+ //
+ // System.out.println();
+
+ return sb.toString();
- static char[] characters = { '\u0001'/*  */, '\u0003'/*  */,
- '\u0004'/*  */, };
+ }
- final private static String HTML_NEW_LINE = "<BR/>";
+ private static String getIconLocationForResult(Result result) {
- final private static String PATH_SEPARATOR = "/";
+ if (SearchFields.COMPONENT_FIELD.equals(result.getField())) {
+ return "icons/component.png' title='Component";
+
+ } else if (SearchFields.COMPOSITE_FIELD.equals(result.getField())) {
+ return "icons/composite.png' title='Composite";
- final private static int MAX_CONTENT_LINE_WIDTH = 300;
+ } else if (SearchFields.ARTIFACT_FIELD.equals(result.getField())) {
+ return "icons/artifact.png' title='Artifact";
+ }
+
+ return "icons/feed-icon.png";
+
+ }
+
+ private static void writeResultIcon(Writer writer, Result result) throws IOException {
+ writer.write("<img src='");
+ writer.write(getIconLocationForResult(result));
+ writer.write("'/> ");
- final private static String HIGHLIGHT_START = "<font color='#FF0000'>";
-
- final private static String HIGHLIGHT_END = "</font>";
-
- @Reference
- public ContributionsReader contributionReader;
-
- @Reference
- public LocalItemCollection contributionCollection;
-
- @Reference
- public DomainSearch domainSearch;
-
- private int elementCounter;
-
- public void delete(String key) throws NotFoundException {
- System.out.println("delete");
- }
-
- private static void startIndentation(int size, StringWriter writer) {
- writer
- .write("<p style='margin-top:0em;margin-bottom:0em;padding:0em;margin-left:");
- writer.write(Integer.toString(size));
- writer.write("em'>");
-
- }
-
- private static void endIndentation(StringWriter writer) {
- writer.write("</p>");
- }
-
- public Item get(String key) throws NotFoundException {
-
- try {
-
- if (key.startsWith("highlight")) {
- int lastSemicolonIndex = key.lastIndexOf(";");
- String artifact = key.substring(lastSemicolonIndex + 1);
- int secondLastSemicolonIndex = key.lastIndexOf(";",
- lastSemicolonIndex - 1);
- String contribution = key.substring(
- secondLastSemicolonIndex + 1, lastSemicolonIndex);
- String query = key.substring("highlight".length(),
- secondLastSemicolonIndex);
+ }
- return highlightArtifact(contribution, artifact, query);
+ private static Result writeFileContentResultToHTML(int indentation, Result result, StringWriter writer)
+ throws IOException {
- } else if (key.startsWith("query")) {
- return executeQuery(key.substring("query".length()));
-
- } else {
- throw new NotFoundException("Invalid operation!");
- }
+ Map<String, Result> contents = result.getContents();
+ writeResultIcon(writer, result);
- } catch (Exception t) {
+ if (contents.size() == 1 && SearchFields.ARTIFACT_FIELD.equals(contents.values().iterator().next().getField())) {
- if (t instanceof NotFoundException) {
- throw (NotFoundException) t;
- }
+ writer.write(result.getValue());
+ contents = result.getContents();
- throw new NotFoundException("Internal error!");
+ while (contents.size() == 1 && SearchFields.ARTIFACT_FIELD.equals(contents.values().iterator().next()
+ .getField())) {
- }
+ result = contents.values().iterator().next();
- }
+ writer.write(PATH_SEPARATOR);
+ StringEscapeUtils.escapeHtml(writer, result.getValue());
- private Item highlightArtifact(String contribution, String artifact,
- String query) throws NotFoundException {
+ contents = result.getContents();
- // Item item = this.contributionCollection.get(contribution);
- //
- // if (item == null) {
- // throw new NotFoundException("contribution not found: " +
- // contribution);
- // }
- //
- // String location = item.getAlternate();
- //
- // if (location.endsWith(".jar") || location.endsWith(".zip")) {
- // location = "jar:" + (location.startsWith("file:") ? "" : "file:") +
- // location + '!' + (artifact.startsWith("/") ? "" : "/") + artifact;
- //
- // } else {
- // location += (location.endsWith("/") ? "" : "/") + artifact;
- // }
- //
- // try {
- // Reader reader = new InputStreamReader(new
- // URL(location).openStream());
- // StringBuilder sb = new StringBuilder();
- // int c;
- //
- // // TODO: load the chars into an array buffer instead of one
- // // at a
- // // time
- // while ((c = reader.read()) != -1) {
- // char character = (char) c;
- //
- // if (!Character.isIdentifierIgnorable(character)) {
- // sb.append(character);
- // }
- //
- // }
- //
- // String highlightedText =
- // this.domainSearch.highlight(SearchFields.FILE_CONTENT_FIELD,
- // sb.toString(), query);
- // highlightedText =
- // HighlightingUtil.replaceHighlightMarkupBy(highlightedText,
- // HIGHLIGHT_START, HIGHLIGHT_END);
- //
- // item = new Item();
- // item.setTitle("Highlighted Artifact");
- // item.setContents(highlightedText);
- //
- // return item;
- //
- // } catch (Exception e) {
- // throw new NotFoundException("Could not highlight artifact: " +
- // e.getMessage(), e);
- // }
-
- return null;
-
- }
-
- private Item executeQuery(String query) throws NotFoundException {
-
- if (!this.domainSearch.indexExists()) {
-
- Contribution[] contributions = this.contributionReader
- .readContributions();
-
- for (Contribution contribution : contributions) {
-
- if (!contribution.getURI().equals(
- DomainManagerUtil.DEPLOYMENT_CONTRIBUTION_URI)) {
-
- this.domainSearch.contributionUpdated(contribution,
- contribution);
-
- }
-
- }
-
- }
-
- Result[] results;
- try {
- results = this.domainSearch.parseAndSearch(query, true);
-
- } catch (Exception e1) {
-
- throw new NotFoundException("Exception while searching: "
- + e1.getMessage(), e1);
-
- }
-
- Item item = new Item();
- item.setTitle("Results");
-
- StringWriter sw = new StringWriter();
- this.elementCounter = 0;
-
- if (results.length > 0) {
-
- for (Result result : results) {
-
- try {
- writeToHTML(0, result, sw);
-
- } catch (IOException e) {
- // ignore result
- }
-
- }
-
- String contents = HighlightingUtil.replaceHighlightMarkupBy(sw
- .getBuffer(), HIGHLIGHT_START, HIGHLIGHT_END);
-
- item.setContents(replaceAll(contents, 40) + "end");
-
- } else {
- item.setContents("No results match: <u>" + query + "</u>");
- }
-
- System.out.println(item.getContents());
-
- return item;
-
- }
-
- //
- // private static String replaceAll(CharSequence c) {
- // StringBuilder sb = new StringBuilder();
- // // HashSet<Character> set = new HashSet<Character>();
- // Arrays.sort(characters);
- // // int start = 0, end = 4;
- // // char[] chars = new char[end - start];
- // // System.arraycopy(characters, start, chars, 0, end - start);
- //
- // for (int i = 0 ; i < c.length() ; i++) {
- // char actual = c.charAt(i);
- //
- // //if (Arrays.binarySearch(characters, actual) < 0) {
- //
- // if (!Character.isIdentifierIgnorable(actual)) {
- // sb.append(actual);
- //
- // } else {
- // //sb.append('0');
- // }
- //
- // }
- // //
- // // System.out.println("set-size: " + set.size());
- // // for (char character : set) {
- // // System.out.print(",");
- // // System.out.print((int) character);
- // // System.out.print("/*" + character + "*/");
- // //
- // // }
- // //
- // // System.out.println();
- //
- // return sb.toString();
- //
- // }
+ }
- private static String replaceAll(CharSequence c, int less) {
- StringBuilder sb = new StringBuilder();
- // HashSet<Character> set = new HashSet<Character>();
- Arrays.sort(characters);
- // int start = 0, end = 4;
- // char[] chars = new char[end - start];
- // System.arraycopy(characters, start, chars, 0, end - start);
+ } else {
+ StringEscapeUtils.escapeHtml(writer, result.getValue());
+ }
- for (int i = 0; i < c.length(); i++) {
- char actual = c.charAt(i);
+ return result;
- // if (Arrays.binarySearch(characters, actual) < 0) {
+ }
- // if (actual != '\u000b' && actual != '\u0020' &&
- // actual != '\u000c' && actual != '\u0009' &&
- // actual != ')' && actual != '(') {
+ private static String removeHighlighting(String text) {
+ return HighlightingUtil.replaceHighlightMarkupBy(text, "", "");
+ }
- if (actual > less || actual == '&' || actual == '#'
- || actual == '\'' || actual == ' ' || actual == '%'
- || actual == ':' || actual == '(' || actual == ')'
- || actual == '"') {
+ private static void writeResultName(Result result, StringWriter writer) throws IOException {
- sb.append(actual);
-
- } else {
- // sb.append('0');
- }
-
- }
- //
- // System.out.println("set-size: " + set.size());
- // for (char character : set) {
- // System.out.print(",");
- // System.out.print((int) character);
- // System.out.print("/*" + character + "*/");
- //
- // }
- //
- // System.out.println();
-
- return sb.toString();
-
- }
-
- private static String getIconLocationForResult(Result result) {
-
- if (SearchFields.COMPONENT_FIELD.equals(result.getField())) {
- return "icons/component.png' title='Component";
-
- } else if (SearchFields.COMPOSITE_FIELD.equals(result.getField())) {
- return "icons/composite.png' title='Composite";
-
- } else if (SearchFields.ARTIFACT_FIELD.equals(result.getField())) {
- return "icons/artifact.png' title='Artifact";
- }
-
- return "icons/feed-icon.png";
-
- }
-
- private static void writeResultIcon(Writer writer, Result result)
- throws IOException {
- writer.write("<img src='");
- writer.write(getIconLocationForResult(result));
- writer.write("'/> ");
-
- }
-
- private static Result writeFileContentResultToHTML(int indentation,
- Result result, StringWriter writer) throws IOException {
-
- Map<String, Result> contents = result.getContents();
- writeResultIcon(writer, result);
+ if (SearchFields.CONTRIBUTION_FIELD.equals(result.getField())) {
+ writer.write("<a href='/contribution/");
+ writer.write(removeHighlighting(result.getValue()));
+ writer.write("'>");
+ writer.write(StringEscapeUtils.escapeHtml(result.getValue()));
+ writer.write("</a>");
- if (contents.size() == 1
- && SearchFields.ARTIFACT_FIELD.equals(contents.values()
- .iterator().next().getField())) {
+ } else if (SearchFields.COMPOSITE_FIELD.equals(result.getField())) {
+ writer.write("<a href='/composite-source/composite:");
+ writer.write(getContributionURI(result));
+ writer.write(';');
+ writer.write(removeHighlighting(result.getValue()));
+ writer.write("'>");
+ writer.write(StringEscapeUtils.escapeHtml(result.getValue()));
+ writer.write("</a>");
- writer.write(result.getValue());
- contents = result.getContents();
+ } else {
+ StringEscapeUtils.escapeHtml(writer, result.getValue());
+ }
- while (contents.size() == 1
- && SearchFields.ARTIFACT_FIELD.equals(contents.values()
- .iterator().next().getField())) {
+ }
- result = contents.values().iterator().next();
+ private static String getContributionURI(Result result) {
- writer.write(PATH_SEPARATOR);
- StringEscapeUtils.escapeHtml(writer, result.getValue());
+ if (result == null) {
+ return "";
- contents = result.getContents();
+ } else if (SearchFields.CONTRIBUTION_FIELD.equals(result.getField())) {
+ return removeHighlighting(result.getValue());
- }
+ } else {
+ return getContributionURI(result.getContainer());
+ }
- } else {
- StringEscapeUtils.escapeHtml(writer, result.getValue());
- }
+ }
- return result;
+ private void writeToHTML(int indentation, Result result, StringWriter writer) throws IOException {
- }
+ startIndentation(indentation++, writer);
+ String field = result.getField();
- private static String removeHighlighting(String text) {
- return HighlightingUtil.replaceHighlightMarkupBy(text, "", "");
- }
+ if (SearchFields.FILE_CONTENT_FIELD.equals(field)) {
+ String content = result.getValue();
- private static void writeResultName(Result result, StringWriter writer)
- throws IOException {
+ if (content != null && content.length() > 0 && DomainSearchFormatter.isHighlighted(content)) {
- if (SearchFields.CONTRIBUTION_FIELD.equals(result.getField())) {
- writer.write("<a href='/contribution/");
- writer.write(removeHighlighting(result.getValue()));
- writer.write("'>");
- writer.write(StringEscapeUtils.escapeHtml(result.getValue()));
- writer.write("</a>");
+ writer.write(HTML_NEW_LINE);
- } else if (SearchFields.COMPOSITE_FIELD.equals(result.getField())) {
- writer.write("<a href='/composite-source/composite:");
- writer.write(getContributionURI(result));
- writer.write(';');
- writer.write(removeHighlighting(result.getValue()));
- writer.write("'>");
- writer.write(StringEscapeUtils.escapeHtml(result.getValue()));
- writer.write("</a>");
+ this.elementCounter++;
+ writer.write("<div style='margin-top:0em;margin-left:");
+ writer.write(Integer.toString(indentation));
+ writer
+ .write("em;background-color:#FFE175;max-width:100%;border-style:dashed;border-width:1px;padding:5px'>" + "<p style='margin:0px;padding:0px;font-size:70%'>"
+ + "<a style='margin:0px;padding:0px' href='#filecontent");
- } else {
- StringEscapeUtils.escapeHtml(writer, result.getValue());
- }
+ writer.write(Integer.toString(this.elementCounter));
- }
+ String contributionPlusArtifact =
+ getContributionURI(result) + ";" + removeHighlighting(result.getContainer().getValue());
- private static String getContributionURI(Result result) {
+ // writer.write("' onclick='search");
+ // writer.write("'>view all</a>&nbsp;&nbsp;<a href='/files/contribution=");
+ writer.write("' onclick='getHighlighted(\"");
+ writer.write(contributionPlusArtifact);
+ writer.write("\")'>view all</a>&nbsp;&nbsp;<a href='/files/contribution=");
- if (result == null) {
- return "";
+ writer.write(contributionPlusArtifact);
+ writer.write("'>download</a></p><p style='margin:8px 0px 0px 0px;padding:0px'>");
- } else if (SearchFields.CONTRIBUTION_FIELD.equals(result.getField())) {
- return removeHighlighting(result.getValue());
+ int i = 0;
+ while (i < content.length()) {
+ StringEscapeUtils.escapeHtml(writer, content.substring(i, Math.min(i + MAX_CONTENT_LINE_WIDTH,content.length())));
+ writer.write(HTML_NEW_LINE);
+ i += MAX_CONTENT_LINE_WIDTH;
+ }
- } else {
- return getContributionURI(result.getContainer());
- }
+ writer.write("</p></div>");
- }
+ }
- private void writeToHTML(int indentation, Result result, StringWriter writer)
- throws IOException {
+ } else if (SearchFields.ARTIFACT_FIELD.equals(field)) {
+ result = writeFileContentResultToHTML(indentation, result, writer);
+ } else {
+ writeResultIcon(writer, result);
+ writeResultName(result, writer);
+ }
- startIndentation(indentation++, writer);
- String field = result.getField();
+ endIndentation(writer);
- if (SearchFields.FILE_CONTENT_FIELD.equals(field)) {
- String content = result.getValue();
+ for (Result actualResult : result.getContents().values()) {
+ writeToHTML(indentation, actualResult, writer);
+ }
+ }
- if (content != null && content.length() > 0
- && DomainSearchFormatter.isHighlighted(content)) {
+ public Entry<String, Item>[] getAll() {
+ System.out.println("getAll");
+ return null;
+ }
- writer.write(HTML_NEW_LINE);
+ public String post(String key, Item item) {
+ System.out.println("post");
+ return null;
+ }
- this.elementCounter++;
- writer.write("<div style='margin-top:0em;margin-left:");
- writer.write(Integer.toString(indentation));
- writer
- .write("em;background-color:#FFE175;max-width:100%;border-style:dashed;border-width:1px;padding:5px'>"
- + "<p style='margin:0px;padding:0px;font-size:70%'>"
- + "<a style='margin:0px;padding:0px' href='#filecontent");
+ public void put(String key, Item item) throws NotFoundException {
+ System.out.println("put");
+ }
- writer.write(Integer.toString(this.elementCounter));
-
- String contributionPlusArtifact = getContributionURI(result)
- + ";"
- + removeHighlighting(result.getContainer().getValue());
-
- // writer.write("' onclick='search");
- // writer.write("'>view all</a>&nbsp;&nbsp;<a href='/files/contribution=");
- writer.write("' onclick='getHighlighted(\"");
- writer.write(contributionPlusArtifact);
- writer
- .write("\")'>view all</a>&nbsp;&nbsp;<a href='/files/contribution=");
-
- writer.write(contributionPlusArtifact);
- writer
- .write("'>download</a></p><p style='margin:8px 0px 0px 0px;padding:0px'>");
-
- int i = 0;
- while (i < content.length()) {
- StringEscapeUtils.escapeHtml(writer, content.substring(i,
- Math.min(i + MAX_CONTENT_LINE_WIDTH, content
- .length())));
- writer.write(HTML_NEW_LINE);
- i += MAX_CONTENT_LINE_WIDTH;
-
- }
-
- writer.write("</p></div>");
-
- }
-
- } else if (SearchFields.ARTIFACT_FIELD.equals(field)) {
- result = writeFileContentResultToHTML(indentation, result, writer);
-
- } else {
-
- writeResultIcon(writer, result);
- writeResultName(result, writer);
-
- }
-
- endIndentation(writer);
-
- for (Result actualResult : result.getContents().values()) {
- writeToHTML(indentation, actualResult, writer);
- }
-
- }
-
- public Entry<String, Item>[] getAll() {
- System.out.println("getAll");
- return null;
- }
-
- public String post(String key, Item item) {
- System.out.println("post");
- return null;
- }
-
- public void put(String key, Item item) throws NotFoundException {
- System.out.println("put");
- }
-
- public Entry<String, Item>[] query(String queryString) {
- System.out.println("query");
- return null;
- }
+ public Entry<String, Item>[] query(String queryString) {
+ System.out.println("query");
+ return null;
+ }
}