001: //=============================================================================
002: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.fao.geonet.csw.common.requests;
025:
026: import java.util.ArrayList;
027: import java.util.HashSet;
028: import org.fao.geonet.csw.common.Csw;
029: import org.fao.geonet.csw.common.Csw.Section;
030: import org.jdom.Element;
031:
032: //=============================================================================
033:
034: /** Params:
035: * - sections (0..n)
036: * - updateSequence (0..1)
037: * - acceptFormats (0..n)
038: * - acceptVersions (0..n)
039: */
040:
041: public class GetCapabilitiesRequest extends CatalogRequest {
042: private String sequence;
043:
044: private ArrayList<String> alVersions = new ArrayList<String>();
045: private ArrayList<String> alFormats = new ArrayList<String>();
046: private HashSet<Section> hsSections = new HashSet<Section>();
047:
048: //---------------------------------------------------------------------------
049: //---
050: //--- Constructor
051: //---
052: //---------------------------------------------------------------------------
053:
054: public GetCapabilitiesRequest() {
055: }
056:
057: //---------------------------------------------------------------------------
058: //---
059: //--- API methods
060: //---
061: //---------------------------------------------------------------------------
062:
063: public void addVersion(String version) {
064: alVersions.add(version);
065: }
066:
067: //---------------------------------------------------------------------------
068:
069: public void addSection(Section section) {
070: hsSections.add(section);
071: }
072:
073: //---------------------------------------------------------------------------
074:
075: public void addOutputFormat(String format) {
076: alFormats.add(format);
077: }
078:
079: //---------------------------------------------------------------------------
080:
081: public void setUpdateSequence(String sequence) {
082: this .sequence = sequence;
083: }
084:
085: //---------------------------------------------------------------------------
086: //---
087: //--- Protected methods
088: //---
089: //---------------------------------------------------------------------------
090:
091: protected String getRequestName() {
092: return "GetCapabilities";
093: }
094:
095: //---------------------------------------------------------------------------
096:
097: protected void setupGetParams() {
098: addParam("request", getRequestName());
099: addParam("service", Csw.SERVICE);
100:
101: if (sequence != null)
102: addParam("updateSequence", sequence);
103:
104: fill("acceptVersions", alVersions);
105: fill("sections", hsSections);
106: fill("acceptFormats", alFormats);
107: }
108:
109: //---------------------------------------------------------------------------
110:
111: protected Element getPostParams() {
112: Element params = new Element(getRequestName(),
113: Csw.NAMESPACE_CSW);
114:
115: params.setAttribute("service", Csw.SERVICE);
116:
117: if (sequence != null)
118: params.setAttribute("updateSequence", sequence);
119:
120: fill(params, "AcceptVersions", "Version", alVersions,
121: Csw.NAMESPACE_OWS);
122: fill(params, "Sections", "Section", hsSections,
123: Csw.NAMESPACE_OWS);
124: fill(params, "AcceptFormats", "OutputFormat", alFormats,
125: Csw.NAMESPACE_OWS);
126:
127: return params;
128: }
129: }
130:
131: //=============================================================================
|