http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java deleted file mode 100755 index 478202d..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/ProfileQueryServlet.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -import org.apache.oodt.profile.Profile; -import org.apache.oodt.profile.handlers.ProfileHandler; -import org.apache.oodt.xmlquery.QueryElement; -import org.apache.oodt.xmlquery.XMLQuery; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import java.io.IOException; -import java.util.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - - -/** - * Profile query servlet handles profile queries. It returns every matching profile from - * every query handler that provides matching profiles. If no handlers are installed, - * then it returns an empty <profiles> document. - * - */ -public class ProfileQueryServlet extends QueryServlet { - /** {@inheritDoc} */ - protected List getServers(Configuration config) { - return config.getProfileServers(); - } - - /** {@inheritDoc} */ - protected void handleQuery(XMLQuery query, List handlers, HttpServletRequest req, HttpServletResponse res) - throws IOException { - // Find if the query should be targeted to specific handlers. - Set ids = new HashSet(); - if (query.getFromElementSet() != null) { - for (Object o : query.getFromElementSet()) { - QueryElement qe = (QueryElement) o; - if ("handler".equals(qe.getRole()) && qe.getValue() != null) { - ids.add(qe.getValue()); - } - } - } - - res.setContentType("text/xml"); // XML, comin' at ya - res.getWriter().println("<?xml version='1.0' encoding='UTF-8'?>"); // UTF-8 no less. Boo-ya. - res.getWriter().println("<!DOCTYPE profiles PUBLIC '" // Get a doctype in there for the highly ... - + Profile.PROFILES_DTD_FPI + "' '" // ... anal ... - + Profile.PROFILES_DTD_URL + "'>"); // ... retentive. - res.getWriter().println("<profiles>"); // Start tag for the whole /sbin/fsck mess - Transformer transformer = null; // Start out w/no transformer and no doc - Document doc = null; // Don't make 'em if we don't need 'em - boolean sentAtLeastOne = false; // Track if we send any profiles at all - Exception exception = null; // And save any exception - for (Object handler1 : handlers) { - try { // To iterate over each handler - ProfileHandler handler = (ProfileHandler) handler1; // Get the handler - String id = handler.getID(); // Get the ID, and if targeting to IDs - if (!ids.isEmpty() && !ids.contains(id)) { - continue; // ... and it's not one we want, skip it. - } - List results = handler.findProfiles(query); // Have it find profiles - if (results == null) { - results = Collections.EMPTY_LIST; // Assume nothing - } - for (Object result1 : results) { // For each matching profile - Profile profile = (Profile) result1; // Get the profile - if (transformer == null) { // No transformer/doc yet? - transformer = createTransformer(); // Then make the transformer - doc = Profile.createProfileDocument(); // And the doc - } // And use the doc ... - Node profileNode = profile.toXML(doc); // To render the profile into XML - DOMSource source = new DOMSource(profileNode); // And the XML becomes is source - StreamResult result = new StreamResult(res.getWriter()); // And the response is a result - transformer.transform(source, result); // And serialize into glorious text - sentAtLeastOne = true; // OK, we got at least one out the doo - } - } catch (Exception ex) { // Uh oh - exception = ex; // OK, just hold onto it for now - } - } - if (!sentAtLeastOne && exception != null) { // Got none out the door and had an error? - res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, // Then we can report it. - exception.getMessage()); - return; - } - - // However, if we get here, we got at least one profile out the door. In - // that case, hide any error that might've occurred from subsequent - // handlers. (Or, if we get here, there were no errors. Yay.) - res.getWriter().println("</profiles>"); // End tag for the whole fsck'n mess - } - - /** - * Create a transformer, properly configured for XML text serialization. - * - * @return a <code>Transformer</code> value. - * @throws TransformerException if an error occurs. - */ - private static Transformer createTransformer() throws TransformerException { - Transformer transformer; - synchronized (TRANSFORMER_FACTORY) { - transformer = TRANSFORMER_FACTORY.newTransformer(); - } - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.VERSION, "1.0"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transformer.setOutputProperty(OutputKeys.STANDALONE, "no"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.MEDIA_TYPE, "text/xml"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - - return transformer; - } - - /** Sole transformer factory this class will ever need. */ - private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); -} -
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/ProfileServer.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProfileServer.java b/grid/src/main/java/org/apache/oodt/grid/ProfileServer.java deleted file mode 100755 index f273fa6..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/ProfileServer.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -import org.apache.oodt.profile.handlers.ProfileHandler; - -/** - * A profile server. - * - */ -public class ProfileServer extends Server { - /** - * Creates a new <code>ProfileServer</code> instance. - * - * @param configuration - * System configuration. - * @param className - * Class name of profile handler. - */ - public ProfileServer(Configuration configuration, String className) { - super(configuration, className); - } - - /** {@inheritDoc} */ - protected String getType() { - return "profile"; - } - - public int hashCode() { - return super.hashCode() ^ 0x55555555; - } - - public boolean equals(Object obj) { - return super.equals(obj) && obj instanceof ProfileServer; - } - - public String toString() { - return "ProfileServer[" + super.toString() + "]"; - } - - /** - * Create a query handler from this server. - * - * @return a <code>ProfileHandler</code> value. - * @throws ClassNotFoundException - * if the class can't be found. - * @throws InstantiationException - * if the handler can't be instantiated. - * @throws IllegalAccessException - * if the handler has no public constructor. - */ - public ProfileHandler createProfileHandler() throws ClassNotFoundException, - InstantiationException, IllegalAccessException { - return (ProfileHandler) createHandler(); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java deleted file mode 100755 index 13f902e..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/QueryServlet.java +++ /dev/null @@ -1,274 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.xml.sax.SAXException; -import org.apache.oodt.xmlquery.XMLQuery; - -/** - * Query servlet provides common query functionality for profile queries and product - * queries. It treats GETs as POSTs, retrieves the complete XMLQuery (if the - * <code>xmlq</code> request parameter appears) or constructs a new XMLQuery (using the - * <code>q</code> request parameter, which contains just a query expression), updates - * system properties for the handlers, instantiates any new handlers, and then runs the - * query. - * - */ -public abstract class QueryServlet extends GridServlet { - /** - * Get a list of {@link Server}s that will provide handlers to handle the query. - * Subclasses implement this by returning a list of either {@link ProductServer}s - * or {@link ProfileServer}s. - * - * @param config a <code>Configuration</code> value. - * @return a <code>List</code> value of {@link Server}s of some kind. - */ - protected abstract List getServers(Configuration config); - - /** - * Handle the query. Subclasses implement this by parsing the query and returning - * some results. - * - * @param query The query to handle. - * @param handlers A list of either product <code>QueryHandler</code>s or profile <code>ProfileHandler</code>s. - * @param req a <code>HttpServletRequest</code> value. - * @param res a <code>HttpServletResponse</code> value. - * @throws IOException if an I/O error occurs. - * @throws ServletException if a servlet error occurs. - */ - protected abstract void handleQuery(XMLQuery query, List handlers, HttpServletRequest req, HttpServletResponse res) - throws IOException; - - /** - * Treat GETs as POSTs. - * - * @param req a <code>HttpServletRequest</code> value. - * @param res a <code>HttpServletResponse</code> value. - * @throws IOException if an error occurs. - * @throws ServletException if an error occurs. - */ - public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { - doPost(req, res); - } - - /** - * Handle the query. - * - * @param req a <code>HttpServletRequest</code> value. - * @param res a <code>HttpServletResponse</code> value. - * @throws IOException if an error occurs. - * @throws ServletException if an error occurs. - */ - public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { - try { - XMLQuery query = getQuery(req, res); // Get the query - if (query == null) { - return; // No query? My favorite case, right here! - } - - Configuration config = getConfiguration(); // Get the current configuration. - updateProperties(config); // Using it, update the system properties - updateHandlers(getServers(config)); // And any servers. - - List handlerObjects = new ArrayList(handlers.size()); // Start with no handlers. - for (Object handler : handlers) { // For each server - InstantiedHandler ih = (InstantiedHandler) handler; // Get its handler - handlerObjects.add(ih.getHandler()); // Add its handler - } - handleQuery(query, handlerObjects, req, res); // Handlers: handle query, please - } catch (RuntimeException ex) { - throw ex; - } catch (Exception ex) { - throw new ServletException(ex); - } - } - - /** - * Get the query from an HTTP request. The request must have either a - * <code>xmlq</code> parameter (which is given priority) or a <code>q</code> - * parameter. We expect <code>xmlq</code> to contain the XML text format of an - * XMLQuery object. <code>q</code> can contain just the query expression, from - * which we'll construct a fresh <code>XMLQuery</code> with reasonable defaults. - * If the user specifies the <code>q</code> paramater, we'll treat it as a parsed - * query, letting the XMLQuery class parse it and build its various expression - * stacks according to the DIS syntax. The user can specify the <code>unp</code> - * parameter to control this behavior, though. Set to the string - * <code>true</code> and we'll treat the query as <em>unparsed</em>, and the - * XMLQuery class should leave it alone. Otherwise, an other value (or - * unspecified) will be interpreted as <code>false</code>, meaning the query will - * be parsed. - * - * @param req a <code>HttpServletRequest</code> value. - * @param res a <code>HttpServletResponse</code> value. - * @return a <code>XMLQuery</code> value. - * @throws IOException if an error occurs. - */ - protected XMLQuery getQuery(HttpServletRequest req, HttpServletResponse res) throws IOException { - String xmlq = req.getParameter("xmlq"); // Grab any xmlq - String q = req.getParameter("q"); // Grab any q - String unp = req.getParameter("unp"); // And grab any unp (pronounced "unp") - if (xmlq == null) { - xmlq = ""; // No xmlq? Use epsilon - } - if (q == null) { - q = ""; // No q? Use lambda - } - if (unp == null) { - unp = ""; // Use some other greek letter for empty str - } - String[] mimes = req.getParameterValues("mime"); // Grab any mimes - if (mimes == null) { - mimes = EMPTY_STRING_ARRAY; // None? Use empty array - } - - if (xmlq.length() > 0) { - try { // Was there an xmlq? - return new XMLQuery(xmlq); // Use it in its entirety, ignoring the rest - } catch (SAXException ex) { // Can't parse it? - res.sendError(HttpServletResponse.SC_BAD_REQUEST, // Then that's a bad ... - "cannot parse xmlq: " + ex.getMessage()); // ... request, which I hate - return null; // so flag it with a null - } - } else if (q.length() > 0) { // Was there a q? - boolean unparsed = "true".equals(unp); // If so, was there also an unp? - return new XMLQuery(q, "wgq", "Web Grid Query", // Use it to make an XMLQuery - "Query from Web-Grid", /*ddID*/null, // And all of these extra - /*resultModeId*/null, /*propType*/null, // parameters really annoy - /*propLevels*/null, /*maxResults*/Integer.MAX_VALUE, // the poop out of me - Arrays.asList(mimes), !unparsed); // It's just a query for /sbin/fsck sake! - } - - res.sendError(HttpServletResponse.SC_BAD_REQUEST, "xmlq or q parameters required"); - return null; - } - - /** - * Update the query handlers instantiated. - * - * @param servers a <code>List</code> of {@link Server}s. - * @throws ClassNotFoundException if a class can't be found. - * @throws InstantiationException if a class can't be instantiated. - * @throws IllegalAccessException if a constructor isn't public. - */ - private synchronized void updateHandlers(List servers) throws ClassNotFoundException, InstantiationException, - IllegalAccessException { - eachServer: - for (Object server1 : servers) { // For each server - Server server = (Server) server1; // Grab the server - for (Object handler1 : handlers) { // For each handler - InstantiedHandler handler = (InstantiedHandler) handler1; // Grab the handler - if (handler.getServer().equals(server)) // Have we already instantiated? - { - continue eachServer; // Yes, try the next server - } - } - InstantiedHandler handler // No. Create ... - = new InstantiedHandler(server, server.createHandler()); // ... a fresh handler - handlers.add(handler); // Save it - } - - for (Iterator i = handlers.iterator(); i.hasNext();) { // Now, for each handler - InstantiedHandler handler = (InstantiedHandler) i.next(); // Grab the handler - if (!servers.contains(handler.getServer())) // Does its server still exist? - { - i.remove(); // If not, remove the handler - } - } - } - - /** - * Update system properties used by query handlers, if any have changed. - * - * @param config a <code>Configuration</code> value. - */ - private synchronized void updateProperties(Configuration config) { - if (properties != null) { // Any old properties? - if (properties.equals(config.getProperties())) { - return; // Yes, any changes? No? Then done. - } - for (Object o : properties.keySet()) { - System.getProperties().remove(o); // and remove it. - } - } - properties = (Properties) config.getProperties().clone(); // Now copy the new settings - System.getProperties().putAll(properties); // And set them! - } - - /** - * Instantiated query handlers. - * - * These are either <code>ProfileHandler</code>s or product <code>QueryHandler</code>s. - */ - protected List handlers = new ArrayList(); - - /** Current settings of system properties. */ - private Properties properties; - - /** - * An instantiated handler. This is a <code>ProfileHandler</code> or a product - * <code>QueryHandler</code> along with the {@link Server} that defined it. - */ - private static class InstantiedHandler { - /** - * Creates a new <code>InstantiedHandler</code> instance. - * - * @param server a <code>Server</code>. - * @param handler a <code>ProfileHandler</code> or a product <code>QueryHandler</code>. - */ - InstantiedHandler(Server server, Object handler) { - this.server = server; - this.handler = handler; - } - - /** - * Get the server that defined this handler. - * - * @return a <code>Server</code> value. - */ - public Server getServer() { - return server; - } - - /** - * Get the handler. - * - * @return a <code>ProfileHandler</code> or a product <code>QueryHandler</code>. - */ - public Object getHandler() { - return handler; - } - - /** Server that defines the handler. */ - private Server server; - - /** A <code>ProfileHandler</code> or a product <code>QueryHandler</code> */ - private Object handler; - } - - /** So we don't create a bunch of empty string arrays, here's the only one we'll ever need. */ - private static final String[] EMPTY_STRING_ARRAY = new String[0]; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java deleted file mode 100644 index 4b7068b..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/RestfulProductQueryServlet.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * 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. - */ -package org.apache.oodt.grid; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.oodt.xmlquery.XMLQuery; - -/** - * The {@link RestfulProductQueryServlet} is an alternative to the standard {@link ProductQueryServlet} - * that allows clients to use a more intuitive syntax for encoding query constraints, than the traditional - * DIS-style syntax. - * For example, instead of encoding a request as: - * "?q=identifier+EQ+urn:nasa:pds:phx_lidar:reduced:LS075RLS_00902835894_1885M1+AND+package+EQ+TGZ" - * a client could encode it as: - * "?identifier=urn:nasa:pds:phx_lidar:reduced:LS075RLS_00902835894_1885M1&package=TGZ". - * Note that this servlet is meant to be back-ward compatible, i.e. it will first process a request by - * parsing the "xmlq=" and "q=" parameters. If those are not found, it will build a request by combining - * all the available HTTP parameters in logical AND. - * Note also that this servlet is NOT enabled by default - * (i.e. it must be explicitly configured by changing the web-grid deployment descriptor web.xml). - * - * @author Luca Cinquini - * - */ -public class RestfulProductQueryServlet extends ProductQueryServlet { - - private static final long serialVersionUID = 1L; - - /** - * Overridden implementation that defaults to the standard behavior if the parameters "q" or "xmlq" are found, - * otherwise it uses the available request parameters to build a constraint query with logical AND. - */ - @Override - protected XMLQuery getQuery(HttpServletRequest req, HttpServletResponse res) throws IOException { - - // if DIS-style parameters are found, default to standard processing - if (req.getParameter("xmlq") !=null || req.getParameter("q")!=null) { - return super.getQuery(req, res); - - // combine all HTTP (name, value) pairs into XML query string with logical AND - } else { - - StringBuilder q = new StringBuilder(""); - Enumeration<String> parameterNames = req.getParameterNames(); - while (parameterNames.hasMoreElements()) { - String paramName = parameterNames.nextElement(); - String[] paramValues = req.getParameterValues(paramName); - for (String paramValue : paramValues) { - if (q.length() > 0) { - q.append(" AND "); - } - q.append(paramName).append(" EQ ").append(paramValue); - } - } - - // build XMLQuery object from HTTP parameters - // no need to URL-encode since this request doesn't go over the network - System.out.println("Executing query="+q.toString()); - return new XMLQuery(q.toString(), "wgq", "Web Grid Query", - "Query from Web-Grid", /*ddID*/null, - /*resultModeId*/null, /*propType*/null, - /*propLevels*/null, /*maxResults*/Integer.MAX_VALUE, - new ArrayList<String>(), true); - } - - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/Server.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/Server.java b/grid/src/main/java/org/apache/oodt/grid/Server.java deleted file mode 100755 index 84185e1..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/Server.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; - -import java.io.Serializable; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.List; - -/** - * An abstract server defines the code base and class name of a query handler. - * - */ -public abstract class Server implements Serializable { - /** - * Creates a new <code>Server</code> instance. - * - * @param configuration - * System configuration. - * @param className - * Class name of the query handler. - */ - public Server(Configuration configuration, String className) { - this.configuration = configuration; - this.className = className; - } - - /** - * Render this server into XML. - * - * @param owner - * Owning document. - * @return This server, as XML. - */ - public Node toXML(Document owner) { - Element elem = owner.createElement("server"); - elem.setAttribute("className", className); - elem.setAttribute("type", getType()); - return elem; - } - - /** - * Get the class name of the query handler. - * - * @return Class name of the query handler. - */ - public String getClassName() { - return className; - } - - /** - * Create the handler. - * - * @return an instantiated handlre. - * @throws ClassNotFoundException - * if the handler class can't be found. - * @throws InstantiationException - * if the handler object can't be created. - * @throws IllegalAccessException - * if the handler class doesn't provide a public no-args - * constructor. - */ - public Object createHandler() throws ClassNotFoundException, - InstantiationException, IllegalAccessException { - List urlList = configuration.getCodeBases(); - Class clazz; - if (urlList.isEmpty()) { - clazz = Class.forName(className); - } else { - URL[] urls = (URL[]) urlList.toArray(new URL[urlList.size()]); - URLClassLoader loader = new URLClassLoader(urls, getClass() - .getClassLoader()); - clazz = loader.loadClass(className); - } - return clazz.newInstance(); - } - - /** - * Set the class name of the handler. - * - * @param className - * Class name of the handler. - */ - public void setClassName(String className) { - this.className = className; - } - - /** - * Return the type of the handler. - * - * @return Either <code>product</code> or <code>profile</code>. - */ - protected abstract String getType(); - - public int hashCode() { - return configuration.hashCode() ^ className.hashCode(); - } - - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof Server) { - Server rhs = (Server) obj; - return className.equals(rhs.className); - } - return false; - } - - public String toString() { - return "Server[className=" + className + "]"; - } - - /** - * Create a server from an XML element. - * - * @param elem - * XML element, presumed to be a <server> element. - * @return a <code>Server</code> subclass. - * @throws SAXException - * if the element can't be properly parsed. - */ - public static Server create(Configuration configuration, Element elem) - throws SAXException { - String type = elem.getAttribute("type"); - - String className = elem.getAttribute("className"); - - // Replace with a factory some day... - if ("product".equals(type)) { - return new ProductServer(configuration, className); - } else if ("profile".equals(type)) { - return new ProfileServer(configuration, className); - } else { - throw new SAXException("unknown server type `" + type + "'"); - } - } - - /** Configuration. */ - protected Configuration configuration; - - /** Class name of the handler class. */ - protected String className; - - private static final URL[] EMPTY_URL_ARRAY = new URL[0]; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/java/org/apache/oodt/grid/Utility.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/Utility.java b/grid/src/main/java/org/apache/oodt/grid/Utility.java deleted file mode 100755 index e160e52..0000000 --- a/grid/src/main/java/org/apache/oodt/grid/Utility.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -/** - * Utility methods for web grid. - * - */ -public class Utility { - /** - * Provide XHTML-safe escaping for a string. Basically, this is the same as - * XML-escaping, but since some user agents don't recognize - * <code>&apos;</code>, we use <code>&#39;</code> instead. - * - * @param str - * String to escape. - * @return <var>str</var> escaped. - */ - public static String esc(String str) { - StringBuilder s = new StringBuilder(str.length()); // Assume at least the same - // length - for (int i = 0; i < str.length(); ++i) { // For each character - char c = str.charAt(i); // Grab the character - switch (c) { // Now consider what it is ... - case '<': // A less than? - s.append("<"); // Well, that's < - break; - case '>': // A greater than? - s.append(">"); // That's > - break; - case '&': // An ampersand? - s.append("&"); // We all know what that is - break; - case '\'': // A tick? - s.append("'"); // Not ' ! TRICKY! - break; - case '\"': // A quote? - s.append("""); // Yadda, yadda, yadda - break; - default: // Anything else may pass - s.append(c); // ... through unchanged - break; - } - } - return s.toString(); // Donenacious. - } - - /** - * Tell if a host name refers to the localhost. This checks the standard IPv6 - * address, IPv4 address, and host name for localhost. - * - * @param host - * Host name to check. - * @return True if <var>host</var> names the localhost. - */ - public static boolean isLocalhost(String host) { - return "0:0:0:0:0:0:0:1".equals(host) || "127.0.0.1".equals(host) - || "localhost".equals(host); - } - - /** - * Do not call. - */ - private Utility() { - throw new IllegalStateException("This is a \u00abutility\u00bb class"); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/META-INF/context.xml ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/META-INF/context.xml b/grid/src/main/webapp/META-INF/context.xml deleted file mode 100755 index a82645f..0000000 --- a/grid/src/main/webapp/META-INF/context.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<Context - cookies='true' - override='true' - privileged='false' - reloadable='false' - unpackWAR='true'/> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/WEB-INF/jetty-web.xml ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/WEB-INF/jetty-web.xml b/grid/src/main/webapp/WEB-INF/jetty-web.xml deleted file mode 100755 index 52b2379..0000000 --- a/grid/src/main/webapp/WEB-INF/jetty-web.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<!DOCTYPE Configure PUBLIC '-//Mort Bay Consulting//DTD Configure 1.2//EN' 'http://jetty.mortbay.org/configure_1_2.dtd'> -<Configure class='org.mortbay.jetty.servlet.WebApplicationContext'> - <Set name='extractWAR'>true</Set> -</Configure> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/WEB-INF/web.xml b/grid/src/main/webapp/WEB-INF/web.xml deleted file mode 100755 index 98dfcef..0000000 --- a/grid/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> - <icon> - <small-icon>images/webapp-small.png</small-icon> - <large-icon>images/webapp-large.png</large-icon> - </icon> - <display-name>Web Grid</display-name> - <description> - Web Grid is an OODT web application that provides HTTP based - access to OODT profile and product query handlers. It also - includes web accessible configuration and updates with a simple - administrative security policy. - </description> - <distributable/> - <servlet> - <servlet-name>product</servlet-name> - <display-name>Product</display-name> - <description> - </description> - <servlet-class>org.apache.oodt.grid.ProductQueryServlet</servlet-class> - </servlet> - <servlet> - <servlet-name>profile</servlet-name> - <display-name>Profile</display-name> - <description> - </description> - <servlet-class>org.apache.oodt.grid.ProfileQueryServlet</servlet-class> - </servlet> - <servlet> - <servlet-name>config</servlet-name> - <display-name>Configure</display-name> - <description> - </description> - <servlet-class>org.apache.oodt.grid.ConfigServlet</servlet-class> - </servlet> - <servlet> - <servlet-name>login</servlet-name> - <display-name>Login</display-name> - <description> - </description> - <servlet-class>org.apache.oodt.grid.LoginServlet</servlet-class> - </servlet> - <servlet-mapping> - <servlet-name>product</servlet-name> - <url-pattern>/prod</url-pattern> - </servlet-mapping> - <servlet-mapping> - <servlet-name>profile</servlet-name> - <url-pattern>/prof</url-pattern> - </servlet-mapping> - <servlet-mapping> - <servlet-name>config</servlet-name> - <url-pattern>/conf</url-pattern> - </servlet-mapping> - <servlet-mapping> - <servlet-name>login</servlet-name> - <url-pattern>/login</url-pattern> - </servlet-mapping> - <session-config> - <session-timeout>0</session-timeout> - </session-config> - <welcome-file-list> - <welcome-file>index.html</welcome-file> - </welcome-file-list> - <error-page> - <exception-type>org.apache.oodt.grid.AuthenticationRequiredException</exception-type> - <location>/error.jsp</location> - </error-page> -</web-app> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/config.jsp ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/config.jsp b/grid/src/main/webapp/config.jsp deleted file mode 100755 index 1c5c699..0000000 --- a/grid/src/main/webapp/config.jsp +++ /dev/null @@ -1,205 +0,0 @@ -<%@ page language="java" session="true" contentType="text/html; charset=UTF-8" info="Config" errorPage="error.jsp" - import="java.util.Map,java.util.Iterator,org.apache.oodt.grid.Server,org.apache.oodt.grid.Utility,java.net.URL" %> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<jsp:useBean id="cb" scope="session" class="org.apache.oodt.grid.ConfigBean"/> -<?xml version='1.0' encoding='UTF-8'?> -<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> -<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> - <head> - <title>Web Grid Configuration</title> - <link rel='stylesheet' type='text/css' href='style.css'/> - </head> - <body> - <h1>Web Grid Configuration</h1> - - <% if (cb.getMessage().length() > 0) { %> - <div class='error'><jsp:getProperty name='cb' property='message'/></div> - <% } %> - - <form action='conf' method='post'> - - <fieldset> - <legend>Administrative Settings</legend> - <div class='field'> - <label for='passwordField'>New Administrator Password</label> - <div class='fieldHelp'> - Leave blank to leave password unchanged. - </div> - <input id='passwordField' type='password' name='password'/> - </div> - - <div class='field'> - <label for='lhf'>Require Administrative Access from Local Host Only</label> - <div class='fieldHelp'> - Click Yes to enable administrative access from browsers - running on the local web-server host only. Click No to - allow any host to access these administrative pages. - </div> - <input id='lhf' type='radio' name='localhost' value='on' <%= cb.isLocalhostRequired()? "checked='checked'" : "" %> />Yes - <input type='radio' name='localhost' value='off' <%= !cb.isLocalhostRequired()? "checked='checked'" : "" %> />No - </div> - - <div class='field'> - <label for='httpsField'>Require HTTPS for Administrative Access</label> - <div class='fieldHelp'> - Click Yes to require HTTPS for access to these administrative pages. Note that this will require - your web server to also support HTTPS. If you're not sure, <strong>click No</strong>. - </div> - <input id='httpsField' type='radio' name='https' value='on' <%= cb.isHttpsRequired()? "checked='checked'" : "" %> />Yes - <input type='radio' name='https' value='off' <%= !cb.isHttpsRequired()? "checked='checked'" : "" %> />No - </div> - </fieldset> - - <fieldset> - <legend>System Properties</legend> - <div class='field'> - <div class='fieldHelp'>To add a new system property, enter - its key and value at the bottom. You can change the values - of existing properties. To delete an existing property, - check the box to its right.</div> - <table> - <thead><tr><th>#</th><th>Key</th><th>Value</th><th>Delete?</th></tr></thead> - <tbody> - <% int row = 1; for (Iterator i = cb.getProperties().entrySet().iterator(); i.hasNext(); ++row) { - Map.Entry entry = (Map.Entry) i.next(); - String key = (String) entry.getKey(); - String val = (String) entry.getValue(); - %> - <tr class='<%= row % 2 == 0? "evenRow" : "oddRow"%>'> - <td><%= row %>.</td> - <td><span class='key'><%= Utility.esc(key) %></span></td> - <td><input type='text' name='val-<%= Utility.esc(key) %>' value='<%= Utility.esc(val) %>'/></td> - <td><input type='checkbox' name='del-<%= Utility.esc(key) %>'/></td> - </tr> - <% } %> - <tr class='newRow'> - <td>(New)</td> - <td><input type='text' id='newkey' name='newkey'/></td> - <td><input type='text' id='newval' name='newval'/></td> - <td> </td> - </tr> - </tbody> - </table> - </div> - </fieldset> - - <fieldset> - <legend>Code Bases</legend> - <div class='fieldHelp'>Specify a URL for each code base. URLs - to files are assumed to be jar files. URLs that end in a - <code>/</code> refer to directories containing class files. - Check the box to delete a code base. - </div> - - <table> - <thead><tr><th>#</th><th>Code Base</th><th>Delete?</th></thead> - <tbody> - <% row = 0; for (Iterator i = cb.getConfiguration().getCodeBases().iterator(); i.hasNext(); ++row) { - URL codeBaseURL = (URL) i.next(); - %> - <tr class='<%= row+1 % 2 == 0? "evenRow" : "oddRow"%>'> - <td><%= row+1 %>.</td> - <td><%= Utility.esc(codeBaseURL.toString()) %></td> - <td><input type='checkbox' name='delcb-<%= row %>'/></td> - </tr> - <% } %> - <tr class='newRow'> - <td>(New)</td> - <td><input type='text' name='newcb'/></td> - <td> </td> - </tr> - </tbody> - </table> - </fieldset> - - <table> - <caption>Query Handlers</caption> - <tbody> - <tr style="vertical-align: top;"> - <td> - <fieldset> - <legend>Product Query Handlers</legend> - <div class='field'> - <div class='fieldHelp'>Specify the class name for each - product query handler; the class must implement the - <code>org.apache.oodt.product.QueryHandler</code> interface.</div> - <table> - <thead><tr><th>#</th><th>Class Name</th><th>Delete?</th></tr></thead> - <tbody> - <% row = 0; for (Iterator i = cb.getProductServers().iterator(); i.hasNext(); ++row) { - Server server = (Server) i.next(); - String className = server.getClassName(); - %> - <tr class='<%= row % 2 == 0? "oddRow" : "evenRow" %>'> - <td><%= row+1 %>.</td> - <td><code><%= Utility.esc(className) %></code></td> - <td><input type='checkbox' name='drm-<%= row %>'/></td> - </tr> - <% } %> - <tr class='newRow'> - <td>(New)</td> - <td><input type='text' name='d-newcn'/></td> - <td> </td> - </tr> - </tbody> - </table> - </div> - </fieldset> - </td> - <td> - <fieldset> - <legend>Profile Query Handlers</legend> - <div class='field'> - <div class='fieldHelp'>Specify the class name for each - profile query handler; the class must implement the - <code>org.apache.oodt.profile.handlers.ProfileHandler</code> interface.</div> - <table> - <thead><tr><th>#</th><th>Class Name</th><th>Delete?</th></tr></thead> - <tbody> - <% row = 0; for (Iterator i = cb.getProfileServers().iterator(); i.hasNext(); ++row) { - Server server = (Server) i.next(); - String className = server.getClassName(); - %> - <tr class='<%= row % 2 == 0? "oddRow" : "evenRow" %>'> - <td><%= row+1 %>.</td> - <td><code><%= Utility.esc(className) %></code></td> - <td><input type='checkbox' name='mrm-<%= row %>'/></td> - </tr> - <% } %> - <tr class='newRow'> - <td>(New)</td> - <td><input type='text' name='m-newcn'/></td> - <td> </td> - </tr> - </tbody> - </table> - </div> - </fieldset> - </td> - </tr> - </tbody> - </table> - - <div class='formControls'> - <input type='submit' name='submit' value='Save Changes'/> - </div> - - </form> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/error.jsp ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/error.jsp b/grid/src/main/webapp/error.jsp deleted file mode 100755 index 3305a36..0000000 --- a/grid/src/main/webapp/error.jsp +++ /dev/null @@ -1,60 +0,0 @@ -<%@ page language="java" session="true" contentType="text/html; charset=UTF-8" info="Config" isErrorPage="true" - import="org.apache.oodt.grid.AuthenticationRequiredException,java.io.StringWriter,java.io.PrintWriter" -%> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<jsp:useBean id="cb" scope="session" class="org.apache.oodt.grid.ConfigBean"/> -<?xml version='1.0' encoding='UTF-8'?> -<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> -<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> - <head> - <title>Web Grid</title> - <link rel='stylesheet' type='text/css' href='style.css'/> - </head> - <body> - <%! StringWriter s = new StringWriter(); - PrintWriter w = new PrintWriter(s); %> - <% exception.printStackTrace(w); w.close(); %> - - <h1>Web Grid</h1> - <% if (cb.getMessage().length() > 0) { %> - <div class='error'><jsp:getProperty name='cb' property='message'/></div> - <% } %> - - <% if (exception instanceof AuthenticationRequiredException) { %> - <form action='login' method='post'> - <fieldset> - <legend>Log In</legend> - <div class='field'> - <label for='pw'>Administrator password:</label> - <div class='fieldHelp'> - Passwords are case sensitve; check your CAPS LOCK key, if necessary. - </div> - <input id='pw' type='password' name='password'/> - </div> - <div class='formControls'> - <input type='submit' name='submit' value='Log In'/> - </div> - </fieldset> - </form> - <% } else { %> - <h1>Error</h1> - <div>Exception <code><%= exception.getClass().getName() %></code>: <%= exception.getMessage() %></div> - <pre><%= s.getBuffer().toString() %></pre> - <% } %> - </body> -</html> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/images/webapp-large.png ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/images/webapp-large.png b/grid/src/main/webapp/images/webapp-large.png deleted file mode 100755 index 87a5bb0..0000000 Binary files a/grid/src/main/webapp/images/webapp-large.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/images/webapp-small.png ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/images/webapp-small.png b/grid/src/main/webapp/images/webapp-small.png deleted file mode 100755 index d0dd963..0000000 Binary files a/grid/src/main/webapp/images/webapp-small.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/index.html ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/index.html b/grid/src/main/webapp/index.html deleted file mode 100755 index 3d2f161..0000000 --- a/grid/src/main/webapp/index.html +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> -<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> - <head> - <title>Web Grid</title> - <link rel="stylesheet" type="text/css" href="style.css" /> - </head> - <h1>Web Grid</h1> - <ul> - <li><a href='config.jsp'>Configure</a> the system</li> - <li><a href='http://oodt.jpl.nasa.gov/web-grid/'>Learn more</a> about OODT web-based grid technologies</li> - </ul> - <p>OODT is a product of the <a href="http://www.apache.org/">Apache Software Foundation</a>. Check out - our <a href="http://oodt.apache.org/">web page</a> for more information. - </p> -</html> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/main/webapp/style.css ---------------------------------------------------------------------- diff --git a/grid/src/main/webapp/style.css b/grid/src/main/webapp/style.css deleted file mode 100755 index 0cce428..0000000 --- a/grid/src/main/webapp/style.css +++ /dev/null @@ -1,161 +0,0 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. -*/ -body { - font-family: "Lucida Grande", Helvetica, sans; - background-color: white; - color: black; - margin: 2em; - padding: 0; - vertical-align: top; -} - -h1 { - font-size: 160%; -} - -h2 { - font-size: 150%; -} - -h3 { - font-size: 140%; - border-bottom: none; - font-weight: bold; -} - -fieldset { - border: 1 solid #336699; - margin: 1em 0 1em 0; - padding: 0 1em 1em 1em; - line-height: 1.5em; - width: auto; -} - -legend { - background: white; - padding: 0.5em; - font-size: 90%; -} - -form { - border: none; - margin: 0; -} - -textarea { - font: 110% "American Typewriter", Courier, monospace; - border: 1 solid #369; - color: black; - background-color: white; - width: 100%; -} - -input { - font-family: <dtml-var fontFamily>; - visibility: visible; - border: 1 solid #369; - color: black; - background-color: white; - vertical-align: middle; -} - -select { - border: 1 solid #369; - color: black; - vertical-align: top; -} - -.field { - top: 0; - left: 0; - margin: 0 1em 1em 0; -} - -.field .field { - margin: 1em 0 0 0; -} - -.field label { - font-size: 100%; - font-weight: bold; -} - -.fieldRequired { - background: url(required.gif) center left no-repeat; - padding: 0 0 0 8px; - color: black; -} - -.fieldHelp { - font-size: 90%; - color: #666; - margin: 0 0 0.2em 0; -} - -.formHelp:hover { - color: black; - cursor: default; -} - -.formControls { - margin: 1em 0 0 0; -} - -.error { - /* Class for error indication in forms */ - color: #ff6633; - border: 1 solid #ff6633; - padding: 1em; - margin: 0 0 1em 0; - width: 68% !important; -} - -.evenRow { - background: #eee; -} - -.newRow { - border-top: solid; - border-width: 1; - background: #ffe; -} - -th { - border-bottom: solid; - border-width: 1px; - vertical-align: top; -} - -tr { - vertical-align: top; -} - -td { - vertical-align: top; -} - -tbody { - vertical-align: top; -} - -table { - vertical-align: top; -} - -caption { - font-size: 150% -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/site/resources/images/web-grid.jpg ---------------------------------------------------------------------- diff --git a/grid/src/site/resources/images/web-grid.jpg b/grid/src/site/resources/images/web-grid.jpg deleted file mode 100755 index 015bb43..0000000 Binary files a/grid/src/site/resources/images/web-grid.jpg and /dev/null differ http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/site/resources/images/web-grid.psd ---------------------------------------------------------------------- diff --git a/grid/src/site/resources/images/web-grid.psd b/grid/src/site/resources/images/web-grid.psd deleted file mode 100755 index e9d898e..0000000 Binary files a/grid/src/site/resources/images/web-grid.psd and /dev/null differ http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/site/resources/slides.pdf ---------------------------------------------------------------------- diff --git a/grid/src/site/resources/slides.pdf b/grid/src/site/resources/slides.pdf deleted file mode 100755 index 82f64ce..0000000 Binary files a/grid/src/site/resources/slides.pdf and /dev/null differ http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/site/site.xml ---------------------------------------------------------------------- diff --git a/grid/src/site/site.xml b/grid/src/site/site.xml deleted file mode 100644 index 1a85fa9..0000000 --- a/grid/src/site/site.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<project name="Web Grid"> - - <body> - <links> - <item name="OODT" href="../oodt-site/"/> - <item name="Grid" href="../grid/"/> - </links> - - <menu ref="reports" inherit="bottom"/> - - </body> - -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/site/xdoc/index.xml ---------------------------------------------------------------------- diff --git a/grid/src/site/xdoc/index.xml b/grid/src/site/xdoc/index.xml deleted file mode 100755 index 78e4ea7..0000000 --- a/grid/src/site/xdoc/index.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<document> - <properties> - <title>Web Grid</title> - <author email='[email protected]'>Sean Kelly</author> - </properties> - <!-- Sirius Isness - Irrational Substance --> - <body> - <section name='Web Grid'> - <p>The OODT <a href='/grid/'>grid services</a> - (<a href='/grid-product/'>product</a> - and <a href='/grid-profile/'>profile</a> services) use CORBA - or RMI as their underlying network transport. However, - limitations of CORBA and RMI make them inappropriate for - large-scale deployments. For one, both are procedural - mechanisms, providing a remote interface that resembles a - method call. This makes streaming of data from a service - impossible, because there are limitations to the sizes of data - structures that can be passed over a remote method call. - Instead, repeated calls must be made to retrieve each block of - a product, making transfer speeds horribly slow compared to - HTTP or FTP. (Block-based retrieval of profiles was never - implemented, resulting in out of memory conditions for large - profile results, which is another problem.) - </p> - <p>Second, both CORBA and RMI rely on a central name registry. - The registry makes an object independent of its network - location, enabling a client to call it by name (looking up its - last known location in the registry). However, this requires - that server objects be able to make outbound network calls to - the registry (through any outbound firewall), and that the - registry accept those registrations (through any inbound - firewall). This required administrative action at - institutions hosting server objects and at the institution - hosting the registry. Often, these firewall exceptions would - change without notice as system adminstrators changed at each - location (apparently firewall exceptions are poorly documented - everywhere). - </p> - <p>Further, in the two major deployments of OODT (PDS and EDRN), - server objects have almost never moved, nullifying any benefit - of the registry. This project, OODT Web Grid, avoids the - prolems of CORBA and RMI by using HTTP as the transport - mechanism for products and profiles. Further, it provides a - password-protected mechanism to add new sets of product and - profile query handlers, enabling seamless activation of - additional capabilities. - </p> - </section> - <section name='Documentation'> - <p>Further documentation on Web Grid is forthcoming. In the - mean time, check out these <a href='./slides.pdf'>presentation - slides</a>. (Don't worry, they're not in PowerPoint format.) - </p> - </section> - </body> -</document> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/grid/src/test/org/apache/oodt/grid/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/grid/src/test/org/apache/oodt/grid/ConfigurationTest.java b/grid/src/test/org/apache/oodt/grid/ConfigurationTest.java deleted file mode 100755 index e54281b..0000000 --- a/grid/src/test/org/apache/oodt/grid/ConfigurationTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.grid; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.Arrays; -import junit.framework.TestCase; -import org.xml.sax.SAXException; - -/** - * Test the {@link Configuration} class. - * - */ -public class ConfigurationTest extends TestCase { - /** - * Creates a new <code>ConfigurationTest</code> instance. - * - * @param caseName - * Test case name. - */ - public ConfigurationTest(String caseName) { - super(caseName); - } - - /** - * Set up by creating a temporary config file. - * - * @throws Exception - * if an error occurs. - */ - public void setUp() throws Exception { - super.setUp(); - System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - System.setProperty("javax.xml.parsers.SAXParserFactory", - "org.apache.xerces.jaxp.SAXParserFactoryImpl"); - System.setProperty("javax.xml.transform.TransformerFactory", - "org.apache.xalan.processor.TransformerFactoryImpl"); - configFile = File.createTempFile("config", ".xml"); - configFile.deleteOnExit(); - } - - /** - * Tear down by deleting the temporary config file. - * - * @throws Exception - * if an error occurs. - */ - public void tearDown() throws Exception { - configFile.delete(); - super.tearDown(); - } - - /** - * Test to see if the default values of the {@link Configuration} are - * reasonable. - * - * @throws IOException - * if an error occurs. - * @throws SAXException - * if an error occurs. - */ - public void testDefaults() throws IOException, SAXException { - Configuration config = new Configuration(configFile); - assertTrue("Expect localhost not required by default", !config - .isLocalhostRequired()); - assertTrue("Expect https not required by default", !config - .isHTTPSrequired()); - assertTrue("Expect no product servers by default", config - .getProductServers().isEmpty()); - assertTrue("Expect no profile servers by default", config - .getProfileServers().isEmpty()); - assertTrue("Default password not set", Arrays.equals( - Configuration.DEFAULT_PASSWORD, config.getPassword())); - assertTrue("Expect no properties", config.getProperties().isEmpty()); - assertTrue("Expect no code bases", config.getCodeBases().isEmpty()); - } - - /** - * Test to see if the mutators work. - * - * @throws IOException - * if an error occurs. - * @throws SAXException - * if an error occurs. - */ - public void testMutators() throws IOException, SAXException { - Configuration config = new Configuration(configFile); - - assertTrue(!config.isHTTPSrequired()); - config.setHTTPSrequired(true); - assertTrue("Cannot set https as required", config.isHTTPSrequired()); - - assertTrue(!config.isLocalhostRequired()); - config.setLocalhostRequired(true); - assertTrue("Cannot set localhost as required", config.isLocalhostRequired()); - - byte[] password = { (byte) 'x', (byte) 'y', (byte) 'z' }; - assertTrue(Arrays.equals(Configuration.DEFAULT_PASSWORD, config - .getPassword())); - config.setPassword(password); - assertTrue("Cannot change password", Arrays.equals(password, config - .getPassword())); - - try { - config.setPassword(null); - fail("Null password allowed"); - } catch (IllegalArgumentException good) { - } - - // Profile/product servers in the config have no mutators to test (they - // return references to each Set). Same with Properties and code bases. - } - - /** - * Test to see if XML serialization works. - * - * @throws IOException - * if an error occurs. - * @throws SAXException - * if an error occurs. - */ - public void testSerialization() throws IOException, SAXException { - Configuration a = new Configuration(configFile); - - byte[] password = { (byte) 'x', (byte) 'y', (byte) 'z' }; - URL prodServerURL = new URL("http://localhost/prod.jar"); - URL profServerURL = new URL("http://localhost/prof.jar"); - ProductServer prod = new ProductServer(a, "prod"); - ProfileServer prof = new ProfileServer(a, "prof"); - - a.setLocalhostRequired(true); - a.setHTTPSrequired(true); - a.setPassword(password); - a.getProductServers().add(prod); - a.getProfileServers().add(prof); - a.getProperties().setProperty("a", "b"); - a.getCodeBases().add(prodServerURL); - a.getCodeBases().add(profServerURL); - a.save(); - - Configuration b = new Configuration(configFile); - assertTrue("localhost state not saved", b.isLocalhostRequired()); - assertTrue("https state not saved", b.isHTTPSrequired()); - assertTrue("Password not saved", Arrays.equals(password, b.getPassword())); - assertEquals("Product server not saved", 1, b.getProductServers().size()); - assertEquals("Product server not saved properly", prod, b - .getProductServers().iterator().next()); - assertEquals("Profile server not saved", 1, b.getProfileServers().size()); - assertEquals("Profile server not saved properly", prof, b - .getProfileServers().iterator().next()); - assertEquals("Properties not saved properly", "b", b.getProperties() - .getProperty("a")); - assertEquals("Code bases not saved properly", 2, b.getCodeBases().size()); - assertTrue(b.getCodeBases().contains(prodServerURL)); - assertTrue(b.getCodeBases().contains(profServerURL)); - - assertEquals("Configuration.equals doesn't work", a, b); - } - - /** Test config file. */ - private File configFile; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/pom.xml ---------------------------------------------------------------------- diff --git a/opendapps/pom.xml b/opendapps/pom.xml deleted file mode 100644 index 0d8b27c..0000000 --- a/opendapps/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-core</artifactId> - <version>1.1-SNAPSHOT</version> - <relativePath>../core/pom.xml</relativePath> - </parent> - <artifactId>opendapps</artifactId> - <name>Apache OODT Configurable OPeNDAP Profile Server</name> - <description>A generic, configurable Apache OODT profile server - implementation that easily connects to OPeNDAP data sources. Connections - are configured via an XML configuration file, providing information on how - to extract and translate datasets from OPeNDAP and THREDDS into OODT profiles.</description> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <groupId>edu.ucar</groupId> - <artifactId>netcdf4</artifactId> - </dependency> - <dependency> - <groupId>edu.ucar</groupId> - <artifactId>opendap</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-profile</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-xmlquery</artifactId> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> - <!-- enable creation of single jar to use this module stand alone --> - <executions> - <execution> - <id>make-assembly</id> - <!-- bind to the packaging phase --> - <goals> - <goal>single</goal> - </goals> - <!-- this is used for inheritance merges --> - <phase>package</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - <scm> - <!--<connection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/opendapps</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/opendapps</developerConnection> - <url>http://svn.apache.org/viewvc/oodt/trunk/opendapps</url>--> - <tag>0.13-SNAPSHOT</tag> - </scm> -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/java/org/apache/oodt/opendapps/DapNames.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/DapNames.java b/opendapps/src/main/java/org/apache/oodt/opendapps/DapNames.java deleted file mode 100644 index 6ee2378..0000000 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/DapNames.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.opendapps; - - -/** - * - * A set of named constants for extracting information from OPeNDAP {@link opendap.dap.DAS} - * profiles. - * - */ -public interface DapNames { - - String ACTUAL_RANGE = "actual_range"; - - String UNITS = "units"; - - String START = "start"; - - String END = "end"; - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java deleted file mode 100644 index 760dea6..0000000 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetCrawler.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.opendapps; - -//JDK imports - -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.opendapps.config.OpendapConfig; -import org.apache.oodt.opendapps.extractors.MetadataExtractor; -import org.apache.oodt.opendapps.extractors.ThreddsMetadataExtractor; - -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -import thredds.catalog.InvAccess; -import thredds.catalog.InvCatalogRef; -import thredds.catalog.InvDataset; -import thredds.catalog.InvService; -import thredds.catalog.ServiceType; -import thredds.catalog.crawl.CatalogCrawler; - -/** - * Crawls a catalog and returns all the datasets and their references. - * - */ -public class DatasetCrawler implements CatalogCrawler.Listener { - - private static Logger LOG = Logger.getLogger(DatasetCrawler.class.getName()); - - private List<String> urls = new Vector<String>(); - - private Map<String, Metadata> datasetMet; - - private String datasetURL = null; - - private OpendapConfig conf = null; - - public DatasetCrawler(String datasetURL, OpendapConfig conf) { - this.datasetURL = datasetURL.endsWith("/") ? datasetURL : datasetURL + "/"; - this.datasetMet = new ConcurrentHashMap<String, Metadata>(); - this.conf = conf; - } - - /* - * (non-Javadoc) - * - * @see - * thredds.catalog.crawl.CatalogCrawler.Listener#getCatalogRef(thredds.catalog - * .InvCatalogRef, java.lang.Object) - */ - public boolean getCatalogRef(InvCatalogRef dd, Object context) { - return true; - } - - /* - * (non-Javadoc) - * - * @see - * thredds.catalog.crawl.CatalogCrawler.Listener#getDataset(thredds.catalog - * .InvDataset, java.lang.Object) - */ - public void getDataset(InvDataset dd, Object context) { - String url = this.datasetURL + dd.getCatalogUrl().split("#")[1]; - - LOG.log(Level.FINE, url + " is the computed access URL for this dataset"); - // look for an OpenDAP access URL, only extract metadata if it is found - List<InvAccess> datasets = dd.getAccess(); - if (dd.getAccess() != null && dd.getAccess().size() > 0) { - for (InvAccess single : datasets) { - InvService service = single.getService(); - // note: select the OpenDAP access URL based on THREDDS service type - if (service.getServiceType() == ServiceType.OPENDAP) { - LOG.log(Level.FINE, "Found OpenDAP access URL: " + single.getUrlPath()); - String opendapurl = this.datasetURL + single.getUrlPath(); - // extract metadata from THREDDS catalog - MetadataExtractor extractor = new ThreddsMetadataExtractor(dd); - Metadata met = new Metadata(); - extractor.extract(met, conf); - // index metadata by opendap access URL - this.datasetMet.put(opendapurl, met); - this.urls.add(opendapurl); - break; - } - } - } - } - - /** - * Gets the set of String {@link java.net.URL}s crawled. - * - * @return A {@link List} of {@link String} representations of {@link java.net.URL}s. - */ - public List<String> getURLs() { - return this.urls; - } - - /** - * Returns the exracted THREDDS {@link InvDataset} metadata. The dataset - * metadata is mapped to the unique THREDDS dataset URL. - * - * @return the exracted THREDDS {@link InvDataset} metadata. - */ - public Map<String, Metadata> getDatasetMet() { - return this.datasetMet; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java b/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java deleted file mode 100644 index ba22df8..0000000 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * 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. - */ - -package org.apache.oodt.opendapps; - -//JDK imports -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.opendapps.config.OpendapConfig; -import org.apache.oodt.xmlquery.XMLQuery; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import opendap.dap.DConnect; -import opendap.dap.DataDDS; -import thredds.catalog.crawl.CatalogCrawler; -import ucar.nc2.util.CancelTask; - -//OODT imports -//NetCDF-Java imports - -/** - * - * This class takes in a query and the main catalog url and returns a list of - * relevant dataset urls - * - */ -public class DatasetExtractor { - - private static Logger LOG = Logger - .getLogger(DatasetExtractor.class.getName()); - - public static final String FINDALL = "PFunction=findall"; - - public static final String FINDSOME = "PFunction=findsome"; - - public static final String FINDQUERY = "PFunction=findquery"; - - private String q; - - private String mainCatalogURL; - - private String datasetURL; - - private List<String> allUrls; - - private Map<String, Metadata> datasetMet; - - private OpendapConfig conf; - - public DatasetExtractor(XMLQuery q, String mainCatalogURL, String datasetURL, OpendapConfig conf) { - this.q = q.getKwdQueryString().trim(); - this.mainCatalogURL = mainCatalogURL; - this.datasetURL = datasetURL; - this.conf = conf; - this.initExtraction(); - } - - public List<String> getDapUrls() { - List<String> urls = null; - - if (this.q.contains(FINDALL)) { - urls = this.allUrls; - } else if (this.q.contains(FINDSOME)) { - urls = this.getFindSome(); - } else if (this.q.contains(FINDQUERY)) { - urls = this.getFindQuery(); - } - - return urls; - } - - public Metadata getDatasetMet(String opendapUrl){ - return this.datasetMet.get(opendapUrl); - } - - private void initExtraction() { - DatasetCrawler listener = new DatasetCrawler(this.datasetURL, this.conf); - CancelTask ignore = new CancelTask() { - public boolean isCancel() { - return false; - } - - public void setError(String msg) { - LOG.log(Level.WARNING, msg); - } - - @Override - public void setProgress(String s, int i) { - - } - - }; - - LOG.log(Level.FINE, "catalogURL: " + this.mainCatalogURL); - // Note: look for all datasets, that have either a urlPath="" attribute, or a <access> subelement - CatalogCrawler crawler = new CatalogCrawler(CatalogCrawler.USE_ALL, false, listener); - crawler.crawl(this.mainCatalogURL, ignore, System.out, this); - this.allUrls = listener.getURLs(); - this.datasetMet = listener.getDatasetMet(); - } - - private List<String> getFindQuery() { - LOG.log(Level.FINE, "PFunction: findquery selected: orig query: [" + this.q - + "]"); - String queryExpression = ""; - Pattern parameterPattern = Pattern.compile("PParameter=\"(.+?)\""); - Matcher urlsMatch = parameterPattern.matcher(this.q); - while (urlsMatch.find()) { - queryExpression = urlsMatch.group(1); - } - - List<String> datasetUrls = new Vector<String>(); - - for (String datasetUrl : this.allUrls) { - DConnect dConn = null; - try { - dConn = new DConnect(datasetUrl, true); - } catch (FileNotFoundException e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, datasetUrl - + " is neither a valid URL nor a filename."); - } - try { - DataDDS dds = null; - if (dConn != null) { - dds = dConn.getData(queryExpression, null); - } - - if (dds != null) { - datasetUrls.add(datasetUrl); - } - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.SEVERE, " Some DAP2Exception or not a validate DDS", e); - } - } - - return datasetUrls; - - } - - private List<String> getFindSome() { - LOG.log(Level.FINE, "PFunction: findsome selected"); - String urlsString = ""; - Pattern parameterPattern = Pattern.compile("PParameter=\"(.+?)\""); - Matcher urlsMatch = parameterPattern.matcher(this.q); - while (urlsMatch.find()) { - urlsString = urlsMatch.group(1); - } - - LOG.log(Level.FINE, "PParameter: [" + urlsString - + "] parsed from original string query: [" + this.q + "]"); - - List<String> openDapUrls = new ArrayList<String>(); - - StringTokenizer tokens = new StringTokenizer(urlsString, ","); - while (tokens.hasMoreTokens()) { - openDapUrls.add(tokens.nextToken()); - } - - LOG.log(Level.FINE, "OPeNDAP urls: [" + openDapUrls + "]"); - return openDapUrls; - } - -}
