[MOBY-guts] biomoby commit

Gary Schiltz gss at pub.open-bio.org
Fri Nov 18 18:28:42 UTC 2005


gss
Fri Nov 18 13:28:42 EST 2005
Update of /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/servlets/dev
In directory pub.open-bio.org:/tmp/cvs-serv22515/src/org/semanticmoby/ref/servlets/dev

Modified Files:
	RepositoryPrintServlet.java 
Log Message:
Accept format parameter; print N3 by default

s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/servlets/dev RepositoryPrintServlet.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/servlets/dev/RepositoryPrintServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/servlets/dev/RepositoryPrintServlet.java	2005/10/09 01:11:21	1.3
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/servlets/dev/RepositoryPrintServlet.java	2005/11/18 18:28:42	1.4
@@ -18,29 +18,37 @@
 
         PrintWriter    out     = response.getWriter();
         StorageManager manager = new StorageManager();
-
+        
+        String format = "N3";
+        Model model = null;
+        
         try {
-
-            Model model = manager.openDBModel();
+            model = manager.openDBModel();
 
             if (model.isEmpty()) {
-
                 out.println("The repository is empty");
             } else {
-
-                StmtIterator it = model.listStatements();
-
-                while (it.hasNext()) {
-
-                    out.println(it.nextStatement());
+                String fmt = request.getParameter("format");
+                if ("rdf".equalsIgnoreCase(fmt)) {
+                    format = "RDF/XML-ABBREV";
+                } else if ("nt".equalsIgnoreCase(fmt)) {
+                    format = "N-TRIPLES";
                 }
+                model.write(out, format);
             }
 
             model.close();
         } catch (StorageException e) {
-
             e.printStackTrace();
             throw new ServletException(e);
+        } finally {
+            if (model != null) {
+                try {
+                    model.close();
+                } catch (Throwable t) {
+                    t.printStackTrace();
+                }
+            }
         }
     }
 }




More information about the MOBY-guts mailing list