diff --git a/geoportal_1/.classpath b/geoportal_1/.classpath
index 3b02e59..5ba1b84 100644
--- a/geoportal_1/.classpath
+++ b/geoportal_1/.classpath
@@ -6,18 +6,24 @@
-
-
+
+
-
+
+
-
+
+
+
+
+
+
diff --git a/geoportal_1/.project b/geoportal_1/.project
index 270bb76..3a3fc74 100644
--- a/geoportal_1/.project
+++ b/geoportal_1/.project
@@ -1,15 +1,35 @@
- geoportal
+ geoportalDev
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ com.aptana.ide.core.unifiedBuilder
+
+
+
org.eclipse.jdt.core.javabuilder
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
org.eclipse.m2e.core.maven2Builder
@@ -17,7 +37,12 @@
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.jdt.core.javanature
+ com.aptana.projects.webnature
org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.jsdt.core.jsNature
+ org.eclipse.wst.common.project.facet.core.nature
diff --git a/geoportal_1/.settings/.jsdtscope b/geoportal_1/.settings/.jsdtscope
new file mode 100644
index 0000000..29f5d7d
--- /dev/null
+++ b/geoportal_1/.settings/.jsdtscope
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/geoportal_1/.settings/org.eclipse.core.resources.prefs b/geoportal_1/.settings/org.eclipse.core.resources.prefs
index 8b421bd..839d647 100644
--- a/geoportal_1/.settings/org.eclipse.core.resources.prefs
+++ b/geoportal_1/.settings/org.eclipse.core.resources.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
-encoding//src/main/java/org/OpenGeoPortal/Export/GeoCommons/GeoCommonsJsonClient.java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
encoding/=UTF-8
diff --git a/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.container b/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.name b/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/geoportal_1/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/geoportal_1/java_library_licenses_summary.txt b/geoportal_1/java_library_licenses_summary.txt
new file mode 100644
index 0000000..af59d38
--- /dev/null
+++ b/geoportal_1/java_library_licenses_summary.txt
@@ -0,0 +1,15 @@
+
+Java:
+Spring Framework version 2.0 of the Apache License.
+Spring Security Apache 2.0 license
+GeoTools LGPL ; example code is explicitly public domain http://docs.geotools.org/stable/userguide/welcome/license.html
+Apache HttpComponents Apache 2.0 license
+Commons Compress Apache 2.0 license
+HttpClient Mime Apache 2.0 license
+Jackson JSON library dual, Apache 2.0, LGPL 2.1
+JUnit IBM's Common Public License Version 0.5
+Solr Apache 2.0 license
+cors filter Apache 2.0 license. http://software.dzhuvinov.com/cors-filter.html
+log4j Apache 2.0 license
+slf4j MIT license
+Selenium Apache 2.0 License
\ No newline at end of file
diff --git a/geoportal_1/pom.xml b/geoportal_1/pom.xml
index b44f614..cdd8f2c 100644
--- a/geoportal_1/pom.xml
+++ b/geoportal_1/pom.xml
@@ -1,31 +1,46 @@
- 4.0.0
- org.OpenGeoPortal
- geoportal
- war
- 1.2.RC1
- opengeoportal webapp
- http://opengeoportal.org
-
+ on a headless server use -Dheadless=true. additional information is at http://code.google.com/p/opengeoportal/wiki/AutomatedTesting -->
- 3.1.2.RELEASE
- 2.0.5
- UTF-8
- UTF-8
+ 4.0.3.RELEASE
+ 3.2.3.RELEASE
+ 10-SNAPSHOT
+ 2.3.2
+ UTF-8
+ UTF-8
+ 1.7.2
+ opengeoportal
@@ -131,28 +146,24 @@
test
-
-
+
org.apache.httpcomponents
httpcore
- 4.2.1
+ 4.3
org.apache.httpcomponents
httpclient
- 4.2.1
+ 4.3.1
junit
junit
- 4.8.1
- test
+ 4.11
@@ -162,98 +173,197 @@
runtime
-
-
org.slf4j
jcl-over-slf4j
- 1.6.6
+ 1.7.5
org.slf4j
slf4j-api
- 1.6.6
+ 1.7.5
org.slf4j
slf4j-log4j12
- 1.6.6
+ 1.7.5
log4j
log4j
- 1.2.14
+ 1.2.17
org.apache.solr
solr-solrj
- 4.0.0
+ 4.5.1
org.springframework.security
spring-security-core
- 3.1.2.RELEASE
+ ${org.springframework.security.version}
org.springframework.security
spring-security-config
- 3.1.2.RELEASE
+ ${org.springframework.security.version}
org.springframework.security
spring-security-web
- 3.1.2.RELEASE
+ ${org.springframework.security.version}
org.springframework.security
spring-security-ldap
- 3.1.2.RELEASE
-
-
- org.codehaus.jackson
- jackson-core-lgpl
- 1.9.9
-
-
- org.codehaus.jackson
- jackson-mapper-lgpl
- 1.9.9
-
-
- org.apache.commons
- commons-compress
- 1.4.1
-
-
- org.apache.httpcomponents
- httpmime
- 4.2.1
-
-
- javax.servlet
- javax.servlet-api
- 3.1-b02
- provided
-
+ ${org.springframework.security.version}
+
+
+ org.springframework.security
+ spring-security-cas
+ ${org.springframework.security.version}
+
+
+ org.apache.commons
+ commons-compress
+ 1.6
+
+
+ org.apache.httpcomponents
+ httpmime
+ 4.3.1
+
+
+ com.thetransactioncompany
+ cors-filter
+ 1.9.2
+
+
+
+ org.geotools
+ gt-main
+ ${geotools.version}
+
+
+ org.geotools
+ gt-shapefile
+ ${geotools.version}
+
+
+ org.geotools
+ gt-metadata
+ ${geotools.version}
+
+
+ org.geotools
+ gt-referencing
+ ${geotools.version}
+
+
+ org.geotools
+ gt-epsg-hsql
+ ${geotools.version}
+
+
+ org.geotools
+ gt-epsg-extension
+ ${geotools.version}
+
+
+ org.geotools
+ gt-wfs
+ ${geotools.version}
+
+
+ org.apache.httpcomponents
+ httpclient-cache
+ 4.3.1
+
+
+
+ javax.servlet
+ servlet-api
+ 2.5
+ provided
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ javax.servlet
+ jstl
+ 1.2
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.1
+
+
+ org.eclipse.persistence
+ eclipselink
+ 2.5.2-M1
+
- opengeoportal
+ ${warFile.name}
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 2.12
-
-
-
- integration-test
- verify
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.0
+
+ 1.7
+ 1.7
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.12
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+ ro.isdc.wro4j
+ wro4j-maven-plugin
+ ${wro4j.version}
+
+
+ compile
+
+ run
+
+
+
+
+ ogp,ogpLib
+ true
+ ${basedir}/target/${warFile.name}/resources/css/
+ ${basedir}/target/${warFile.name}/resources/javascript/
+ ro.isdc.wro.extensions.manager.standalone.GoogleStandaloneManagerFactory
+
+
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/AbstractLayerDownloader.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/AbstractLayerDownloader.java
deleted file mode 100644
index 3953644..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/AbstractLayerDownloader.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.io.File;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-
-/**
- * Abstract class for downloading layers
- * @author chris
- *
- */
-//the layer downloader should handle all the errors thrown by the download method,
-//and take care of layer status
-abstract class AbstractLayerDownloader implements LayerDownloader {
- private String responseFileType;
- private String responseFileName;
-
- public String getResponseFileType() {
- return this.responseFileType;
- }
-
- public String getResponseFileName() {
- return this.responseFileName;
- }
-
- public void setResponseFileName(String responseFileName) {
- this.responseFileName = responseFileName;
- }
-
- abstract public void downloadLayers(MethodLevelDownloadRequest request) throws Exception;
-
- /**
- * method for changing a layer's Name to a string that can be used as a file name.
- * could be more robust
- *
- * @param layerName
- * @return filtered layer name
- */
- String filterFileName(String layerName){
- //remove the workspace name prefix if it exists
- layerName = layerName.substring(layerName.indexOf(":") + 1);
- //replace periods with underscores
- layerName = layerName.replace(".", "_");
- return layerName;
- }
-
- /**
- * method creates a new file, adds the appropriate extension to the filename based on MIME-TYPE
- * @param layerObject
- * @return a handle to the new file
- */
- File createNewFileObject(LayerRequest layerObject){
- //TODO probably should put this in a separate class or find an existing class that does MIME-TYPE to file extenstion mapping
- String fileName = this.filterFileName(layerObject.getLayerInfo().getName());
- String responseContentType = layerObject.responseMIMEType;
- System.out.println("response MIME-Type: " + responseContentType);
- //get info from RequestedLayer object
- if (responseContentType.indexOf(";") > -1){
- responseContentType = responseContentType.substring(0, responseContentType.indexOf(";"));
- }
- String fileExtension;
- if ((responseContentType.contains("text/xml")||responseContentType.contains("application/xml"))){
- fileExtension = ".xml";
- } else if ((responseContentType.contains("text/html")||responseContentType.contains("application/html"))){
- fileExtension = ".html";
- } else if (responseContentType.contains("application/zip")){
- fileExtension = ".zip";
- } else if ((responseContentType.equals("image/tiff;subtype=\"geotiff\""))||responseContentType.contains("image/tiff")){
- fileExtension = ".tif";
- } else if (responseContentType.contains("image/jpeg")){
- fileExtension = ".jpg";
- } else if (responseContentType.contains("application/vnd.google-earth.kmz")){
- fileExtension = ".kmz";
- } else if (responseContentType.contains("application/vnd.ogc.se_xml")){
- fileExtension = "_error.xml";
- } else {
- fileExtension = ".unk";
- }
-
- File newFile = new File(layerObject.getTargetDirectory(), fileName + fileExtension);
- int i = 1;
- while (newFile.exists()){
- newFile = new File(layerObject.getTargetDirectory(), fileName + i + fileExtension);
- i++;
- }
- return newFile;
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/DownloadConfigRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/DownloadConfigRetriever.java
deleted file mode 100644
index 0877894..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/DownloadConfigRetriever.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.OpenGeoPortal.Download.Config;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-
-public interface DownloadConfigRetriever {
- String getClassKey(LayerRequest layer) throws Exception;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/OgpDownloadConfigRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/OgpDownloadConfigRetriever.java
deleted file mode 100644
index ce495eb..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Config/OgpDownloadConfigRetriever.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.OpenGeoPortal.Download.Config;
-
-import java.util.Iterator;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.node.ArrayNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OgpDownloadConfigRetriever extends ConfigRetriever implements DownloadConfigRetriever{
-
- /*
- *
- * if (!currentLayer.accessLevel.equalsIgnoreCase("public")){
- try {
- if (currentLayer.institution.equalsIgnoreCase(this.searchConfigRetriever.getHome())){
- if (!this.getLocallyAuthenticated()){
- //if the user is not logged in, deny the request
- currentLayer.setStatus(LayerStatus.PERMISSION_DENIED);
- continue;
- }
- } else {
- //currently no way to log in to remote institutions, so just deny all requests
- currentLayer.setStatus(LayerStatus.PERMISSION_DENIED);
- continue;
- }
- } catch (Exception e){
- currentLayer.setStatus(LayerStatus.PERMISSION_DENIED);
- System.out.println("CONFIGURATION ERROR: Please set your home institution in ogpConfig.json.");
- }
- }
- *
- *
- * (non-Javadoc)
- * @see org.OpenGeoPortal.Download.DownloadConfigRetriever#getClassKey(org.OpenGeoPortal.Download.RequestedLayer)
- */
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- public String getClassKey(LayerRequest layer) throws Exception {
- this.readConfigFile();
- SolrRecord record = layer.getLayerInfo();
- JsonNode institutions = this.configContents.path("institutions");
- ArrayNode jsonArray = (ArrayNode) institutions.path(record.getInstitution());
- Iterator institutionIterator = jsonArray.getElements();
- String classKey = null;
- while (institutionIterator.hasNext()){
- JsonNode currentNode = institutionIterator.next();
- ArrayNode accessArrayNode = (ArrayNode) currentNode.path("accessLevel");
- Boolean accessMatch = false;
- Iterator accessIterator = accessArrayNode.iterator();
- while (accessIterator.hasNext()){
- if (accessIterator.next().getTextValue().equalsIgnoreCase(record.getAccess().toLowerCase())){
- accessMatch = true;
- }
- }
- if (!accessMatch){
- continue;
- }
- logger.debug("access match");
- Boolean dataTypeMatch = false;
- ArrayNode dataTypeArrayNode = (ArrayNode) currentNode.path("dataType");
- String generalizedDataType = record.getDataType().toLowerCase();
-
- if (generalizedDataType.equals("point")||generalizedDataType.equals("line")||generalizedDataType.equals("polygon")){
- generalizedDataType = "vector";
- }
- Iterator dataTypeIterator = dataTypeArrayNode.iterator();
- while (dataTypeIterator.hasNext()){
- if (dataTypeIterator.next().getTextValue().equalsIgnoreCase(generalizedDataType)){
- dataTypeMatch = true;
- }
- }
- if (!dataTypeMatch){
- continue;
- }
- logger.debug("data type match");
- Boolean outputFormatMatch = false;
- ArrayNode outputFormatArrayNode = (ArrayNode) currentNode.path("outputFormats");
- Iterator outputFormatIterator = outputFormatArrayNode.iterator();
- while (outputFormatIterator.hasNext()){
- if (outputFormatIterator.next().getTextValue().equalsIgnoreCase(layer.getRequestedFormat().toLowerCase())){
- outputFormatMatch = true;
- }
- }
- if (!outputFormatMatch){
- continue;
- }
- logger.debug("requested format match");
- classKey = currentNode.path("classKey").getTextValue();
- if (accessMatch && dataTypeMatch && outputFormatMatch){
- break;
- }
- }
- if (classKey == null){
- logger.error("Class Key not defined for this layer.");
- throw new Exception("Class Key not defined for this layer.");
- }
- logger.debug(layer.getId() + ": " + classKey);
- return classKey;
- }
-
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/DownloadRetrievalController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/DownloadRetrievalController.java
deleted file mode 100644
index ee2f7e7..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/DownloadRetrievalController.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.OpenGeoPortal.Download.Controllers;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.UUID;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Download.DownloadRequest;
-import org.OpenGeoPortal.Download.RequestStatusManager;
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@Controller
-@RequestMapping("/getDownload")
-public class DownloadRetrievalController {
- @Autowired
- private RequestStatusManager requestStatusManager;
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- final static long TIMEOUT = 5000;//milliseconds
- final static long INTERVAL = 500;//milliseconds
-
- @RequestMapping(method=RequestMethod.GET)
- public void getDownload(@RequestParam("requestId") String requestId, HttpServletResponse response) throws IOException, InterruptedException {
-
- DownloadRequest layerDownloadRequest = requestStatusManager.getDownloadRequest(UUID.fromString(requestId));
- File downloadPackage = layerDownloadRequest.getDownloadPackage();
- long counter = 0;
- //a final check. should never get here via the client
- while (!downloadPackage.exists()){
- Thread.sleep(INTERVAL);
- counter += INTERVAL;
- if (counter >= TIMEOUT){
- logger.error("Download timed out. File could not be found.");
- throw new IOException("File does not exist.");
- }
- }
- logger.info("Milliseconds slept: " + Long.toString(counter));
- response.setContentLength((int) downloadPackage.length());
- response.setContentType("application/zip");
- response.addHeader("Content-Disposition", "attachment;filename=" + downloadPackage.getName());
- FileUtils.copyFile(downloadPackage, response.getOutputStream());
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/MetadataDownloadController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/MetadataDownloadController.java
deleted file mode 100644
index 2a10146..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Controllers/MetadataDownloadController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.OpenGeoPortal.Download.Controllers;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Download.MetadataRetriever;
-import org.OpenGeoPortal.Metadata.LayerInfoRetriever;
-import org.OpenGeoPortal.Utilities.OgpFileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-@RequestMapping("/getMetadata")
-public class MetadataDownloadController {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private MetadataRetriever metadataRetriever;
- @Autowired
- private LayerInfoRetriever layerInfoRetriever;
-
- @RequestMapping(value="/{download}", method=RequestMethod.GET)
- public @ResponseBody void processMetadataDownload(@PathVariable String download, @RequestParam("id") String id, HttpServletResponse response) throws Exception {
- Boolean downloadBool = false;
- if (download.equals("download")){
- downloadBool = true;
- }
- handleMetadataRequest(id, downloadBool, response);
- }
-
-
- @RequestMapping(method=RequestMethod.GET)
- public @ResponseBody void processMetadataDownload(@RequestParam("id") String id, HttpServletResponse response) throws Exception {
- /**
- * This controller should receive a GET request with the layerId and a boolean "inline" that tells whether the data should
- * appear inline or as an attachment
- *
- * @author Chris Barnett
- */
- handleMetadataRequest(id, false, response);
- }
-
- private void handleMetadataRequest(String id, Boolean download, HttpServletResponse response) throws IOException{
- String disposition;
- String contentType;
- if (download){
- disposition = "attachment";
- contentType = "application/octet-stream";
- } else {
- disposition = "inline";
- contentType = "application/xml";
- }
-
- String metadataString = null;
- try {
- metadataString = this.metadataRetriever.getXMLStringFromId(id, "fgdc");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- response.setContentLength(metadataString.getBytes("UTF-8").length);
- String fileName = null;
- try {
- fileName = layerInfoRetriever.getAllLayerInfo(id).getName();
- } catch (Exception e) {
- e.printStackTrace();
- fileName = id;
- }
- response.setHeader("Content-Disposition", disposition + "; filename=\""
- + OgpFileUtils.filterName(fileName) + ".xml" + "\"");
- response.setContentType(contentType);
- // return a link to the zip file, or info to create link
- response.getWriter().write(metadataString);
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandler.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandler.java
deleted file mode 100644
index 47a0dd4..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandler.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.util.Map;
-import java.util.UUID;
-
-public interface DownloadHandler {
- public UUID requestLayers(String sessionId, Map layerMap, String[] requestedBounds, String emailAddress, Boolean locallyAuthenticated) throws Exception;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandlerImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandlerImpl.java
deleted file mode 100644
index e07a501..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadHandlerImpl.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.OpenGeoPortal.Download.LayerDownloader;
-import org.OpenGeoPortal.Download.Config.DownloadConfigRetriever;
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-import org.OpenGeoPortal.Download.Types.LayerRequest.Status;
-import org.OpenGeoPortal.Metadata.LayerInfoRetriever;
-import org.OpenGeoPortal.Solr.SearchConfigRetriever;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.OpenGeoPortal.Utilities.DirectoryRetriever;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-
-/**
- * This is an abstract class that provides the logic to determine which concrete class
- * should be selected to download a layer.
- *
- *
- * @author Chris Barnett
- *
- */
-public class DownloadHandlerImpl implements DownloadHandler, BeanFactoryAware {
- private List layerInfo;
- private Boolean locallyAuthenticated = false;
- @Autowired
- protected LayerInfoRetriever layerInfoRetriever;
- @Autowired
- protected DownloadConfigRetriever downloadConfigRetriever;
- @Autowired
- protected SearchConfigRetriever searchConfigRetriever;
- private String emailAddress = "";
- @Autowired
- private DirectoryRetriever directoryRetriever;
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- protected RequestStatusManager requestStatusManager;
-
- protected BeanFactory beanFactory;
-
- /**
- * a method to set the locallyAuthenticated property.
- *
- * This is a way to pass information about the user's session into the java class. If the user has
- * authenticated locally, a session variable is set. The calling code should set this value.
- *
- * @param authenticated true if the user has authenticated locally, otherwise false
- */
- public void setLocallyAuthenticated(Boolean authenticated){
- this.locallyAuthenticated = authenticated;
- }
-
- /**
- * a method to get the locallyAuthenticated property.
- *
- * @return true if the user has authenticated locally, otherwise false
- */
- public Boolean getLocallyAuthenticated(){
- return this.locallyAuthenticated;
- }
-
-
- /**
- * a method that sets an email address. Only used for certain download types
- *
- * @param a string containing the user's email address passed from the client
- */
- public void setReplyEmail(String emailAddress){
- this.emailAddress = emailAddress;
- }
-
-
-
- /**
- * the main method of the class. Initializes layers and bounds, calls download actions in appropriate
- * order
- *
- * @param layerMap a hashmap that maps Solr layer IDs to requested download format
- * @param bounds an array of geodetic bounding coordinates (eastmost, southmost, westmost, northmost)
- * @return boolean that indicates the success of the function
- * @throws Exception
- */
- public UUID requestLayers(String sessionId, Map layerMap, String[] bounds, String emailAddress, Boolean locallyAuthenticated) throws Exception{
- this.setReplyEmail(emailAddress);
- this.setLocallyAuthenticated(locallyAuthenticated);
- Map > downloadRequestMap = null;
- UUID requestId = UUID.randomUUID();
- downloadRequestMap = this.createDownloadRequestMap(layerMap, bounds);
- this.submitDownloadRequest(sessionId, requestId, downloadRequestMap);
- return requestId;
- }
-
- private Map > createDownloadRequestMap (Map layerMap, String[] bounds) throws Exception {
- this.layerInfo = this.layerInfoRetriever.fetchAllLayerInfo(layerMap.keySet());
- Map > downloadMap = new HashMap>();
- for (SolrRecord record: this.layerInfo){
- logger.debug("Requested format: " + layerMap.get(record.getLayerId()));
- LayerRequest layerRequest = this.createLayerRequest(record, layerMap.get(record.getLayerId()), bounds);
- String currentClassKey = null;
- try {
- currentClassKey = this.downloadConfigRetriever.getClassKey(layerRequest);
- logger.info("DownloadKey: " + currentClassKey);
- } catch(Exception e) {
- layerRequest.setStatus(Status.FAILED);
- logger.info("No download method found for: '" + record.getLayerId() +"'");
- continue;
- }
- if (downloadMap.containsKey(currentClassKey)){
- List currentLayerList = downloadMap.get(currentClassKey);
- currentLayerList.add(layerRequest);
- } else {
- List newLayerList = new ArrayList();
- newLayerList.add(layerRequest);
- downloadMap.put(currentClassKey, newLayerList);
- }
- }
- return downloadMap;
-
- }
-
- private LayerRequest createLayerRequest(SolrRecord solrRecord, String requestedFormat, String[] bounds){
- LayerRequest layer = new LayerRequest(solrRecord, requestedFormat);
- layer.setRequestedBounds(new BoundingBox(bounds[0], bounds[1], bounds[2], bounds[3]));
- layer.setEmailAddress(this.emailAddress);
- layer.setTargetDirectory(this.directoryRetriever.getDownloadDirectory());
- return layer;
- }
-
-
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
- this.beanFactory = beanFactory;
- }
-
- /**
- * a method to get a concrete class of type LayerDownloader given a string key defined in WEB-INF/download.xml
- *
- *
- * @param downloaderKey a string key that identifies a concrete class of LayerDownloader
- * @return the concrete LayerDownloader object
- */
- public LayerDownloader getLayerDownloader(String downloaderKey){
- LayerDownloader layerDownloader = (LayerDownloader) beanFactory.getBean(downloaderKey);
- return layerDownloader;
- }
-
- /**
- * a method that finds the appropriate concrete LayerDownloader and makes the actual request to download layers.
- *
- * @param downloadMap a map that relates a string key (that identifies the concrete LayerDownloader Class) to a List of
- * LayerRequest objects that can be downloaded using that concrete class.
- */
- @Async
- public void submitDownloadRequest(String sessionId, UUID requestId, Map > downloadMap) {
- List requestList = new ArrayList();
- for (String currentDownloader: downloadMap.keySet()){
- //get concrete class key from config
- List layerRequests = downloadMap.get(currentDownloader);
- MethodLevelDownloadRequest request = new MethodLevelDownloadRequest(layerRequests);
-
- try{
- LayerDownloader layerDownloader = this.getLayerDownloader(currentDownloader);
- layerDownloader.downloadLayers(requestId, request);
- requestList.add(request);
-
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("runDownloadRequest: " + e.getMessage());
- //should put error info in the status manager for these layers
- }
- }
- requestStatusManager.addDownloadRequest(requestId, sessionId, requestList);
- }
-
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadPackager.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadPackager.java
deleted file mode 100644
index d39d96b..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadPackager.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.util.UUID;
-
-public interface DownloadPackager {
- void packageFiles(UUID requestId) throws Exception;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadRequest.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadRequest.java
deleted file mode 100644
index c47c225..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadRequest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.OpenGeoPortal.Download.Controllers.RequestStatusController.StatusSummary;
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-import org.OpenGeoPortal.Download.Types.LayerRequest.Status;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DownloadRequest {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- private UUID requestId;
- private String sessionId;
- private File downloadPackage;
- private List requestList = new ArrayList();
- private Boolean downloadPackageSet = false;;
-
- public UUID getRequestId() {
- return requestId;
- }
- public void setRequestId(UUID requestId) {
- this.requestId = requestId;
- }
- public String getSessionId() {
- return sessionId;
- }
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- public File getDownloadPackage() {
- return downloadPackage;
- }
- public void setDownloadPackage(File downloadPackage) {
- this.downloadPackage = downloadPackage;
- logger.info("Download package: " + downloadPackage.getAbsolutePath());
- this.downloadPackageSet = true;
- }
-
- public List getRequestList() {
- return requestList;
- }
-
- public void setRequestList(List layerRequests){
- requestList = layerRequests;
- }
-
- private Boolean isPostProcessingComplete(){
- if (downloadPackageSet){
- if (this.downloadPackage.exists()){
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- public Boolean isReadyForPackaging(){
- StatusSummary completionStatus = getRawStatusSummary();
- if (completionStatus.equals(StatusSummary.COMPLETE_SUCCEEDED) || completionStatus.equals(StatusSummary.COMPLETE_PARTIAL)){
- if (!isPostProcessingComplete()){
- return true;
- }
- }
- return false;
- }
-
- private StatusSummary getRawStatusSummary(){
- //Processing or Complete for the request
- StatusSummary completionStatus = null;
- int successCount = 0;
- int failureCount = 0;
- List layerList = new ArrayList();
- for (MethodLevelDownloadRequest request: requestList){
- layerList.addAll(request.getRequestList());
- }
- for (LayerRequest request: layerList){
- if (request.getStatus().equals(Status.PROCESSING)){
- return StatusSummary.PROCESSING;
- } else if (request.getStatus().equals(Status.SUCCESS)) {
- successCount++;
- } else if (request.getStatus().equals(Status.FAILED)){
- failureCount++;
- }
- }
- if (failureCount == 0){
- completionStatus = StatusSummary.COMPLETE_SUCCEEDED;
- } else if (successCount == 0){
- completionStatus = StatusSummary.COMPLETE_FAILED;
- } else {
- completionStatus = StatusSummary.COMPLETE_PARTIAL;
- }
- return completionStatus;
- }
-
- public StatusSummary getStatusSummary() {
- StatusSummary completionStatus = getRawStatusSummary();
-
- if (completionStatus.equals(StatusSummary.COMPLETE_SUCCEEDED) || completionStatus.equals(StatusSummary.COMPLETE_PARTIAL)){
- if (!isPostProcessingComplete()){
- return StatusSummary.PROCESSING;
- }
- }
- return completionStatus;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/MethodLevelDownloadRequest.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/MethodLevelDownloadRequest.java
deleted file mode 100644
index 38af26d..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/MethodLevelDownloadRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.OpenGeoPortal.Download;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MethodLevelDownloadRequest {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private List requestList = new ArrayList();
-
- MethodLevelDownloadRequest(List request){
- setRequestList(request);
- }
-
- public List getRequestList() {
- return requestList;
- }
-
- public void setRequestList(List layerRequests){
- requestList = layerRequests;
- }
- public void addLayerRequest(LayerRequest layerRequest) {
- this.requestList.add(layerRequest);
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/AbstractDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/AbstractDownloadMethod.java
deleted file mode 100644
index c897bea..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/AbstractDownloadMethod.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-import java.util.concurrent.Future;
-
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.OpenGeoPortal.Utilities.DirectoryRetriever;
-import org.OpenGeoPortal.Utilities.OgpFileUtils;
-import org.OpenGeoPortal.Utilities.Http.HttpRequester;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.AsyncResult;
-
-public abstract class AbstractDownloadMethod {
- protected LayerRequest currentLayer;
- protected HttpRequester httpRequester;
- @Autowired
- protected DirectoryRetriever directoryRetriever;
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-
- public HttpRequester getHttpRequester() {
- return httpRequester;
- }
-
- public void setHttpRequester(HttpRequester httpRequester) {
- this.httpRequester = httpRequester;
- }
-
- public abstract Set getExpectedContentType();
-
- public Boolean expectedContentTypeMatched(String foundContentType){
- if (getExpectedContentType().contains(foundContentType)){
- return true;
- } else {
- return false;
- }
- }
-
- @Async
- public Future download(LayerRequest currentLayer) throws Exception {
- this.currentLayer = currentLayer;
- currentLayer.setMetadata(this.includesMetadata());
- InputStream inputStream = this.httpRequester.sendRequest(this.getUrl(), createDownloadRequest(), getMethod());
- File directory = getDirectory();
- String contentType = httpRequester.getContentType().toLowerCase();
- Boolean contentMatch = expectedContentTypeMatched(contentType);
- if (!contentMatch){
- logger.error("Unexpected content type: " + contentType);
- //If their is a mismatch with the expected content, but the response is text, we want to at least log the response
- if (contentType.toLowerCase().contains("text")||contentType.toLowerCase().contains("html")||contentType.toLowerCase().contains("xml")){
- logger.error("Returned text: " + IOUtils.toString(inputStream));
- }
-
- throw new Exception("Unexpected content type");
-
- }
- File outputFile = OgpFileUtils.createNewFileFromDownload(currentLayer.getLayerInfo().getName(), contentType, directory);
- //OutputStream outputStream = new FileOutputStream(outputFile);
- //FileUtils with a BufferedInputStream seems to be the fastest method with a small sample size. requires more testing
- InputStream bufferedIn = new BufferedInputStream(inputStream);
- FileUtils.copyInputStreamToFile(bufferedIn, outputFile);
- /*try {
- int currentBytes;
- while ((currentBytes = bufferedIn.read()) != -1) {
- outputStream.write(currentBytes);
- }
- } finally {
- try {
- bufferedIn.close();
- } finally {
- outputStream.close();
- }
- }*/
-
- return new AsyncResult(outputFile);
- }
-
- protected abstract Boolean includesMetadata();
-
- private File getDirectory() throws IOException{
- File downloadDirectory = this.directoryRetriever.getDownloadDirectory();
- File newDir = File.createTempFile("OGP", "", downloadDirectory);
- newDir.delete();
- //Boolean success=
- newDir.mkdir();
- newDir.setReadable(true);
- newDir.setWritable(true);
- return newDir;
- }
-
- public abstract String createDownloadRequest() throws Exception;
-
- public abstract String getUrl();
-
- public abstract String getMethod();
-
- public BoundingBox getClipBounds(){
- SolrRecord layerInfo = this.currentLayer.getLayerInfo();
- BoundingBox nativeBounds = new BoundingBox(layerInfo.getMinX(), layerInfo.getMinY(), layerInfo.getMaxX(), layerInfo.getMaxY());
- BoundingBox bounds = nativeBounds.getIntersection(this.currentLayer.getRequestedBounds());
- return bounds;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/EmailDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/EmailDownloadMethod.java
deleted file mode 100644
index 25e732a..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/EmailDownloadMethod.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.util.concurrent.Future;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-
-public interface EmailDownloadMethod {
-
- Boolean includesMetadata();
-
- String createDownloadRequest();
-
- Future sendEmail(LayerRequest currentLayer)
- throws Exception;
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/MultiLayerDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/MultiLayerDownloadMethod.java
deleted file mode 100644
index b69ffc5..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/MultiLayerDownloadMethod.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.File;
-import java.util.concurrent.Future;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-
-public interface MultiLayerDownloadMethod {
-
- Boolean includesMetadata();
-
- String createDownloadRequest();
-
- Future download(LayerRequest currentLayer)
- throws Exception;
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/PerLayerDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/PerLayerDownloadMethod.java
deleted file mode 100644
index e892aa6..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/PerLayerDownloadMethod.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.File;
-import java.util.concurrent.Future;
-
-import org.OpenGeoPortal.Download.Types.LayerRequest;
-
-public interface PerLayerDownloadMethod {
-
- Future download(LayerRequest currentLayer) throws Exception;
- Boolean includesMetadata();
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWcsDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWcsDownloadMethod.java
deleted file mode 100644
index 0608f30..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWcsDownloadMethod.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-public class ProxiedWcsDownloadMethod extends WcsDownloadMethod
- implements PerLayerDownloadMethod {
- private String proxyTo;
- @Override
- public String getUrl(){
- return this.proxyTo;
- }
- public String getProxyTo() {
- return proxyTo;
- }
- public void setProxyTo(String proxyTo) {
- this.proxyTo = proxyTo;
- };
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWfsDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWfsDownloadMethod.java
deleted file mode 100644
index 265d101..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/ProxiedWfsDownloadMethod.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-
-public class ProxiedWfsDownloadMethod extends
- WfsDownloadMethod implements PerLayerDownloadMethod {
- private String proxyTo;
- @Override
- public String getUrl(){
- return this.proxyTo;
- }
- public String getProxyTo() {
- return proxyTo;
- }
- public void setProxyTo(String proxyTo) {
- this.proxyTo = proxyTo;
- };
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wcs1_1_1DownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wcs1_1_1DownloadMethod.java
deleted file mode 100644
index 7577d75..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wcs1_1_1DownloadMethod.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Wcs1_1_1DownloadMethod extends AbstractDownloadMethod implements PerLayerDownloadMethod {
- private static final Boolean INCLUDES_METADATA = false;
- private static final String METHOD = "POST";
-
- @Override
- public String getMethod(){
- return METHOD;
- }
-
- @Override
- public Set getExpectedContentType(){
- Set expectedContentType = new HashSet();
- expectedContentType.add("application/zip");
- return expectedContentType;
- }
-
- public String createDownloadRequest() throws Exception {
- //--generate POST message
- //info needed: geometry column, bbox coords, epsg code, workspace & layername
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user (will also need to transform the bbox)
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user
-
- SolrRecord layerInfo = this.currentLayer.getLayerInfo();
- BoundingBox nativeBounds = new BoundingBox(layerInfo.getMinX(), layerInfo.getMinY(), layerInfo.getMaxX(), layerInfo.getMaxY());
- BoundingBox bounds = nativeBounds.getIntersection(this.currentLayer.getRequestedBounds());
- String layerName = this.currentLayer.getLayerNameNS();
-
- Map describeLayerInfo = getWcsDescribeLayerInfo();
- String epsgCode = describeLayerInfo.get("SRS");
- String domainSubset = "";
-
- //wcs requires this info, even for full extent
- String gmlLow = describeLayerInfo.get("gridEnvelopeLow");
- String gmlHigh = describeLayerInfo.get("gridEnvelopeHigh");
- String axes = "";
- if (describeLayerInfo.containsKey("axis1")){
- axes += "";
- axes += describeLayerInfo.get("axis1");
- axes += "";
- if (describeLayerInfo.containsKey("axis2")){
- axes += "";
- axes += describeLayerInfo.get("axis2");
- axes += "";
- }
- }
- domainSubset = ""
- + ""
- + bounds.generateGMLEnvelope(4326)
- + ""
- + ""
- + ""
- + "" + gmlLow + ""
- + "" + gmlHigh + ""
- + ""
- + ""
- + axes
- + ""
- + ""
- + "";
-
- String format = "GeoTIFF";
-
- String getCoverageRequest = ""
- + "" + layerName + ""
- + domainSubset
- + ""
- + "";
-
-
-
- //--generate POST message
- //info needed: geometry column, bbox coords, epsg code, workspace & layername
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user (will also need to transform the bbox)
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user
-
- /* get coverage 1.1.1 request example
- * */
- /*String getCoverageRequest = "" +
- "sde:GISPORTAL.GISOWNER01.LANDINFO_K01C" +
- "" +
- "" +
- "8.0 -11.0" +
- "12.0 -5.0" +
- "" +
- "" +
- "" +
- "";
- */
-
-
- return getCoverageRequest;
- }
-
- @Override
- public String getUrl(){
- return this.currentLayer.getWcsUrl();
- };
-
- private Map getWcsDescribeLayerInfo()
- throws Exception
- {
- //should be xml
- //do this later....
- /*DocumentFragment requestXML = createDocumentFragment();
- // Insert the root element node
- Element rootElement = requestXML.createElement("DescribeFeatureType");
- requestXML.appendChild(rootElement);*/
- /*returned xml for 1.1.1 request
- *
-
- GISPORTAL.GISOWNER01.LANDINFO_K01CGenerated from ArcSDE Raster
- WCSArcSDE RasterGISPORTAL.GISOWNER01.LANDINFO_K01C
- sde:GISPORTAL.GISOWNER01.LANDINFO_K01C
-
- -11.0 8.0-5.0 12.0
-
- 8.0 -11.012.0 -5.0
- urn:ogc:def:crs:EPSG::4326
- urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs-10.999550448428494 11.999550456848008
- 4.4953472869180695E-4 0.0 0.0 -4.4951788966269695E-4urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS
- contents
- 0.0254.0
- nearestlinear
- cubicnearest neighbor
- Band_1
- urn:ogc:def:crs:EPSG::4326EPSG:4326
- application/gtopo30application/arcgrid
- image/gifimage/pngimage/jpeg
- image/tiffimage/tiff;subtype="geotiff"
-
- */
- String layerName = this.currentLayer.getLayerNameNS();
- String describeCoverageRequest = "SERVICE=WCS&VERSION=1.1.1&REQUEST=DescribeCoverage&IDENTIFIERS=" + layerName;
-
- InputStream inputStream = this.httpRequester.sendRequest(this.currentLayer.getWcsUrl(), describeCoverageRequest, "GET");
- //parse the returned XML and return needed info as a map
- // Create a factory
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // Use document builder factory
- DocumentBuilder builder = factory.newDocumentBuilder();
- //Parse the document
- Document document = builder.parse(inputStream);
- //initialize return variable
- Map describeLayerInfo = new HashMap();
-
- //get the needed nodes
- Node schemaNode = document.getFirstChild();
- if (schemaNode.getNodeName().equals("ServiceExceptionReport")){
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception("ServiceException: " + errorMessage);
- }
-
- try{
- NodeList supportedCRSs = document.getElementsByTagName("wcs:supportedCRS");
- //NodeList supportedCRSs = document.getElementsByTagName("wcs:requestResponseCRSs");
- describeLayerInfo.put("SRS", supportedCRSs.item(0).getTextContent().trim());
- NodeList gridEnvelopeLow = document.getElementsByTagName("gml:low");
- describeLayerInfo.put("gridEnvelopeLow", gridEnvelopeLow.item(0).getTextContent().trim());
- NodeList gridEnvelopeHigh = document.getElementsByTagName("gml:high");
- describeLayerInfo.put("gridEnvelopeHigh", gridEnvelopeHigh.item(0).getTextContent().trim());
- NodeList axes = document.getElementsByTagName("gml:axisName");
- axes.getLength();
- for (int i = 0; i < axes.getLength(); i++){
- describeLayerInfo.put("axis" + i, axes.item(i).getTextContent().trim());
- }
- //NodeList supportedFormats = document.getElementsByTagName("wcs:supportedFormats");
- //NodeList supportedFormats = document.getElementsByTagName("wcs:supportedCRS");
- //describeLayerInfo.put("nativeFormat", supportedFormats.item(0).getTextContent().trim());
- } catch (Exception e){
- throw new Exception("error getting layer info: "+ e.getMessage());
- }
- return describeLayerInfo;
-
- }
-
- void handleServiceException(Node schemaNode) throws Exception{
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception(errorMessage);
- }
-
- @Override
- public Boolean includesMetadata() {
- return INCLUDES_METADATA;
- }
-
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WcsDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WcsDownloadMethod.java
deleted file mode 100644
index b5a0717..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WcsDownloadMethod.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class WcsDownloadMethod extends AbstractDownloadMethod implements PerLayerDownloadMethod {
- private static final Boolean INCLUDES_METADATA = false;
- private static final String METHOD = "POST";
-
- @Override
- public String getMethod(){
- return METHOD;
- }
-
- @Override
- public Set getExpectedContentType(){
- Set expectedContentType = new HashSet();
- expectedContentType.add("application/zip");
- return expectedContentType;
- }
-
- public String createDownloadRequest() throws Exception {
- //--generate POST message
- //info needed: geometry column, bbox coords, epsg code, workspace & layername
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user (will also need to transform the bbox)
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user
-
- SolrRecord layerInfo = this.currentLayer.getLayerInfo();
- BoundingBox nativeBounds = new BoundingBox(layerInfo.getMinX(), layerInfo.getMinY(), layerInfo.getMaxX(), layerInfo.getMaxY());
- BoundingBox bounds = nativeBounds.getIntersection(this.currentLayer.getRequestedBounds());
- String layerName = this.currentLayer.getLayerNameNS();
-
- Map describeLayerInfo = getWcsDescribeLayerInfo();
- String epsgCode = describeLayerInfo.get("SRS");
- String domainSubset = "";
-
- //wcs requires this info, even for full extent
- String gmlLow = describeLayerInfo.get("gridEnvelopeLow");
- String gmlHigh = describeLayerInfo.get("gridEnvelopeHigh");
- String axes = "";
- if (describeLayerInfo.containsKey("axis1")){
- axes += "";
- axes += describeLayerInfo.get("axis1");
- axes += "";
- if (describeLayerInfo.containsKey("axis2")){
- axes += "";
- axes += describeLayerInfo.get("axis2");
- axes += "";
- }
- }
- domainSubset = ""
- + ""
- + bounds.generateGMLEnvelope(4326)
- + ""
- + ""
- + ""
- + "" + gmlLow + ""
- + "" + gmlHigh + ""
- + ""
- + ""
- + axes
- + ""
- + ""
- + "";
-
- String format = "GeoTIFF";
-
- String getCoverageRequest = ""
- + "" + layerName + ""
- + domainSubset
- + ""
- + "";
-
- return getCoverageRequest;
- }
-
- @Override
- public String getUrl(){
- return this.currentLayer.getWcsUrl();
- };
-
- Map getWcsDescribeLayerInfo()
- throws Exception
- {
- //should be xml
- //do this later....
- /*DocumentFragment requestXML = createDocumentFragment();
- // Insert the root element node
- Element rootElement = requestXML.createElement("DescribeFeatureType");
- requestXML.appendChild(rootElement);*/
- String layerName = this.currentLayer.getLayerNameNS();
- String describeCoverageRequest = ""
- + "" + layerName + ""
- + "";
-
- InputStream inputStream = this.httpRequester.sendRequest(this.getUrl(), describeCoverageRequest, "POST");
- //parse the returned XML and return needed info as a map
- // Create a factory
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // Use document builder factory
- DocumentBuilder builder = factory.newDocumentBuilder();
- //Parse the document
- Document document = builder.parse(inputStream);
- //initialize return variable
- Map describeLayerInfo = new HashMap();
-
- //get the needed nodes
- Node schemaNode = document.getFirstChild();
- if (schemaNode.getNodeName().equals("ServiceExceptionReport")){
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception("ServiceException: " + errorMessage);
- }
-
- try{
- //NodeList supportedCRSs = document.getElementsByTagName("wcs:supportedCRS");
- NodeList supportedCRSs = document.getElementsByTagName("wcs:requestResponseCRSs");
- describeLayerInfo.put("SRS", supportedCRSs.item(0).getTextContent().trim());
- NodeList gridEnvelopeLow = document.getElementsByTagName("gml:low");
- describeLayerInfo.put("gridEnvelopeLow", gridEnvelopeLow.item(0).getTextContent().trim());
- NodeList gridEnvelopeHigh = document.getElementsByTagName("gml:high");
- describeLayerInfo.put("gridEnvelopeHigh", gridEnvelopeHigh.item(0).getTextContent().trim());
- NodeList axes = document.getElementsByTagName("gml:axisName");
- axes.getLength();
- for (int i = 0; i < axes.getLength(); i++){
- describeLayerInfo.put("axis" + i, axes.item(i).getTextContent().trim());
- }
- //NodeList supportedFormats = document.getElementsByTagName("wcs:supportedFormats");
- //NodeList supportedFormats = document.getElementsByTagName("wcs:supportedCRS");
- //describeLayerInfo.put("nativeFormat", supportedFormats.item(0).getTextContent().trim());
- } catch (Exception e){
- throw new Exception("error getting layer info: "+ e.getMessage());
- }
- return describeLayerInfo;
- }
-
- void handleServiceException(Node schemaNode) throws Exception{
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception(errorMessage);
- }
-
- @Override
- public Boolean includesMetadata() {
- return INCLUDES_METADATA;
- }
-
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wfs1_1DownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wfs1_1DownloadMethod.java
deleted file mode 100644
index 07da542..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/Wfs1_1DownloadMethod.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Wfs1_1DownloadMethod extends AbstractDownloadMethod implements PerLayerDownloadMethod {
- private static final Boolean INCLUDES_METADATA = false;
- private static final String METHOD = "POST";
-
- @Override
- public String getMethod(){
- return METHOD;
- }
-
- @Override
- public Set getExpectedContentType(){
- Set expectedContentType = new HashSet();
- expectedContentType.add("application/zip");
- return expectedContentType;
- }
-
- public String createDownloadRequest() throws Exception {
- //--generate POST message
- //info needed: geometry column, bbox coords, epsg code, workspace & layername
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user (will also need to transform the bbox)
- String layerName = this.currentLayer.getLayerNameNS();
- SolrRecord layerInfo = this.currentLayer.getLayerInfo();
- BoundingBox nativeBounds = new BoundingBox(layerInfo.getMinX(), layerInfo.getMinY(), layerInfo.getMaxX(), layerInfo.getMaxY());
- BoundingBox bounds = nativeBounds.getIntersection(this.currentLayer.getRequestedBounds());
-
- String workSpace = layerInfo.getWorkspaceName();
- Map describeLayerInfo = getWfsDescribeLayerInfo();
- int epsgCode = 4326;//we are filtering the bounds based on WGS84
- String geometryColumn = describeLayerInfo.get("geometryColumn");
- String nameSpace = describeLayerInfo.get("nameSpace");
- String bboxFilter = "";
- if (!nativeBounds.isEquivalent(bounds)){
- bboxFilter += ""
- + ""
- + "" + geometryColumn + ""
- + bounds.generateGMLEnvelope(epsgCode)
- + ""
- + "";
- }
- // TODO should be xml
- String getFeatureRequest = ""
- + ""
- + bboxFilter
- + ""
- + "";
-
- return getFeatureRequest;
- }
-
- @Override
- public String getUrl(){
- return this.currentLayer.getWfsUrl();
- };
-
- Map getWfsDescribeLayerInfo()
- throws Exception
- {
- // TODO should be xml
- /*DocumentFragment requestXML = createDocumentFragment();
- // Insert the root element node
- Element rootElement = requestXML.createElement("DescribeFeatureType");
- requestXML.appendChild(rootElement);*/
- String layerName = this.currentLayer.getLayerNameNS();
- String describeFeatureRequest = ""
- + "" + layerName + ""
- + "";
-
- InputStream inputStream = this.httpRequester.sendRequest(this.getUrl(), describeFeatureRequest, "POST");
- System.out.println(this.httpRequester.getContentType());//check content type before doing any parsing of xml?
-
- //parse the returned XML and return needed info as a map
- // Create a factory
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // Use document builder factory
- DocumentBuilder builder = factory.newDocumentBuilder();
- //Parse the document
- Document document = builder.parse(inputStream);
- //initialize return variable
- Map describeLayerInfo = new HashMap();
-
- //get the namespace info
- Node schemaNode = document.getFirstChild();
- if (schemaNode.getNodeName().equals("ServiceExceptionReport")){
- this.handleServiceException(schemaNode);
- }
- try {
- NamedNodeMap schemaAttributes = schemaNode.getAttributes();
- describeLayerInfo.put("nameSpace", schemaAttributes.getNamedItem("targetNamespace").getNodeValue());
-
- //we can get the geometry column name from here
- NodeList elementNodes = document.getElementsByTagName("xsd:element");
- for (int i = 0; i < elementNodes.getLength(); i++){
- Node currentNode = elementNodes.item(i);
- NamedNodeMap currentAttributeMap = currentNode.getAttributes();
- String attributeValue = null;
- for (int j = 0; j < currentAttributeMap.getLength(); j++){
- Node currentAttribute = currentAttributeMap.item(j);
- String currentAttributeName = currentAttribute.getNodeName();
- if (currentAttributeName.equals("name")){
- attributeValue = currentAttribute.getNodeValue();
- } else if (currentAttributeName.equals("type")){
- if (currentAttribute.getNodeValue().startsWith("gml:")){
- describeLayerInfo.put("geometryColumn", attributeValue);
- break;
- }
- }
- }
- }
-
- } catch (Exception e){
- throw new Exception("error getting layer info: "+ e.getMessage());
- }
-
- return describeLayerInfo;
- }
-
- void handleServiceException(Node schemaNode) throws Exception{
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception(errorMessage);
- }
-
- @Override
- public Boolean includesMetadata() {
- return INCLUDES_METADATA;
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WfsDownloadMethod.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WfsDownloadMethod.java
deleted file mode 100644
index b21de9b..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Methods/WfsDownloadMethod.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.OpenGeoPortal.Download.Methods;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.OpenGeoPortal.Download.Types.BoundingBox;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class WfsDownloadMethod extends AbstractDownloadMethod implements PerLayerDownloadMethod {
- private static final Boolean INCLUDES_METADATA = false;
- private static final String METHOD = "POST";
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- @Override
- public String getMethod(){
- return METHOD;
- }
-
- @Override
- public Set getExpectedContentType(){
- Set expectedContentType = new HashSet();
- expectedContentType.add("application/zip");
- return expectedContentType;
- }
-
- public String createDownloadRequest() throws Exception {
- //--generate POST message
- //info needed: geometry column, bbox coords, epsg code, workspace & layername
- //all client bboxes should be passed as lat-lon coords. we will need to get the appropriate epsg code for the layer
- //in order to return the file in original projection to the user (will also need to transform the bbox)
- String layerName = this.currentLayer.getLayerNameNS();
- SolrRecord layerInfo = this.currentLayer.getLayerInfo();
- BoundingBox nativeBounds = new BoundingBox(layerInfo.getMinX(), layerInfo.getMinY(), layerInfo.getMaxX(), layerInfo.getMaxY());
- BoundingBox bounds = nativeBounds.getIntersection(this.currentLayer.getRequestedBounds());
-
- String workSpace = layerInfo.getWorkspaceName();
- Map describeLayerInfo = getWfsDescribeLayerInfo();
- String geometryColumn = describeLayerInfo.get("geometryColumn");
- String nameSpace = describeLayerInfo.get("nameSpace");
- int epsgCode = 4326;//we are filtering the bounds based on WGS84
- String bboxFilter = "";
- if (!nativeBounds.isEquivalent(bounds)){
-
- bboxFilter += ""
- + ""
- + "" + geometryColumn + ""
- + bounds.generateGMLBox(epsgCode)
- + ""
- + "";
- }
-
- String getFeatureRequest = ""
- + ""
- + bboxFilter
- + ""
- + "";
-
- return getFeatureRequest;
- }
-
- @Override
- public String getUrl(){
- return this.currentLayer.getWfsUrl();
- };
-
- Map getWfsDescribeLayerInfo() throws Exception {
- // TODO should be xml doc fragment?
- String layerName = this.currentLayer.getLayerNameNS();
- String describeFeatureRequest = ""
- + "" + layerName + ""
- + "";
-
- InputStream inputStream = this.httpRequester.sendRequest(this.getUrl(), describeFeatureRequest, "POST");
- String contentType = this.httpRequester.getContentType();
-
- if (!contentType.contains("xml")){
- throw new Exception("Expecting an XML response; instead, got content type '" + contentType + "'");
- }
- //parse the returned XML and return needed info as a map
- // Create a factory
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // Use document builder factory
- DocumentBuilder builder = factory.newDocumentBuilder();
- //Parse the document
- Document document = builder.parse(inputStream);
- //initialize return variable
- Map describeLayerInfo = new HashMap();
-
- //get the namespace info
- Node schemaNode = document.getFirstChild();
- if (schemaNode.getNodeName().equals("ServiceExceptionReport")){
- this.handleServiceException(schemaNode);
- }
- try {
- NamedNodeMap schemaAttributes = schemaNode.getAttributes();
- describeLayerInfo.put("nameSpace", schemaAttributes.getNamedItem("targetNamespace").getNodeValue());
-
- //we can get the geometry column name from here
- NodeList elementNodes = document.getElementsByTagName("xsd:element");
- for (int i = 0; i < elementNodes.getLength(); i++){
- Node currentNode = elementNodes.item(i);
- NamedNodeMap currentAttributeMap = currentNode.getAttributes();
- String attributeValue = null;
- for (int j = 0; j < currentAttributeMap.getLength(); j++){
- Node currentAttribute = currentAttributeMap.item(j);
- String currentAttributeName = currentAttribute.getNodeName();
- if (currentAttributeName.equals("name")){
- attributeValue = currentAttribute.getNodeValue();
- } else if (currentAttributeName.equals("type")){
- if (currentAttribute.getNodeValue().startsWith("gml:")){
- describeLayerInfo.put("geometryColumn", attributeValue);
- break;
- }
- }
- }
- }
-
- } catch (Exception e){
- throw new Exception("Error getting layer info from DescribeFeatureType: "+ e.getMessage());
- }
-
- return describeLayerInfo;
- }
-
- void handleServiceException(Node schemaNode) throws Exception{
- String errorMessage = "";
- for (int i = 0; i < schemaNode.getChildNodes().getLength(); i++){
- String nodeName = schemaNode.getChildNodes().item(i).getNodeName();
- if (nodeName.equals("ServiceException")){
- errorMessage += schemaNode.getChildNodes().item(i).getTextContent().trim();
- }
- }
- throw new Exception(errorMessage);
- }
-
- @Override
- public Boolean includesMetadata() {
- return INCLUDES_METADATA;
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Types/BoundingBox.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Types/BoundingBox.java
deleted file mode 100644
index 16acb93..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Download/Types/BoundingBox.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.OpenGeoPortal.Download.Types;
-
-/**
- * A simple class that represents a bounding box in geodetic coordinates, with some convenience methods
- * @author chris
- *
- */
-public class BoundingBox {
- private Double minX;
- private Double minY;
- private Double maxX;
- private Double maxY;
-
- /**
- * BoundingBox constructor from Doubles
- * @param minX
- * @param minY
- * @param maxX
- * @param maxY
- */
- public BoundingBox(Double minX, Double minY, Double maxX, Double maxY){
- this.init(minX, minY, maxX, maxY);
- }
-
- /**
- * BoundingBox constructor from Strings
- * @param minX
- * @param minY
- * @param maxX
- * @param maxY
- */
- public BoundingBox(String minX, String minY, String maxX, String maxY){
- this.init(Double.parseDouble(minX), Double.parseDouble(minY), Double.parseDouble(maxX), Double.parseDouble(maxY));
- }
-
- private void init(Double minX, Double minY, Double maxX, Double maxY){
- this.minX = minX;
- this.minY = minY;
- this.maxX = maxX;
- this.maxY = maxY;
- }
-
- public Double getMinX(){
- return this.minX;
- }
-
- public Double getMaxX(){
- return this.maxX;
- }
-
- public Double getMinY(){
- return this.minY;
- }
-
- public Double getMaxY(){
- return this.maxY;
- }
-
- @Override
- public String toString(){
- return Double.toString(this.minX) + "," + Double.toString(this.minY) + "," +Double.toString(this.maxX) + "," + Double.toString(this.maxY);
- }
-
- public Double getAspectRatio(){
- Double aspectRatio = (this.getMinX() - this.getMaxX())/(this.getMinY() - this.getMaxY());
- aspectRatio = Math.abs(aspectRatio);
- return aspectRatio;
- }
-
- public String generateGMLEnvelope(int epsgCode){
- String envelope = ""
- + "" + Double.toString(this.getMinX()) + " " + Double.toString(this.getMinY()) + ""
- + "" + Double.toString(this.getMaxX()) + " " + Double.toString(this.getMaxY()) + ""
- + "";
- return envelope;
- }
- /*
- *
- -75.102613,40.212597 -72.361859,41.512517
-
- */
- public String generateGMLBox(int epsgCode){
- String envelope = ""
- + "" + Double.toString(this.getMinX()) + "," + Double.toString(this.getMinY())
- + " " + Double.toString(this.getMaxX()) + "," + Double.toString(this.getMaxY()) + ""
- + "";
- return envelope;
- }
-
- public BoundingBox getIntersection(BoundingBox anotherBoundingBox){
- Double intersectionMinX = Math.max(this.getMinX(), anotherBoundingBox.getMinX());
- Double intersectionMaxX = Math.min(this.getMaxX(), anotherBoundingBox.getMaxX());
- Double intersectionMinY = Math.max(this.getMinY(), anotherBoundingBox.getMinY());
- Double intersectionMaxY = Math.min(this.getMaxY(), anotherBoundingBox.getMaxY());
- BoundingBox intersection = new BoundingBox(intersectionMinX, intersectionMinY, intersectionMaxX, intersectionMaxY);
- return intersection;
- }
-
- public Boolean isEquivalent(BoundingBox anotherBoundingBox){
- double acceptableDelta = .001;
- if ((Math.abs(this.minX - anotherBoundingBox.minX) < acceptableDelta)&&
- (Math.abs(this.minX - anotherBoundingBox.minX) < acceptableDelta)&&
- (Math.abs(this.minX - anotherBoundingBox.minX) < acceptableDelta)&&
- (Math.abs(this.minX - anotherBoundingBox.minX) < acceptableDelta)){
- return true;
- } else {
- return false;
- }
- }
-
- public String toString1_3() {
- //wms 1.3 reverses the axes
- return Double.toString(this.minY) + "," + Double.toString(this.minX) + "," + Double.toString(this.maxY) + "," + Double.toString(this.maxX);
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Export/GeoCommons/ExportRequestController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Export/GeoCommons/ExportRequestController.java
deleted file mode 100644
index d5d2bc4..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Export/GeoCommons/ExportRequestController.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.OpenGeoPortal.Export.GeoCommons;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.node.ObjectNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.context.request.RequestContextHolder;
-
-@Controller
-@RequestMapping("/geocommons/requestExport")
-public class ExportRequestController {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private GeoCommonsExportHandler geoCommonsExportHandler;
-
-
- @RequestMapping(method=RequestMethod.POST, produces="application/json")
- public @ResponseBody Map handleExportRequest(HttpServletRequest request)
- throws ServletException, IOException {
- //given a list of ogpids, export them to geocommons
- //read the POST'ed JSON object
- ObjectMapper mapper = new ObjectMapper();
- JsonNode rootNode = mapper.readTree(request.getInputStream());
- String basemap = rootNode.path("basemap").getTextValue();
- String bbox = rootNode.path("extent").getTextValue();
- String username = rootNode.path("username").getTextValue();
- String password = rootNode.path("password").getTextValue();
-
- ObjectNode responseJson = mapper.createObjectNode();
- //response json format
- //{"status": "", "message": "", mapUrl: "", "layers": []}
- //status where in the process
- //statusMessage text
- //mapUrl:
- //layers
- //layerId:
- //progress: dataset, map
- //format: shp, wms, etc.
- //url:
-
- /*if ((username.isEmpty())||(password.isEmpty())){
- response.sendError(500, "This request requires a valid GeoCommons username and password.");
- return;
- }*/
- String title = rootNode.path("title").getTextValue();
- String description = rootNode.path("description").getTextValue();
- JsonNode idArray = rootNode.path("OGPIDS");
- ArrayList layers = new ArrayList();
- for (JsonNode idNode : idArray){
- layers.add(idNode.getTextValue());
- }
- /*if (layers.isEmpty()) {
- //response.sendError(400, "No layers specified in request.");
- ArrayNode arrayNode = mapper.createArrayNode();
- responseJson.put("status", "");
- responseJson.put("statusMessage", "No layers specified in request");
- response.getOutputStream().print(responseJson.asText());
- return;
- }*/
-
- String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();
- GeoCommonsExportRequest exportRequest = new GeoCommonsExportRequest();
- exportRequest.setSessionId(sessionId);
- exportRequest.setUsername(username);
- exportRequest.setPassword(password);
- exportRequest.setBasemap(basemap);
- exportRequest.setTitle(title);
- exportRequest.setDescription(description);
- exportRequest.setBbox(bbox);
- exportRequest.setLayerIds(layers);
-
- UUID requestId = geoCommonsExportHandler.requestExport(exportRequest);
- Map map = new HashMap();
- map.put("requestId", requestId.toString());
- return map;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/LayerInfoRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/LayerInfoRetriever.java
deleted file mode 100644
index 2c0927b..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/LayerInfoRetriever.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.OpenGeoPortal.Metadata;
-
-import java.util.List;
-import java.util.Set;
-
-import org.OpenGeoPortal.Solr.SolrRecord;
-
-public interface LayerInfoRetriever {
- public List fetchAllLayerInfo(Set layerIds) throws Exception;
- public String getWMSUrl(SolrRecord solrRecord);
- SolrRecord getAllLayerInfo(String layerId) throws Exception;
- boolean hasProxy(SolrRecord solrRecord);
- public String getWFSUrl(SolrRecord solrRecord);
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/SolrLayerInfoRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/SolrLayerInfoRetriever.java
deleted file mode 100644
index bcd6659..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Metadata/SolrLayerInfoRetriever.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.OpenGeoPortal.Metadata;
-
-import java.util.List;
-import java.util.Set;
-
-import org.OpenGeoPortal.Solr.SearchConfigRetriever;
-import org.OpenGeoPortal.Solr.SolrClient;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.OpenGeoPortal.Utilities.ParseJSONSolrLocationField;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SolrLayerInfoRetriever implements LayerInfoRetriever{
- private SearchConfigRetriever searchConfigRetriever;
- private SolrClient solrClient;
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- public void setSolrClient(SolrClient solrClient) {
- this.solrClient = solrClient;
- }
-
- public void setSearchConfigRetriever(SearchConfigRetriever searchConfigRetriever) throws Exception{
- this.searchConfigRetriever = searchConfigRetriever;
- }
-
- public List fetchAllLayerInfo(Set layerIds) throws SolrServerException {
- SolrServer server = solrClient.getSolrServer();
- String query = "";
- for (String layerId : layerIds){
- query += "LayerId:" + layerId.trim();
- query += " OR ";
- }
- if (query.length() > 0){
- query = query.substring(0, query.lastIndexOf(" OR "));
- }
- /*ModifiableSolrParams params = new ModifiableSolrParams();
- params.set("q", query);
-
- QueryResponse response = server.query(params);*/
- logger.debug("Solr query terms: " + query);
- SolrQuery queryObj = new SolrQuery();
- queryObj.setQuery(query);
- QueryResponse response = null;
- try {
- response = server.query(queryObj);
- } catch (Exception e){
- logger.error(e.getMessage());
- }
- //logger.info(response.getResults().get(0).getFieldValue("Name").toString());
- List results = response.getBeans(SolrRecord.class);
-
- return results;
- }
-
- @Override
- public String getWMSUrl(SolrRecord solrRecord) {
- if (hasProxy(solrRecord)){
- String institution = solrRecord.getInstitution();//layerInfo.get("Institution");
- String accessLevel = solrRecord.getAccess();//layerInfo.get("Access")
- try {
- String proxyUrl = this.searchConfigRetriever.getWmsProxy(institution, accessLevel);
- logger.info("Has proxy url: " + proxyUrl);
- return proxyUrl;
- } catch (Exception e) {
- // TODO Auto-generated catch block
- logger.error("Error getting proxy");
- e.printStackTrace();
- return null;
- }
- } else {
- return ParseJSONSolrLocationField.getWmsUrl(solrRecord.getLocation());
- }
- }
-
- @Override
- public boolean hasProxy(SolrRecord layerInfo) {
- String institution = layerInfo.getInstitution();
- String accessLevel = layerInfo.getAccess();
- String wmsProxyUrl = null;
- try {
- wmsProxyUrl = this.searchConfigRetriever.getWmsProxy(institution, accessLevel);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (wmsProxyUrl != null){
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public SolrRecord getAllLayerInfo(String layerId) throws SolrServerException{
- String query = "LayerId:" + layerId.trim();
- SolrQuery queryObj = new SolrQuery();
- queryObj.setQuery( query );
- List results = solrClient.getSolrServer().query(queryObj).getBeans(SolrRecord.class);
- return results.get(0);
- }
-
- @Override
- public String getWFSUrl(SolrRecord solrRecord) {
- logger.info("Has proxy url: " + Boolean.toString(hasProxy(solrRecord)));
- if (hasProxy(solrRecord)){
- String institution = solrRecord.getInstitution();//layerInfo.get("Institution");
- String accessLevel = solrRecord.getAccess();//layerInfo.get("Access")
- try {
- return this.searchConfigRetriever.getWfsProxy(institution, accessLevel);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- logger.error("Error getting proxy");
- e.printStackTrace();
- return null;
- }
- } else {
- return ParseJSONSolrLocationField.getWfsUrl(solrRecord.getLocation());
- }
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/AuthenticatingGenericProxy.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/AuthenticatingGenericProxy.java
deleted file mode 100644
index 09aee35..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/AuthenticatingGenericProxy.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.AbstractHttpClient;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.protocol.BasicHttpContext;
-
-public class AuthenticatingGenericProxy extends GenericProxyImpl implements GenericProxy {
- private HttpEntity responseEntity;
- private UsernamePasswordCredentials credentials;
- private Boolean useAuthentication;
- private String username;
- private String password;
-
- //break this down into pieces so I can reuse better
- //now that these are pieces, I can separate them into other classes and inject for a modular proxy
- //do I need the request object?
-
- public void setUsername(String username) {
- this.setUseAuthentication();
- this.username = username;
- }
-
- public void setPassword(String password) {
- this.setUseAuthentication();
- this.password = password;
- }
-
- public void setUseAuthentication(){
- this.useAuthentication = false;
- if ((this.username != null)&&(!this.username.isEmpty())){
- if ((this.password != null)&&(!this.password.isEmpty())){
- //use authentication if a username and password are provided
- this.useAuthentication = true;
- }
- }
- }
-
- public void abstractRequest(HttpServletRequest request, HttpServletResponse response, String remoteAddress, String action){
- HttpHost targetHost = new HttpHost(remoteAddress);
- HttpClient httpclient = this.ogpHttpClient.getHttpClient();
-
- if (useAuthentication){
- int port = targetHost.getPort();
- String hostName = targetHost.getHostName();
-
- this.credentials = new UsernamePasswordCredentials(this.username, this.password);
-//this may not work. may need a new client.
- ((AbstractHttpClient) httpclient).getCredentialsProvider().setCredentials(
- new AuthScope(hostName, port),
- this.credentials);
-
- // Create AuthCache instance
- AuthCache authCache = new BasicAuthCache();
- // Generate BASIC scheme object and add it to the local auth cache
- BasicScheme basicAuth = new BasicScheme();
-
- authCache.put(targetHost, basicAuth);
-
- // Add AuthCache to the execution context
- BasicHttpContext localcontext = new BasicHttpContext();
- localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
- }
-
- try {
-
- HttpGet internalRequest = new HttpGet(remoteAddress);
- HttpResponse internalResponse = httpclient.execute(internalRequest);
- //internalResponse.getEntity().getContent()
- // copy headers
- //this.copyHeaders(internalResponse, response);
-
- this.checkStatus(internalResponse, response);
-
- if (action.equalsIgnoreCase("copy")){
- this.copyResponse(internalResponse, response);
- } else if (action.equalsIgnoreCase("stream")){
- responseEntity = internalResponse.getEntity();
- }
-
-
- } catch (Exception e){
- System.out.println("generic proxy failed");
- System.out.println(e.getMessage());
- try {
- response.getOutputStream().print(e.getMessage());
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- e.getStackTrace();
- } finally {
- // When HttpClient instance is no longer needed,
- // shut down the connection manager to ensure
- // immediate deallocation of all system resources
- httpclient.getConnectionManager().shutdown();
- }
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/GetFeatureInfoController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/GetFeatureInfoController.java
deleted file mode 100644
index aecaf08..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/GetFeatureInfoController.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.OpenGeoPortal.Proxy.Controllers;
-
-import java.io.InputStream;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Metadata.LayerInfoRetriever;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.OpenGeoPortal.Utilities.Http.HttpRequester;
-import org.apache.commons.compress.utils.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@Controller
-@RequestMapping("/featureInfo")
-public class GetFeatureInfoController {
- private static final int NUMBER_OF_FEATURES = 1;
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- @Autowired @Qualifier("httpRequester.generic")
- private HttpRequester httpRequester;
- @Autowired
- private LayerInfoRetriever layerInfoRetriever;
-
- @RequestMapping(method=RequestMethod.GET)
- public void getFeatureInfo(@RequestParam("OGPID") String layerId, @RequestParam("bbox") String bbox,
- @RequestParam("x") String xCoord,@RequestParam("y") String yCoord,
- @RequestParam("width") String width,@RequestParam("height") String height,
- HttpServletRequest request, HttpServletResponse response) throws Exception {
-
- String format = "application/vnd.ogc.gml";
-
- Set layerIds = new HashSet();
- layerIds.add(layerId);
- SolrRecord layerInfo = null;
- try {
- layerInfo = this.layerInfoRetriever.fetchAllLayerInfo(layerIds).get(0);
- } catch (Exception e) {
- e.printStackTrace();
- //response.sendError(500);
- }
- String previewUrl = null;
- try {
- //is there a proxy?
- previewUrl = this.layerInfoRetriever.getWMSUrl(layerInfo);
- } catch (Exception e) {
- e.printStackTrace();
- //response.sendError(500);
- }
-
- /*
- * http://www.example.com/wfs?
- service=wfs&
- version=1.1.0&
- request=GetFeature&
- typeName=layerName&
- maxFeatures=NUMBER_OF_FEATURES&srsName=EPSG:900913
- bbox=a1,b1,a2,b2
- bbox should be determined by the client. the size of a pixel?
- */
- String layerName = layerInfo.getWorkspaceName() + ":" + layerInfo.getName();
- String query = "service=wms&version=1.1.1&request=GetFeatureInfo&info_format=" + format
- + "&SRS=EPSG:900913&feature_count=" + NUMBER_OF_FEATURES + "&styles=&height=" + height + "&width=" + width +"&bbox=" + bbox
- + "&x=" + xCoord + "&y=" + yCoord +"&query_layers=" + layerName + "&layers=" + layerName;
-
- /*String query = "service=wfs&version=1.1.0&request=GetFeature&typeName=" + layerName + "&maxFeatures=" + NUMBER_OF_FEATURES
- + "&srsName=EPSG:900913&bbox=" + bbox;*/
- logger.info("executing WMS getFeatureRequest: " + previewUrl + "?" + query);
- if (!previewUrl.contains("http")){
-
- request.getRequestDispatcher(previewUrl + "?" + query).forward(request, response);
-
- } else {
- InputStream input = httpRequester.sendRequest(previewUrl, query, "GET");
- logger.debug(httpRequester.getContentType());
- response.setContentType(httpRequester.getContentType());
- IOUtils.copy(input, response.getOutputStream());
- }
- }
-
- public LayerInfoRetriever getLayerInfoRetriever() {
- return layerInfoRetriever;
- }
-
- public void setLayerInfoRetriever(LayerInfoRetriever layerInfoRetriever) {
- this.layerInfoRetriever = layerInfoRetriever;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/ImageController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/ImageController.java
deleted file mode 100644
index dacfb00..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/ImageController.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package org.OpenGeoPortal.Proxy.Controllers;
-
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.OpenGeoPortal.Metadata.LayerInfoRetriever;
-import org.OpenGeoPortal.Proxy.ImageHandler;
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest.LayerImage;
-import org.OpenGeoPortal.Security.OgpUserContext;
-import org.OpenGeoPortal.Solr.SearchConfigRetriever;
-import org.OpenGeoPortal.Solr.SolrRecord;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.context.request.RequestContextHolder;
-
-@Controller
-@RequestMapping("/requestImage")
-public class ImageController {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private LayerInfoRetriever layerInfoRetriever;
- @Autowired
- private SearchConfigRetriever searchConfigRetriever;
- @Autowired
- private ImageHandler imageHandler;
- private @Value("${ogp.proxyToWMS}") String proxyTo;
- private boolean isLocallyAuthenticated;// = true;
- @Autowired
- private OgpUserContext ogpUserContext;
- private String home;// = "Tufts";
- private ImageRequest imageRequest;
-
- @RequestMapping(method=RequestMethod.POST, headers = "content-type=application/x-www-form-urlencoded", consumes="application/json", produces="application/json")
- public @ResponseBody Map processImageRequest(@RequestBody String imageRequest) throws Exception {
- /**
- * This controller given the above parameters + z order, grabs images
- * from various servers and composites them. Is passed a custom json object to maintain structure.
- *
- * We should offer formats available via geoserver.
- *
- * determine if a layer is within the provided bounds and exclude it if not
- *
- * @author Chris Barnett
- */
- home = this.searchConfigRetriever.getHome();
- //
- ObjectMapper mapper = new ObjectMapper();
- try {
- this.imageRequest = mapper.readValue(URLDecoder.decode(imageRequest, "UTF-8"), ImageRequest.class);
- } catch (Exception e){
- e.printStackTrace();
- }
- this.isLocallyAuthenticated = ogpUserContext.isAuthenticatedLocally();
-
- Map map = new HashMap();
- populateImageRequest();
- UUID requestId = imageHandler.requestImage(RequestContextHolder.currentRequestAttributes().getSessionId(), this.imageRequest);
- logger.debug("Image requested.");
- map.put("requestId", requestId.toString());
- return map;
- }
-
-
- private Boolean hasPermission(SolrRecord currentLayer){
- if (!currentLayer.getAccess().equalsIgnoreCase("public")){
- try {
- if (currentLayer.getInstitution().equalsIgnoreCase(this.home)){
- if (!this.isLocallyAuthenticated){
- return false;
- } else {
- return true;
- }
- } else {
- return false;
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
-
- } else {
- return true;
- }
- }
-
-
- private void populateImageRequest() throws Exception{
- String baseQuery = generateBaseQuery(imageRequest);
- //I'm making the assumption that the overhead of having separate http requests
- //to Solr is far greater than iterating over these lists
-
- List layerInfo = this.layerInfoRetriever.fetchAllLayerInfo(imageRequest.getLayerIds());
-
- for (LayerImage layerImage: imageRequest.getLayers()){
- String currentId = layerImage.getLayerId();
- for (SolrRecord solrRecord : layerInfo){
- if (!hasPermission(solrRecord)){
- //skip layers the user doesn't have permission to retrieve
- //the client should never send these layers, since the user shouldn't be able to preview them
- continue;
- }
- if (solrRecord.getLayerId().equalsIgnoreCase(currentId)){
- layerImage.setSolrRecord(solrRecord);
- String layerQueryString = "&layers=" + solrRecord.getWorkspaceName() + ":" + solrRecord.getName();
- String currentSLD = layerImage.getSld();
- if ((currentSLD != null)&&(!currentSLD.equals("null")&&(!currentSLD.isEmpty()))){
- layerQueryString += "&sld_body=" + URLEncoder.encode(currentSLD, "UTF-8");
- }
-
- layerImage.setQueryString(baseQuery + layerQueryString);
- logger.debug(layerImage.getQueryString());
- if (this.layerInfoRetriever.hasProxy(solrRecord)){
- layerImage.setBaseUrl(this.proxyTo);
- } else {
- try {
- layerImage.setBaseUrl(this.layerInfoRetriever.getWMSUrl(solrRecord));
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
-
- }
- }
- }
-
- }
-
- private String generateBaseQuery(ImageRequest imageRequest){
- //switch based on format to add dpi settings, change/add header info
- /*try {
- logger.info("format: " + imageRequest.getFormat());
- } catch (NullPointerException e){
- logger.info("format is null");
- }
- try {
- logger.info("srs: " + imageRequest.getSrs());
- } catch (NullPointerException e){
- logger.info("srs is null");
- }
- try {
- logger.info("bbox: " + imageRequest.getBbox());
- } catch (NullPointerException e){
- logger.info("bbox is null");
- }*/
-
- String genericQueryString;
- genericQueryString = "service=wms&version=1.1.1&request=GetMap&format=" + imageRequest.getFormat() + "&SRS=" + imageRequest.getSrs();
- genericQueryString += "&styles=&bbox=" + imageRequest.getBbox();
-
- if (imageRequest.getFormat().equals("image/png")){
-
- /*int requestedDpi = 90;//dpi & size options?
- url$ += "&format_options=dpi:" + Integer.toString(requestedDpi) + ";";
- width = Integer.toString(Math.round(Integer.parseInt(width) * requestedDpi / 90));
- height = Integer.toString(Math.round(Integer.parseInt(height) * requestedDpi / 90));
- */
- genericQueryString += "&tiled=false&transparent=true";
- }
- genericQueryString += "&height=" + imageRequest.getHeight() + "&width=" + imageRequest.getWidth();
- logger.debug(genericQueryString);
- return genericQueryString;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/RestrictedWMSController.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/RestrictedWMSController.java
deleted file mode 100644
index f90895c..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/Controllers/RestrictedWMSController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.OpenGeoPortal.Proxy.Controllers;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Proxy.GenericProxy;
-import org.OpenGeoPortal.Security.OgpUserContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@Controller
-@RequestMapping("/restricted/*")
-public class RestrictedWMSController {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private @Value("${ogp.proxyToWMS}") String proxyTo;
-
-
- @Autowired
- private OgpUserContext ogpUserContext;
- @Autowired @Qualifier("proxy.simple")
- private GenericProxy genericProxy;
-
- @RequestMapping(value="/wms", method=RequestMethod.GET)
- public void forwardWMSRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
- // check authentication
- if (ogpUserContext.isAuthenticatedLocally()){
- // forward the request to the protected GeoServer instance
-
- String remoteUrl = this.getProxyTo() + "?"
- + request.getQueryString();
- logger.info("executing WMS request to protected GeoServer: "
- + remoteUrl);
- this.genericProxy.proxyRequest(request, response, remoteUrl);
- } else {
- response.sendError(403);
- }
- }
-
- public String getProxyTo() {
- return proxyTo;
- }
-
- public void setProxyTo(String proxyTo) {
- this.proxyTo = proxyTo;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/GenericProxyImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/GenericProxyImpl.java
deleted file mode 100644
index 0b9fd86..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/GenericProxyImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Utilities.Http.OgpHttpClient;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-public class GenericProxyImpl implements GenericProxy {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- private HttpEntity responseEntity;
- @Autowired @Qualifier("httpClient.pooling")
- protected OgpHttpClient ogpHttpClient;
-
- public void proxyRequest(HttpServletRequest request,
- HttpServletResponse response, String remoteUrl){
- this.abstractRequest(request, response, remoteUrl, "copy");
- }
-
- public void abstractRequest(HttpServletRequest request, HttpServletResponse response, String remoteUrl, String action){
- HttpClient httpclient = ogpHttpClient.getHttpClient();
- try {
-
- HttpGet internalRequest = new HttpGet(remoteUrl);
- HttpResponse internalResponse = httpclient.execute(internalRequest);
-
- this.checkStatus(internalResponse, response);
-
- if (action.equalsIgnoreCase("copy")){
- this.copyResponse(internalResponse, response);
- } else if (action.equalsIgnoreCase("stream")){
- responseEntity = internalResponse.getEntity();
- }
-
-
- } catch (Exception e){
- logger.error("generic proxy failed");
- logger.error(e.getMessage());
- try {
- response.getOutputStream().print(e.getMessage());
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- e.getStackTrace();
- } finally {
- // When HttpClient instance is no longer needed,
- // shut down the connection manager to ensure
- // immediate deallocation of all system resources
- //httpclient.getConnectionManager().shutdown();
- }
- }
-
- public InputStream getContentStream(HttpServletRequest request, HttpServletResponse response, String remoteUrl){
- this.abstractRequest(request, response, remoteUrl, "stream");
- try {
- return this.responseEntity.getContent();
- } catch (IllegalStateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
- public void checkStatus (HttpResponse internalResponse, HttpServletResponse externalResponse) throws IOException{
- if (internalResponse.getStatusLine().getStatusCode() != 200){
- externalResponse.sendError(internalResponse.getStatusLine().getStatusCode());
- logger.error("Status returned: " + internalResponse.getStatusLine());
- }
- }
-
- public void copyHeaders (HttpResponse internalResponse, HttpServletResponse externalResponse){
- Header[] headers = internalResponse.getAllHeaders();
- for (int i = 0; i < headers.length; i++) {
- //System.out.println(headers[i]);
- if (!headers[i].getName().equals("Content-Disposition")){
- externalResponse.setHeader(headers[i].getName(), headers[i].getValue());
- }
- }
- }
-
- public void copyResponse(HttpResponse internalResponse, HttpServletResponse externalResponse) throws IOException{
- HttpEntity entity = internalResponse.getEntity();
- //System.out.println(entity.getContentType());
-
- OutputStream outputStream = externalResponse.getOutputStream();
- BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(entity.getContent());
-
- try {
- int currentBytes;
- while ((currentBytes = bufferedInputStream.read()) != -1) {
- //System.out.println("Receiving " + currentBytes + " bytes");
- bufferedOutputStream.write(currentBytes);
- }
- } catch (Exception e){
- e.getStackTrace();
- }
- finally {
- try {
- bufferedInputStream.close();
- } finally {
- bufferedOutputStream.close();
- }
- }
-
- EntityUtils.consume(entity);
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageCompositorImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageCompositorImpl.java
deleted file mode 100644
index 498ea71..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageCompositorImpl.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.RescaleOp;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest;
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest.ImageStatus;
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest.LayerImage;
-import org.OpenGeoPortal.Utilities.DirectoryRetriever;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-
-public class ImageCompositorImpl implements ImageCompositor {
- private static final String FORMAT_SUFFIX = "png";
-
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- private Graphics2D compositeImageGraphicsObj;
- @Autowired
- private DirectoryRetriever directoryRetriever;
- @Autowired
- private ImageDownloader imageDownloader;
-
-
- @Async
- @Override
- public void createComposite(ImageRequest imageRequest) {
- downloadLayerImages(imageRequest);
- logger.debug("Creating image composite...");
- BufferedImage compositeImage = new BufferedImage(imageRequest.getWidth(), imageRequest.getHeight(), BufferedImage.TYPE_INT_ARGB);
-
- try {
- compositeImageGraphicsObj = compositeImage.createGraphics();
-
- //at this point, we need to iterate over the zIndexes, construct appropriate urls, layer on top of image, then write to a file
- //should sort based on zOrder
- List layerImageList = imageRequest.getLayers();
- Collections.sort(layerImageList);
- for (LayerImage layerImage: layerImageList){
- //now we have everything we need to create a request
- //this needs to be done for each image received
- try {
- processLayer(layerImage);
- layerImage.setImageStatus(ImageStatus.SUCCESS);
- } catch (Exception e) {
- //just skip it
- logger.error("There was an error processing this layer image. Skipping...");
- layerImage.setImageStatus(ImageStatus.FAILED);
- e.printStackTrace();
- }
- }
- try {
- imageRequest.setDownloadFile(writeImage(compositeImage));
-
- } catch (IOException e) {
- e.printStackTrace();
- }//write this location + status to the manager object
- } catch (Exception e){
- e.printStackTrace();
- } finally {
- compositeImageGraphicsObj.dispose();
- }
- }
-
- private void downloadLayerImages(ImageRequest imageRequest) {
- List layerImageList = imageRequest.getLayers();
- for (LayerImage layerImage: layerImageList){
- //now we have everything we need to create a request
- //this needs to be done for each image received
- try {
- layerImage.setImageFileFuture(imageDownloader.getImage(layerImage.getBaseUrl(), layerImage.getQueryString()));
- } catch (Exception e) {
- //just skip it
- layerImage.setImageStatus(ImageStatus.FAILED);
- logger.error("There was a problem getting this image. Skipping.");
- e.printStackTrace();
- }
- }
- }
-
- private File getDirectory() throws IOException{
- File downloadDirectory = this.directoryRetriever.getDownloadDirectory();
- File newDir = File.createTempFile("OGP", "", downloadDirectory);
- newDir.delete();
- //Boolean success=
- newDir.mkdir();
- newDir.setReadable(true);
- newDir.setWritable(true);
- return newDir;
- }
-
- private File writeImage(BufferedImage compositeImage) throws IOException{
- File imageDirectory = getDirectory();
- File outputFile = getOutputFile(imageDirectory);
- try {
- //write image to file
- ImageIO.write(compositeImage, FORMAT_SUFFIX, outputFile);
- } catch (IOException e) {
- //...
- }
-
- logger.info("Image written");
- return outputFile;
- }
-
- private File getOutputFile(File imageDirectory){
- File outputFile;
- do {
- String outputFileName = "OGPImage." + FORMAT_SUFFIX;
- outputFile = new File(imageDirectory, outputFileName);
- } while (outputFile.exists());
- return outputFile;
- }
-
- private void processLayer(LayerImage layerImage) {
- //now we have everything we need to create a request
- logger.debug("processing layer");
- BufferedImage currentImg = null;
- File imgFile = null;
- try {
- imgFile = layerImage.getImageFileFuture().get();
- currentImg = ImageIO.read(imgFile);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- logger.debug("image retrieved");
- //this needs to be done for each image received
-
- //this defines opacity
- float[] scales = { 1f, 1f, 1f, 1f};
- scales[3] = layerImage.getOpacity() / 100f;
- //System.out.println(scales[3]);
- float[] offsets = new float[4];
- RescaleOp rop = new RescaleOp(scales, offsets, null);
- logger.info("drawing layer...");
- compositeImageGraphicsObj.drawImage(currentImg, rop, 0, 0);
- //cleaning up temp file
- imgFile.delete();
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloader.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloader.java
deleted file mode 100644
index a3f533d..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloader.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.Future;
-
-public interface ImageDownloader {
- Future getImage(String baseUrl, String queryString) throws IOException;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloaderImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloaderImpl.java
deleted file mode 100644
index 0c3a2fc..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageDownloaderImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.concurrent.Future;
-
-import org.OpenGeoPortal.Utilities.Http.HttpRequester;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.AsyncResult;
-
-public class ImageDownloaderImpl implements ImageDownloader {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- @Autowired @Qualifier("httpRequester.generic")
- private HttpRequester httpRequester;
-
- @Override
- @Async
- public Future getImage(String baseUrl, String queryString) throws IOException {
- File tempFile = File.createTempFile("img", ".png");
- logger.info(baseUrl);
- InputStream is = this.httpRequester.sendRequest(baseUrl, queryString, "GET");
- String contentType = this.httpRequester.getContentType();
- if (contentType.toLowerCase().contains("png")){
- FileUtils.copyInputStreamToFile(is, tempFile);
- } else {
- if ((contentType.toLowerCase().contains("xml"))||(contentType.toLowerCase().contains("html"))||
- (contentType.toLowerCase().contains("text"))){
- logger.error("Response content: " + IOUtils.toString(is));
- }
- throw new IOException("Unexpected content-type: " + contentType);
- }
- return new AsyncResult(tempFile);
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandler.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandler.java
deleted file mode 100644
index 08c08fb..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandler.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.util.UUID;
-
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest;
-
-public interface ImageHandler {
-
- UUID requestImage(String sessionId, ImageRequest imageRequest);
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandlerImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandlerImpl.java
deleted file mode 100644
index c3c4cf9..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/ImageHandlerImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.util.UUID;
-
-import org.OpenGeoPortal.Download.RequestStatusManager;
-import org.OpenGeoPortal.Proxy.Controllers.ImageRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class ImageHandlerImpl implements ImageHandler {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private RequestStatusManager requestStatusManager;
- @Autowired
- private ImageCompositor imageCompositor;
-
- @Override
- public UUID requestImage(String sessionId, ImageRequest imageRequest){
- UUID requestId = registerRequest(sessionId, imageRequest);
- logger.debug("Image Request registered: " + requestId.toString());
- imageCompositor.createComposite(imageRequest);
- return requestId;
- }
-
- private UUID registerRequest(String sessionId, ImageRequest imageRequest) {
- UUID requestId = UUID.randomUUID();
- requestStatusManager.addImageRequest(requestId, sessionId, imageRequest);
- return requestId;
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/RestrictedWMSProxy.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/RestrictedWMSProxy.java
deleted file mode 100644
index 553ef0d..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Proxy/RestrictedWMSProxy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.OpenGeoPortal.Proxy;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.OpenGeoPortal.Security.OgpUserContext;
-import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.web.HttpRequestHandler;
-
-@Deprecated
-public class RestrictedWMSProxy implements HttpRequestHandler {
- private GenericProxy genericProxy;
- private String proxyTo;
- @Autowired
- private OgpUserContext ogpUserContext;
-
- //this needs to handle authentication if supplied a username and password
-
- public String getProxyTo() {
- return proxyTo;
- }
-
- public void setProxyTo(String proxyTo) {
- this.proxyTo = proxyTo;
- }
-
- public void setGenericProxy(GenericProxy genericProxy) {
- this.genericProxy = genericProxy;
- }
-
- public GenericProxy getGenericProxy() {
- return this.genericProxy;
- }
-
- /*private Boolean isLocallyAuthenticated(){
- try {
- return SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
- } catch (NullPointerException e){
- return false;
- }
- }*/
-
- @Override
- public void handleRequest(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- // check authentication
- if (ogpUserContext.isAuthenticatedLocally()){
- // forward the request to the protected GeoServer instance
- System.out.println("executing WMS request to protected GeoServer: "
- + request.getQueryString());
- String remoteUrl = this.proxyTo + "?"
- + request.getQueryString();
-
- this.genericProxy.proxyRequest(request, response, remoteUrl);
- } else {
- response.sendError(401);
- }
-
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContext.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContext.java
deleted file mode 100644
index 91c2974..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContext.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.OpenGeoPortal.Security;
-
-public interface OgpUserContext {
- //boolean authenticate(String username, String password);
- boolean isAuthenticatedLocally();
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContextImpl.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContextImpl.java
deleted file mode 100644
index 292a513..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Security/OgpUserContextImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.OpenGeoPortal.Security;
-
-import org.springframework.security.core.context.SecurityContextHolder;
-
-public class OgpUserContextImpl implements OgpUserContext {
-
- @Override
- public boolean isAuthenticatedLocally() {
- boolean authenticated = false;
- try {
- authenticated = SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
- } catch (NullPointerException e){
- authenticated = false;
- }
- return authenticated;
- }
-
- /*@Override
- public boolean authenticate(String username, String password) {
- // TODO Auto-generated method stub
- return authenticationMethod.authenticate(username, password);
- }*/
-
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/OgpConfigRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/OgpConfigRetriever.java
deleted file mode 100644
index 3ec0aaf..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/OgpConfigRetriever.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.OpenGeoPortal.Solr;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.OpenGeoPortal.Download.Config.ConfigRetriever;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.node.ArrayNode;
-
-public class OgpConfigRetriever extends ConfigRetriever implements
- SearchConfigRetriever {
-
- public String getSearchUrl() throws IOException {
- this.readConfigFile();
- JsonNode jsonObject = this.configContents.path("search");
- return jsonObject.path("serviceAddress").getTextValue();
- }
-
- public String getSearchPort() throws IOException {
- this.readConfigFile();
- JsonNode jsonObject = this.configContents.path("search");
- int searchPort = jsonObject.path("servicePort").asInt();
- return Integer.toString(searchPort);
- }
-
- public String getSearchType() throws IOException {
- this.readConfigFile();
- JsonNode jsonObject = this.configContents.path("search");
- return jsonObject.path("serviceType").getTextValue();
- }
-
- public String getHome() throws IOException {
- this.readConfigFile();
- return this.configContents.path("homeInstitution").getTextValue();
- }
-
- public Boolean isOgp() {
- return true;
- }
-
- public String getArbitrary(String configKey) throws Exception {
- /*
- * this only works for strings in the top level. should eventually be
- * more generic
- */
- this.readConfigFile();
- return this.configContents.path(configKey).getTextValue();
- }
-
- private String getProxy(String institution, String accessLevel, String serviceKey)
- throws IOException {
- this.readConfigFile();
- institution = institution.trim();
- accessLevel = accessLevel.trim();
- JsonNode allInstitutionsObject = this.configContents.path("institutions");
- JsonNode institutionObject = allInstitutionsObject.path(institution);
- if (institutionObject.has("proxy")) {
- JsonNode proxyObject = institutionObject.path("proxy");
- ArrayNode accessNode = (ArrayNode) proxyObject.path("accessLevel");
- Iterator accessIterator = accessNode.getElements();
- while (accessIterator.hasNext()){
- String currentValue = accessIterator.next().getTextValue();
- if (currentValue.equalsIgnoreCase(accessLevel)){
- return proxyObject.path(serviceKey).getTextValue();
- }
- }
- return null;
-
- } else {
- return null;
- }
- }
-
- @Override
- public String getWmsProxy(String institution, String accessLevel)
- throws IOException {
- return getProxy(institution, accessLevel, "wms");
- }
-
- @Override
- public String getWfsProxy(String institution, String accessLevel)
- throws IOException {
- return getProxy(institution, accessLevel, "wfs");
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SearchConfigRetriever.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SearchConfigRetriever.java
deleted file mode 100644
index a707746..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SearchConfigRetriever.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.OpenGeoPortal.Solr;
-
-import java.io.IOException;
-
-public interface SearchConfigRetriever {
-
- String getSearchUrl() throws Exception;
-
- String getSearchPort() throws Exception;
-
- String getHome() throws Exception;
-
- String getArbitrary(String configKey) throws Exception;
-
- String getWmsProxy(String institution, String accessLevel) throws Exception;
-
- String getWfsProxy(String institution, String accessLevel) throws IOException;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/Searcher.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/Searcher.java
deleted file mode 100644
index 10b6a2e..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/Searcher.java
+++ /dev/null
@@ -1,648 +0,0 @@
-package org.OpenGeoPortal.Solr;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-
-
-/**
- * code to generate the elements in the Solr search query
- * currently this class deals with spatial filtering:
- * is a layer within a map
- * is a layer within an expanded map
- * does a layer cover a map
- * does the map and layer intersect
- * how close is the scale of the layer to the scale of the map
- *
- * this class also contains some static functions to deal with
- * the next and previous buttons (setting startIndex and rows)
- * sort order (sortColumn and sortOrder) and similar functions.
- * These static functions sometimes take an HttpServletRequest
- * object and therefore know the name of the parameter on the
- * client side.
- *
- * this class is used by both the basic and advanced search
- *
- * @author smcdon08
- *
- */
-@SuppressWarnings("unused")
-public class Searcher
-{
-
- // values used to control boost
- // adjusting them is a black art
- String layerWithinMapBoost = "10.0";
- String layerMatchesScaleBoost = "15.0";
- String layerMatchesCenterBoost = "3.0";
-
- String layerCoversMapBoost = "0.1";
- String layerWithinExpandedMapBoost = "4.0";
- String layerIntersectionScaleBoost = "2.0";
-
- // Solr seems picky about encoding so we build the search strings with the following elements
- public final static String asterik = "%2a";
- public final static String openParen = "%28";
- public final static String closeParen = "%29";
- public final static String openBracket = "%5B";
- public final static String closeBracket = "%5D";
- public final static String colon = "%3a";
- public final static String tilde = "%7e";
- public final static String comma = "%2c";
- public final static String space = "%20";
- public final static String equals = "%3D";
-
- double mapMinX;
- double mapMaxX;
- double mapMinY;
- double mapMaxY;
-
- /**
- * pass in the bounding box for the displayed map
- * @param minX
- * @param maxX
- * @param minY
- * @param maxY
- */
- public Searcher(double minX, double maxX, double minY, double maxY)
- {
- this.mapMinX = minX;
- this.mapMaxX = maxX;
- this.mapMinY = minY;
- this.mapMaxY = maxY;
- }
-
- /**
- * return a Solr spatial search containing all elements
- * @return
- */
- public String geoSearch()
- {
- String geoFilter = layerWithinMapScore() + layerMatchesArea() + layerNearCenterLongitude() + layerNearCenterLatitude();
- return geoFilter;
- }
-
-
- /**
- * compute a score for layers within the current map
- * the layer's MinX and MaxX must be within the map extent in X
- * and the layer's MinY and MaxY must be within the map extent in Y
- * I had trouble using a range based test (e.g., MinX:[mapMinX+TO+mapMapX])
- * along with other scoring functions based on _val_. So, this function
- * is like the other scoring functions and uses _val_.
- * The Solr "sum" function returns 4 if the layer is contained within the map.
- * The outer "map" converts 4 to 1 and anything else to 0.
- * @return
- */
- public String layerWithinMapScore()
- {
- String layerWithinMap = "";
- layerWithinMap += "product(" + layerWithinMapBoost + ",map(sum(";
- layerWithinMap += "map(MinX," + mapMinX + "," + mapMaxX + ",1,0),";
- layerWithinMap += "map(MaxX," + mapMinX + "," + mapMaxX + ",1,0),";
- layerWithinMap += "map(MinY," + mapMinY + "," + mapMaxY + ",1,0),";
- layerWithinMap += "map(MaxY," + mapMinY + "," + mapMaxY + ",1,0))";
- layerWithinMap += ",4,4,1,0)))";
- layerWithinMap = "_val_:\"" + layerWithinMap + "\"";
- return layerWithinMap;
-
- }
- /**
- * return a search element to identify layers completely within the displayed map
- * @return Solr search clause
- * @see layerIntersectsMapFilter() or layerIntersectsMapScore() or layerWithinMapScore()
- * @deprecated either filter results with bounding box intersection or increase score with layerWithinMapScore()
- */
- @Deprecated
- //@see layerIntersectsMapFilter() or layerIntersectsMapScore
- public String layerWithinMap()
- {
- String layerWithinMap = "";
- layerWithinMap = openParen;
- layerWithinMap += "MinX" + colon + openBracket + mapMinX + "+TO+" + mapMaxX + closeBracket;
- layerWithinMap += "+AND+MaxX" + colon + openBracket + mapMinX + "+TO+" + mapMaxX + closeBracket;
- layerWithinMap += "+AND+MinY" + colon + openBracket + mapMinY + "+TO+" + mapMaxY + closeBracket;
- layerWithinMap += "+AND+MaxY" + colon + openBracket + mapMinY + "+TO+" + mapMaxY + closeBracket;
- layerWithinMap += closeParen;
- layerWithinMap += "^" + layerWithinMapBoost;
- return layerWithinMap;
- }
-
- /**
- * return a search element to identify layers that completely cover the displayed map
- * @return Solr search clause
- * @see layerIntersectsMapFilter() or layerIntersectsMapScore()
- * @deprecated filter results with bounding box intersection, we don't need to boost layers that cover the map
- */
- public String layerCoversMap()
- {
- String layerCoversMap = openParen;
- layerCoversMap += "MinX" + colon + openBracket + "-181.+TO+" + mapMinX + closeBracket;
- layerCoversMap += "+AND+MaxX" + colon + openBracket + mapMaxX + "+TO+181." + closeBracket;
- layerCoversMap += "+AND+MinY"+ colon + openBracket + "-91.+TO+" + mapMinY + closeBracket;
- layerCoversMap += "+AND+MaxY" + colon + openBracket + mapMaxY + "+TO+91." + closeBracket;
- layerCoversMap += closeParen + "^" + layerCoversMapBoost;
- return layerCoversMap;
- }
-
- /**
- * is the layer contained within a larger map with the same center
- * currently we make the map 50% larger in both width and height
- * @return Solr search clause
- * @deprecated with bounding box intersection, we don't use this
- */
- public String layerWithinExpandedMap()
- {
- double deltaX = Math.abs(mapMaxX - mapMinX);
- double expandedMapMinX = mapMinX - (deltaX/2.);
- double expandedMapMaxX = mapMaxX + (deltaX/2.);
- double deltaY = Math.abs(mapMaxY - mapMinY);
- double expandedMapMinY = mapMinY - (deltaY/2.);
- double expandedMapMaxY = mapMaxY + (deltaY/2.);
- String layerWithinMap = openParen + "MinX" + colon + openBracket + expandedMapMinX + "+TO+" + expandedMapMaxX + closeBracket;
- layerWithinMap += "+AND+MaxX" + colon + openBracket + expandedMapMinX + "+TO+" + expandedMapMaxX + closeBracket;
- layerWithinMap += "+AND+MinY" + colon + openBracket + expandedMapMinY + "+TO+" + expandedMapMaxY + closeBracket;
- layerWithinMap += "+AND+MaxY" + colon + openBracket + expandedMapMinY + "+TO+" + expandedMapMaxY + closeBracket + closeParen
- + "^" + layerWithinExpandedMapBoost;
- return layerWithinMap;
- }
-
- /**
- * return a search element to boost the scores of layers whose scale matches the displayed map scale
- * specifically, it compares their size in longitude
- * @return
- * @deprecated
- * @see layerMatchesArea()
- */
- public String layerMatchesScaleLongitude()
- {
- double deltaX = Math.abs(mapMaxX - mapMinX);
- String layerMatchesScale = "_val_:\"product(" + layerMatchesScaleBoost
- + ",recip(sum(abs(sum(sum(MaxX,product(-1,MinX)),-" + deltaX + ")),.01),1,1,1))\"";
- return layerMatchesScale;
- }
-
- /**
- *
- * @return
- * @deprecated
- * @see layerMatchesArea()
- */
- public String layerMatchesScaleLatitude()
- {
- double deltaY = Math.abs(mapMaxY - mapMinY);
- String layerMatchesScale = "_val_:\"product(" + layerMatchesScaleBoost
- + ",recip(sum(abs(sum(sum(MaxY,product(-1,MinY)),-" + deltaY + ")),.01),1,1,1))\"";
- return layerMatchesScale;
- }
-
- /**
- * score layer based on how close map center longitude is to the layer's center longitude
- * @return
- */
- public String layerNearCenterLongitude()
- {
- double centerX = (mapMaxX + mapMinX)/2.;
- String layerMatchesCenter = "_val_:\"product(" + layerMatchesCenterBoost
- + ",recip(abs(sub(product(sum(MaxX,MinX),.5)," + centerX + ")),1,1000,1000))\"";
- return layerMatchesCenter;
- }
-
- /**
- * score layer based on how close map center latitude is to the layer's center latitude
- * @return
- */
- public String layerNearCenterLatitude()
- {
- double centerY = (mapMaxY + mapMinY)/2.;
- String layerMatchesCenter = "_val_:\"product(" + layerMatchesCenterBoost
- + ",recip(abs(sub(product(sum(MaxY,MinY),.5)," + centerY + ")),1,1000,1000))\"";
- return layerMatchesCenter;
- }
-
-
- /**
- * return a search element to boost the scores of layers whose scale matches the displayed map scale
- * specifically, it compares their area
- * @return
- */
- public String layerMatchesArea()
- {
- double mapDeltaX = Math.abs(mapMaxX - mapMinX);
- double mapDeltaY = Math.abs(mapMaxY - mapMinY);
- double mapArea = (mapDeltaX * mapDeltaY);
- System.out.println("map area = " + mapArea);
- String layerMatchesArea = "_val_:\"product(" + layerMatchesScaleBoost
- + ",recip(sum(abs(sub(Area," + mapArea + ")),.01),1,1000,1000))\"";
- return layerMatchesArea;
- }
-
- /**
- * return a search element to detect intersecting layers
- * computes intersection of axis aligned bounding boxes (AABB) using separating axis
- * note that if the map covers the layer or if the map is contained within the layer, there is no separating axis
- * so this function works for them as well.
- * implementing separating axis on AABB in Solr's functional language (which lacks an if statement)
- * is a little tricky so this function generates a complicated string
- *
- *
- * some info on separating access on AABB see:
- * http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php?page=3
- *
- * this function returns something that looks like:
- * product(2.0,
- * map(sum(map(sub(abs(sub(-71.172866821289,CenterX)),sum(0.7539367675480051,HalfWidth)),0,400000,1,0),
- * map(sub(abs(sub(42.3588141761575,CenterY)),sum(0.6900056205085008,HalfHeight)),0,400000,1,0)),0,0,1,0))
- *
- * @return
- */
- public String layerIntersectsMapAux()
- {
- double mapCenterX = (mapMaxX + mapMinX) / 2.;
- double mapHalfWidth = (mapMaxX - mapMinX) / 2.;
- double mapCenterY = (mapMaxY + mapMinY) / 2.;
- double mapHalfHeight = (mapMaxY - mapMinY) / 2.;
-
- String centerDistanceX = "abs(sub(" + mapCenterX + ",CenterX))";
- String centerDistanceY = "abs(sub(" + mapCenterY + ",CenterY))";
- // the separatingAxis is positive if it is actually a separating axis (no intersection)
- String separatingAxisX = "sub(" + centerDistanceX + ",sum(" + mapHalfWidth + ",HalfWidth))";
- String separatingAxisY = "sub(" + centerDistanceY + ",sum(" + mapHalfHeight + ",HalfHeight))";
- // separatingAxisFlag is either 0 or 1, 1 when a separating axis exists
- String separatingAxisFlagX = "map(" + separatingAxisX + ",0,400000,1,0)";
- String separatingAxisFlagY = "map(" + separatingAxisY + ",0,400000,1,0)";
- // separatingAxisExists: 0 for no, 1 or 2 for yes
- String separatingAxisExists = "sum(" + separatingAxisFlagX + "," + separatingAxisFlagY + ")";
- // separatingAxisExistsFlag: 0 if no separating axis (the boxes intersect so add to score)
- // or 1 if axis exists (that is, the boxes don't intersect so don't add to score)
- String separatingAxisExistsFlag = "map(" + separatingAxisExists + ",0,0,1,0)";
- String intersectionScore = "product(" + layerIntersectionScaleBoost + "," + separatingAxisExistsFlag + ")";
- return intersectionScore;
- }
-
- /**
- * return a Solr filter to find layers
- * return a Solr frange expression that can be used with a "fq" clause
- * frange takes the result of a Solr function and filters/clips layers based on a range
- * @return
- */
- public String layerIntersectsMapFilter()
- {
- String intersectionScore = layerIntersectsMapAux();
- String solrFunction = "{!frange+l" + equals + "1+u" + equals + "10}" + intersectionScore;
- return solrFunction;
- }
-
- /**
- * return a Solr scoring clause to find layers
- * @return a Solr _val_ expression that can be used with a "q" clause
- */
- public String layerIntersectsMapScore()
- {
- String intersectionScore = layerIntersectsMapAux();
- String solrFunction = "_val_:\"" + intersectionScore + "\"";
- return solrFunction;
- }
-
- /**
- * create a string with the Solr start and row parameters
- * these attributes are used to specify which subset of the result set should be returned
- * the request parameters must have the name startIndex and rows.
- * @param request
- * @return
- */
- public static String resultSubset(HttpServletRequest request)
- {
- // specify which subset of search results to return, supports next/previous buttons
- String startIndex$ = request.getParameter("startIndex");
- if (startIndex$ == null) startIndex$ = "0";
- startIndex$ = startIndex$.trim();
- String rows$ = request.getParameter("rows");
- if (rows$ == null) rows$ = "20";
- rows$ = rows$.trim();
- String returnValue = "start=" + startIndex$ + "&rows=" + rows$;
- return returnValue;
- }
-
-
-
- /**
- * create a string with the Solr sort parameter
- * @param request
- * @return sort=LayerDisplayName+asc
- */
- public static String sortOrder(HttpServletRequest request)
- {
- String sortColumn = request.getParameter("sortColumn");
- if (sortColumn == null)
- sortColumn = "score";
- else if (sortColumn.equals("LayerDisplayName"))
- sortColumn = "LayerDisplayNameSort";
- else if (sortColumn.equals("DataType"))
- sortColumn = "DataTypeSort";
- else if (sortColumn.equals("Originator"))
- sortColumn = "OriginatorSort";
- else if (sortColumn.equals("Publisher"))
- sortColumn = "PublisherSort";
- else if (sortColumn.equals("Institution"))
- sortColumn = "InstitutionSort";
- String sortOrder = request.getParameter("sortOrder");
- if (sortOrder == null)
- sortOrder = "desc";
- String returnValue = "sort=" + sortColumn + "+" + sortOrder;
- return returnValue;
- }
-
- /**
- * create the solr date search string from the request date parameters
- * if not dates are specified, return empty string
- * if only one date is specified, default values are generated for the other date
- * default fromDate is 0001, default toDate is this year plus one
- * dates sent to solr must be of the form 1995-12-31T23:59:59Z
- * @param request
- * @return
- */
- public static String dateClause(HttpServletRequest request)
- {
- String dateSuffix = "-01-01T01:01:01Z";
- String fromDate = getRequestParameter(request, "dateFrom");
- String toDate = getRequestParameter(request, "dateTo");
- System.out.println("fromDate = " + fromDate +", toDate = " + toDate);
- if ((fromDate == null) && (toDate == null))
- return "";
- if (fromDate == null)
- fromDate = "0001";
- if (toDate == null)
- {
- // instead, should I just use the year 9999? what about Y10K?
- Calendar now = Calendar.getInstance();
- int year = now.get(Calendar.YEAR);
- toDate = Integer.toString(year) + 1;
- }
- String searchClause = "ContentDate" + colon
- + openBracket + fromDate + dateSuffix + "+TO+" + toDate + dateSuffix + closeBracket;
- return searchClause;
- }
-
- /**
- * returns the parameter from the request
- * converts the value "undefined" to null
- * @param request
- * @param parameterName
- * @return null or the string value
- */
- public static String getRequestParameter(HttpServletRequest request, String parameterName)
- {
- String returnValue = request.getParameter(parameterName);
- if (returnValue == null)
- return returnValue;
- if (returnValue.equals("undefined"))
- return null;
- returnValue = returnValue.trim();
- if (returnValue.length() == 0)
- return null;
- return returnValue;
- }
-
-
-
- /**
- * create a Solr filter string based on user's data type selections
- * e.g., Raster, Paper Map, etc.
- */
- public static String createDataTypeFilter(HttpServletRequest request)
- {
- // first, see what check boxes are on and store in vector
- Vector dataTypes = new Vector();
-
- String includeRaster = request.getParameter("typeRaster");
- if (includeRaster == null) includeRaster = "";
- if (includeRaster.equals("on"))
- {
- dataTypes.add("Raster");
- }
-
- String includeVector = request.getParameter("typeVector");
- if (includeVector == null) includeVector = "";
- if (includeVector.equals("on"))
- {
- dataTypes.add("Point");
- dataTypes.add("Line");
- dataTypes.add("Polygon");
- }
- String includeScannedMap = request.getParameter("typeMap");
- if (includeScannedMap == null) includeScannedMap = "";
- if (includeScannedMap.equals("on"))
- {
- dataTypes.add("Paper+Map");
- }
-
- // now, convert data types to Solr filter
- String dataTypeFilter = "";
- for (int i = 0 ; i < dataTypes.size() ; i++)
- {
- String currentType = dataTypes.get(i);
- if (i > 0)
- dataTypeFilter += "+OR+";
- dataTypeFilter += "DataType" + colon + currentType;
- }
- return dataTypeFilter;
- }
-
- /**
- * create a Solr filter string based on user's data source selections
- * e.g., MIT, Harvard, etc.
- */
- public static String createDataSourceFilter(HttpServletRequest request)
- {
- // first, see what check boxes are on and store in vector
- Vector dataSources = new Vector();
-
- String sourceHarvard = request.getParameter("sourceHarvard");
- if (sourceHarvard == null) sourceHarvard = "";
- if (sourceHarvard.equals("on"))
- dataSources.add("Harvard");
- String sourceMit = request.getParameter("sourceMit");
- if (sourceMit == null) sourceMit = "";
- if (sourceMit.equals("on"))
- dataSources.add("MIT");
- String sourceMassGis = request.getParameter("sourceMassGis");
- if (sourceMassGis == null) sourceMassGis = "";
- if (sourceMassGis.equals("on"))
- dataSources.add("MassGis");
- String sourcePrinceton = request.getParameter("sourcePrinceton");
- if (sourcePrinceton == null) sourcePrinceton = "";
- if (sourcePrinceton.equals("on"))
- dataSources.add("Princeton");
- String sourceTufts = request.getParameter("sourceTufts");
- if (sourceTufts == null) sourceTufts = "";
- if (sourceTufts.equals("on"))
- dataSources.add("Tufts");
-
- // now, convert data types to Solr filter
- String dataSourceFilter = "";
- for (int i = 0 ; i < dataSources.size() ; i++)
- {
- String currentSource = dataSources.get(i);
- if (i > 0)
- dataSourceFilter += "+OR+";
- dataSourceFilter += "Institution" + colon + currentSource;
- }
- return dataSourceFilter;
- }
-
-
- public static String createPublisherFilter(HttpServletRequest request)
- {
- String temp = request.getParameter("publisher");
- String[] publishers = temp.split(" ");
- String publishersFilter = "";
- for (int i = 0 ; i < publishers.length ; i++)
- {
- String currentSource = publishers[i];
- if (i > 0)
- publishersFilter += "+OR+";
- publishersFilter += "Publisher" + colon + currentSource;
- }
- return publishersFilter;
- }
-
- public static String createBasicKeywordFilter(HttpServletRequest request)
- {
- String searchTerm = request.getParameter("searchTerm");
- if (searchTerm == null)
- return "";
- searchTerm = searchTerm.trim();
- if (searchTerm.length() == 0)
- return "";
- String[] searchTerms = searchTerm.split(" ");
- String keywordFilter = "";
- for (int i = 0 ; i < searchTerms.length ; i++)
- {
- String currentSearchTerm = searchTerms[i];
- if (i > 0)
- keywordFilter += "+OR+";
- keywordFilter += "LayerDisplayName" + Searcher.colon + currentSearchTerm;
- //solrQuery += "+OR+Institution" + Searcher.colon + currentSearchTerm + "^2";
- keywordFilter += "+OR+Publisher" + Searcher.colon + currentSearchTerm;
- keywordFilter += "+OR+Originator" + Searcher.colon + currentSearchTerm;
- //solrQuery += "+OR+DataType" + Searcher.colon + currentSearchTerm;
- keywordFilter += "+OR+ThemeKeywords" + Searcher.colon + currentSearchTerm;
- keywordFilter += "+OR+PlaceKeywords" + Searcher.colon + currentSearchTerm;
- //geoFilter += "+OR+Abstract" + Searcher.colon + "'" + currentKeyword + "'" + "^0.5";
- }
- return keywordFilter;
- }
-
- public static String createBasicKeywordScore(HttpServletRequest request)
- {
- String searchTerm = request.getParameter("searchTerm");
- if (searchTerm == null)
- return "";
- searchTerm = searchTerm.trim();
- if (searchTerm.length() == 0)
- return "";
- String[] searchTerms = searchTerm.split(" ");
- String keywordScore = "";
- for (int i = 0 ; i < searchTerms.length ; i++)
- {
- String currentSearchTerm = searchTerms[i];
- if (i > 0)
- keywordScore += "+OR+";
- keywordScore += "LayerDisplayName" + Searcher.colon + currentSearchTerm + "^3";
- ////solrQuery += "+OR+Institution" + Searcher.colon + currentSearchTerm + "^2";
- //keywordScore += "+OR+Publisher" + Searcher.colon + currentSearchTerm;
- //keywordScore += "+OR+Originator" + Searcher.colon + currentSearchTerm;
- ////solrQuery += "+OR+DataType" + Searcher.colon + currentSearchTerm;
- keywordScore += "+OR+ThemeKeywords" + Searcher.colon + currentSearchTerm + "^2";
- keywordScore += "+OR+PlaceKeywords" + Searcher.colon + currentSearchTerm + "^2";
- ////geoFilter += "+OR+Abstract" + Searcher.colon + "'" + currentKeyword + "'" + "^0.5";
- }
- return keywordScore;
- }
-
- /**
- * return a Solr expression specifying which columns should be returned for a typical search
- * @return
- */
- public static String getColumnsForSearch()
- {
- String returnValue = "&fl=Name" + comma + "CollectionId" + comma + "Institution"
- + comma + "Access" + comma + "DataType" + comma + "Availability"
- + comma + "LayerDisplayName" + comma + "Publisher" + comma + "Originator"
- + comma + "ThemeKeywords" + comma + "PlaceKeywords" + comma + "Location"
- + comma + "MinX" + comma + "MaxX" + comma + "MinY" + comma + "MaxY"
- + comma + "ContentDate" + comma + "LayerId";
- return returnValue;
- }
-
- /**
- * return a Solr expression specifying which columns should be returned on query for FGDC text
- * @return
- */
- public static String getColumnsForFgdcText()
- {
- String returnValue = "&fl=LayerId" + comma + "FgdcText";
- return returnValue;
- }
-
- /**
- * send query to Solr and return results
- * @param serverName
- * @param solrQuery
- * @return
- */
- public static String executeSolrSearch(String serverName, String solrQuery)
- {
- int port = 8480;
- String url$ = "http://" + serverName + ":" + port + "/solr/select/?" + solrQuery
- + "&debugQuery=off&version=2.2&rows=20&indent=on&wt=json&";
- try
- {
- URL url = new URL(url$);
- InputStream inputStream = url.openStream();
- System.out.println("inputStream = " + inputStream);
- InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
- String currentLine = bufferedReader.readLine();
- String json = "";
- while (currentLine != null)
- {
- currentLine = currentLine.replaceAll("\\n|\\r", " ");
- json = json + currentLine;
- if (currentLine.contains("LayerId"))
- System.out.println(currentLine);
- currentLine = bufferedReader.readLine();
- }
- return json;
- }
- catch (IOException e)
- {
- System.out.println("error in exectuteSolrSearch with url = " + url$);
- return "";
- }
-
- }
-
-
- /**
- * used for testing
- * this is used in conjunction with a set of 14 test layers
- * it validates the intersection code
- * @param args
- */
- public static void main(String[] args)
- {
- Searcher searcher = new Searcher(12, 25, 12, 15);
- String intersection = searcher.layerIntersectsMapFilter();
- System.out.println("intersection = " + intersection);
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrClient.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrClient.java
deleted file mode 100644
index 2f4d220..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrClient.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.OpenGeoPortal.Solr;
-
-import org.apache.solr.client.solrj.SolrServer;
-
-public interface SolrClient {
- public SolrServer getSolrServer();
- public Boolean commit();
- public String delete(String[] layerIds) throws Exception;
- public Boolean verifyIngest(String layerId) throws Exception;
- public int add(SolrRecord solrRecord);
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrJClient.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrJClient.java
deleted file mode 100644
index 21066e7..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Solr/SolrJClient.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.OpenGeoPortal.Solr;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SolrJClient implements SolrClient{
- private SearchConfigRetriever searchConfigRetriever;
- private SolrServer solrServer;
- protected final Logger logger = LoggerFactory.getLogger(this.getClass());
- //String solrUrl;
-
-
- public SolrJClient(SearchConfigRetriever searchConfigRetriever) {
- this.searchConfigRetriever = searchConfigRetriever;
- init();
- }
-
- public void init() {
- try {
- String url = searchConfigRetriever.getSearchUrl();
- url = url.substring(0, url.indexOf("/select"));
- //logger.info(url);
- SolrServer server = new HttpSolrServer(url);
- // Note that the following property could be set through JVM level arguments too
- /*System.setProperty("solr.solr.home", "/home/shalinsmangar/work/oss/branch-1.3/example/solr");
- CoreContainer.Initializer initializer = new CoreContainer.Initializer();
- CoreContainer coreContainer = initializer.initialize();
- EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "");*/
- this.solrServer = server;
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- logger.error("problem creating solr server");
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- logger.error("problem creating solr server");
- }
- }
-
- public SolrServer getSolrServer(){
- return solrServer;
- }
-
- public Boolean commit() {
- try {
- UpdateResponse updateResponse = solrServer.commit();
- return successResponse(updateResponse);
- } catch (SolrServerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return false;
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return false;
-
- }
-
- }
-
- private Boolean successResponse(UpdateResponse updateResponse){
- if (updateResponse.getStatus() == 200){
- return true;
- } else {
- return false;
- }
- }
-
- public String delete(String[] layerIds) throws Exception {
- //List ids = Arrays.asList(layerIds);
- String query = "";
- for (String layerId : layerIds){
- query += "LayerId:" + layerId.trim();
- query += " OR ";
- }
- if (query.length() > 0){
- query = query.substring(0, query.lastIndexOf(" OR "));
- }
- //logger.info(query);
- UpdateResponse updateResponse = solrServer.deleteByQuery(query);
- //UpdateResponse updateResponse = solrServer.deleteById(ids);
- if (successResponse(updateResponse)){
- return updateResponse.toString();
- }
- return "";
- }
-
- public Boolean verifyIngest(String layerId) throws Exception {
- SolrQuery query = new SolrQuery();
- query.setQuery("LayerId:" + layerId);
- QueryResponse queryResponse = solrServer.query(query);
- int numFound = Integer.getInteger(queryResponse.getResponseHeader().get("numFound").toString());
- if (numFound == 1){
- return true;
- } else {
- if (numFound > 1){
- throw new Exception("There is more than 1 layer with LayerId:" + layerId);
- } else {
- return false;
- }
- }
- }
-
- public int add(SolrRecord solrRecord) {
- int status = 0;
- UpdateResponse updateResponse = null;
- try {
- logger.debug("begin adding solr record");
- updateResponse = solrServer.addBean(solrRecord);
- status = updateResponse.getStatus();
- logger.debug("Status code: " + Integer.toString(status));
-
- } catch (IOException e) {
- logger.error("IO Exception trying to add Bean");
- e.printStackTrace();
- } catch (SolrServerException e) {
- logger.error("SolrServer Exception trying to add Bean");
- e.printStackTrace();
- } catch (SolrException e){
- logger.error("SolrException: SolrRecord values =" + solrRecord.toString());
- } catch (Exception e){
- logger.error("Unknown Exception trying to add Bean");
- e.printStackTrace();
- }
- logger.info("committing add to Solr");
- commit();
- return status;
- };
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/GetDirectory.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/GetDirectory.java
deleted file mode 100644
index 62d92aa..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/GetDirectory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.springframework.core.io.Resource;
-
-public class GetDirectory implements DirectoryRetriever {
- private static final String DOWNLOAD_DIRECTORY = "download";
- Resource resource;
-
-
- public void setResource(Resource resource){
- this.resource = resource;
- }
-
- /**
- * a method to create a directory to put downloaded files into, if it doesn't already exist
- * @throws IOException
- *
- */
- public File getDirectory(String directoryName) throws IOException{
- //check permissions
-
- String directoryString = this.resource.getFile().getParentFile().getParentFile().getAbsolutePath();
- directoryString += "/" + directoryName;
- //System.out.println(directoryString);
- File theDirectory = new File(directoryString);
-
- if (!theDirectory.exists()){
- theDirectory.mkdir();
- }
-
- if (!theDirectory.canRead() || !theDirectory.canWrite()){
- throw new IOException("Download directory is inaccessible.");
- } else {
- return theDirectory;
- }
- }
-
- public File getDownloadDirectory() {
- try {
- File theDirectory = this.getDirectory(DOWNLOAD_DIRECTORY);
- return theDirectory;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- System.out.println("The directory \"" + DOWNLOAD_DIRECTORY + "\" could not be retrieved.");
- return null;
- }
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/OgpHttpClient.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/OgpHttpClient.java
deleted file mode 100644
index 97eb48b..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/OgpHttpClient.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.OpenGeoPortal.Utilities.Http;
-
-import org.apache.http.client.HttpClient;
-
-public interface OgpHttpClient {
- HttpClient getHttpClient();
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/PoolingHttpClient.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/PoolingHttpClient.java
deleted file mode 100644
index d359a25..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/Http/PoolingHttpClient.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.OpenGeoPortal.Utilities.Http;
-
-import org.apache.http.client.HttpClient;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PoolingHttpClient implements OgpHttpClient {
- final Logger logger = LoggerFactory.getLogger(this.getClass());
- private PoolingClientConnectionManager connectionManager;
- private HttpClient client;
-
- PoolingHttpClient(){
- SchemeRegistry schemeRegistry = new SchemeRegistry();
- schemeRegistry.register(
- new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
- schemeRegistry.register(
- new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
- connectionManager = new PoolingClientConnectionManager(schemeRegistry);
- /*
- *
- *
-
-CoreConnectionPNames.TCP_NODELAY='http.tcp.nodelay': determines whether Nagle's algorithm is to be used. Nagle's algorithm tries to conserve bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY. Data will be sent earlier, at the cost of an increase in bandwidth consumption. This parameter expects a value of type java.lang.Boolean. If this parameter is not set, TCP_NODELAY will be enabled (no delay).
-
-CoreConnectionPNames.SOCKET_BUFFER_SIZE='http.socket.buffer-size': determines the size of the internal socket buffer used to buffer data while receiving / transmitting HTTP messages. This parameter expects a value of type java.lang.Integer. If this parameter is not set, HttpClient will allocate 8192 byte socket buffers.
-
- *
- *
- */
- // Increase max total connection to 200
- //cm.setMaxTotal(200);
- // Increase default max connection per route to 20
- //cm.setDefaultMaxPerRoute(20);
- // Increase max connections for localhost:80 to 50
- //HttpHost localhost = new HttpHost("locahost", 80);
- //cm.setMaxPerRoute(new HttpRoute(localhost), 50);
- client = new DefaultHttpClient(connectionManager);
- client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
- client.getParams().setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 16384);
- }
-
- @Override
- public HttpClient getHttpClient() {
- return client;
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/LinkShortenReturnGoogle.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/LinkShortenReturnGoogle.java
deleted file mode 100644
index bc406de..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/LinkShortenReturnGoogle.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-@JsonIgnoreProperties(ignoreUnknown=true)
-public class LinkShortenReturnGoogle {
- /*{
- "kind": "urlshortener#url",
- "id": "http://goo.gl/fbsS",
- "longUrl": "http://www.google.com/"
-}
-*/ @JsonProperty
- private String kind;
- @JsonProperty
- private String id;
- @JsonProperty
- private String longUrl;
- /*
- *
- * {
- "error": {
- "errors": [
- {
- "domain": "global",
- "reason": "required",
- "message": "Required",
- "locationType": "parameter",
- "location": "resource.longUrl"
- }
- ],
- "code": 400,
- "message": "Required"
- }
- }
- *
- *
- *
- */
- /* public static class Error {
- private String code;
- private String message;
-
- public void setCode(String code){
- this.code = code;
- }
- public String getCode(){
- return this.code;
- }
-
- public void setMessage(String message){
- this.message = message;
- }
- public String getMessage() {
- return this.message;
- }
- }*/
- public void setKind (String kind){
- this.kind = kind;
- }
- public String getKind(){
- return this.kind;
- }
- public void setId (String id){
- this.id = id;
- }
- public String getId (){
- return this.id;
- }
- public void setLongUrl (String longUrl){
- this.longUrl = longUrl;
- }
- public String getLongUrl (){
- return this.longUrl;
- }
-
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ParseJSONSolrLocationField.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ParseJSONSolrLocationField.java
deleted file mode 100644
index 7a65b08..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ParseJSONSolrLocationField.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import java.io.IOException;
-
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.node.ArrayNode;
-
-public final class ParseJSONSolrLocationField {
-
- public static String getWmsUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- ArrayNode urls = (ArrayNode) rootNode.path("wms");
- return urls.get(0).asText();
- }
-
- public static String getTilecacheUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- ArrayNode urls = (ArrayNode) rootNode.path("tilecache");
- return urls.get(0).asText();
- }
-
- public static String getWfsUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- String wfsURL = rootNode.path("wfs").getTextValue();
- return wfsURL;
- }
-
- public static String getWcsUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- String wfsURL = rootNode.path("wcs").getTextValue();
- return wfsURL;
- }
-
- public static String getServiceStartUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- String wfsURL = rootNode.path("serviceStart").getTextValue();
- return wfsURL;
- }
-
- public static String getDownloadUrl(String locationField){
- JsonNode rootNode = parseLocationField(locationField);
- String wfsURL = rootNode.path("download").getTextValue();
- return wfsURL;
- }
-
- private static JsonNode parseLocationField(String locationField){
- ObjectMapper mapper = new ObjectMapper();
- JsonNode rootNode = null;
- try {
- rootNode = mapper.readTree(locationField);
- } catch (JsonProcessingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return rootNode;
-
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/QuickDownload.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/QuickDownload.java
deleted file mode 100644
index d5ef0b1..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/QuickDownload.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import java.io.File;
-
-import org.OpenGeoPortal.Layer.BoundingBox;
-
-public interface QuickDownload {
- public File downloadZipFile(String layerId, BoundingBox bounds) throws Exception;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortener.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortener.java
deleted file mode 100644
index 9a82b2f..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-public interface UrlShortener {
- public String retrieveShortLink(String longUrl) throws Exception;
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortenerGoogle.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortenerGoogle.java
deleted file mode 100644
index d863027..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/UrlShortenerGoogle.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.OpenGeoPortal.Solr.SearchConfigRetriever;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-
-public class UrlShortenerGoogle implements UrlShortener {
- private String url = "https://www.googleapis.com/urlshortener/v1/url?key=";
- private SearchConfigRetriever searchConfigRetriever;
-
- public void setSearchConfigRetriever(SearchConfigRetriever searchConfigRetriever){
- this.searchConfigRetriever = searchConfigRetriever;
- }
-
- public SearchConfigRetriever getSearchConfigRetriever(){
- return this.searchConfigRetriever;
- }
-
- public String retrieveShortLink(String longUrl) throws Exception{
- /*
- * /*POST https://www.googleapis.com/urlshortener/v1/url
- Content-Type: application/json
-
- {"longUrl": "http://www.google.com/"}
- */
- RestTemplate template = new RestTemplate();
- List> messageConverters = new ArrayList>();
- messageConverters.add(new MappingJacksonHttpMessageConverter());
- template.setMessageConverters(messageConverters);
- //now we need to add the parameters
- String apiKey = this.searchConfigRetriever.getArbitrary("googleAPIKey");
-
- LinkShortenRequestGoogle postObject = new LinkShortenRequestGoogle(longUrl);
- LinkShortenReturnGoogle result = template.postForObject(url + apiKey, postObject, LinkShortenReturnGoogle.class);
-
- return result.getId();
- }
-}
diff --git a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ZipFilePackager.java b/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ZipFilePackager.java
deleted file mode 100644
index 97fc112..0000000
--- a/geoportal_1/src/main/java/org/OpenGeoPortal/Utilities/ZipFilePackager.java
+++ /dev/null
@@ -1,227 +0,0 @@
-package org.OpenGeoPortal.Utilities;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
-import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
-import org.apache.commons.compress.archivers.zip.ZipFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ZipFilePackager{
- /**
- * Adds a set of files to a zip archive.
- * @param Set filesToPackage
- * @param File zipArchive
- *
- * @throws FileNotFoundException
- */
- final static Logger logger = LoggerFactory.getLogger(ZipFilePackager.class.getName());
-
- public static File zipUpFile(File fileToZip) throws IOException{
- String zipFileName = fileToZip.getName() + ".zip";
- File zipFile = new File(fileToZip.getParent(), zipFileName);
- ZipArchiveOutputStream newZipStream = new ZipArchiveOutputStream(zipFile);
- //add this uncompressed file to the archive
- int bytesRead;
- byte[] buffer = new byte[1024 * 1024];
-
- ZipArchiveEntry zipEntry = new ZipArchiveEntry(fileToZip.getName());
- newZipStream.putArchiveEntry(zipEntry);
- FileInputStream currentFileStream = new FileInputStream(fileToZip);
- while ((bytesRead = currentFileStream.read(buffer))!= -1) {
- newZipStream.write(buffer, 0, bytesRead);
- }
- newZipStream.closeArchiveEntry();
- newZipStream.close();
- currentFileStream.close();
- logger.info("Deleting: " + fileToZip.getName());
- fileToZip.delete();
- return zipFile;
- }
-
- public static void addFilesToArchive(Set filesToPackage, File zipArchive) throws IOException {
- if (filesToPackage.isEmpty()){
- //if there are no files, don't do anything.
- logger.error("No files to package.");
- return;
- }
- if (filesToPackage.size() == 1){
- File returnFile = filesToPackage.iterator().next();
- if (returnFile.getName().toLowerCase().endsWith(".zip")){
- logger.debug("Only 1 zip file...no need to process");
- returnFile.renameTo(zipArchive);
- return;
- }
- }
- byte[] buffer = new byte[1024 * 1024];
-
- ZipArchiveOutputStream newZipStream = new ZipArchiveOutputStream(zipArchive);
- int zipFileCounter = 0;
- for (File currentFile : filesToPackage){
- try{
- FileInputStream currentFileStream = new FileInputStream(currentFile);
- zipFileCounter++;
- if (!currentFile.getName().toLowerCase().endsWith(".zip")){
- logger.debug("Adding uncompressed file...");
- //add this uncompressed file to the archive
- int bytesRead;
- String entryName = currentFile.getName();
- logger.debug("Zipping: " + entryName);
- ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName);
- newZipStream.putArchiveEntry(zipEntry);
- while ((bytesRead = currentFileStream.read(buffer))!= -1) {
- newZipStream.write(buffer, 0, bytesRead);
- }
- newZipStream.closeArchiveEntry();
- } else {
- logger.debug("Adding entries from compressed file...");
- //read the entries from the zip file and copy them to the new zip archive
- //so that we don't have to recompress them.
- ZipArchiveInputStream currentZipStream = new ZipArchiveInputStream(currentFileStream);
- ArchiveEntry currentEntry;
- while ((currentEntry = currentZipStream.getNextEntry()) != null) {
- String entryName = currentEntry.getName();
- logger.debug("Zipping: " + entryName);
- ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName);
- try {
- newZipStream.putArchiveEntry(zipEntry);
- } catch (Exception e){
- //duplicate names should never happen.
- entryName = Math.round(Math.random() * 10000) + "_" + entryName;
- ZipArchiveEntry zipEntry2 = new ZipArchiveEntry(entryName);
- newZipStream.putArchiveEntry(zipEntry2);
- }
- int bytesRead;
- while ((bytesRead = currentZipStream.read(buffer))!= -1) {
- newZipStream.write(buffer, 0, bytesRead);
- }
- newZipStream.closeArchiveEntry();
- }
- currentZipStream.close();
- }
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- //always delete the file
- logger.debug("Deleting: " + currentFile.getName());
- currentFile.delete();
-
- }
- }
-
- if (zipFileCounter > 0){
- try {
- newZipStream.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- //long endTime = System.currentTimeMillis();
- //logger2.info(zipFileCounter + " file(s) zipped in " + (endTime - startTime) + " milliseconds.");
- }
-
- /*public static Set unarchiveFiles(File zippedFile) throws Exception {
- ZipFile zipFile = new ZipFile(zippedFile);
- zipFile.
- ZipArchiveEntry entry = zipFile.getEntry(name);
- InputStream content = zipFile.getInputStream(entry);
- try {
- READ UNTIL content IS EXHAUSTED
- } finally {
- content.close();
- }
- }*/
- public static Set unarchiveFiles(File zipArchive) throws Exception {
- Set unarchivedFiles = new HashSet();
- try{
- if (!zipArchive.canRead()){
- if (!zipArchive.setReadable(true)){
- throw new IOException("File is not readable");
- }
- }
- String fileName = zipArchive.getName();
- File containerDir;
- if (fileName.endsWith(".zip")){
- fileName = fileName.substring(0, fileName.lastIndexOf(".zip"));
- containerDir = new File(zipArchive.getParentFile(), fileName);
- containerDir.mkdir();
- } else {
- throw new IOException("Not a zipfile!");
- }
- ZipFile zipFile = new ZipFile(zipArchive);
- Enumeration entries = zipFile.getEntriesInPhysicalOrder();
-
- while (entries.hasMoreElements()) {
- ZipArchiveEntry currentEntry = entries.nextElement();
- String entryName = currentEntry.getName();
- logger.debug("Current entry: " + entryName);
- try {
- logger.debug(zipArchive.getParent() + "/" + currentEntry.getName());
- File destFile = new File(containerDir, currentEntry.getName());
- if (currentEntry.isDirectory()){
- destFile.mkdir();
- logger.debug("created directory: " + destFile.getAbsolutePath());
- // create the parent directory structure if needed
- } else {
- File parentDir = destFile.getParentFile();
- if (!parentDir.exists()){
- parentDir.mkdir();
- }
- destFile.createNewFile();
- logger.debug("created file: " + destFile.getAbsolutePath());
- copyInputStream(zipFile.getInputStream(currentEntry),
- new BufferedOutputStream(new FileOutputStream(destFile)));
- unarchivedFiles.add(destFile);
- logger.info("Unzipped file : " + destFile.getName());
- }
- } catch (Exception e){
- e.printStackTrace();
- logger.error("zip exception:" + e.getMessage());
- break;
- }
- }
-
- zipFile.close();
-
- } catch (FileNotFoundException e) {
- logger.error("file not found exception");
- //e.printStackTrace();
- } catch (IOException e) {
- logger.error("IO exception");
- //e.printStackTrace();
- }
- return unarchivedFiles;
- }
-
-
-
- public static final void copyInputStream(InputStream in, OutputStream out)
- throws IOException
- {
- byte[] buffer = new byte[2048];
- int len;
- while((len = in.read(buffer)) >= 0)
- out.write(buffer, 0, len);
- in.close();
- out.close();
- }
-}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/HomeController.java b/geoportal_1/src/main/java/org/opengeoportal/HomeController.java
new file mode 100644
index 0000000..fcd6890
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/HomeController.java
@@ -0,0 +1,97 @@
+package org.opengeoportal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opengeoportal.config.ogp.OgpConfig;
+import org.opengeoportal.config.ogp.OgpConfigRetriever;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+@Controller
+public class HomeController {
+ @Autowired
+ private OgpConfigRetriever ogpConfigRetriever;
+
+ final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @RequestMapping(value={"/index", "/"}, method=RequestMethod.GET)
+ public ModelAndView getHomePage(@RequestParam(value="ogpids", defaultValue = "") Set layerIds,
+ @RequestParam(value="bbox", defaultValue = "-180,-90,180,90") String bbox,
+ @RequestParam(value="layer[]", defaultValue = "") Set layers,
+ @RequestParam(value="minX", defaultValue = "-180") String minx,
+ @RequestParam(value="maxX", defaultValue = "180") String maxx,
+ @RequestParam(value="minY", defaultValue = "-90") String miny,
+ @RequestParam(value="maxY", defaultValue = "90") String maxy,
+ @RequestParam(value="dev", defaultValue = "false") Boolean isDev) throws Exception {
+ //@RequestParam("ogpids") Set layerIds, ..should be optional. also a param to set dev vs. prod
+ //create the model to return
+ ModelAndView mav = new ModelAndView("ogp_home");
+
+ mav.addObject("dev", isDev);
+
+ //if ogpids exists, add them to the Model
+
+ if (!layerIds.isEmpty()){
+
+ mav.addObject("shareIds", getQuotedSet(layerIds));
+ mav.addObject("shareBbox", bbox);
+ } else if (!layers.isEmpty()){
+ //support old style share just in case
+ mav.addObject("shareIds", getQuotedSet(layers));
+ mav.addObject("shareBbox", minx + "," + miny + "," + maxx + "," + maxy);
+ } else {
+ //default values
+ mav.addObject("shareIds", layerIds);
+ mav.addObject("shareBbox", bbox);
+ }
+
+
+
+ addConfig(mav);
+
+ //Debugging
+ /*Iterator> iter = mav.getModelMap().entrySet().iterator();
+ while (iter.hasNext()){
+ Entry stuff = iter.next();
+ logger.info(stuff.getKey());
+ logger.info((String) stuff.getValue());
+ }*/
+ return mav;
+
+ }
+
+ private Set getQuotedSet(Set uqSet){
+ Set quotedSet = new HashSet();
+ for (String item: uqSet){
+ quotedSet.add("\"" + item + "\"");
+ }
+
+ return quotedSet;
+ }
+
+ private void addConfig(ModelAndView mav){
+ OgpConfig conf = ogpConfigRetriever.getConfig();
+
+ mav.addObject("titlePrimary", conf.getPageTitlePrimary());
+ mav.addObject("titleOffset", conf.getPageTitleOffset());
+
+ mav.addObject("extraJs", conf.getJsLocalized()); //
+ mav.addObject("extraCss", conf.getCssLocalized()); //
+
+ mav.addObject("searchUrl", conf.getSearchUrl().toString());
+ mav.addObject("analyticsId", conf.getAnalyticsId());
+
+ mav.addObject("loginRepository", conf.getLoginConfig().getRepositoryId());
+ mav.addObject("loginType", conf.getLoginConfig().getType());
+ mav.addObject("loginUrl", conf.getLoginConfig().getUrl());
+ mav.addObject("secureDomain", conf.getLoginConfig().getSecureDomain());
+
+ }
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/admin/AdminController.java b/geoportal_1/src/main/java/org/opengeoportal/admin/AdminController.java
new file mode 100644
index 0000000..8edf04a
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/admin/AdminController.java
@@ -0,0 +1,40 @@
+package org.opengeoportal.admin;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+
+import org.opengeoportal.config.search.SearchConfigRetriever;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping("/admin")
+public class AdminController {
+
+ final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ SearchConfigRetriever searchConfigRetriever;
+
+ @RequestMapping(value="setSearch", method=RequestMethod.GET, produces="application/json")
+ public @ResponseBody Map setSearchUrl(@RequestParam("url") String url) throws Exception {
+ Boolean success = false;
+ try {
+ //searchConfigRetriever.setSearchUrl(url);
+ success = true;
+ } catch (Exception e){
+ logger.error("Problem setting solr url: " + url);
+ }
+ Map responseMap = new LinkedHashMap();
+ responseMap.put("success", success);
+ return responseMap;
+ }
+
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/ConfigController.java b/geoportal_1/src/main/java/org/opengeoportal/config/ConfigController.java
new file mode 100644
index 0000000..1319180
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/ConfigController.java
@@ -0,0 +1,54 @@
+package org.opengeoportal.config;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opengeoportal.config.ogp.OgpConfig;
+import org.opengeoportal.config.ogp.OgpConfigRetriever;
+import org.opengeoportal.config.proxy.ProxyConfig;
+import org.opengeoportal.config.proxy.ProxyConfigRetriever;
+import org.opengeoportal.config.repositories.RepositoryConfig;
+import org.opengeoportal.config.repositories.RepositoryConfigRetriever;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping("/config")
+public class ConfigController {
+
+ final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ RepositoryConfigRetriever repositoryConfigRetriever;
+
+ @Autowired
+ OgpConfigRetriever ogpConfigRetriever;
+
+ @Autowired
+ ProxyConfigRetriever proxyConfigRetriever;
+
+ @RequestMapping(value="repositories", method=RequestMethod.GET, produces="application/json")
+ public @ResponseBody List getRepositoryConfig() throws Exception {
+
+ return repositoryConfigRetriever.getConfig();
+ }
+
+ @RequestMapping(value="general", method=RequestMethod.GET, produces="application/json")
+ public @ResponseBody OgpConfig getSearchConfig() throws Exception {
+
+ return ogpConfigRetriever.getConfig();
+ }
+
+ @RequestMapping(value="proxy", method=RequestMethod.GET, produces="application/json")
+ public @ResponseBody List getProxyConfig() throws Exception {
+ //must only serve a reduced version...we don't want to hand out internal addresses/credentials to the client
+ return proxyConfigRetriever.getPublicConfig();
+
+ }
+}
\ No newline at end of file
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/PropertiesFile.java b/geoportal_1/src/main/java/org/opengeoportal/config/PropertiesFile.java
new file mode 100644
index 0000000..624e561
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/PropertiesFile.java
@@ -0,0 +1,57 @@
+package org.opengeoportal.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+
+public class PropertiesFile {
+ Properties properties;
+ Resource resource;// ogp.properties
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public void setResource(Resource resource){
+ this.resource = resource;
+ }
+
+ public void refreshProperties() throws IOException {
+ readProperties();
+ }
+
+ private void readProperties() throws IOException{
+ InputStream is = null;
+ try{
+ properties = new Properties();
+ is = resource.getInputStream();
+ properties.load(is);
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ }
+
+ public String getProperty(String propertyName) throws IOException{
+ if (properties == null){
+ readProperties();
+ }
+ return properties.getProperty(propertyName);
+ }
+
+ public Properties getProperties() throws IOException {
+ if (properties == null){
+ readProperties();
+ }
+ return properties;
+ }
+
+ public String[] getPropertyArray(String propertyName) throws IOException {
+ return this.getProperty(propertyName).split(",");
+ }
+
+ public String getProperty(String propertyKey, String defaultValue) {
+ return properties.getProperty(propertyKey, defaultValue);
+ }
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfig.java b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfig.java
new file mode 100644
index 0000000..394ce26
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfig.java
@@ -0,0 +1,108 @@
+package org.opengeoportal.config.ogp;
+
+import java.net.URL;
+
+public class OgpConfig {
+/*
+ * really a catch-all for the other stuff the web app needs.
+ *
+ *
+ */
+
+ String pageTitlePrimary;
+ String pageTitleOffset;
+ String jsLocalized;
+ String cssLocalized;
+ URL searchUrl;
+ String analyticsId;
+ LoginConfig loginConfig = new LoginConfig();
+
+ public String getPageTitlePrimary() {
+ return pageTitlePrimary;
+ }
+
+ public void setPageTitlePrimary(String pageTitle) {
+ this.pageTitlePrimary = pageTitle;
+ }
+
+ public String getPageTitleOffset() {
+ return pageTitleOffset;
+ }
+
+ public void setPageTitleOffset(String pageTitleOffset) {
+ this.pageTitleOffset = pageTitleOffset;
+ }
+
+ public String getJsLocalized() {
+ return jsLocalized;
+ }
+
+ public void setJsLocalized(String jsLocalized) {
+ this.jsLocalized = jsLocalized;
+ }
+
+ public String getCssLocalized() {
+ return cssLocalized;
+ }
+
+ public void setCssLocalized(String cssLocalized) {
+ this.cssLocalized = cssLocalized;
+ }
+
+ public URL getSearchUrl() {
+ return searchUrl;
+ }
+
+ public void setSearchUrl(URL searchUrl) {
+ this.searchUrl = searchUrl;
+ }
+
+ public String getAnalyticsId() {
+ return analyticsId;
+ }
+
+ public void setAnalyticsId(String analyticsId) {
+ this.analyticsId = analyticsId;
+ }
+
+ public LoginConfig getLoginConfig() {
+ return loginConfig;
+ }
+
+ public void setLoginConfig(LoginConfig loginConfig) {
+ this.loginConfig = loginConfig;
+ }
+
+ public class LoginConfig {
+ String repositoryId;
+ String type;
+ String url;
+ String secureDomain;
+
+ public String getRepositoryId() {
+ return repositoryId;
+ }
+ public void setRepositoryId(String repositoryId) {
+ this.repositoryId = repositoryId;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public String getSecureDomain() {
+ return secureDomain;
+ }
+ public void setSecureDomain(String secureDomain) {
+ this.secureDomain = secureDomain;
+ }
+ }
+
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetriever.java b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetriever.java
new file mode 100644
index 0000000..0a16b0c
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetriever.java
@@ -0,0 +1,13 @@
+package org.opengeoportal.config.ogp;
+
+
+public interface OgpConfigRetriever {
+
+ OgpConfig getConfig();
+
+ OgpConfig load() throws Exception;
+
+ String getPropertyWithDefault(String propertyName,
+ String defaultPropertyValue);
+
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetrieverFromProperties.java b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetrieverFromProperties.java
new file mode 100644
index 0000000..fd66f03
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/ogp/OgpConfigRetrieverFromProperties.java
@@ -0,0 +1,141 @@
+package org.opengeoportal.config.ogp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.lang3.StringUtils;
+import org.opengeoportal.config.PropertiesFile;
+import org.opengeoportal.config.ogp.OgpConfig.LoginConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OgpConfigRetrieverFromProperties implements OgpConfigRetriever {
+
+ //property keys
+ private static final String ANALYTICS_KEY = "apikey.analytics";
+ private static final String TITLE_PRIMARY = "ogp.pageTitle.primary";
+ private static final String TITLE_OFFSET = "ogp.pageTitle.offset";
+ private static final String EXTRA_JS = "ogp.jsLocalized";
+ private static final String EXTRA_CSS = "ogp.cssLocalized";
+ private static final String EXTERNAL_SEARCH_URL = "solr.url.external";
+ private static final String LOGIN_REPOSITORY = "login.repository";
+ private static final String LOGIN_TYPE = "login.type";
+ private static final String LOGIN_URL = "login.url";
+ private static final String SECURE_DOMAIN = "login.secureDomain";
+
+ //default values
+ private static final String TITLE_PRIMARY_DEFAULT = "Open";
+ private static final String TITLE_OFFSET_DEFAULT = "Geoportal";
+
+ private static final String LOGIN_TYPE_DEFAULT = "form";
+ private static final String LOGIN_URL_DEFAULT = "login";
+
+
+
+ PropertiesFile propertiesFile;
+ Properties props;
+ OgpConfig ogpConfig;
+
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public PropertiesFile getPropertiesFile() {
+ return propertiesFile;
+ }
+
+ public void setPropertiesFile(PropertiesFile propertiesFile) {
+ this.propertiesFile = propertiesFile;
+ }
+
+
+ @Override
+ public OgpConfig getConfig() {
+ return ogpConfig;
+ }
+
+ public void setOgpConfig(OgpConfig ogpConfig) {
+ this.ogpConfig = ogpConfig;
+ }
+
+ @Override
+ public OgpConfig load() throws Exception {
+ props = propertiesFile.getProperties();
+
+ ogpConfig = new OgpConfig();
+
+ URL extUrl = null;
+ if (props.containsKey(EXTERNAL_SEARCH_URL)){
+ String extSearch = props.getProperty(EXTERNAL_SEARCH_URL);
+ //add /select, remove trailing slash
+ if (extSearch.endsWith("/")){
+ extSearch = extSearch.substring(0, extSearch.lastIndexOf("/"));
+ }
+ if (!extSearch.endsWith("select")){
+ extSearch += "/select";
+ }
+
+ try{
+ extUrl = new URL(extSearch);
+ ogpConfig.setSearchUrl(extUrl);
+ } catch (MalformedURLException e){
+ throw new Exception("External Search URL ['property " + EXTERNAL_SEARCH_URL + "'] is malformed!");
+ }
+ } else {
+ throw new Exception("Must set a search URL!");
+ }
+
+
+ String analyticsKey = getPropertyWithDefault(ANALYTICS_KEY, "");
+ ogpConfig.setAnalyticsId(analyticsKey);
+
+ String pageTitlePrimary = getPropertyWithDefault(TITLE_PRIMARY, TITLE_PRIMARY_DEFAULT);
+ ogpConfig.setPageTitlePrimary(pageTitlePrimary);
+
+ String pageTitleOffset = getPropertyWithDefault(TITLE_OFFSET, TITLE_OFFSET_DEFAULT);
+ ogpConfig.setPageTitleOffset(pageTitleOffset);
+
+ String extraJs = getPropertyWithDefault(EXTRA_JS, "");
+ ogpConfig.setJsLocalized(extraJs);
+
+ String extraCss = getPropertyWithDefault(EXTRA_CSS, "");
+ ogpConfig.setCssLocalized(extraCss);
+
+
+ LoginConfig logConf = ogpConfig.getLoginConfig();
+
+ //This should throw an error if LOGIN_REPOSITORY is not set properly
+ String val = getPropertyWithDefault(LOGIN_REPOSITORY, "");
+ if (StringUtils.isNotEmpty(val)){
+ logConf.setRepositoryId(val);
+ } else {
+ throw new Exception("Must set a value for Login Repository! ['" + LOGIN_REPOSITORY + "']");
+ }
+
+ String typeVal = getPropertyWithDefault(LOGIN_TYPE, LOGIN_TYPE_DEFAULT);
+ logConf.setType(typeVal);
+
+ String urlVal = getPropertyWithDefault(LOGIN_URL, LOGIN_URL_DEFAULT);
+ logConf.setUrl(urlVal);
+
+ String sdVal = getPropertyWithDefault(SECURE_DOMAIN, ""); ; //should default to current domain with https:; for now let the client do this
+ logConf.setSecureDomain(sdVal);
+
+
+ return ogpConfig;
+ }
+
+ @Override
+ public String getPropertyWithDefault(String propertyName, String defaultPropertyValue){
+ String val = null;
+ if (props.containsKey(propertyName) && StringUtils.isNotEmpty(props.getProperty(propertyName))){
+ val = props.getProperty(propertyName); //default to type form
+ } else {
+
+ logger.warn(propertyName + " not set. Using default value '" + defaultPropertyValue + "'.");
+ val = defaultPropertyValue;
+ }
+
+ return val;
+ }
+
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/proxy/InternalServerMapping.java b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/InternalServerMapping.java
new file mode 100644
index 0000000..191d733
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/InternalServerMapping.java
@@ -0,0 +1,40 @@
+package org.opengeoportal.config.proxy;
+
+public class InternalServerMapping implements ServerMapping {
+ String type;//wfs,wms,wcs...could be others
+ String internalUrl;
+ String externalUrl;
+ String username;
+ String password;
+
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getInternalUrl() {
+ return internalUrl;
+ }
+ public void setInternalUrl(String internalUrl) {
+ this.internalUrl = internalUrl;
+ }
+ public String getExternalUrl() {
+ return externalUrl;
+ }
+ public void setExternalUrl(String externalUrl) {
+ this.externalUrl = externalUrl;
+ }
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ this.username = username;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfig.java b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfig.java
new file mode 100644
index 0000000..b184272
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfig.java
@@ -0,0 +1,43 @@
+package org.opengeoportal.config.proxy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProxyConfig {
+/*# if you are using ogp to proxy download and preview of layers, set it
+# up here. (form is: proxy.${repository id}.*)
+proxy.tufts.accessLevel=restricted
+
+proxy.tufts.geoserver.internal=http://127.0.0.1:8580
+proxy.tufts.geoserver.external=restricted
+proxy.tufts.geoserver.username=
+proxy.tufts.geoserver.password=
+*/
+ String repositoryId;
+ List accessLevels;
+ List serverMapping = new ArrayList();
+
+ public String getRepositoryId() {
+ return repositoryId;
+ }
+
+ public void setRepositoryId(String repositoryId) {
+ this.repositoryId = repositoryId;
+ }
+
+ public List getAccessLevels() {
+ return accessLevels;
+ }
+
+ public void setAccessLevels(List accessLevels) {
+ this.accessLevels = accessLevels;
+ }
+
+ public List getServerMapping() {
+ return serverMapping;
+ }
+
+ public void setServerMapping(List serverMapping) {
+ this.serverMapping = serverMapping;
+ }
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetriever.java b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetriever.java
new file mode 100644
index 0000000..c28c38f
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetriever.java
@@ -0,0 +1,28 @@
+package org.opengeoportal.config.proxy;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface ProxyConfigRetriever {
+
+ String getExternalProxyUrl(String type, String repository, String accessLevel) throws Exception;
+
+ String getInternalProxyUrl(String type, String repository, String accessLevel) throws Exception;
+
+ boolean hasProxy(String type, String repository, String accessLevel);
+
+ boolean hasCredentials(String type, String repository, String accessLevel);
+
+ List load() throws IOException;
+
+ List getConfig();
+
+ List getPublicConfig();
+
+ String getInternalUrl(String type, String repository, String accessLevel,
+ String locationField) throws Exception;
+
+ String getExternalUrl(String type, String repository, String accessLevel,
+ String locationField) throws Exception;
+
+}
diff --git a/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetrieverFromProperties.java b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetrieverFromProperties.java
new file mode 100644
index 0000000..5a07e2c
--- /dev/null
+++ b/geoportal_1/src/main/java/org/opengeoportal/config/proxy/ProxyConfigRetrieverFromProperties.java
@@ -0,0 +1,274 @@
+package org.opengeoportal.config.proxy;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.opengeoportal.config.PropertiesFile;
+import org.opengeoportal.utilities.LocationFieldUtils;
+import org.opengeoportal.utilities.OgpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ProxyConfigRetrieverFromProperties implements ProxyConfigRetriever {
+
+ PropertiesFile propertiesFile;
+ List proxyConfig;
+
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public PropertiesFile getPropertiesFile() {
+ return propertiesFile;
+ }
+
+ public void setPropertiesFile(PropertiesFile propertiesFile) {
+ this.propertiesFile = propertiesFile;
+ }
+
+ @Override
+ public List getConfig(){
+ return proxyConfig;
+ }
+
+ @Override
+ public List load() throws IOException {
+ Properties props = propertiesFile.getProperties();
+ proxyConfig = new ArrayList();
+
+ //populate a List of ProxyConfig objects
+
+ Set