getTimes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * XML string into abstract features then to PDOs
+ * @param payload
+ * @return
+ */
+ public PluginDataObject[] asPluginDataObjects(String payload) {
+
+ try {
+ FeatureCollectionType featureList = SerializationUtil.unmarshalFromXml(FeatureCollectionType.class, payload);
+ if (featureList.getNumberOfFeatures().intValue() > 0) {
+ int i = 0;
+ metadataAdapter.setPdos(featureList.getNumberOfFeatures().intValue());
+ for (FeaturePropertyType type : featureList.getFeatureMember()) {
+ JAXBElement extends AbstractFeatureType> feature = type.getFeature();
+ metadataAdapter.getPdos()[i] = metadataAdapter.getRecord(feature);
+ i++;
+ }
+ }
+ } catch (JAXBException e) {
+ statusHandler.handle(Priority.PROBLEM, "Can't de-serialize FeatureCollection", e);
+ }
+ return null;
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/ConnectionUtil.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/ConnectionUtil.java
index 627e08889f..3758173089 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/ConnectionUtil.java
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/ConnectionUtil.java
@@ -22,6 +22,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.util;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.regex.Pattern;
import com.raytheon.edex.colormap.ColorMapManager;
import com.raytheon.uf.common.comm.ProxyConfiguration;
@@ -45,6 +46,7 @@ import dods.dap.DConnect;
* ------------ ---------- ----------- --------------------------
* Jun 28, 2012 819 djohnson Initial creation
* Apr 01, 2013 1786 mpduff Pulled proxy settings out to util class.
+ * May 12, 2013 753 dhladky Expanded for use with other connection types
*
*
*
@@ -60,7 +62,7 @@ public class ConnectionUtil {
+ File.separator + "proxy.properties";
static ConnectionUtil instance = new ConnectionUtil();
-
+
static volatile boolean initialized;
private ProxyConfiguration proxySettings;
@@ -107,6 +109,8 @@ public class ConnectionUtil {
return instance.getProxyInformation();
}
+
+
private static synchronized void initialize() {
ProxyConfiguration proxyInformation = instance.getProxyInformation();
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalPersistUtil.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalPersistUtil.java
index 0a87b11f99..3dbd4675f4 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalPersistUtil.java
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalPersistUtil.java
@@ -52,7 +52,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.mapping.PluginRouteList;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Nov 26, 2012 1367 dhladky Common plugin route persistance
+ * Nov 26, 2012 1367 dhladky Common plugin route persistence
*
*
*
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java
new file mode 100644
index 0000000000..14e1568952
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java
@@ -0,0 +1,47 @@
+package com.raytheon.uf.edex.datadelivery.retrieval.util;
+
+import com.raytheon.uf.common.comm.HttpClient;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.common.status.UFStatus.Priority;
+
+/**
+ *
+ * WFS Connection.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * May 12, 2013 753 dhladky created.
+ *
+ *
+ *
+ * @author dhladky
+ * @version 1.0
+ */
+
+
+public class WfsConnectionUtil {
+
+ private static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(WfsConnectionUtil.class);
+
+ public static String wfsConnect(String address, String message) {
+ String xmlResponse = null;
+ // sets up any proxy info that might be necessary
+ ConnectionUtil.getProxyParameters();
+ HttpClient http = HttpClient.getInstance();
+
+ try {
+ xmlResponse = http.post(address, message);
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, "Couldn't connect to WFS server: "+address+" with posted message of: "+message, e);
+ }
+
+ return xmlResponse;
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalAdapter.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalAdapter.java
deleted file mode 100644
index b29e110889..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalAdapter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
-
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
-
-import java.util.HashMap;
-
-import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
-import com.raytheon.uf.common.dataplugin.PluginDataObject;
-import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
-import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
-import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
-import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
-
-/**
- * WFS OGC Provider Retrieval Adapter
- *
- *
- *
- * SOFTWARE HISTORY
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Jan 07, 2011 dhladky Initial creation
- * Jul 25, 2012 955 djohnson Moved to wfs specific package.
- *
- *
- *
- * @author dhladky
- * @version 1.0
- */
-
-public class WFSRetrievalAdapter extends RetrievalAdapter {
-
- public WFSRetrievalAdapter() {
-
- }
-
- @Override
- public IRetrievalRequestBuilder createRequestMessage(
- RetrievalAttribute prxml) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public HashMap processResponse(
- IRetrievalResponse response) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public RetrievalResponse performRequest(
- IRetrievalRequestBuilder request) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalGenerator.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalGenerator.java
deleted file mode 100644
index dd2753cce2..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WFSRetrievalGenerator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
-
-import java.util.List;
-
-import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
-import com.raytheon.uf.common.datadelivery.registry.Subscription;
-import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
-import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
-import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
-import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
-
-/**
- *
- * WFS Retrieval Generator.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Jul 25, 2012 955 djohnson Moved to wfs specific package.
- * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
- *
- *
- *
- * @author djohnson
- * @version 1.0
- */
-class WFSRetrievalGenerator extends RetrievalGenerator {
-
- WFSRetrievalGenerator() {
- super(ServiceType.WFS);
- }
-
- @Override
- public List buildRetrieval(SubscriptionBundle bundle) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected RetrievalAdapter getServiceRetrievalAdapter() {
- return new WFSRetrievalAdapter();
- }
-
- @Override
- protected Subscription removeDuplicates(Subscription sub) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRequestBuilder.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRequestBuilder.java
new file mode 100644
index 0000000000..893c374aef
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRequestBuilder.java
@@ -0,0 +1,164 @@
+package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.geotools.geometry.jts.ReferencedEnvelope;
+
+import com.raytheon.uf.common.datadelivery.registry.Coverage;
+import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
+import com.raytheon.uf.common.datadelivery.registry.Time;
+import com.raytheon.uf.common.datadelivery.retrieval.util.HarvesterServiceManager;
+import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
+import com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.edex.datadelivery.retrieval.request.RequestBuilder;
+
+/**
+ *
+ * WFS Request Builder.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * May 12, 2013 753 dhladky created.
+ *
+ *
+ *
+ * @author dhladky
+ * @version 1.0
+ */
+
+public class WfsRequestBuilder extends RequestBuilder {
+
+ private static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(WfsRequestBuilder.class);
+
+ protected static ServiceConfig wfsServiceConfig;
+
+ public static final String separator = getServiceConfig().getConstantValue("COMMA");
+
+ private final String wfsURL;
+
+ WfsRequestBuilder(WfsRetrievalAdapter adapter,
+ RetrievalAttribute attXML) {
+ super(attXML);
+
+ // Create URL
+ // this works in this order
+ StringBuilder buffer = new StringBuilder();
+ // apply the base WFS service URL
+ buffer.append(adapter.getProviderRetrievalXMl().getConnection()
+ .getUrl());
+ buffer.append("?");
+ // apply the feature you are trying to retrieve
+ buffer.append(getRetrievalAttribute().getParameter().getProviderName());
+ // process the coverage bounding box
+ buffer.append(processCoverage());
+ // process the time range you are trying to retrieve
+ buffer.append(processTime(getRetrievalAttribute().getTime()));
+
+ this.wfsURL = buffer.toString().trim();
+ }
+
+ private static ThreadLocal ogcDateFormat = new ThreadLocal() {
+
+ @Override
+ protected SimpleDateFormat initialValue() {
+
+ SimpleDateFormat sdf = new SimpleDateFormat(getServiceConfig()
+ .getDateConfig().getFormats().get(0));
+ return sdf;
+ }
+ };
+
+ @Override
+ public String processTime(Time time) {
+
+ try {
+ if (time.getEndDate() != null && time.getStartDate() != null) {
+ Date sDate = time.getStartDate();
+ Date eDate = time.getEndDate();
+ String endDateString = ogcDateFormat.get().format(eDate);
+ String startDateString = ogcDateFormat.get().format(sDate);
+ StringBuilder sb = new StringBuilder();
+ sb.append("&TIME=");
+ sb.append(startDateString);
+ sb.append("/");
+
+ if (!endDateString.equals(startDateString)) {
+ sb.append(endDateString);
+ }
+
+ return sb.toString();
+ }
+ } catch (Exception e) {
+ statusHandler.error("Couldn't parse Time object." + e);
+ }
+
+ // no times, return blank
+ return getServiceConfig().getConstantValue("BLANK");
+ }
+
+ @Override
+ public String processCoverage() {
+
+ // &srsName=crs:84&bbox=-100.0,41.0,-98.0,43.0
+ StringBuilder sb = new StringBuilder();
+ Coverage coverage = getRetrievalAttribute().getCoverage();
+
+ if (coverage != null) {
+ ReferencedEnvelope re = coverage.getRequestEnvelope();
+ // manage the box
+ double lowerLon = re.getMinX();
+ double lowerLat = re.getMinY();
+ double upperLon = re.getMaxX();
+ double upperLat = re.getMaxY();
+
+ sb.append("&srsName=");
+ sb.append(coverage.getEnvelope().getCoordinateReferenceSystem()
+ .getName());
+ sb.append("&bbox=");
+ sb.append(lowerLon);
+ sb.append(separator);
+ sb.append(lowerLat);
+ sb.append(separator);
+ sb.append(upperLon);
+ sb.append(separator);
+ sb.append(upperLat);
+
+ return sb.toString();
+ }
+
+ return getServiceConfig().getConstantValue("BLANK");
+ }
+
+ @Override
+ public String getRequest() {
+ return wfsURL;
+ }
+
+ @Override
+ public RetrievalAttribute getAttribute() {
+ return getRetrievalAttribute();
+ }
+
+ /**
+ * Get the instance of the service config
+ * @return
+ */
+ private static ServiceConfig getServiceConfig() {
+
+ if (wfsServiceConfig == null) {
+ wfsServiceConfig = HarvesterServiceManager.getInstance()
+ .getServiceConfig(ServiceType.WFS);
+ }
+
+ return wfsServiceConfig;
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalAdapter.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalAdapter.java
new file mode 100644
index 0000000000..89f61c92a4
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalAdapter.java
@@ -0,0 +1,141 @@
+package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
+
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
+import com.raytheon.uf.common.dataplugin.PluginDataObject;
+import com.raytheon.uf.common.event.EventBus;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.common.status.UFStatus.Priority;
+import com.raytheon.uf.common.util.CollectionUtil;
+import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalEvent;
+import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
+import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
+import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
+import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
+import com.raytheon.uf.edex.datadelivery.retrieval.response.WfsTranslator;
+import com.raytheon.uf.edex.datadelivery.retrieval.util.WfsConnectionUtil;
+
+/**
+ * WFS OGC Provider Retrieval Adapter
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 07, 2011 dhladky Initial creation
+ * Jul 25, 2012 955 djohnson Moved to wfs specific package.
+ * May 12, 2013 753 dhladky implemented.
+ *
+ *
+ *
+ * @author dhladky
+ * @version 1.0
+ */
+
+public class WfsRetrievalAdapter extends RetrievalAdapter {
+
+ private static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(WfsRetrievalAdapter.class);
+
+ private Pattern splitter = Pattern.compile("?");
+
+ @Override
+ public IRetrievalRequestBuilder createRequestMessage(
+ RetrievalAttribute attXML) {
+
+ WfsRequestBuilder reqBuilder = new WfsRequestBuilder(this, attXML);
+
+ return reqBuilder;
+ }
+
+ @Override
+ public Map processResponse(
+ IRetrievalResponse response) throws TranslationException {
+
+ Map map = new HashMap();
+ WfsTranslator translator;
+ try {
+ translator = getWfsTranslator(response.getAttribute());
+ } catch (InstantiationException e) {
+ throw new TranslationException(
+ "Unable to instantiate a required class!", e);
+ }
+
+ String payload = (String) response.getPayLoad();
+
+ try {
+ if (payload != null) {
+ PluginDataObject[] pdos = translator
+ .asPluginDataObjects(payload);
+
+ if (!CollectionUtil.isNullOrEmpty(pdos)) {
+ String pluginName = pdos[0].getPluginName();
+ map.put(pluginName,
+ CollectionUtil.combine(PluginDataObject.class,
+ map.get(pluginName), pdos));
+ }
+ }
+ } catch (ClassCastException e) {
+ throw new TranslationException(e);
+ }
+
+ return map;
+
+ }
+
+ @Override
+ public RetrievalResponse performRequest(
+ IRetrievalRequestBuilder request) {
+
+ String xmlMessage = null;
+ try {
+ // break url into CGI parameters and address
+ splitter.split(request.getRequest());
+ String[] parts = splitter.split(request.getRequest());
+ xmlMessage = WfsConnectionUtil.wfsConnect(parts[0], parts[1]);
+ } catch (Exception e) {
+ statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
+ EventBus.publish(new RetrievalEvent(e.getMessage()));
+ }
+
+ RetrievalResponse pr = new WfsRetrievalResponse(request.getAttribute());
+ pr.setPayLoad(xmlMessage);
+
+ return pr;
+ }
+
+ /**
+ * @param attribute
+ * @return
+ */
+ WfsTranslator getWfsTranslator(RetrievalAttribute attribute)
+ throws InstantiationException {
+ return new WfsTranslator(attribute);
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalGenerator.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalGenerator.java
new file mode 100644
index 0000000000..8bcb849900
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalGenerator.java
@@ -0,0 +1,227 @@
+package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.raytheon.uf.common.datadelivery.registry.Coverage;
+import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
+import com.raytheon.uf.common.datadelivery.registry.Parameter;
+import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
+import com.raytheon.uf.common.datadelivery.registry.PointTime;
+import com.raytheon.uf.common.datadelivery.registry.Provider.ProviderType;
+import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
+import com.raytheon.uf.common.datadelivery.registry.Subscription;
+import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
+import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
+import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
+import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
+import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.common.status.UFStatus.Priority;
+import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
+import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
+
+/**
+ *
+ * WFS Retrieval Generator.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Jul 25, 2012 955 djohnson Moved to wfs specific package.
+ * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
+ * May 12, 2013 753 dhladky Implemented
+ *
+ *
+ *
+ * @author djohnson
+ * @version 1.0
+ */
+class WfsRetrievalGenerator extends RetrievalGenerator {
+
+ private static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(WfsRetrievalGenerator.class);
+
+ WfsRetrievalGenerator() {
+ super(ServiceType.WFS);
+ }
+
+ @Override
+ public List buildRetrieval(SubscriptionBundle bundle) {
+
+ List retrievals = Collections.emptyList();
+ switch (bundle.getDataType()) {
+ case POINT:
+ retrievals = getPointRetrievals(bundle);
+ break;
+ default:
+ statusHandler.error("Grid DATA WFS NOT YET IMPLEMENTED");
+ throw new IllegalArgumentException("Grid DATA WFS NOT YET IMPLEMENTED");
+ }
+
+ return retrievals;
+ }
+
+ /**
+ * create the grid type retrievals
+ *
+ * @param bundle
+ * @return
+ */
+ private List getPointRetrievals(SubscriptionBundle bundle) {
+
+ List retrievals = new ArrayList();
+ Subscription sub = bundle.getSubscription();
+
+ sub = removeDuplicates(sub);
+
+ if (sub != null) {
+
+ PointTime subTime = (PointTime) sub.getTime();
+ String retrievalUrl = getRetrievalUrl(sub);
+ sub.setUrl(retrievalUrl);
+
+ if (sub.getUrl() == null) {
+ statusHandler
+ .info("Skipping subscription that is unfulfillable with the current metadata.");
+ return Collections.emptyList();
+ }
+
+ // with point data they all have the same data
+ Parameter param = sub.getParameter().get(0);
+ Retrieval retrieval = getRetrieval(sub, bundle,
+ param, subTime);
+ retrievals.add(retrieval);
+ }
+
+ return retrievals;
+ }
+
+ /**
+ * Determines the retrieval URL
+ *
+ * @param subscription
+ * the subscription
+ * @return the url for retrieval or null if no retrieval should take place
+ */
+ private static String getRetrievalUrl(Subscription subscription) {
+ String url = subscription.getUrl();
+
+ DataSetMetaData result = null;
+ try {
+ result = DataDeliveryHandlers.getDataSetMetaDataHandler().getById(
+ url);
+ if (result == null) {
+ throw new RegistryHandlerException(
+ "Unable to find the dataset by id from its unique url!",
+ new NullPointerException("DataSetMetaData"));
+ }
+
+ if (satisfiesSubscriptionCriteria(subscription, result)) {
+ return url;
+ }
+ } catch (RegistryHandlerException e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Unable to find the dataset by id from its unique url!", e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Determines whether a subscription can be satisified by the dataset
+ * metadata.
+ *
+ * @param subscription
+ * the subscription
+ * @param dsmd
+ * the dataset metadata
+ * @return true if the datasetmetadata will satisfy the subscription
+ */
+ @VisibleForTesting
+ static boolean satisfiesSubscriptionCriteria(Subscription subscription,
+ DataSetMetaData dsmd) {
+
+
+ if (dsmd instanceof PointDataSetMetaData) {
+ PointDataSetMetaData data = (PointDataSetMetaData) dsmd;
+ //TODO determine some check for validity of point data sets
+
+ return true;
+
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Get the retrieval
+ *
+ * @param sub
+ * @param bundle
+ * @param param
+ * @param level
+ * @param Time
+ * @return
+ */
+ private Retrieval getRetrieval(Subscription sub, SubscriptionBundle bundle,
+ Parameter param, PointTime time) {
+
+ Retrieval retrieval = new Retrieval();
+ retrieval.setSubscriptionName(sub.getName());
+ retrieval.setServiceType(getServiceType());
+ retrieval.setConnection(bundle.getConnection());
+ retrieval.getConnection().setUrl(sub.getUrl());
+ retrieval.setOwner(sub.getOwner());
+ retrieval.setSubscriptionType(getSubscriptionType(sub));
+ retrieval.setNetwork(sub.getRoute());
+
+ // Coverage and type processing
+ Coverage cov = sub.getCoverage();
+ ProviderType pt = null;
+ if (cov instanceof Coverage){
+ pt = ProviderType.POINT;
+ retrieval.setProviderType(pt);
+ } else {
+ throw new UnsupportedOperationException(
+ "WFS retrieval does not yet support coverages other than Point. ");
+ }
+
+ // Attribute processing
+ RetrievalAttribute att = new RetrievalAttribute();
+ Parameter lparam = processParameter(param);
+ att.setCoverage(cov);
+ lparam.setLevels(param.getLevels());
+ att.setTime(time);
+ att.setParameter(lparam);
+ att.setSubName(retrieval.getSubscriptionName());
+ att.setPlugin(pt.getPlugin());
+ att.setProvider(sub.getProvider());
+ retrieval.addAttribute(att);
+
+ return retrieval;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RetrievalAdapter getServiceRetrievalAdapter() {
+ return new WfsRetrievalAdapter();
+ }
+
+ @Override
+ protected Subscription removeDuplicates(Subscription sub) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalResponse.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalResponse.java
new file mode 100644
index 0000000000..6f03f720ec
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsRetrievalResponse.java
@@ -0,0 +1,51 @@
+package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
+import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
+import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
+
+/**
+ * {@link RetrievalResponse} for WFS.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * May 12, 2013 753 dhladky Initial creation
+ *
+ *
+ *
+ * @author dhladky
+ * @version 1.0
+ */
+
+@DynamicSerialize
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class WfsRetrievalResponse extends RetrievalResponse {
+
+ @XmlElement
+ private String payload;
+
+ public WfsRetrievalResponse(RetrievalAttribute attribute) {
+
+ }
+
+ @Override
+ public void setPayLoad(Object payLoad) {
+ this.payload = (String)payload;
+ }
+
+ @Override
+ public String getPayLoad() {
+ return payload;
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsServiceFactory.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsServiceFactory.java
index 1c03dd09c5..a3dc604ba6 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsServiceFactory.java
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/wfs/WfsServiceFactory.java
@@ -36,6 +36,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 955 djohnson Initial creation
+ * May 12, 2013 753 dhladky implementation
*
*
*
@@ -75,7 +76,7 @@ public class WfsServiceFactory implements ServiceFactory {
*/
@Override
public RetrievalGenerator getRetrievalGenerator() {
- return new WFSRetrievalGenerator();
+ return new WfsRetrievalGenerator();
}
}