committing domain-manager changes from patch tuscany_2552_phillipe_ramalho_08_16_2009.patch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6a8186a0b6
commit
a4f020f2df
10 changed files with 294 additions and 175 deletions
branches/sca-java-1.x/modules/domain-manager/src/main
java/org/apache/tuscany/sca/domain/manager/impl
resources
|
@ -222,7 +222,12 @@ public class ContributionCollectionImpl implements ItemCollection, LocalItemColl
|
|||
// Write the workspace
|
||||
writeWorkspace(workspace);
|
||||
|
||||
// add it to the search index, contributionUpdated is called to guarantee
|
||||
// only one contribution with the same URI in the index
|
||||
this.domainSearch.contributionUpdated(contribution, contribution);
|
||||
|
||||
return key;
|
||||
|
||||
}
|
||||
|
||||
public void put(String key, Item item) throws NotFoundException {
|
||||
|
@ -256,11 +261,18 @@ public class ContributionCollectionImpl implements ItemCollection, LocalItemColl
|
|||
Workspace workspace = readWorkspace();
|
||||
List<Contribution> contributions = workspace.getContributions();
|
||||
for (int i = 0, n = contributions.size(); i < n; i++) {
|
||||
if (contributions.get(i).getURI().equals(key)) {
|
||||
|
||||
Contribution contribution = contributions.get(i);
|
||||
|
||||
if (contribution.getURI().equals(key)) {
|
||||
contributions.remove(i);
|
||||
|
||||
|
||||
// Write the workspace
|
||||
writeWorkspace(workspace);
|
||||
|
||||
// delete it from the search index
|
||||
this.domainSearch.contributionRemoved(contribution);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import javax.xml.stream.XMLStreamWriter;
|
|||
import org.apache.tuscany.sca.assembly.AssemblyFactory;
|
||||
import org.apache.tuscany.sca.assembly.Composite;
|
||||
import org.apache.tuscany.sca.assembly.xml.Constants;
|
||||
import org.apache.tuscany.sca.contribution.Contribution;
|
||||
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
|
||||
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
|
||||
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
|
||||
|
@ -89,12 +90,18 @@ public class DeployedCompositeCollectionImpl implements ItemCollection, LocalIte
|
|||
@Reference
|
||||
public LocalItemCollection deployableCollection;
|
||||
|
||||
@Reference
|
||||
public DomainSearch domainSearch;
|
||||
|
||||
@Reference(required=false)
|
||||
public LocalItemCollection processCollection;
|
||||
|
||||
@Reference
|
||||
public DomainManagerConfiguration domainManagerConfiguration;
|
||||
|
||||
@Reference
|
||||
public ContributionsReader contributionReader;
|
||||
|
||||
private ModelFactoryExtensionPoint modelFactories;
|
||||
private AssemblyFactory assemblyFactory;
|
||||
private StAXArtifactProcessor<Composite> compositeProcessor;
|
||||
|
@ -214,6 +221,8 @@ public class DeployedCompositeCollectionImpl implements ItemCollection, LocalIte
|
|||
// Write the composite collection
|
||||
writeCompositeCollection(compositeCollection);
|
||||
|
||||
updateDomainSearch(contributionURI);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -238,6 +247,8 @@ public class DeployedCompositeCollectionImpl implements ItemCollection, LocalIte
|
|||
// Write the domain composite
|
||||
writeCompositeCollection(compositeCollection);
|
||||
|
||||
updateDomainSearch(contributionURI);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +278,10 @@ public class DeployedCompositeCollectionImpl implements ItemCollection, LocalIte
|
|||
|
||||
// Write the domain composite
|
||||
writeCompositeCollection(compositeCollection);
|
||||
updateDomainSearch(contributionURI);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,6 +300,22 @@ public class DeployedCompositeCollectionImpl implements ItemCollection, LocalIte
|
|||
}
|
||||
}
|
||||
|
||||
private void updateDomainSearch(String contributionURI) {
|
||||
Contribution[] contributions = this.contributionReader.readContributions();
|
||||
|
||||
for (Contribution contribution : contributions) {
|
||||
|
||||
if (contributionURI.equals(contribution.getURI())) {
|
||||
this.domainSearch.contributionUpdated(contribution, contribution);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Entry<String, Item>[] query(String queryString) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.apache.tuscany.sca.domain.manager.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -64,7 +67,9 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
}
|
||||
|
||||
public Item get(String key) throws NotFoundException {
|
||||
|
||||
try {
|
||||
|
||||
if (key.startsWith("highlight")) {
|
||||
int lastSemicolonIndex = key.lastIndexOf(";");
|
||||
String artifact = key.substring(lastSemicolonIndex + 1);
|
||||
|
@ -80,6 +85,7 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
} else {
|
||||
throw new NotFoundException("Invalid operation!");
|
||||
}
|
||||
|
||||
} catch (Exception t) {
|
||||
if (t instanceof NotFoundException) {
|
||||
throw (NotFoundException)t;
|
||||
|
@ -91,61 +97,59 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
|
||||
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);
|
||||
// }
|
||||
Item item = this.contributionCollection.get(contribution);
|
||||
|
||||
return null;
|
||||
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 = highlightedText.replaceAll("\n", "<br/>");
|
||||
highlightedText = highlightedText.replaceAll(" ", " ");
|
||||
highlightedText =
|
||||
HighlightingUtil.replaceHighlightMarkupBy(highlightedText, HIGHLIGHT_START, HIGHLIGHT_END);
|
||||
|
||||
item = new Item();
|
||||
item.setTitle(contribution + ";" + artifact);
|
||||
item.setContents(highlightedText);
|
||||
|
||||
return item;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new NotFoundException("Could not highlight artifact: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Item executeQuery(String query) throws NotFoundException {
|
||||
|
@ -184,7 +188,7 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
|
||||
String contents = HighlightingUtil.replaceHighlightMarkupBy(sw.getBuffer(), HIGHLIGHT_START, HIGHLIGHT_END);
|
||||
|
||||
item.setContents(replaceAll(contents, 40) + "end");
|
||||
item.setContents(replaceAll(contents, 40));
|
||||
|
||||
} else {
|
||||
item.setContents("No results match: <u>" + query + "</u>");
|
||||
|
@ -196,43 +200,6 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
// 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>();
|
||||
|
@ -387,37 +354,44 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
String content = result.getValue();
|
||||
|
||||
if (content != null && content.length() > 0 && DomainSearchFormatter.isHighlighted(content)) {
|
||||
|
||||
String contributionPlusArtifact =
|
||||
getContributionURI(result) + ";" + removeHighlighting(result.getContainer().getValue());
|
||||
|
||||
writer.write(HTML_NEW_LINE);
|
||||
|
||||
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'>");
|
||||
writer.write("em;background-color:#FFE175;max-width:100%;border-style:dashed;border-width:1px;padding:5px' id='");
|
||||
writer.write(contributionPlusArtifact);
|
||||
writer.write("'>");
|
||||
writer.write("<p style='margin:0px;padding:0px;font-size:70%'>");
|
||||
//+ "<a style='margin:0px;padding:0px' href='#filecontent");
|
||||
//writer.write(Integer.toString(this.elementCounter));
|
||||
// + "<a style='margin:0px;padding:0px' href='#filecontent");
|
||||
// writer.write(Integer.toString(this.elementCounter));
|
||||
|
||||
String contributionPlusArtifact = getContributionURI(result) + ";" + removeHighlighting(result.getContainer().getValue());
|
||||
|
||||
|
||||
// writer.write("' onclick='search");
|
||||
// writer.write("'>view all</a> <a href='/files/contribution=");
|
||||
writer.write("<a style='margin:0px;padding:0px' href='javascript:document.getElementByID(\"searchGadget\").contentWindow.getHighlighted(\"");
|
||||
writer.write("<a style='margin:0px;padding:0px' href='javascript:getHighlighted(\"");
|
||||
writer.write(contributionPlusArtifact);
|
||||
writer.write("\");'>view all</a> ");
|
||||
|
||||
|
||||
writer.write("<a href='/files/contribution=");
|
||||
writer.write(contributionPlusArtifact);
|
||||
writer.write("'>download</a></p><p style='margin:8px 0px 0px 0px;padding:0px'>");
|
||||
writer.write("'>download</a></p><div id='");
|
||||
writer.write("test");
|
||||
writer.write("' 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())));
|
||||
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>");
|
||||
writer.write("</div>");
|
||||
writer.write("</div>");
|
||||
|
||||
}
|
||||
|
@ -450,9 +424,41 @@ public class Searcher implements ItemCollection, LocalItemCollection {
|
|||
System.out.println("put");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Entry<String, Item>[] query(String queryString) {
|
||||
System.out.println("query");
|
||||
return null;
|
||||
|
||||
try {
|
||||
|
||||
Item item;
|
||||
String key;
|
||||
|
||||
if (queryString.startsWith("highlight")) {
|
||||
int lastSemicolonIndex = queryString.lastIndexOf(";");
|
||||
String artifact = queryString.substring(lastSemicolonIndex + 1);
|
||||
int secondLastSemicolonIndex = queryString.lastIndexOf(";", lastSemicolonIndex - 1);
|
||||
String contribution = queryString.substring(secondLastSemicolonIndex + 1, lastSemicolonIndex);
|
||||
String query = queryString.substring("highlight".length(), secondLastSemicolonIndex);
|
||||
|
||||
item = highlightArtifact(contribution, artifact, query);
|
||||
key = queryString.substring("highlight".length());
|
||||
|
||||
} else if (queryString.startsWith("query")) {
|
||||
key = queryString.substring("query".length());
|
||||
item = executeQuery(key);
|
||||
|
||||
} else {
|
||||
throw new NotFoundException("Invalid operation!");
|
||||
}
|
||||
|
||||
Entry<String, Item>[] returnArray = new Entry[1];
|
||||
returnArray[0] = new Entry<String, Item>(key, item);
|
||||
|
||||
return returnArray;
|
||||
|
||||
} catch (Exception t) {
|
||||
return new Entry[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
<service name="Widget">
|
||||
<t:binding.http uri="http://localhost:9990/ui/search"/>
|
||||
</service>
|
||||
|
||||
<reference name="searcher" target="SearcherCollectionComponent/ItemCollection">
|
||||
<t:binding.atom/>
|
||||
</reference>
|
||||
|
||||
</component>
|
||||
|
||||
<component name="HomeGadget">
|
||||
|
@ -216,6 +221,8 @@
|
|||
<reference name="deployableCollection" target="DeployableCompositeCollectionComponent/LocalItemCollection"/>
|
||||
<reference name="processCollection" target="NodeProcessCollectionFacadeComponent/LocalItemCollection"/>
|
||||
<reference name="domainManagerConfiguration" target="DomainManagerConfigurationComponent"/>
|
||||
<reference name="domainSearch" target="DomainSearchComponent"/>
|
||||
<reference name="contributionReader" target="DeployableCompositeCollectionComponent/ContributionsReader"/>
|
||||
</component>
|
||||
|
||||
<component name="CloudCompositeServiceComponent">
|
||||
|
@ -257,17 +264,6 @@
|
|||
<reference name="processCollection" target="NodeProcessCollectionComponent/LocalItemCollection"/>
|
||||
</component>
|
||||
|
||||
<component name="SearchGadget">
|
||||
<t:implementation.widget location="search-gadget.html"/>
|
||||
<service name="Widget">
|
||||
<t:binding.http uri="http://localhost:9990/ui/search-gadget"/>
|
||||
</service>
|
||||
<reference name="searcher" target="SearcherCollectionComponent/ItemCollection">
|
||||
<t:binding.atom/>
|
||||
</reference>
|
||||
|
||||
</component>
|
||||
|
||||
<component name="SearcherCollectionComponent">
|
||||
<implementation.java class="org.apache.tuscany.sca.domain.manager.impl.Searcher"/>
|
||||
|
||||
|
|
|
@ -29,17 +29,8 @@
|
|||
<body>
|
||||
<div id="home">
|
||||
|
||||
<form>
|
||||
<table border="0" align="center">
|
||||
<tr><td valign="top"><span style="font-size:150%; color: blue">Search:</span></td><td><input type="text" name="search" size="50"/></td></tr>
|
||||
<tr><td></td><td align="center"><input type="button" name="search" value="Search" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gadget = gadget(window, document);
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
|
||||
<div id="homeGadgetDiv"></div>
|
||||
|
||||
<br><br><br><br><br><br><br>
|
||||
<center>This page is under construction, searching the domain is not implemented yet.</center>
|
||||
|
||||
<iframe id="toolbarGadget" src="toolbar-gadget.html" style="visibility: hidden;"></iframe>
|
||||
<iframe id="homeGadget" src="home-gadget.html" style="visibility: hidden;"></iframe>
|
||||
</body>
|
||||
|
|
|
@ -27,41 +27,13 @@
|
|||
|
||||
<link rel="stylesheet" type="text/css" href="manager.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="domainSearch">
|
||||
|
||||
<form id="domainSearchForm">
|
||||
|
||||
<p style="margin-top:1em;margin-bottom:1em;margin-left:1em;margin-right:1em">
|
||||
<input id="searchField" type="text" value="" /> <input id="searchButton" type="button" value="Search" onclick="search()" />
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<div id="results"></div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
//@Reference
|
||||
var searcher = new tuscany.sca.Reference("searcher");
|
||||
|
||||
var gadget = gadget(window, document);
|
||||
|
||||
var lastQuery = "";
|
||||
|
||||
elementByID(gadget, 'searchButton').onclick = search;
|
||||
|
||||
|
||||
function search() {
|
||||
lastQuery = elementByID(gadget, 'searchField').value;
|
||||
searcher.get("query" + lastQuery, searchResponse);
|
||||
function search(query) {
|
||||
searcher.get("query" + query, searchResponse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getHighlighted(artifact) {
|
||||
searcher.get("highlight" + lastQuery + ";" + artifact, searchResponse);
|
||||
}
|
||||
|
@ -72,17 +44,57 @@
|
|||
|
||||
var results = elementByID(gadget, "results");
|
||||
results.innerHTML = content[0].firstChild.data;
|
||||
|
||||
}
|
||||
|
||||
function searchResponse(feed) {
|
||||
alert("processing results");
|
||||
var entries = feed.getElementsByTagName("entry");
|
||||
var content = entries[0].getElementsByTagName("content");
|
||||
|
||||
var results = elementByID(gadget, "results");
|
||||
results.innerHTML = content[0].firstChild.data;
|
||||
|
||||
}
|
||||
|
||||
function getParameter( name )
|
||||
{
|
||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||
var regex = new RegExp( regexS );
|
||||
var results = regex.exec( window.top.location.href );
|
||||
if( results == null )
|
||||
return ""
|
||||
else
|
||||
return results[1];
|
||||
}
|
||||
|
||||
function checkQuery() {
|
||||
var query = getParameter("query");
|
||||
|
||||
if (query.length > 0) {
|
||||
search(query);
|
||||
|
||||
} else {
|
||||
search("*:*");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="checkQuery()">
|
||||
<div id="results"></div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//@Reference
|
||||
var searcher = new tuscany.sca.Reference("searcher");
|
||||
|
||||
var gadget = gadget(window, document);
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -21,46 +21,107 @@
|
|||
<title>SCA Domain - Search</title>
|
||||
|
||||
<script type="text/javascript" src="utils.js"></script>
|
||||
<script type="text/javascript" src="../search/search.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="manager.css">
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function search(query) {
|
||||
searcher.get("query" + query, searchResponse);
|
||||
}
|
||||
|
||||
function getHighlighted(artifact) {
|
||||
|
||||
var query = getParameter("query");
|
||||
|
||||
if (query.length == 0) {
|
||||
query = "*:*";
|
||||
}
|
||||
|
||||
searcher.get("highlight" + query + ";" + artifact, highlightResponse);
|
||||
}
|
||||
|
||||
function highlightResponse(feed) {
|
||||
var entries = feed.getElementsByTagName("entry");
|
||||
var content = entries[0].getElementsByTagName("content");
|
||||
var title = entries[0].getElementsByTagName("title")[0].firstChild.data;
|
||||
|
||||
var fileContent = document.getElementById(title);
|
||||
fileContent.innerHTML = content[0].firstChild.data;
|
||||
|
||||
}
|
||||
|
||||
function searchResponse(feed) {
|
||||
var entries = feed.getElementsByTagName("entry");
|
||||
var content = entries[0].getElementsByTagName("content");
|
||||
|
||||
var results = document.getElementById("results");
|
||||
results.innerHTML = content[0].firstChild.data;
|
||||
|
||||
}
|
||||
|
||||
function getParameter( name )
|
||||
{
|
||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||
var regex = new RegExp( regexS );
|
||||
var results = regex.exec( window.top.location.href );
|
||||
if( results == null )
|
||||
return ""
|
||||
else
|
||||
return results[1];
|
||||
}
|
||||
|
||||
function checkQuery() {
|
||||
var query = getParameter("query");
|
||||
|
||||
if (query.length > 0) {
|
||||
search(query);
|
||||
|
||||
} else {
|
||||
search("*:*");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body onload="checkQuery()">
|
||||
<div id="toolbarGadgetDiv"></div>
|
||||
<br>
|
||||
|
||||
<span class=hd1>
|
||||
SCA Domain<br><br>
|
||||
Domain Search <a href="/search/"><img src="icons/feed-icon.png" border="0"></a>
|
||||
Results<br>
|
||||
</span>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<div id="searchGadgetDiv"></div>
|
||||
</p>
|
||||
|
||||
<div id="results"></div>
|
||||
|
||||
<iframe id="toolbarGadget" src="toolbar-gadget.html"></iframe>
|
||||
<iframe id="searchGadget" src="search-gadget.html" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var toolbarGadgetDiv = elementByID(document, 'toolbarGadgetDiv');
|
||||
var searchGadgetDiv = elementByID(document, 'searchGadgetDiv');
|
||||
|
||||
var toolbarGadget = elementByID(document, 'toolbarGadget');
|
||||
var searchGadget = elementByID(document, 'searchGadget');
|
||||
|
||||
function ongadget(win, doc) {
|
||||
if (doc == content(toolbarGadget)) {
|
||||
toolbarGadgetDiv.innerHTML = doc.body.innerHTML;
|
||||
return toolbarGadgetDiv;
|
||||
} else if (doc == content(searchGadget)) {
|
||||
searchGadgetDiv.innerHTML = doc.body.innerHTML;
|
||||
searchGadgetDiv.showContributions = true;
|
||||
searchGadgetDiv.showComponents = true;
|
||||
return searchGadgetDiv;
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
//@Reference
|
||||
var searcher = new tuscany.sca.Reference("searcher");
|
||||
|
||||
var gadget1 = gadget(window, document);
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -42,6 +42,18 @@
|
|||
|
||||
var toolbarDiv = elementByID(gadget, 'toolbar');
|
||||
toolbarDiv.innerHTML = toolbar(home, tools);
|
||||
|
||||
|
||||
function gup( name ) {
|
||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||
var regex = new RegExp( regexS );
|
||||
var results = regex.exec( window.location.href );
|
||||
if( results == null )
|
||||
return "";
|
||||
else
|
||||
return results[1];
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -157,7 +157,9 @@ function toolbar(home, tools) {
|
|||
for (var i = 0; i < tools.length; i++) {
|
||||
toolbar = toolbar + '<td class=ltbar>' +tools[i].print() + '</td>'
|
||||
}
|
||||
|
||||
|
||||
toolbar = toolbar + '<td class=ltbar><input id="searchField" type="text" value="" /> <input id="searchButton" type="submit" value="Search" onclick="window.location=\'/ui/search/?query=\' + elementByID(gadget(window, document), \'searchField\').value" /></td>'
|
||||
|
||||
toolbar = toolbar + '</tr></table></td>' +
|
||||
'<td class=rtbar><table border="0" cellpadding="0" cellspacing="0" align="right"><tr>' +
|
||||
'<td class=rtbar>' + home.print() + '</td></tr></table></td>' +
|
||||
|
|
Loading…
Add table
Reference in a new issue