001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data.ows;
017:
018: import java.io.IOException;
019: import java.io.InputStream;
020: import java.io.OutputStream;
021: import java.net.URL;
022: import java.util.Properties;
023:
024: import org.geotools.ows.ServiceException;
025:
026: /**
027: * This represents a Request to be made against a Open Web Service.
028: *
029: * @author rgould
030: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/data/ows/Request.java $
031: */
032: public interface Request {
033:
034: /** Represents the REQUEST parameter */
035: public static final String REQUEST = "REQUEST"; //$NON-NLS-1$
036: /** Represents the VERSION parameter */
037: public static final String VERSION = "VERSION"; //$NON-NLS-1$
038: /** Represents the WMTVER parameter */
039: public static final String WMTVER = "WMTVER"; //$NON-NLS-1$
040: public static final String SERVICE = "SERVICE";
041:
042: /**
043: * Once the properties of the request are configured, this will return
044: * the URL that points to the server and contains all of the appropriate
045: * name/value parameters.
046: *
047: * @return a URL that can be used to issue the request
048: */
049: public URL getFinalURL();
050:
051: /**
052: * Sets the name/value property for this request.
053: *
054: * Note that when using this method, it is up to the programmer to
055: * provide their own encoding of <code>value</code> according to the
056: * OWS specifications! The code will not do this for you.
057: *
058: * Different OWS specifications define different ways to do this. There are
059: * notorious differences between WMS 1.1.1 (section 6.2.1) and
060: * WMS 1.3.0 (section 6.3.2) for example.
061: *
062: * If value is null, "name" is removed from the properties table.
063: *
064: * @param name the name of the property
065: * @param value the value of the property
066: */
067: public void setProperty(String name, String value);
068:
069: /**
070: * @return a copy of this request's properties
071: */
072: public Properties getProperties();
073:
074: /**
075: * Each Request must know how to create it's counterpart Response.
076: * Given the content type and input stream (containin the response data),
077: * this method must return an appropriate Response object.
078: *
079: * @param contentType the MIME type of the data in the inputStream
080: * @param inputStream contains the data from the response
081: * @throws ServiceException
082: * @throws IOException
083: */
084: Response createResponse(String contentType, InputStream inputStream)
085: throws ServiceException, IOException;
086:
087: /**
088: * This method indicates whether this request needs to transmit some data
089: * to the server using POST. If this returns true, performPostOutput() will be called
090: * during the connection, allowing the data to be written out to the server.
091: *
092: * @return true if this request needs POST support, false otherwise.
093: */
094: boolean requiresPost();
095:
096: /**
097: * If this request uses POST, it must specify the content type of the data
098: * that is to be written out during performPostOutput().
099: *
100: * For open web services, this is usually "application/xml".
101: *
102: * @return the MIME type of the data to be sent during the request
103: */
104: String getPostContentType();
105:
106: /**
107: * This is called during the connection to the server, allowing this
108: * request to write out data to the server by using the provided
109: * outputStream.
110: *
111: * Implementors of this method do not need to call outputStream.flush() or
112: * outputStream.close(). The framework will call them immediately after
113: * calling this method.
114: *
115: * @param outputStream
116: */
117: void performPostOutput(OutputStream outputStream)
118: throws IOException;
119: }
|