Modified: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java?rev=1160770&r1=1160769&r2=1160770&view=diff
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java
 (original)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java
 Tue Aug 23 16:11:20 2011
@@ -5,10 +5,7 @@ import static javax.ws.rs.core.MediaType
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -32,7 +29,11 @@ import javax.ws.rs.core.Response.Status;
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.format.KRFormat;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
-import org.apache.stanbol.owl.web.OWLOntologyWriter;
+import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
+import 
org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
+import org.apache.stanbol.owl.transformation.JenaToOwlConvert;
 import org.apache.stanbol.reasoners.jena.JenaReasoningService;
 import org.apache.stanbol.reasoners.owlapi.OWLApiReasoningService;
 import org.apache.stanbol.reasoners.servicesapi.InconsistentInputException;
@@ -40,24 +41,25 @@ import org.apache.stanbol.reasoners.serv
 import org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException;
 import org.apache.stanbol.reasoners.servicesapi.ReasoningServicesManager;
 import 
org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException;
-import org.apache.stanbol.reasoners.web.writers.JenaModelWriter;
+import org.apache.stanbol.rules.base.api.RuleStore;
 import org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxOntologyFormat;
 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.io.OWLOntologyCreationIOException;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.MissingImportEvent;
 import org.semanticweb.owlapi.model.MissingImportListener;
-import org.semanticweb.owlapi.model.OWLAxiom;
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+import org.semanticweb.owlapi.model.SWRLRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
 import com.sun.jersey.api.view.Viewable;
 import com.sun.jersey.multipart.FormDataParam;
 
@@ -65,21 +67,36 @@ import com.sun.jersey.multipart.FormData
 public class ReasoningServiceTaskResource extends BaseStanbolResource {
     private Logger log = LoggerFactory.getLogger(getClass());
     private ServletContext context;
-
+    private HttpHeaders headers;
     /**
      * TODO: We may want to extend the possible tasks in the future, demanding 
the execution to some
      * delegate...
      */
     public static final String[] TASKS = {"enrich", "classify", "check"};
 
-    private ReasoningService service;
+    private ReasoningService<?,?,?> service;
     private String taskID;
+    private RuleStore ruleStore;
+    private ONManager onManager;
 
     public ReasoningServiceTaskResource(@PathParam(value = "service") String 
serviceID,
                                         @PathParam(value = "task") String 
taskID,
-                                        @Context ServletContext 
servletContext) {
+                                        @Context ServletContext servletContext,
+                                        @Context HttpHeaders headers) {
         super();
+
+        // ServletContext
         this.context = servletContext;
+
+        // HttpHeaders
+        this.headers = headers;
+
+        // Retrieve the rule store
+        this.ruleStore = (RuleStore) 
ContextHelper.getServiceFromContext(RuleStore.class, servletContext);
+
+        // Retrieve the ontology network manager
+        this.onManager = (ONManager) 
ContextHelper.getServiceFromContext(ONManager.class, servletContext);
+
         // Retrieve the service
         try {
             service = getService(serviceID);
@@ -87,6 +104,7 @@ public class ReasoningServiceTaskResourc
             log.error("Service not found: {}", serviceID);
             throw new WebApplicationException(e, Response.Status.NOT_FOUND);
         }
+
         // Check if the task is allowed
         if (Arrays.asList(TASKS).contains(taskID)) {
             this.taskID = taskID;
@@ -106,16 +124,127 @@ public class ReasoningServiceTaskResourc
         }
     }
 
+//    @GET
+//    @Path("/ontonet/session")
+//    @Produces({TEXT_HTML, "text/plain", KRFormat.RDF_XML, KRFormat.TURTLE, 
"text/turtle", "text/n3"})
+//    public Response getOntonetSession(@QueryParam("session") String 
sessionID,
+//                                      @QueryParam("target") String 
targetGraphID) {
+//        log.info("Called /ontonet/session with session={} and target={}", 
sessionID, targetGraphID);
+//        // If session is null, describe the service
+//        if (sessionID == null) {
+//            return Response.ok(new Viewable("ontonet-session", 
this)).build();
+//        }
+//        // Get the session
+//        log.info("Session requested is {}", sessionID);
+//        Set<OntologyScope> scopes = 
this.onManager.getScopeRegistry().getRegisteredScopes();
+//        log.info("Registered scopes are {}", scopes.size());
+//        OntologyScope scope = null;
+//        SessionOntologySpace sspace = null;
+//        for (OntologyScope sc : scopes) {
+//            log.info("Lookup for session space in scope {}", sc);
+//            if (sc == null) {
+//                log.warn("A Scope is null! Why it's in the registry!?");
+//                continue;
+//            } else {
+//                sspace = sc.getSessionSpace(IRI.create(sessionID));
+//                if (sspace != null) {
+//                    scope = sc;
+//                    break;
+//                } 
+//            }
+//        }
+//        log.info("Found scope: {}", scope);
+//        log.info("Found session space: {}", sspace);
+//
+//        // If session cannot be retrieved, return 404
+//        if (sspace == null) {
+//            log.error("Session space does not exists!: {}", sessionID);
+//            throw new WebApplicationException(new 
IllegalArgumentException("Session does not exists!"),
+//                    Response.Status.NOT_FOUND);
+//        }
+//
+//        // Get the session as OWLOntology
+//        OWLOntology input = sspace.asOWLOntology();
+//        log.info("Session ontology is: {}", input);
+//
+//        // Now we select the service type
+//        if (service instanceof JenaReasoningService) {
+//            Model inputModel = new 
JenaToOwlConvert().ModelOwlToJenaConvert(input, "TURTLE");
+//            return executeJenaReasoningService((JenaReasoningService) 
service, inputModel, null,
+//                targetGraphID);
+//        } else if (service instanceof OWLApiReasoningService) {
+//            return executeOWLApiReasoningService((OWLApiReasoningService) 
service, input, null, targetGraphID);
+//        } else {
+//            throw new WebApplicationException(new Exception("Unsupported 
implementation"),
+//                    Response.Status.INTERNAL_SERVER_ERROR);
+//        }
+//
+//    }
+
+//    @GET
+//    @Path("/ontonet/scope")
+//    @Produces({TEXT_HTML, "text/plain", KRFormat.RDF_XML, KRFormat.TURTLE, 
"text/turtle", "text/n3"})
+//    public Response getOntonetScope(@QueryParam("scope") String scopeID,
+//                                    @QueryParam("recipe") String recipeID,
+//                                    @QueryParam("target") String 
targetGraph) {
+//        // If session is null, describe the service
+//        // If target is null, then get back results, elsewhere put it in 
target graph
+//        return null;
+//    }
+
+    /**
+     * Generate inferences from the input file. Output comes back to the 
client.
+     * 
+     * @param file
+     * @return
+     */
     @POST
     @Consumes({MULTIPART_FORM_DATA})
-    @Produces({TEXT_HTML, KRFormat.RDF_XML, KRFormat.TURTLE, KRFormat.OWL_XML})
+    @Produces({TEXT_HTML, "text/plain", KRFormat.RDF_XML, KRFormat.TURTLE, 
"text/turtle", "text/n3"})
     public Response postData(@FormDataParam("file") File file) {
         log.info("Called POST on service {} to perform task {}", service, 
taskID);
         log.info("on input file: {}", file);
-        return Response.ok(new Viewable("index", this), TEXT_HTML).build();
+        if (file.exists() && file.canRead()) {
+            // Select the service implementation
+            if (getCurrentService() instanceof JenaReasoningService) {
+                // Prepare input data
+                Model input;
+                try {
+                    input = 
ModelFactory.createDefaultModel().read(file.toURI().toURL().toString());
+                } catch (MalformedURLException e) {
+                    throw new WebApplicationException(new 
IllegalArgumentException("Cannot read file"),
+                            Response.Status.INTERNAL_SERVER_ERROR);
+                }
+                return executeJenaReasoningService((JenaReasoningService) 
getCurrentService(), input, null,
+                    null);
+            } else if (getCurrentService() instanceof OWLApiReasoningService) {
+                OWLOntology input = null;
+                try {
+                    input = 
createOWLOntologyManager().loadOntologyFromOntologyDocument(file);
+                } catch (OWLOntologyCreationIOException e) {
+                    throw new WebApplicationException(e, 
Response.Status.NOT_FOUND);
+                } catch (OWLOntologyCreationException e) {
+                    throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+                }
+                return executeOWLApiReasoningService((OWLApiReasoningService) 
getCurrentService(), input,
+                    null, null);
+            }
+            throw new WebApplicationException(new Exception("Unsupported 
implementation"),
+                    Response.Status.INTERNAL_SERVER_ERROR);
+        } else {
+            log.error("Cannot read file: {}", file);
+            throw new WebApplicationException(new 
IllegalArgumentException("Cannot read file"),
+                    Response.Status.INTERNAL_SERVER_ERROR);
+        }
     }
 
-    private boolean isHTML(HttpHeaders headers) {
+    /**
+     * Check if the client needs a serialization of the output or a human 
readable form (HTML)
+     * 
+     * @param headers
+     * @return
+     */
+    private boolean isHTML() {
         // We only want to state if HTML format is the preferred format
         // requested
         Set<String> htmlformats = new HashSet<String>();
@@ -140,24 +269,24 @@ public class ReasoningServiceTaskResourc
         return true;
     }
 
-    @GET
-    @Produces({TEXT_HTML, "text/plain", KRFormat.RDF_XML, KRFormat.TURTLE, 
"text/turtle", "text/n3"})
-    public Response get(@QueryParam("url") String url, @Context HttpHeaders 
headers) {
-
-        // If url param is missing, we produce the service welcome page
-        if (url == null) {
-            return Response.ok(new Viewable("index", this)).build();
-        }
-        log.info("Called GET on service {} to perform task {}", service, 
taskID);
-        log.info("on input url: {}", url);
-        //
-        if (getCurrentService() instanceof JenaReasoningService) {
-            JenaReasoningService s = (JenaReasoningService) 
getCurrentService();
-
-            if (getCurrentTask().equals("check")) {
-                log.debug("Task is 'check'");
-                boolean isConsistent;
-                isConsistent = 
s.isConsistent(ModelFactory.createDefaultModel().read(url));
+    /**
+     * Execute the JenaReasoningService
+     * 
+     * @param s
+     * @param input
+     * @param rules
+     * @return
+     */
+    private Response executeJenaReasoningService(JenaReasoningService s,
+                                                 Model input,
+                                                 List<Rule> rules,
+                                                 String targetGraphID) {
+        // Check task
+        if (getCurrentTask().equals("check")) {
+            log.debug("Task is 'check'");
+            boolean isConsistent;
+            try {
+                isConsistent = s.isConsistent(input);
                 if (isConsistent) {
                     log.debug("The input is consistent");
                     return Response.ok().build();
@@ -165,15 +294,19 @@ public class ReasoningServiceTaskResourc
                     log.debug("The input is not consistent");
                     return Response.status(Status.NO_CONTENT).build();
                 }
+            } catch (ReasoningServiceException e) {
+                log.error("Error thrown: {}", e);
+                throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
             }
-
+        }
+        try {
             Set<Statement> result = null;
             if (getCurrentTask().equals("classify")) {
                 log.debug("Task is 'classify'");
-                result = 
s.classify(ModelFactory.createDefaultModel().read(url));
+                result = s.classify(input);
             } else if (getCurrentTask().equals("enrich")) {
                 log.debug("Task is: 'enrich'");
-                result = s.enrich(ModelFactory.createDefaultModel().read(url));
+                result = s.enrich(input);
             }
             if (result == null) {
                 log.error("Result is null");
@@ -182,63 +315,73 @@ public class ReasoningServiceTaskResourc
             log.info("Returning {} statements", result.size());
             Model outputModel = ModelFactory.createDefaultModel();
             outputModel.add(result.toArray(new Statement[result.size()]));
-
-            if (isHTML(headers)) {
-
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                outputModel.write(out, "TURTLE");
-                return Response.ok(
-                    new Viewable("result", new 
ReasoningPrettyResultResource(context, uriInfo, out)),
-                    TEXT_HTML).build();
+            // If target is null, then get back results, elsewhere put it in 
target graph
+            if (targetGraphID == null) {
+                if (isHTML()) {
+                    ByteArrayOutputStream out = new ByteArrayOutputStream();
+                    outputModel.write(out, "TURTLE");
+                    return Response.ok(
+                        new Viewable("result", new 
ReasoningPrettyResultResource(context, uriInfo, out)),
+                        TEXT_HTML).build();
+                } else {
+                    return Response.ok(outputModel).build();
+                }
             } else {
-                return Response.ok(outputModel).build();
+                log.error("Not implemented yet! :(");
+                throw new WebApplicationException(501);
             }
+        } catch (ReasoningServiceException e) {
+            log.error("Error thrown: {}", e);
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        } catch (InconsistentInputException e) {
+            log.debug("The input is not consistent");
+            return Response.status(Status.NO_CONTENT).build();
+        }
+    }
+
+    /**
+     * Executes the OWLApiReasoingService
+     * 
+     * @param s
+     * @param input
+     * @param rules
+     * @return
+     */
+    private Response executeOWLApiReasoningService(OWLApiReasoningService s,
+                                                   OWLOntology input,
+                                                   List<SWRLRule> rules,
+                                                   String targetGraphID) {
+        if (getCurrentTask().equals("check")) {
+            log.debug("Task is 'check'");
+            boolean isConsistent;
 
-        } else if (getCurrentService() instanceof OWLApiReasoningService) {
-            OWLApiReasoningService s = (OWLApiReasoningService) 
getCurrentService();
-            OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
-            // Listening for missing imports
-            manager.addMissingImportListener(new MissingImportListener() {
-                @Override
-                public void importMissing(MissingImportEvent arg0) {
-                    log.warn("Missing import: {}", 
arg0.getImportedOntologyURI());
-                }
-            });
-            OWLOntology input = null;
             try {
-                input = 
manager.loadOntologyFromOntologyDocument(IRI.create(url));
-            } catch (OWLOntologyCreationIOException e) {
-                throw new WebApplicationException(e, 
Response.Status.NOT_FOUND);
-            } catch (OWLOntologyCreationException e) {
+                isConsistent = s.isConsistent(input);
+                if (isConsistent) {
+                    log.debug("The input is consistent");
+                    return Response.ok().build();
+                } else {
+                    log.debug("The input is not consistent");
+                    return Response.status(Status.NO_CONTENT).build();
+                }
+            } catch (ReasoningServiceException e) {
                 throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
             }
-            if (getCurrentTask().equals("check")) {
-                log.debug("Task is 'check'");
-                boolean isConsistent;
-
-                try {
-                    isConsistent = s.isConsistent(input);
-                    if (isConsistent) {
-                        log.debug("The input is consistent");
-                        return Response.ok().build();
-                    } else {
-                        log.debug("The input is not consistent");
-                        return Response.status(Status.NO_CONTENT).build();
-                    }
-                } catch (ReasoningServiceException e) {
-                    throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
-                }
+        }
+        // We get the manager from the input ontology
+        // XXX We must be aware of this.
+        OWLOntologyManager manager = input.getOWLOntologyManager();
+        try {
+            OWLOntology output = manager.createOntology();
+            if (getCurrentTask().equals("classify")) {
+                log.debug("Task is 'classify'");
+                manager.addAxioms(output, s.classify(input));
+            } else if (getCurrentTask().equals("enrich")) {
+                log.debug("Task is 'enrich'");
+                manager.addAxioms(output, s.enrich(input));
             }
-            try {
-                OWLOntology output = manager.createOntology();
-                if (getCurrentTask().equals("classify")) {
-                    log.debug("Task is 'classify'");
-                    manager.addAxioms(output, s.classify(input));
-                } else if (getCurrentTask().equals("enrich")) {
-                    log.debug("Task is 'enrich'");
-                    manager.addAxioms(output, s.enrich(input));
-                }
-                if (isHTML(headers)) {
+            if (targetGraphID == null) {
+                if (isHTML()) {
                     ByteArrayOutputStream out = new ByteArrayOutputStream();
                     manager.saveOntology(output, new 
ManchesterOWLSyntaxOntologyFormat(), out);
                     return Response.ok(
@@ -247,44 +390,141 @@ public class ReasoningServiceTaskResourc
                 } else {
                     return Response.ok(output).build();
                 }
-            } catch (ReasoningServiceException e) {
-                throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
-            } catch (InconsistentInputException e) {
-                log.debug("The input is not consistent");
-                return Response.status(Status.NO_CONTENT).build();
+
+            } else {
+                log.error("Not implemented yet! :(");
+                throw new WebApplicationException(501);
+            }
+        } catch (ReasoningServiceException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        } catch (InconsistentInputException e) {
+            log.debug("The input is not consistent");
+            return Response.status(Status.NO_CONTENT).build();
+        } catch (OWLOntologyCreationException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        } catch (OWLOntologyStorageException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    /**
+     * Get the inferences from input URL. If url param is null, get the HTML 
description of this service/task
+     * 
+     * @param url
+     * @return
+     */
+    @GET
+    @Produces({TEXT_HTML, "text/plain", KRFormat.RDF_XML, KRFormat.TURTLE, 
"text/turtle", "text/n3"})
+    public Response get(@QueryParam("url") String url) {
+        // If url param is missing, we produce the service/task welcome page
+        if (url == null) {
+            return Response.ok(new Viewable("index", this)).build();
+        }
+        log.info("Called GET on service {} to perform task {}", service, 
taskID);
+        log.info("on input url: {}", url);
+
+        /**
+         * Select the service implementation
+         */
+        if (getCurrentService() instanceof JenaReasoningService) {
+            // Prepare input data
+            Model input = ModelFactory.createDefaultModel().read(url);
+            return executeJenaReasoningService((JenaReasoningService) 
getCurrentService(), input, null, null);
+        } else if (getCurrentService() instanceof OWLApiReasoningService) {
+            OWLOntology input = null;
+            try {
+                input = 
createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(url));
+            } catch (OWLOntologyCreationIOException e) {
+                throw new WebApplicationException(e, 
Response.Status.NOT_FOUND);
             } catch (OWLOntologyCreationException e) {
                 throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
-            } catch (OWLOntologyStorageException e) {
-                throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
             }
+            return executeOWLApiReasoningService((OWLApiReasoningService) 
getCurrentService(), input, null,
+                null);
         }
         throw new WebApplicationException(new Exception("Unsupported 
implementation"),
                 Response.Status.INTERNAL_SERVER_ERROR);
     }
 
-    public ReasoningService getCurrentService() {
+    private OWLOntologyManager createOWLOntologyManager() {
+        // We isolate here the creation of the temporary manager
+        // TODO How to behave when resolving owl:imports?
+        // We should set the manager to use a service to lookup for 
ontologies, instead of trying on the web
+        // directly
+        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+        manager.setSilentMissingImportsHandling(true);
+        // Listening for missing imports
+        manager.addMissingImportListener(new MissingImportListener() {
+            @Override
+            public void importMissing(MissingImportEvent arg0) {
+                log.warn("Missing import: {}", arg0.getImportedOntologyURI());
+            }
+        });
+        return manager;
+    }
+
+    /**
+     * The actual path, to be used in the template.
+     * 
+     * @return
+     */
+    public String getCurrentPath() {
+        return uriInfo.getPath().replaceAll("[\\/]*$", "");
+    }
+
+    /**
+     * The selected service
+     * 
+     * @return
+     */
+    public ReasoningService<?,?,?> getCurrentService() {
         return this.service;
     }
 
+    /**
+     * The selected task
+     * 
+     * @return
+     */
     public String getCurrentTask() {
         return this.taskID;
     }
 
+    /**
+     * The list of supported tasks.
+     */
     public List<String> getSupportedTasks() {
         return Arrays.asList(ReasoningServiceTaskResource.TASKS);
     }
 
-    private ReasoningService getService(String servicePath) throws 
UnboundReasoningServiceException {
+    /**
+     * To retrieve the service using the service manager
+     * 
+     * @param servicePath
+     * @return
+     * @throws UnboundReasoningServiceException
+     */
+    private ReasoningService<?,?,?> getService(String servicePath) throws 
UnboundReasoningServiceException {
         return getServicesManager().get(servicePath);
     }
 
+    /**
+     * Get the service manager from the context
+     * 
+     * @return
+     */
     private ReasoningServicesManager getServicesManager() {
         log.debug("(getServicesManager()) ");
         return (ReasoningServicesManager) 
ContextHelper.getServiceFromContext(ReasoningServicesManager.class,
             this.context);
     }
 
-    public Set<ReasoningService> getActiveServices() {
+    /**
+     * Gets the list of active services
+     * 
+     * @return
+     */
+    public Set<ReasoningService<?,?,?>> getActiveServices() {
         log.debug("(getActiveServices()) There are {} reasoning services", 
getServicesManager().size());
         return getServicesManager().asUnmodifiableSet();
     }

Modified: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource.java?rev=1160770&r1=1160769&r2=1160770&view=diff
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource.java
 (original)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource.java
 Tue Aug 23 16:11:20 2011
@@ -34,7 +34,7 @@ public class ReasoningServicesResource e
     }
 
     public String getCurrentPath() {
-        return uriInfo.getPath();
+        return uriInfo.getPath().replaceAll("[\\/]*$","");
     }
 
     public String[] getTasks() {
@@ -53,7 +53,7 @@ public class ReasoningServicesResource e
             this.context);
     }
 
-    public Set<ReasoningService> getActiveServices() {
+    public Set<ReasoningService<?,?,?>> getActiveServices() {
         log.debug("(getActiveServices()) There are {} reasoning services", 
getServicesManager().size());
         return getServicesManager().asUnmodifiableSet();
     }

Modified: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/index.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/index.ftl?rev=1160770&r1=1160769&r2=1160770&view=diff
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/index.ftl
 (original)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/index.ftl
 Tue Aug 23 16:11:20 2011
@@ -16,16 +16,26 @@
 -->
 <#import "/imports/common.ftl" as common>
 <#escape x as x?html>
-<@common.page title="Apache Stanbol Reasoners: Service 
/${it.currentService.path}/${it.currentTask}" hasrestapi=false> 
+<@common.page title="Reasoning Service 
/${it.currentService.path}/${it.currentTask}" hasrestapi=false> 
                
  <div class="panel" id="webview">
-       <p><b>Service type:</b> ${it.currentService.class.name}</p>
-       <p><b>Path:</b> ${it.currentService.path}</p>
+       <h3>/${it.currentPath}</h3>
+       <p><b>Service type:</b> <tt>${it.currentService.class.name}</tt></p>
+       <p><b>Name:</b> ${it.currentService.path}</p>
        <p><b>Task:</b> ${it.currentTask}</p>
        
-       <p><em>To test the service, you can send a URL</em></p>
-       <form method="GET">
+       <form method="GET" accept-charset="utf-8">
+       <fieldset>
+       <legend>Submit a URL to the service</legend>
        <p><b>URL:</b> <input type="text" name="url" size="80"/> <input 
type="submit" value="Send"/></p>
+       </fieldset>
+       </form>
+       
+       <form method="POST" enctype="multipart/form-data" 
accept-charset="utf-8">
+       <fieldset>
+       <legend>Submit a file to the service</legend>
+       <p><b>File:</b> <input type="file" name="file"/> <input type="submit" 
value="Send"/></p>
+       </fieldset>
        </form>
  </div>
   </@common.page>

Added: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/ontonet-session.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/ontonet-session.ftl?rev=1160770&view=auto
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/ontonet-session.ftl
 (added)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/ontonet-session.ftl
 Tue Aug 23 16:11:20 2011
@@ -0,0 +1,35 @@
+<#--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<#import "/imports/common.ftl" as common>
+<#escape x as x?html>
+<@common.page title="Reasoning Service on OntoNet Session 
/${it.currentService.path}/${it.currentTask}" hasrestapi=false> 
+               
+ <div class="panel" id="webview">
+       <h3>/${it.currentPath}</h3>
+       <p><b>Service type:</b> <tt>${it.currentService.class.name}</tt></p>
+       <p><b>Name:</b> ${it.currentService.path}</p>
+       <p><b>Task:</b> ${it.currentTask}</p>
+       
+       <form method="GET" accept-charset="utf-8">
+       <fieldset>
+       <legend>Submit a session identifier</legend>
+       <p><b>URL:</b> <input type="text" name="session" size="80"/> <input 
type="submit" value="Send"/></p>
+       </fieldset>
+       </form>
+ </div>
+  </@common.page>
+</#escape>
\ No newline at end of file

Modified: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/result.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/result.ftl?rev=1160770&r1=1160769&r2=1160770&view=diff
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/result.ftl
 (original)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource/result.ftl
 Tue Aug 23 16:11:20 2011
@@ -16,7 +16,7 @@
 -->
 <#import "/imports/common.ftl" as common>
 <#escape x as x?html>
-<@common.page title="Apache Stanbol Reasoners: Result" hasrestapi=false> 
+<@common.page title="Reasoners: Result" hasrestapi=false> 
                
  <div class="panel">
 <pre>

Modified: 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource/index.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource/index.ftl?rev=1160770&r1=1160769&r2=1160770&view=diff
==============================================================================
--- 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource/index.ftl
 (original)
+++ 
incubator/stanbol/branches/jena-reasoners/reasoners/web/src/main/resources/org/apache/stanbol/reasoners/web/templates/org/apache/stanbol/reasoners/web/resources/ReasoningServicesResource/index.ftl
 Tue Aug 23 16:11:20 2011
@@ -17,7 +17,7 @@
 <#import "/imports/common.ftl" as common>
 <#import "/imports/reasonersDescription.ftl" as reasonersDescription>
 <#escape x as x?html>
-<@common.page title="Apache Stanbol Reasoners: Services" hasrestapi=false> 
+<@common.page title="Reasoners" hasrestapi=false> 
                
  <div class="panel" id="webview">
  <#if it.activeServices?size == 0>
@@ -34,7 +34,7 @@
     <ul>
 
      <#list it.activeServices as service>
-      <li><b>.../${service.path}</b>:<br/>Tasks:
+      <li><b>${service.path}</b>:
         <#list it.tasks as task> 
                <a href="/${it.currentPath}/${service.path}/${task}" 
title="${service.class.name} Task: ${task}">${task}</a>
         </#list>


Reply via email to