summaryrefslogtreecommitdiffstats
path: root/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java')
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java98
1 files changed, 57 insertions, 41 deletions
diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
index a8625e91a2..754966b9a3 100644
--- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
+++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
+import java.util.List;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -35,8 +36,8 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import org.apache.tuscany.sca.impl.NodeImpl;
import org.oasisopen.sca.annotation.Service;
-import org.apache.tuscany.sca.node.impl.NodeImpl;
/**
* Some hand crafted HTTP code to help me think about what info is missing
@@ -45,16 +46,38 @@ import org.apache.tuscany.sca.node.impl.NodeImpl;
*/
@Service(Domain.class)
public class Domain implements Servlet {
+
public String getDomainComposite(){
- NodeImpl node = (NodeImpl)Tuscany.node;
- String domainComposite = node.dumpDomainComposite();
- return domainComposite;
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ return node.getDomainLevelCompositeAsString();
}
+ public String getContributions(){
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ List<String> contributions = node.getInstalledContributionURIs();
+ return contributions.toString();
+ }
+
+ public String getEndpoints(){
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ return node.getEndpointRegistry().getEndpoints().toString();
+ }
+
+ public String getNodes(String domainName){
+ // use the domain on the file system in lieu of info in the registry
+ File domainDir = new File("target/test-classes/" + domainName);
+ String nodes = "";
+
+ for (File subDir : domainDir.listFiles()){
+ if (subDir.isDirectory()){
+ nodes += subDir.getName() + "\n";
+ }
+ }
+ return nodes;
+ }
+
public String getComponent(){
- NodeImpl node = (NodeImpl)Tuscany.node;
- String domainComposite = node.dumpDomainComposite();
- return domainComposite;
+ return null;
}
public void init(ServletConfig config) throws ServletException {
@@ -75,48 +98,35 @@ public class Domain implements Servlet {
String[] pathElements = pathInfo.split("/");
String domainName = pathElements[0];
- String action = "none";
- if (pathElements.length == 2){
- action = pathElements[1];
- }
// Just some hand crafted code to help me visualize resources
os.print("<html><body>");
- if ( action.equals("composite")){
- String domainComposite = getDomainComposite();
- domainComposite = domainComposite.replaceAll("<", "&lt;");
- domainComposite = domainComposite.replaceAll(">", "&gt;");
- os.print("<html><body><p>" + domainComposite + "</body></html>");
- return;
- } else {
- try {
- File domainDir = new File("target/test-classes/" + domainName);
-
- URI domainDirURI = domainDir.toURI();
- URI domainResourceURI = domainDirURI.resolve(pathInfo);
-
- os.print("<p/>contributions");
-
- for (File subDir : domainDir.listFiles()){
- if (!subDir.isDirectory()){
- os.print("<p/><a href=\"" + subDir.toURI().toString() + "\">" + subDir.getName());
- }
- }
-
- os.print("<p/>nodes");
- os.print("<p/><a href=\"" + domainName + "/composite\">domainComposite</a>");
-
- os.print("</body></html>");
-
- return;
- } catch (Exception ex){
- ex.printStackTrace();
+ if (pathElements.length > 1){
+ String action = "none";
+ action = pathElements[1];
+
+ if ( action.equals("composite")){
+ os.print(prettyPrintXMLString(getDomainComposite()));
+ } else if ( action.equals("contribution")){
+ os.print(prettyPrintXMLString(getContributions()));
+ } else if ( action.equals("endpoint")){
+ os.print(prettyPrintXMLString(getEndpoints()));
+ } else if ( action.equals("node")){
+ os.print(prettyPrintXMLString(getNodes(domainName)));
+ } else {
+ os.print("URL path component " + action + "is invalid");
}
+
+ } else {
+ os.print("<p/><a href=\"" + domainName + "/contribution\">contributions</a>");
+ os.print("<p/><a href=\"" + domainName + "/composite\">domainComposite</a>");
+ os.print("<p/><a href=\"" + domainName + "/endpoint\">endpoints</a>");
+ os.print("<p/><a href=\"" + domainName + "/node\">nodes</a>");
}
- os.print("<html><body><p>no processing</body></html>");
+ os.print("</body></html>");
}
@@ -141,5 +151,11 @@ public class Domain implements Servlet {
os.write(aChar);
}
}
+
+ public String prettyPrintXMLString(String inXML){
+ return inXML.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
+
+ // etc. need to read and write a structured version
+ }
} \ No newline at end of file