Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d518e9e5a4 | ||
|
|
cf24d45760 | ||
|
|
f10f027fb8 | ||
|
|
25759e86a5 | ||
|
|
febd28bc3a | ||
|
|
ad6fe87e81 | ||
|
|
318be5853e | ||
|
|
c44eece1f1 | ||
|
|
c588f2c66b | ||
|
|
0ec95f03f9 | ||
|
|
415df68d4b | ||
|
|
12c2e09c0e | ||
|
|
8f0efbc5de | ||
|
|
baf27a6ed7 | ||
|
|
b12342007b | ||
|
|
e6c77e9508 | ||
|
|
88668158f6 | ||
|
|
c6d6c3d2b9 | ||
|
|
61b914c610 | ||
|
|
ebee7276b2 | ||
|
|
10bf4971b2 | ||
|
|
9a736d2d7e | ||
|
|
8968e36673 | ||
|
|
224061257f | ||
|
|
9e0e9490c2 | ||
|
|
62d34ac345 | ||
|
|
7490529d2d | ||
|
|
7fdf019cd6 | ||
|
|
a8412ea7e9 | ||
|
|
098999b9b2 | ||
|
|
0259686b3c | ||
|
|
d2bbcc46a7 | ||
|
|
7af3899802 | ||
|
|
ff7f383591 | ||
|
|
5447c06dbc | ||
|
|
db5d949e71 | ||
|
|
e48a2b0d88 | ||
|
|
7c20365099 | ||
|
|
1f11fd3207 | ||
|
|
797dac9289 | ||
|
|
55d0e0bd8e | ||
|
|
12ec730db8 | ||
|
|
dbbd54a8ea | ||
|
|
5fbe7ed2e9 | ||
|
|
4d4813007f | ||
|
|
c360e8c532 | ||
|
|
3f22f36aa2 | ||
|
|
5027ba8112 | ||
|
|
bd6bab3ddb | ||
|
|
28a72e2691 | ||
|
|
bde93118d2 | ||
|
|
ebae6cf086 | ||
|
|
a4268dda60 | ||
|
|
f55cb1cbcc | ||
|
|
feb41ad0f7 | ||
|
|
c76e60205c | ||
|
|
9ebfaaafed | ||
|
|
7d0a8319ea | ||
|
|
94c7871cd1 | ||
|
|
4241e4d83d | ||
|
|
1533c7bec4 | ||
|
|
3e810bb869 | ||
|
|
213ed8326d | ||
|
|
c9f51cf388 | ||
|
|
497ec63408 | ||
|
|
631f3a9ffa | ||
|
|
a7d3efc6f7 | ||
|
|
5bd0f5e2e9 | ||
|
|
8cdc7d02b7 | ||
|
|
02439fa277 | ||
|
|
4cfa86400b | ||
|
|
da5ee7c090 | ||
|
|
6327f699ff | ||
|
|
e04dd7428e | ||
|
|
962d28503a | ||
|
|
86a3de1e2d | ||
|
|
fd84472576 | ||
|
|
3e580b73d1 | ||
|
|
75dec9c726 | ||
|
|
f06c49806d | ||
|
|
c17a14d9e0 | ||
|
|
b60e487ffa | ||
|
|
2526337e7d | ||
|
|
81b13eb404 | ||
|
|
b9aae2620b | ||
|
|
96d734f4e8 | ||
|
|
33b951c8ab | ||
|
|
5ca054d021 | ||
|
|
21b9cb1f00 | ||
|
|
ba8f17c5b1 | ||
|
|
3f90df97ba |
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
sudo: false
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- "$HOME/.m2"
|
||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk7
|
||||||
|
- openjdk7
|
||||||
|
script:
|
||||||
|
- mvn -B -T2 -fae clean install
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
on_failure: never
|
||||||
|
after_success:
|
||||||
|
- mvn clean cobertura:cobertura coveralls:report
|
||||||
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 20007-2011 GeoSolutions
|
Copyright (c) 20007-2016 GeoSolutions
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
16
README
16
README
@ -1,16 +0,0 @@
|
|||||||
REST client library to interact with GeoServer (http://www.geoserver.org)
|
|
||||||
|
|
||||||
The purpose of this project is to hold a REST client library to interact with GeoServer; a requirement for this library is to depend as less as possible on external libraries. This library aims at being lean and mean.
|
|
||||||
|
|
||||||
For general questions about this project feel free to use the mailing lists.
|
|
||||||
|
|
||||||
Mailing Lists
|
|
||||||
|
|
||||||
USERS
|
|
||||||
https://groups.google.com/forum/?fromgroups#!forum/geoserver-manager-users
|
|
||||||
DEVELOPERS
|
|
||||||
https://groups.google.com/forum/?fromgroups#!forum/geoserver-manager-devs
|
|
||||||
|
|
||||||
For more information see this page:
|
|
||||||
|
|
||||||
https://github.com/geosolutions-it/geoserver-manager/wiki
|
|
||||||
68
README.md
Normal file
68
README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# geoserver-manager
|
||||||
|
## Status
|
||||||
|
* Master on travis [](https://travis-ci.org/geosolutions-it/geoserver-manager)
|
||||||
|
* Master on Linux + OracleJDK7 [](http://build.geo-solutions.it/jenkins/view/GeoServer-manager/job/GeoServer-Manager-Master/)
|
||||||
|
* Master on Windows + OracleJDK7 [](http://winbuild.geo-solutions.it/jenkins/view/GeoServer-Manager/job/GeoServer-Manager-Master/)
|
||||||
|
* Stable on Linux + OracleJDK7 [](http://build.geo-solutions.it/jenkins/view/GeoServer-manager/job/GeoServer-Manager-Stable/)
|
||||||
|
* Stable on Windows + OracleJDK7 [](http://winbuild.geo-solutions.it/jenkins/view/GeoServer-Manager/job/GeoServer-Manager-Stable/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Intro
|
||||||
|
Client library written in Java to interact with [GeoServer](http://www.geoserver.org) through its [ReST administration interface](http://docs.geoserver.org/stable/en/user/rest/api/index.html).
|
||||||
|
|
||||||
|
The purpose of this project is to hold a ReST client library to interact with GeoServer; a requirement for this library is to depend as less as possible on external libraries. This library aims at being lean and mean.
|
||||||
|
|
||||||
|
For general questions about this project feel free to use the mailing lists.
|
||||||
|
|
||||||
|
## Using the library
|
||||||
|
|
||||||
|
### Working with Maven
|
||||||
|
In order to include the lib and its dependencies in a Maven project, the repository to point at is this one:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<repository>
|
||||||
|
<id>GeoSolutions</id>
|
||||||
|
<url>http://maven.geo-solutions.it/</url>
|
||||||
|
</repository>
|
||||||
|
```
|
||||||
|
|
||||||
|
and the dependency tag for your pom is as follows:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.geosolutions</groupId>
|
||||||
|
<artifactId>geoserver-manager</artifactId>
|
||||||
|
<version>1.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
### Direct Link to JAR
|
||||||
|
If you are simply looking for the JAR to download and use you can find it [here](http://maven.geo-solutions.it/it/geosolutions/geoserver-manager/1.7.0/geoserver-manager-1.7.0.jar).
|
||||||
|
|
||||||
|
### GeoServer Compatibility Matrix
|
||||||
|
|
||||||
|
**GeoServer-Manager/GeoServer** | **2.6.x** |**2.7.x** |**2.8.x** |**2.9.x**
|
||||||
|
-------------------------------- | ----------|----------|----------|---------
|
||||||
|
**1.6.0** | Y | Y | P | P
|
||||||
|
**1.7.0** | N | P | Y | Y
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
You can find some examples in the wiki.
|
||||||
|
## License
|
||||||
|
|
||||||
|
geoserver-manager is released under a permissive [MIT](https://opensource.org/licenses/MIT) license. See [wikipedia](https://en.wikipedia.org/wiki/MIT_License) for more information.
|
||||||
|
|
||||||
|
|
||||||
|
## Mailing Lists
|
||||||
|
|
||||||
|
* [USERS](https://groups.google.com/group/geoserver-manager-users)
|
||||||
|
* [DEVELOPERS](https://groups.google.com/forum/?fromgroups#!forum/geoserver-manager-devs)
|
||||||
|
|
||||||
|
For more information see [this](https://github.com/geosolutions-it/geoserver-manager/wiki) page.
|
||||||
|
|
||||||
|
## Version
|
||||||
|
Current stable version is [1.7.0](https://github.com/geosolutions-it/geoserver-manager/releases/tag/v1.7.0) ([Changelog](https://github.com/geosolutions-it/geoserver-manager/wiki/Changelog)).
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
The work on this library has been initiated by GeoSolutions. Over the years it has been funded by various organizations like UN FAO, German Space Agency (DLR) and others.
|
||||||
|
|
||||||
142
pom.xml
142
pom.xml
@ -1,38 +1,50 @@
|
|||||||
<!-- * GeoServer-Manager - Simple Manager Library for GeoServer * * Copyright
|
<!--
|
||||||
(C) 2007,2011 GeoSolutions S.A.S. * http://www.geo-solutions.it * * Permission
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
is hereby granted, free of charge, to any person obtaining a copy * of this
|
*
|
||||||
software and associated documentation files (the "Software"), to deal * in
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S. http://www.geo-solutions.it
|
||||||
the Software without restriction, including without limitation the rights
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is *
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions: * * The above copyright
|
* furnished to do so, subject to the following conditions:
|
||||||
notice and this permission notice shall be included in * all copies or substantial
|
*
|
||||||
portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
|
* The above copyright notice and this permission notice shall be included in
|
||||||
OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
* all copies or substantial portions of the Software.
|
||||||
OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
*
|
||||||
IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
DEALINGS IN * THE SOFTWARE. -->
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>it.geosolutions</groupId>
|
<groupId>it.geosolutions</groupId>
|
||||||
<artifactId>geoserver-manager</artifactId>
|
<artifactId>geoserver-manager</artifactId>
|
||||||
<version>1.6-SNAPSHOT</version>
|
<version>1.8-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>GeoServer 2 Manager - REST based</name>
|
<name>GeoServer Manager - REST based</name>
|
||||||
<description>
|
<description>
|
||||||
GeoServer Manager is a library to interact with GeoServer 2.x.
|
GeoServer Manager is a library to interact with GeoServer
|
||||||
The scope of this library is to have a simple API, and use as few external
|
The scope of this library is to have a simple API, and use as few external
|
||||||
libs as possible.
|
libs as possible.
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<inceptionYear>2007</inceptionYear>
|
<inceptionYear>2007</inceptionYear>
|
||||||
|
|
||||||
|
<url>https://github.com/geosolutions-it/geoserver-manager</url>
|
||||||
|
|
||||||
<organization>
|
<organization>
|
||||||
<name>GeoSolutions</name>
|
<name>GeoSolutions</name>
|
||||||
<url>http://www.geo-solutions.it</url>
|
<url>http://www.geo-solutions.it</url>
|
||||||
@ -73,11 +85,9 @@
|
|||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<url>http://code.google.com/p/geoserver-manager/</url>
|
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>googlecode</system>
|
<system>GitHub</system>
|
||||||
<url>http://code.google.com/p/geoserver-manager/issues/list</url>
|
<url>https://github.com/geosolutions-it/geoserver-manager/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
@ -90,16 +100,61 @@
|
|||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:[fetch=]https://github.com/geosolutions-it/geoserver-manager.git[push=]git@github.com:geosolutions-it/geoserver-manager.git</connection>
|
<connection>scm:git:[fetch=]https://github.com/geosolutions-it/geoserver-manager.git[push=]git@github.com:geosolutions-it/geoserver-manager.git</connection>
|
||||||
<!--developerConnection>scm:git</developerConnection -->
|
|
||||||
<!--tag>master</tag -->
|
|
||||||
<url>https://github.com/geosolutions-it/geoserver-manager</url>
|
<url>https://github.com/geosolutions-it/geoserver-manager</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>jenkins</system>
|
<system>jenkins</system>
|
||||||
<url>http://ci.geo-solutions.it/</url>
|
<url>http://build.geo-solutions.it/jenkins/view/GeoServer-manager/</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>boundless</id>
|
||||||
|
<name>Boundless Maven Repository</name>
|
||||||
|
<url>https://repo.boundlessgeo.com/main/</url>
|
||||||
|
<!-- contains snapshot and release (including third-party-dependences) -->
|
||||||
|
<!-- Restlet maven Repository (http://maven.restlet.org) -->
|
||||||
|
<!-- ucar (https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases) -->
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>osgeo</id>
|
||||||
|
<name>Open Source Geospatial Foundation Repository</name>
|
||||||
|
<url>http://download.osgeo.org/webdav/geotools/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>maven-restlet</id>
|
||||||
|
<name>Restlet Maven Repository</name>
|
||||||
|
<url>http://maven.restlet.org</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>geosolutions</id>
|
||||||
|
<name>geosolutions repository</name>
|
||||||
|
<url>http://maven.geo-solutions.it/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<downloadUrl>http://maven.geo-solutions.it</downloadUrl>
|
<downloadUrl>http://maven.geo-solutions.it</downloadUrl>
|
||||||
<repository>
|
<repository>
|
||||||
@ -177,7 +232,7 @@
|
|||||||
<extension>
|
<extension>
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
<artifactId>wagon-ftp</artifactId>
|
<artifactId>wagon-ftp</artifactId>
|
||||||
<version>1.0-beta-7</version>
|
<version>2.6</version>
|
||||||
</extension>
|
</extension>
|
||||||
</extensions>
|
</extensions>
|
||||||
</build>
|
</build>
|
||||||
@ -196,8 +251,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId>
|
|
||||||
<version>2.2</version> </plugin> -->
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
@ -231,6 +284,19 @@
|
|||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.json-lib</groupId>
|
||||||
|
<artifactId>json-lib</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<classifier>jdk15</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.servicemix.bundles</groupId>
|
||||||
|
<artifactId>org.apache.servicemix.bundles.restlet</artifactId>
|
||||||
|
<version>1.1.10_3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
@ -244,13 +310,21 @@
|
|||||||
<!-- commons-logging can be rather simply and conveniently excluded as
|
<!-- commons-logging can be rather simply and conveniently excluded as
|
||||||
a dependency by declaring it in the provided scope within the pom.xml file
|
a dependency by declaring it in the provided scope within the pom.xml file
|
||||||
of your project. The actual commons-logging classes would be provided by
|
of your project. The actual commons-logging classes would be provided by
|
||||||
jcl-over-slf4j. This translates into the following pom file snippet: -->
|
jcl-over-slf4j.
|
||||||
<!-- <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId>
|
This translates into the following pom file snippet: -->
|
||||||
<version>1.1.1</version> <scope>provided</scope> </dependency> <dependency>
|
<!-- <dependency>
|
||||||
<groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version>
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
|
|
||||||
<!--================================================================= -->
|
<!--================================================================= -->
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
<!--================================================================= -->
|
<!--================================================================= -->
|
||||||
|
|||||||
39
report.sh
Executable file
39
report.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
echo "
|
||||||
|
Generates git log report between two tags:
|
||||||
|
USAGE:
|
||||||
|
$0 {START_TAG} {STOP_TAG|HEAD} {MESSAGE DESCRIPTION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "What's new?
|
||||||
|
===========
|
||||||
|
|
||||||
|
$3
|
||||||
|
|
||||||
|
Where can I get it?
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Home:
|
||||||
|
https://github.com/geosolutions-it/geoserver-manager
|
||||||
|
* Download:
|
||||||
|
https://github.com/geosolutions-it/geoserver-manager/releases
|
||||||
|
* Documentation:
|
||||||
|
https://github.com/geosolutions-it/geoserver-manager/wiki
|
||||||
|
|
||||||
|
Who contributed to this release?
|
||||||
|
================================
|
||||||
|
|
||||||
|
* List authors of this release
|
||||||
|
"
|
||||||
|
git log $1..$2 --pretty="format:* %aN" | sort | uniq
|
||||||
|
|
||||||
|
echo "
|
||||||
|
========================
|
||||||
|
CHANGES IN THIS RELEASE:
|
||||||
|
========================
|
||||||
|
"
|
||||||
|
git log $1..$2 --no-merges --pretty=oneline --reverse --grep fix --grep improve --grep close --grep "#" --grep add --format='* %s' .
|
||||||
|
|
||||||
|
exit $?
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007,2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -42,6 +42,7 @@ import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
|||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager;
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager.ConfigureCoveragesOption;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager.ConfigureCoveragesOption;
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStyleManager;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStyleManager;
|
||||||
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -58,6 +59,8 @@ import org.apache.commons.io.FilenameUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to a GeoServer instance to publish or modify its contents via REST API.
|
* Connect to a GeoServer instance to publish or modify its contents via REST API.
|
||||||
* <P>
|
* <P>
|
||||||
@ -65,6 +68,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
* @author Lennart Karsten - lennart.k@thinking-aloud.eu
|
||||||
*/
|
*/
|
||||||
public class GeoServerRESTPublisher {
|
public class GeoServerRESTPublisher {
|
||||||
|
|
||||||
@ -90,6 +94,9 @@ public class GeoServerRESTPublisher {
|
|||||||
|
|
||||||
|
|
||||||
private final GeoServerRESTStyleManager styleManager;
|
private final GeoServerRESTStyleManager styleManager;
|
||||||
|
|
||||||
|
private final GeoServerRESTImporterManager importerManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <TT>GeoServerRESTPublisher</TT> to connect against a GeoServer instance with the given URL and user credentials.
|
* Creates a <TT>GeoServerRESTPublisher</TT> to connect against a GeoServer instance with the given URL and user credentials.
|
||||||
*
|
*
|
||||||
@ -109,6 +116,7 @@ public class GeoServerRESTPublisher {
|
|||||||
LOGGER.error("Bad URL: Calls to GeoServer are going to fail" , ex);
|
LOGGER.error("Bad URL: Calls to GeoServer are going to fail" , ex);
|
||||||
}
|
}
|
||||||
styleManager = new GeoServerRESTStyleManager(url, username, password);
|
styleManager = new GeoServerRESTStyleManager(url, username, password);
|
||||||
|
importerManager = new GeoServerRESTImporterManager(url, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@ -356,6 +364,62 @@ public class GeoServerRESTPublisher {
|
|||||||
return styleManager.publishStyle(sldFile, name);
|
return styleManager.publishStyle(sldFile, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store and publish a Style, assigning it a name and choosing the raw format.
|
||||||
|
*
|
||||||
|
* @param sldBody the full SLD document as a String.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
*/
|
||||||
|
public boolean publishStyle(String sldBody, String name, boolean raw) {
|
||||||
|
return styleManager.publishStyle(sldBody, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store and publish a Style, assigning it a name and choosing the raw format.
|
||||||
|
*
|
||||||
|
* @param sldFile the File containing the SLD document.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
*/
|
||||||
|
public boolean publishStyle(File sldFile, String name, boolean raw) {
|
||||||
|
return styleManager.publishStyle(sldFile, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a Style.
|
||||||
|
*
|
||||||
|
* @param sldFile the File containing the SLD document.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
* @throws IllegalArgumentException if the style body or name are null or empty.
|
||||||
|
*/
|
||||||
|
public boolean updateStyle(final File sldFile, final String name, boolean raw)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
return styleManager.updateStyle(sldFile, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a Style.
|
||||||
|
*
|
||||||
|
* @param sldBody the new SLD document as a String.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
* @throws IllegalArgumentException if the style body or name are null or empty.
|
||||||
|
*/
|
||||||
|
public boolean updateStyle(final String sldBody, final String name, boolean raw)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
return styleManager.updateStyle(sldBody, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a Style.
|
* Update a Style.
|
||||||
*
|
*
|
||||||
@ -705,7 +769,9 @@ public class GeoServerRESTPublisher {
|
|||||||
/** ImageMosaic */
|
/** ImageMosaic */
|
||||||
IMAGEMOSAIC,
|
IMAGEMOSAIC,
|
||||||
/** Geo referenced image (JPEG,PNG,TIF) */
|
/** Geo referenced image (JPEG,PNG,TIF) */
|
||||||
WORLDIMAGE;
|
WORLDIMAGE,
|
||||||
|
/** Esri ArcGrid */
|
||||||
|
ARCGRID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a lowercase representation of the parameter value, suitable to construct the rest call.
|
* Returns a lowercase representation of the parameter value, suitable to construct the rest call.
|
||||||
@ -1096,13 +1162,24 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// config layer props (style, ...)
|
// config layer props (style, ...)
|
||||||
final GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
final GSLayerEncoder layerEncoder = configureDefaultStyle(defaultStyle);
|
||||||
if (defaultStyle != null && !defaultStyle.isEmpty())
|
|
||||||
layerEncoder.setDefaultStyle(defaultStyle);
|
|
||||||
|
|
||||||
return configureLayer(workspace, datasetName, layerEncoder);
|
return configureLayer(workspace, datasetName, layerEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GSLayerEncoder configureDefaultStyle(String defaultStyle) {
|
||||||
|
final GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||||
|
if (defaultStyle != null && !defaultStyle.isEmpty()) {
|
||||||
|
if(defaultStyle.indexOf(":") != -1) {
|
||||||
|
String[] wsAndName = defaultStyle.split(":");
|
||||||
|
layerEncoder.setDefaultStyle(wsAndName[0], wsAndName[1]);
|
||||||
|
} else {
|
||||||
|
layerEncoder.setDefaultStyle(defaultStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return layerEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a shapefile.
|
* Publish a shapefile.
|
||||||
*
|
*
|
||||||
@ -1340,7 +1417,7 @@ public class GeoServerRESTPublisher {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public enum Format {
|
public enum Format {
|
||||||
XML, JSON, HTML, SLD;
|
XML, JSON, HTML, SLD, SLD_1_1_0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the mime type from a format.
|
* Gets the mime type from a format.
|
||||||
@ -1358,6 +1435,8 @@ public class GeoServerRESTPublisher {
|
|||||||
return "application/json";
|
return "application/json";
|
||||||
case SLD:
|
case SLD:
|
||||||
return "application/vnd.ogc.sld+xml";
|
return "application/vnd.ogc.sld+xml";
|
||||||
|
case SLD_1_1_0:
|
||||||
|
return "application/vnd.ogc.se+xml";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1450,6 +1529,202 @@ public class GeoServerRESTPublisher {
|
|||||||
.toString()) } : (NameValuePair[]) null);
|
.toString()) } : (NameValuePair[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==========================================================================
|
||||||
|
// === ARCGRID
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload and publish a ArcGrid image.
|
||||||
|
*
|
||||||
|
* @param workspace Workspace to use
|
||||||
|
* @param storeName The store name to be used or created.
|
||||||
|
* @param arcgrid The ArcGrid file.
|
||||||
|
* @return true if success.
|
||||||
|
* @throws FileNotFoundException if ArcGrid file does not exist.
|
||||||
|
*/
|
||||||
|
public boolean publishArcGrid(String workspace, String storeName, File arcgrid)
|
||||||
|
throws FileNotFoundException {
|
||||||
|
return publishCoverage(workspace, storeName, CoverageStoreExtension.ARCGRID,
|
||||||
|
"image/arcgrid", arcgrid, ParameterConfigure.FIRST, (NameValuePair[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload and publish a ArcGrid image.
|
||||||
|
*
|
||||||
|
* @param workspace Workspace to use
|
||||||
|
* @param storeName Name of the coveragestore (if null the file name will be used)
|
||||||
|
* @param coverageName the name of the coverage (if null the file name will be used)
|
||||||
|
* @param arcgrid file to upload
|
||||||
|
* @return true if the operation completed successfully.
|
||||||
|
* @throws FileNotFoundException if file does not exists
|
||||||
|
* @throws IllegalArgumentException if workspace or arcgrid are null
|
||||||
|
*/
|
||||||
|
public boolean publishArcGrid(final String workspace, final String storeName,
|
||||||
|
final String coverageName, final File arcgrid) throws FileNotFoundException,
|
||||||
|
IllegalArgumentException {
|
||||||
|
if (workspace == null || arcgrid == null)
|
||||||
|
throw new IllegalArgumentException("Unable to proceed, some arguments are null");
|
||||||
|
|
||||||
|
return publishCoverage(
|
||||||
|
workspace,
|
||||||
|
(storeName != null) ? storeName : FilenameUtils.getBaseName(arcgrid
|
||||||
|
.getAbsolutePath()), CoverageStoreExtension.ARCGRID, "image/arcgrid",
|
||||||
|
arcgrid, ParameterConfigure.FIRST,
|
||||||
|
(coverageName != null) ? new NameValuePair[] { new NameValuePair("coverageName",
|
||||||
|
coverageName) } : (NameValuePair[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload and publish a ArcGrid image.
|
||||||
|
*
|
||||||
|
* @param workspace Workspace to use
|
||||||
|
* @param storeName Name of the coveragestore (if null the file name will be used)
|
||||||
|
* @param coverageName the name of the coverage (if null the file name will be used)
|
||||||
|
* @param arcgrid file to upload
|
||||||
|
* @param srs the native CRS
|
||||||
|
* @param policy projection policy. See {@link ProjectionPolicy}.
|
||||||
|
* @param defaultStyle the default style to apply.
|
||||||
|
* @param bbox An array of 4 doubles indicating envelope in EPSG:4326. Order is [Xmin, Ymin, Xmax, Ymax].
|
||||||
|
* @return true if the operation completed successfully.
|
||||||
|
* @throws FileNotFoundException if file does not exists
|
||||||
|
* @throws IllegalArgumentException if workspace or arcgrid are null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public boolean publishArcGrid(String workspace, String storeName, String coverageName,
|
||||||
|
File arcgrid, String srs, ProjectionPolicy policy, String defaultStyle, double[] bbox)
|
||||||
|
throws FileNotFoundException, IllegalArgumentException {
|
||||||
|
if (workspace == null || storeName == null || arcgrid == null || coverageName == null
|
||||||
|
|| srs == null || policy == null || defaultStyle == null)
|
||||||
|
throw new IllegalArgumentException("Unable to run: null parameter");
|
||||||
|
|
||||||
|
if (!createCoverageStore(
|
||||||
|
workspace,
|
||||||
|
(storeName != null) ? storeName : FilenameUtils.getBaseName(arcgrid
|
||||||
|
.getAbsolutePath()), UploadMethod.FILE, CoverageStoreExtension.ARCGRID,
|
||||||
|
"image/arcgrid", arcgrid.toURI(), ParameterConfigure.NONE, (NameValuePair[]) null)) {
|
||||||
|
LOGGER.error("Unable to create coverage store for coverage: " + arcgrid);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// config coverage props (srs)
|
||||||
|
final GSCoverageEncoder coverageEncoder = new GSCoverageEncoder();
|
||||||
|
coverageEncoder.setName(coverageName);
|
||||||
|
coverageEncoder.setTitle(coverageName);
|
||||||
|
coverageEncoder.setSRS(srs);
|
||||||
|
coverageEncoder.setNativeFormat("ArcGrid");
|
||||||
|
coverageEncoder.addSupportedFormats("ARCGRID");
|
||||||
|
coverageEncoder.addKeyword("arcGrid");
|
||||||
|
coverageEncoder.addKeyword("WCS");
|
||||||
|
coverageEncoder.setNativeCRS(srs);
|
||||||
|
coverageEncoder.setProjectionPolicy(policy);
|
||||||
|
coverageEncoder.setRequestSRS(srs);
|
||||||
|
coverageEncoder.setResponseSRS(srs);
|
||||||
|
if (bbox != null && bbox.length == 4) {
|
||||||
|
coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], DEFAULT_CRS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!createCoverage(workspace, storeName, coverageEncoder)) {
|
||||||
|
LOGGER.error("Unable to create a coverage store for coverage: " + arcgrid);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// config layer props (style, ...)
|
||||||
|
final GSLayerEncoder layerEncoder = configureDefaultStyle(defaultStyle);
|
||||||
|
|
||||||
|
return configureLayer(workspace, coverageName, layerEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish a ArcGrid already in a filesystem readable by GeoServer.
|
||||||
|
*
|
||||||
|
* @param workspace an existing workspace
|
||||||
|
* @param storeName the coverageStore to be created
|
||||||
|
* @param arcgrid the arcGrid to be published
|
||||||
|
* @param srs the native CRS
|
||||||
|
* @param policy projection policy. See {@link ProjectionPolicy}.
|
||||||
|
* @param defaultStyle the default style to apply.
|
||||||
|
*
|
||||||
|
* @return true if the operation completed successfully.
|
||||||
|
* @throws FileNotFoundException if file does not exists
|
||||||
|
* @throws IllegalArgumentException if any of the mandatory parameters are null.
|
||||||
|
*/
|
||||||
|
public boolean publishExternalArcGrid(String workspace, String storeName, File arcgrid,
|
||||||
|
String coverageName, String srs, ProjectionPolicy policy, String defaultStyle)
|
||||||
|
throws FileNotFoundException, IllegalArgumentException {
|
||||||
|
if (workspace == null || storeName == null || arcgrid == null || coverageName == null
|
||||||
|
|| srs == null || policy == null || defaultStyle == null)
|
||||||
|
throw new IllegalArgumentException("Unable to run: null parameter");
|
||||||
|
|
||||||
|
// config coverage props (srs)
|
||||||
|
final GSCoverageEncoder coverageEncoder = new GSCoverageEncoder();
|
||||||
|
coverageEncoder.setName(coverageName);
|
||||||
|
coverageEncoder.setTitle(coverageName);
|
||||||
|
coverageEncoder.setSRS(srs);
|
||||||
|
coverageEncoder.setProjectionPolicy(policy);
|
||||||
|
|
||||||
|
// config layer props (style, ...)
|
||||||
|
final GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||||
|
layerEncoder.setDefaultStyle(defaultStyle);
|
||||||
|
|
||||||
|
return publishExternalArcGrid(workspace, storeName, arcgrid, coverageEncoder, layerEncoder) != null ? true
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish a ArcGrid already in a filesystem readable by GeoServer.
|
||||||
|
*
|
||||||
|
* @param workspace an existing workspace
|
||||||
|
* @param storeName the coverageStore to be created
|
||||||
|
* @param arcgrid the arcGrid to be published
|
||||||
|
* @param coverageEncoder coverage details. See {@link GSCoverageEncoder}.
|
||||||
|
* @param layerEncoder layer details, See {@link GSLayerEncoder}.
|
||||||
|
*
|
||||||
|
* @return true if the operation completed successfully.
|
||||||
|
* @throws FileNotFoundException if file does not exists
|
||||||
|
* @throws IllegalArgumentException if any of the mandatory parameters are null.
|
||||||
|
*/
|
||||||
|
public RESTCoverageStore publishExternalArcGrid(final String workspace, final String storeName,
|
||||||
|
final File arcgrid, final GSCoverageEncoder coverageEncoder,
|
||||||
|
final GSLayerEncoder layerEncoder) throws IllegalArgumentException,
|
||||||
|
FileNotFoundException {
|
||||||
|
|
||||||
|
if (workspace == null || arcgrid == null || storeName == null || layerEncoder == null
|
||||||
|
|| coverageEncoder == null)
|
||||||
|
throw new IllegalArgumentException("Unable to run: null parameter");
|
||||||
|
|
||||||
|
final String coverageName = coverageEncoder.getName();
|
||||||
|
if (coverageName.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Unable to run: empty coverage store name");
|
||||||
|
}
|
||||||
|
|
||||||
|
// create store
|
||||||
|
final boolean store = publishExternalCoverage(workspace, storeName,
|
||||||
|
CoverageStoreExtension.ARCGRID, "text/plain", arcgrid, ParameterConfigure.NONE,
|
||||||
|
ParameterUpdate.OVERWRITE);
|
||||||
|
if (!store) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Coverage Store
|
||||||
|
if (!createCoverage(workspace, storeName, coverageEncoder)) {
|
||||||
|
if (LOGGER.isErrorEnabled())
|
||||||
|
LOGGER.error("Unable to create a coverage for the store:" + coverageName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Layer
|
||||||
|
if (configureLayer(workspace, coverageName, layerEncoder)) {
|
||||||
|
GeoServerRESTReader reader;
|
||||||
|
try {
|
||||||
|
reader = new GeoServerRESTReader(this.restURL, this.gsuser, this.gspass);
|
||||||
|
return reader.getCoverageStore(workspace, storeName);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// === GEOTIFF
|
// === GEOTIFF
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@ -1545,7 +1820,14 @@ public class GeoServerRESTPublisher {
|
|||||||
coverageEncoder.setName(coverageName);
|
coverageEncoder.setName(coverageName);
|
||||||
coverageEncoder.setTitle(coverageName);
|
coverageEncoder.setTitle(coverageName);
|
||||||
coverageEncoder.setSRS(srs);
|
coverageEncoder.setSRS(srs);
|
||||||
|
coverageEncoder.setNativeFormat("GeoTIFF");
|
||||||
|
coverageEncoder.addSupportedFormats("GEOTIFF");
|
||||||
|
coverageEncoder.addKeyword("geoTiff");
|
||||||
|
coverageEncoder.addKeyword("WCS");
|
||||||
|
coverageEncoder.setNativeCRS(srs);
|
||||||
coverageEncoder.setProjectionPolicy(policy);
|
coverageEncoder.setProjectionPolicy(policy);
|
||||||
|
coverageEncoder.setRequestSRS(srs);
|
||||||
|
coverageEncoder.setResponseSRS(srs);
|
||||||
if (bbox != null && bbox.length == 4) {
|
if (bbox != null && bbox.length == 4) {
|
||||||
coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], DEFAULT_CRS);
|
coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], DEFAULT_CRS);
|
||||||
}
|
}
|
||||||
@ -1556,8 +1838,7 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// config layer props (style, ...)
|
// config layer props (style, ...)
|
||||||
final GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
final GSLayerEncoder layerEncoder = configureDefaultStyle(defaultStyle);
|
||||||
layerEncoder.setDefaultStyle(defaultStyle);
|
|
||||||
|
|
||||||
return configureLayer(workspace, coverageName, layerEncoder);
|
return configureLayer(workspace, coverageName, layerEncoder);
|
||||||
}
|
}
|
||||||
@ -2006,7 +2287,12 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean removeDatastore(String workspace, String storename, final boolean recurse)
|
public boolean removeDatastore(String workspace, String storename, final boolean recurse)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
return removeStore(workspace, storename, StoreType.DATASTORES, recurse);
|
return removeStore(workspace, storename, StoreType.DATASTORES, recurse, Purge.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeDatastore(String workspace, String storename, final boolean recurse, final Purge purge)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
return removeStore(workspace, storename, StoreType.DATASTORES, recurse, purge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2031,9 +2317,27 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean removeCoverageStore(final String workspace, final String storename,
|
public boolean removeCoverageStore(final String workspace, final String storename,
|
||||||
final boolean recurse) throws IllegalArgumentException {
|
final boolean recurse) throws IllegalArgumentException {
|
||||||
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse);
|
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse, Purge.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a given CoverageStore in a given Workspace.
|
||||||
|
*
|
||||||
|
* Note that purging may not work when deleting mosaics (https://jira.codehaus.org/browse/GEOT-4613).
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param storename The name of the CoverageStore to remove.
|
||||||
|
* @param recurse if remove should be performed recursively
|
||||||
|
* @param purge the purge method
|
||||||
|
* @return <TT>true</TT> if the CoverageStore was successfully removed.
|
||||||
|
*/
|
||||||
|
public boolean removeCoverageStore(final String workspace, final String storename,
|
||||||
|
final boolean recurse, final Purge purge) throws IllegalArgumentException {
|
||||||
|
return removeStore(workspace, storename, StoreType.COVERAGESTORES, recurse, purge);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Purge {NONE, METADATA, ALL};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a given Datastore in a given Workspace.
|
* Remove a given Datastore in a given Workspace.
|
||||||
*
|
*
|
||||||
@ -2041,11 +2345,12 @@ public class GeoServerRESTPublisher {
|
|||||||
* @param storename The name of the Datastore to remove.
|
* @param storename The name of the Datastore to remove.
|
||||||
* @param the {@link StoreType} type
|
* @param the {@link StoreType} type
|
||||||
* @param recurse if remove should be performed recursively
|
* @param recurse if remove should be performed recursively
|
||||||
|
* @param purge the purge method
|
||||||
* @throws IllegalArgumentException if workspace or storename are null or empty
|
* @throws IllegalArgumentException if workspace or storename are null or empty
|
||||||
* @return <TT>true</TT> if the store was successfully removed.
|
* @return <TT>true</TT> if the store was successfully removed.
|
||||||
*/
|
*/
|
||||||
private boolean removeStore(String workspace, String storename, StoreType type,
|
private boolean removeStore(String workspace, String storename, StoreType type,
|
||||||
final boolean recurse) throws IllegalArgumentException {
|
final boolean recurse, final Purge purge) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
if (workspace == null || storename == null)
|
if (workspace == null || storename == null)
|
||||||
throw new IllegalArgumentException("Arguments may not be null!");
|
throw new IllegalArgumentException("Arguments may not be null!");
|
||||||
@ -2055,8 +2360,10 @@ public class GeoServerRESTPublisher {
|
|||||||
final StringBuilder url = new StringBuilder(restURL);
|
final StringBuilder url = new StringBuilder(restURL);
|
||||||
url.append("/rest/workspaces/").append(workspace).append("/").append(type).append("/")
|
url.append("/rest/workspaces/").append(workspace).append("/").append(type).append("/")
|
||||||
.append(storename);
|
.append(storename);
|
||||||
if (recurse)
|
url.append("?recurse=").append(recurse);
|
||||||
url.append("?recurse=true");
|
if(purge != null)
|
||||||
|
url.append("&purge=").append(purge);
|
||||||
|
|
||||||
final URL deleteStore = new URL(url.toString());
|
final URL deleteStore = new URL(url.toString());
|
||||||
|
|
||||||
boolean deleted = HTTPUtils.delete(deleteStore.toExternalForm(), gsuser, gspass);
|
boolean deleted = HTTPUtils.delete(deleteStore.toExternalForm(), gsuser, gspass);
|
||||||
@ -2845,4 +3152,58 @@ public class GeoServerRESTPublisher {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#postNewImport() postNewImport} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int postNewImport() throws Exception {
|
||||||
|
return importerManager.postNewImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#postNewTaskAsMultiPartForm(int, String) postNewTaskAsMultiPartForm} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int postNewTaskAsMultiPartForm(int i, String data) throws Exception {
|
||||||
|
return importerManager.postNewTaskAsMultiPartForm(i, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#getTask(int, int) getTask} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public JSONObject getTask(int i, int t) throws Exception {
|
||||||
|
return importerManager.getTask(i, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#putTask(int, int, String) putTask} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void putTask(int i, int t, String json) throws Exception {
|
||||||
|
importerManager.putTask(i, t, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#putTaskLayer(int, int, String) putTaskLayer} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void putTaskLayer(int i, int t, String json) throws Exception {
|
||||||
|
importerManager.putTaskLayer(i, t, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to {@link it.geosolutions.geoserver.rest.manager.GeoServerRESTImporterManager#postImport(int) postImport} method
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void postImport(int i) throws Exception {
|
||||||
|
importerManager.postImport(i);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,10 @@ import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList
|
|||||||
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageIndexSchema;
|
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageIndexSchema;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTWms;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTWmsList;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTWmsStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTWmsStoreList;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
|
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager;
|
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager;
|
||||||
@ -54,7 +58,6 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -203,6 +206,17 @@ public class GeoServerRESTReader {
|
|||||||
return styleManager.existsStyle(styleName);
|
return styleManager.existsStyle(styleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Style exists in the configured GeoServer instance.
|
||||||
|
* @param styleName the name of the style to check for.
|
||||||
|
* @param quietOnNotFound if true, mute exception if false is returned
|
||||||
|
* @return <TT>true</TT> on HTTP 200, <TT>false</TT> on HTTP 404
|
||||||
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String styleName, boolean quietOnNotFound) throws RuntimeException {
|
||||||
|
return styleManager.existsStyle(styleName, quietOnNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GeoServerRESTStyleManager#existsStyle(java.lang.String, java.lang.String)
|
* @see GeoServerRESTStyleManager#existsStyle(java.lang.String, java.lang.String)
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
@ -311,6 +325,31 @@ public class GeoServerRESTReader {
|
|||||||
return RESTDataStore.build(response);
|
return RESTDataStore.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected DataStore is present
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @return boolean indicating if the datastore exists
|
||||||
|
*/
|
||||||
|
public boolean existsDatastore(String workspace, String dsName){
|
||||||
|
return existsDatastore(workspace, dsName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected DataStore is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the datastore exists
|
||||||
|
*/
|
||||||
|
public boolean existsDatastore(String workspace, String dsName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/datastores/" + dsName + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== FEATURETYPES
|
//=== FEATURETYPES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -330,6 +369,33 @@ public class GeoServerRESTReader {
|
|||||||
return RESTFeatureType.build(response);
|
return RESTFeatureType.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected FeatureType is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param ftName name of the featuretype
|
||||||
|
* @return boolean indicating if the featuretype exists
|
||||||
|
*/
|
||||||
|
public boolean existsFeatureType(String workspace, String dsName, String ftName){
|
||||||
|
return existsFeatureType(workspace, dsName, ftName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected FeatureType is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the datastore
|
||||||
|
* @param dsName name of the datastore
|
||||||
|
* @param ftName name of the featuretype
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the featuretype exists
|
||||||
|
*/
|
||||||
|
public boolean existsFeatureType(String workspace, String dsName, String ftName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/datastores/" + dsName + "/featuretypes/" + ftName +".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== COVERAGESTORES
|
//=== COVERAGESTORES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -380,6 +446,31 @@ public class GeoServerRESTReader {
|
|||||||
return RESTCoverageStore.build(response);
|
return RESTCoverageStore.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage store is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the coveragestore exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoveragestore(String workspace, String csName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + csName + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage store is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @return boolean indicating if the coveragestore exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoveragestore(String workspace, String csName){
|
||||||
|
return existsCoveragestore(workspace, csName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== COVERAGES
|
//=== COVERAGES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -416,6 +507,33 @@ public class GeoServerRESTReader {
|
|||||||
return RESTCoverage.build(load(url));
|
return RESTCoverage.build(load(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param dsName name of the coveragestore
|
||||||
|
* @param name name of the coverage
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoverage(String workspace, String store, String name, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + store + "/coverages/"+name+".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Coverage is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param store name of the coveragestore
|
||||||
|
* @param name name of the coverage
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsCoverage(String workspace, String store, String name){
|
||||||
|
return existsCoverage(workspace, store, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get detailed info about a Coverage given the Layer where it's published with.
|
* Get detailed info about a Coverage given the Layer where it's published with.
|
||||||
*
|
*
|
||||||
@ -430,6 +548,153 @@ public class GeoServerRESTReader {
|
|||||||
return RESTCoverage.build(response);
|
return RESTCoverage.build(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//=== WMSSTORES
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get summary info about all WmsStore in a WorkSpace.
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
*
|
||||||
|
* @return summary info about CoverageStores as a {@link RESTWmsStoreList}
|
||||||
|
*/
|
||||||
|
public RESTWmsStoreList getWmsStores(String workspace) {
|
||||||
|
String url = "/rest/workspaces/" + workspace + "/wmsstores.xml";
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("### Retrieving CS list from " + url);
|
||||||
|
}
|
||||||
|
return RESTWmsStoreList.build(load(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get detailed info about a given WmsStore in a given Workspace.
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param wsName The name of the WmsStore
|
||||||
|
* @return WmsStore details as a {@link RESTWmsStore}
|
||||||
|
*/
|
||||||
|
public RESTWmsStore getWmsStore(String workspace, String wsName) {
|
||||||
|
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + ".xml";
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("### Retrieving CS from " + url);
|
||||||
|
}
|
||||||
|
return RESTWmsStore.build(load(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get detailed info about a Wms's Datastore.
|
||||||
|
*
|
||||||
|
* @param wms the RESTWms
|
||||||
|
* @return wmsStore details as a {@link RESTWmsStore}
|
||||||
|
*/
|
||||||
|
public RESTWmsStore getWmsStore(RESTWms wms) {
|
||||||
|
String url = wms.getStoreUrl();
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("### Retrieving CS from fullurl " + url);
|
||||||
|
}
|
||||||
|
String response = loadFullURL(url);
|
||||||
|
return RESTWmsStore.build(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Wms store is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the wmsstore
|
||||||
|
* @param wsName name of the wmsstore
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the wmsstore exists
|
||||||
|
*/
|
||||||
|
public boolean existsWmsstore(String workspace, String wsName, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected wms store is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the wmsstore
|
||||||
|
* @param wsName name of the wmsstore
|
||||||
|
* @return boolean indicating if the wmsstore exists
|
||||||
|
*/
|
||||||
|
public boolean existsWmsstore(String workspace, String wsName){
|
||||||
|
return existsCoveragestore(workspace, wsName, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//=== WMSS
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of wmss (usually only one).
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param wsName The name of the WmsStore
|
||||||
|
* @return wms list as a {@link RESTWmsList}
|
||||||
|
*/
|
||||||
|
public RESTWmsList getWms(String workspace, String wsName) {
|
||||||
|
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + wsName + "/wmslayers.xml";
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("### Retrieving Wmss from " + url);
|
||||||
|
}
|
||||||
|
return RESTWmsList.build(load(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get detailed info about a given Wms.
|
||||||
|
*
|
||||||
|
* @param workspace The name of the workspace
|
||||||
|
* @param store The name of the WmsStore
|
||||||
|
* @param name The name of the Wms
|
||||||
|
* @return wms details as a {@link RESTwms}
|
||||||
|
*/
|
||||||
|
public RESTWms getWms(String workspace, String store, String name) {
|
||||||
|
String url = "/rest/workspaces/" + workspace + "/wmsstores/" + store + "/wmslayers/"+name+".xml";
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("### Retrieving Wmss from " + url);
|
||||||
|
}
|
||||||
|
return RESTWms.build(load(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Wms is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the wmsstore
|
||||||
|
* @param wsName name of the wmsstore
|
||||||
|
* @param name name of the wms
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsWms(String workspace, String store, String name, boolean quietOnNotFound){
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/wmsstores/" + store + "/wmslayers/"+name+".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected wms is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the wmsstore
|
||||||
|
* @param store name of the wmsstore
|
||||||
|
* @param name name of the wms
|
||||||
|
* @return boolean indicating if the coverage exists
|
||||||
|
*/
|
||||||
|
public boolean existsWms(String workspace, String store, String name){
|
||||||
|
return existsWms(workspace, store, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get detailed info about a Wms given the Layer where it's published with.
|
||||||
|
*
|
||||||
|
* @param layer A layer publishing the wmsStore
|
||||||
|
* @return Wms details as a {@link RESTWms}
|
||||||
|
*/
|
||||||
|
public RESTWms getWms(RESTLayer layer) {
|
||||||
|
String response = loadFullURL(layer.getResourceUrl());
|
||||||
|
return RESTWms.build(response);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
@ -508,7 +773,35 @@ public class GeoServerRESTReader {
|
|||||||
return getLayerGroup(null, name);
|
return getLayerGroup(null, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected LayerGroup is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the LayerGroup
|
||||||
|
* @param name name of the LayerGroup
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the LayerGroup exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayerGroup(String workspace, String name, boolean quietOnNotFound){
|
||||||
|
String url;
|
||||||
|
if (workspace == null) {
|
||||||
|
url = baseurl + "/rest/layergroups/" + name + ".xml";
|
||||||
|
} else {
|
||||||
|
url = baseurl + "/rest/workspaces/" + workspace + "/layergroups/" + name + ".xml";
|
||||||
|
}
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected LayerGroup is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the LayerGroup
|
||||||
|
* @param name name of the LayerGroup
|
||||||
|
* @return boolean indicating if the LayerGroup exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayerGroup(String workspace, String name){
|
||||||
|
return existsLayerGroup(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== LAYERS
|
//=== LAYERS
|
||||||
@ -583,6 +876,36 @@ public class GeoServerRESTReader {
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Layer is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the Layer
|
||||||
|
* @param name name of the Layer
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Layer exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayer(String workspace, String name, boolean quietOnNotFound){
|
||||||
|
String url;
|
||||||
|
if (workspace == null) {
|
||||||
|
url = baseurl + "/rest/layers/" + name + ".xml";
|
||||||
|
} else {
|
||||||
|
url = baseurl + "/rest/layers/" + workspace + ":" + name + ".xml";
|
||||||
|
}
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Layer is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the Layer
|
||||||
|
* @param name name of the Layer
|
||||||
|
* @return boolean indicating if the Layer exists
|
||||||
|
*/
|
||||||
|
public boolean existsLayer(String workspace, String name){
|
||||||
|
return existsLayerGroup(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== NAMESPACES
|
//=== NAMESPACES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -634,6 +957,32 @@ public class GeoServerRESTReader {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Namespace is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param prefix namespace prefix.
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Namespace exists
|
||||||
|
*/
|
||||||
|
public boolean existsNamespace(String prefix, boolean quietOnNotFound) {
|
||||||
|
if (prefix == null || prefix.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Namespace prefix cannot be null or empty");
|
||||||
|
}
|
||||||
|
String url = baseurl + "/rest/namespaces/" + prefix + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Namespace is present.
|
||||||
|
*
|
||||||
|
* @param prefix namespace prefix.
|
||||||
|
* @return boolean indicating if the Namespace exists
|
||||||
|
*/
|
||||||
|
public boolean existsNamespace(String prefix){
|
||||||
|
return existsNamespace(prefix, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//=== WORKSPACES
|
//=== WORKSPACES
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -670,6 +1019,36 @@ public class GeoServerRESTReader {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Workspace is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param prefix Workspace prefix.
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Workspace exists
|
||||||
|
*/
|
||||||
|
public boolean existsWorkspace(String prefix, boolean quietOnNotFound) {
|
||||||
|
if (prefix == null || prefix.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Workspace prefix cannot be null or empty");
|
||||||
|
}
|
||||||
|
String url = baseurl + "/rest/workspaces/" + prefix + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Workspace is present.
|
||||||
|
*
|
||||||
|
* @param prefix Workspace prefix.
|
||||||
|
* @return boolean indicating if the Workspace exists
|
||||||
|
*/
|
||||||
|
public boolean existsWorkspace(String prefix){
|
||||||
|
return existsWorkspace(prefix, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//=== Structured Coverages
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a granule for a structured coverage.
|
* Get information about a granule for a structured coverage.
|
||||||
*
|
*
|
||||||
@ -703,6 +1082,38 @@ public class GeoServerRESTReader {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Granule is present. Parameter quietOnNotFound can be used for controlling the logging when 404 is returned.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param coverageStore name of the coveragestore
|
||||||
|
* @param coverage name of the coverage
|
||||||
|
* @param id id of the granule
|
||||||
|
* @param quietOnNotFound if true, no exception is logged
|
||||||
|
* @return boolean indicating if the Granule exists
|
||||||
|
*/
|
||||||
|
public boolean existsGranule(String workspace, String coverageStore, String coverage,
|
||||||
|
String id, boolean quietOnNotFound) {
|
||||||
|
String url = baseurl + "/rest/workspaces/" + workspace + "/coveragestores/" + coverageStore
|
||||||
|
+ "/coverages/" + coverage + "/index/granules/" + id + ".xml";
|
||||||
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the selected Granule is present.
|
||||||
|
*
|
||||||
|
* @param workspace workspace of the coveragestore
|
||||||
|
* @param coverageStore name of the coveragestore
|
||||||
|
* @param coverage name of the coverage
|
||||||
|
* @param id id of the granule
|
||||||
|
* @return boolean indicating if the Granule exists
|
||||||
|
*/
|
||||||
|
public boolean existsGranule(String workspace, String coverageStore, String coverage, String id) {
|
||||||
|
return existsGranule(workspace, coverageStore, coverage, id,
|
||||||
|
Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about the schema of the index for a structured coverage.
|
* Get information about the schema of the index for a structured coverage.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest;
|
package it.geosolutions.geoserver.rest;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -33,6 +34,11 @@ import java.net.ConnectException;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sf.json.JSON;
|
||||||
|
import net.sf.json.JSONSerializer;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.Credentials;
|
import org.apache.commons.httpclient.Credentials;
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
@ -48,6 +54,9 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
|||||||
import org.apache.commons.httpclient.methods.PutMethod;
|
import org.apache.commons.httpclient.methods.PutMethod;
|
||||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
|
import org.apache.commons.httpclient.methods.multipart.FilePart;
|
||||||
|
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
|
||||||
|
import org.apache.commons.httpclient.methods.multipart.Part;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -117,6 +126,22 @@ public class HTTPUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a request using the GET method and parses the result as a json object.
|
||||||
|
*
|
||||||
|
* @param path The path to request.
|
||||||
|
*
|
||||||
|
* @return The result parsed as json.
|
||||||
|
*/
|
||||||
|
public static JSON getAsJSON(String url, String username, String pw) throws Exception {
|
||||||
|
String response = get(url, username, pw);
|
||||||
|
return json(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSON json(String content) {
|
||||||
|
return JSONSerializer.toJSON(content);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PUTs a File to the given URL. <BR>
|
* PUTs a File to the given URL. <BR>
|
||||||
* Basic auth is used if both username and pw are not null.
|
* Basic auth is used if both username and pw are not null.
|
||||||
@ -175,6 +200,23 @@ public class HTTPUtils {
|
|||||||
return put(url, content, "text/xml", username, pw);
|
return put(url, content, "text/xml", username, pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUTs a String representing an JSON Object to the given URL. <BR>
|
||||||
|
* Basic auth is used if both username and pw are not null.
|
||||||
|
*
|
||||||
|
* @param url The URL where to connect to.
|
||||||
|
* @param content The JSON Object to be sent as a String.
|
||||||
|
* @param username Basic auth credential. No basic auth if null.
|
||||||
|
* @param pw Basic auth credential. No basic auth if null.
|
||||||
|
* @return The HTTP response as a String if the HTTP response code was 200
|
||||||
|
* (OK).
|
||||||
|
* @throws MalformedURLException
|
||||||
|
* @return the HTTP response or <TT>null</TT> on errors.
|
||||||
|
*/
|
||||||
|
public static String putJson(String url, String content, String username, String pw) {
|
||||||
|
return put(url, content, "application/json", username, pw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a PUT to the given URL. <BR>
|
* Performs a PUT to the given URL. <BR>
|
||||||
* Basic auth is used if both username and pw are not null.
|
* Basic auth is used if both username and pw are not null.
|
||||||
@ -233,6 +275,38 @@ public class HTTPUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POSTs a list of files as attachments to the given URL. <BR>
|
||||||
|
* Basic auth is used if both username and pw are not null.
|
||||||
|
*
|
||||||
|
* @param url The URL where to connect to.
|
||||||
|
* @param dir The folder containing the attachments.
|
||||||
|
* @param username Basic auth credential. No basic auth if null.
|
||||||
|
* @param pw Basic auth credential. No basic auth if null.
|
||||||
|
* @return The HTTP response as a String if the HTTP response code was 200
|
||||||
|
* (OK).
|
||||||
|
* @throws MalformedURLException
|
||||||
|
* @return the HTTP response or <TT>null</TT> on errors.
|
||||||
|
*/
|
||||||
|
public static String postMultipartForm(String url, File dir, String username, String pw) {
|
||||||
|
try {
|
||||||
|
List<Part> parts = new ArrayList<Part>();
|
||||||
|
for (File f : dir.listFiles()) {
|
||||||
|
parts.add(new FilePart(f.getName(), f));
|
||||||
|
}
|
||||||
|
MultipartRequestEntity multipart = new MultipartRequestEntity(
|
||||||
|
parts.toArray(new Part[parts.size()]), new PostMethod().getParams());
|
||||||
|
|
||||||
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||||
|
multipart.writeRequest(bout);
|
||||||
|
|
||||||
|
return post(url, multipart, username, pw);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Cannot POST " + url, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POSTs a String representing an XML document to the given URL. <BR>
|
* POSTs a String representing an XML document to the given URL. <BR>
|
||||||
* Basic auth is used if both username and pw are not null.
|
* Basic auth is used if both username and pw are not null.
|
||||||
@ -250,6 +324,23 @@ public class HTTPUtils {
|
|||||||
return post(url, content, "text/xml", username, pw);
|
return post(url, content, "text/xml", username, pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POSTs a String representing an JSON Object to the given URL. <BR>
|
||||||
|
* Basic auth is used if both username and pw are not null.
|
||||||
|
*
|
||||||
|
* @param url The URL where to connect to.
|
||||||
|
* @param content The JSON content to be sent as a String.
|
||||||
|
* @param username Basic auth credential. No basic auth if null.
|
||||||
|
* @param pw Basic auth credential. No basic auth if null.
|
||||||
|
* @return The HTTP response as a String if the HTTP response code was 200
|
||||||
|
* (OK).
|
||||||
|
* @throws MalformedURLException
|
||||||
|
* @return the HTTP response or <TT>null</TT> on errors.
|
||||||
|
*/
|
||||||
|
public static String postJson(String url, String content, String username, String pw) {
|
||||||
|
return post(url, content, "application/json", username, pw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a POST to the given URL. <BR>
|
* Performs a POST to the given URL. <BR>
|
||||||
* Basic auth is used if both username and pw are not null.
|
* Basic auth is used if both username and pw are not null.
|
||||||
@ -293,6 +384,7 @@ public class HTTPUtils {
|
|||||||
httpMethod.setRequestEntity(requestEntity);
|
httpMethod.setRequestEntity(requestEntity);
|
||||||
int status = client.executeMethod(httpMethod);
|
int status = client.executeMethod(httpMethod);
|
||||||
|
|
||||||
|
InputStream responseBody;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case HttpURLConnection.HTTP_OK:
|
case HttpURLConnection.HTTP_OK:
|
||||||
case HttpURLConnection.HTTP_CREATED:
|
case HttpURLConnection.HTTP_CREATED:
|
||||||
@ -303,9 +395,10 @@ public class HTTPUtils {
|
|||||||
LOGGER.info("HTTP " + httpMethod.getStatusText() + ": " + response);
|
LOGGER.info("HTTP " + httpMethod.getStatusText() + ": " + response);
|
||||||
return response;
|
return response;
|
||||||
default:
|
default:
|
||||||
|
responseBody = httpMethod.getResponseBodyAsStream();
|
||||||
LOGGER.warn("Bad response: code[" + status + "]" + " msg[" + httpMethod.getStatusText() + "]"
|
LOGGER.warn("Bad response: code[" + status + "]" + " msg[" + httpMethod.getStatusText() + "]"
|
||||||
+ " url[" + url + "]" + " method[" + httpMethod.getClass().getSimpleName()
|
+ " url[" + url + "]" + " method[" + httpMethod.getClass().getSimpleName()
|
||||||
+ "]: " + IOUtils.toString(httpMethod.getResponseBodyAsStream()));
|
+ "]: " + (responseBody != null ? IOUtils.toString(responseBody) : ""));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ConnectException e) {
|
} catch (ConnectException e) {
|
||||||
@ -337,9 +430,8 @@ public class HTTPUtils {
|
|||||||
response = IOUtils.toString(is);
|
response = IOUtils.toString(is);
|
||||||
IOUtils.closeQuietly(is);
|
IOUtils.closeQuietly(is);
|
||||||
if (response.trim().equals("")) {
|
if (response.trim().equals("")) {
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isTraceEnabled())
|
||||||
LOGGER
|
LOGGER.trace("ResponseBody is empty (this may be not an error since we just performed a DELETE call)");
|
||||||
.debug("ResponseBody is empty (this may be not an error since we just performed a DELETE call)");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -27,7 +27,10 @@ package it.geosolutions.geoserver.rest;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -35,6 +38,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
|
public static final String QUIET_ON_NOT_FOUND_PARAM = "quietOnNotFound=";
|
||||||
|
|
||||||
|
public static final boolean DEFAULT_QUIET_ON_NOT_FOUND = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a stylename in global and in all workspaces.
|
* Search for a stylename in global and in all workspaces.
|
||||||
*/
|
*/
|
||||||
@ -43,8 +50,13 @@ public class Util {
|
|||||||
List<RESTStyle> styles = new ArrayList<RESTStyle>();
|
List<RESTStyle> styles = new ArrayList<RESTStyle>();
|
||||||
|
|
||||||
RESTStyle style = reader.getStyle(stylename);
|
RESTStyle style = reader.getStyle(stylename);
|
||||||
if(style != null)
|
|
||||||
|
// We don't want geoserver to be lenient here: take only the real global style if it exists
|
||||||
|
if(style != null) {
|
||||||
|
if(style.getWorkspace() == null || style.getWorkspace().isEmpty()) {
|
||||||
styles.add(style);
|
styles.add(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (String workspace : reader.getWorkspaceNames()) {
|
for (String workspace : reader.getWorkspaceNames()) {
|
||||||
style = reader.getStyle(workspace, stylename);
|
style = reader.getStyle(workspace, stylename);
|
||||||
@ -54,4 +66,56 @@ public class Util {
|
|||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append the quietOnNotFound parameter to the input URL
|
||||||
|
* @param quietOnNotFound parameter
|
||||||
|
* @param url input url
|
||||||
|
* @return a composed url with the parameter appended
|
||||||
|
*/
|
||||||
|
public static String appendQuietOnNotFound(boolean quietOnNotFound, String url) {
|
||||||
|
boolean contains = url.contains("?");
|
||||||
|
String composed = url + (contains ? "&":"?") + QUIET_ON_NOT_FOUND_PARAM + quietOnNotFound;
|
||||||
|
return composed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> safeList(List<T> list) {
|
||||||
|
return list == null ? Collections.EMPTY_LIST : list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Collection<T> safeCollection(Collection<T> collection) {
|
||||||
|
return collection == null ? Collections.EMPTY_SET : collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <TK, TV> Map<TK, TV> safeMap(Map<TK, TV> map) {
|
||||||
|
return map == null ? Collections.EMPTY_MAP : map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static char getParameterSeparator(String url) {
|
||||||
|
char parameterSeparator = '?';
|
||||||
|
if (url.contains("?")) {
|
||||||
|
parameterSeparator = '&';
|
||||||
|
}
|
||||||
|
return parameterSeparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static char getParameterSeparator(StringBuilder url) {
|
||||||
|
char parameterSeparator = '?';
|
||||||
|
if (url.indexOf("?") != -1) {
|
||||||
|
parameterSeparator = '&';
|
||||||
|
}
|
||||||
|
return parameterSeparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean appendParameter(StringBuilder url, String parameterName,
|
||||||
|
String parameterValue) {
|
||||||
|
boolean result = false;
|
||||||
|
if (parameterName != null && !parameterName.isEmpty()
|
||||||
|
&& parameterValue != null && !parameterValue.isEmpty()) {
|
||||||
|
char parameterSeparator = getParameterSeparator(url);
|
||||||
|
url.append(parameterSeparator).append(parameterName.trim())
|
||||||
|
.append('=').append(parameterValue.trim());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a Boundingbox of the following structure
|
||||||
|
*
|
||||||
|
* <minx>472800.0</minx>
|
||||||
|
* <maxx>817362.0</maxx>
|
||||||
|
* <miny>35053.40625</miny>
|
||||||
|
* <maxy>301500.0</maxy>
|
||||||
|
* <crs class="projected">EPSG:21781</crs>
|
||||||
|
*
|
||||||
|
* @author nmandery
|
||||||
|
*/
|
||||||
|
public class RESTBoundingBox {
|
||||||
|
|
||||||
|
protected Element bboxElem;
|
||||||
|
|
||||||
|
public RESTBoundingBox(Element bboxElem) {
|
||||||
|
this.bboxElem = bboxElem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCRS() {
|
||||||
|
return this.bboxElem.getChildText("crs");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected double getEdge(String edge) {
|
||||||
|
return Double.parseDouble(this.bboxElem.getChildText(edge));
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMinX() {
|
||||||
|
return this.getEdge("minx");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMaxX() {
|
||||||
|
return this.getEdge("maxx");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMinY() {
|
||||||
|
return this.getEdge("miny");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMaxY() {
|
||||||
|
return this.getEdge("maxy");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -171,9 +171,9 @@ public class RESTCoverage extends RESTResource {
|
|||||||
// return rootElem.getChildText("name");
|
// return rootElem.getChildText("name");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public String getNativeName() {
|
public String getNativeCoverageName() {
|
||||||
// return rootElem.getChildText("nativeName");
|
return rootElem.getChildText("nativeCoverageName");
|
||||||
// }
|
}
|
||||||
|
|
||||||
public String getNativeFormat() {
|
public String getNativeFormat() {
|
||||||
return rootElem.getChildText("nativeFormat");
|
return rootElem.getChildText("nativeFormat");
|
||||||
@ -282,6 +282,11 @@ public class RESTCoverage extends RESTResource {
|
|||||||
builder.append(getNativeName());
|
builder.append(getNativeName());
|
||||||
builder.append(", ");
|
builder.append(", ");
|
||||||
}
|
}
|
||||||
|
if (getNativeCoverageName() != null) {
|
||||||
|
builder.append("getNativeCoverageName()=");
|
||||||
|
builder.append(getNativeCoverageName());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
if (getAbstract() != null) {
|
if (getAbstract() != null) {
|
||||||
builder.append("getAbstract()=");
|
builder.append("getAbstract()=");
|
||||||
builder.append(getAbstract());
|
builder.append(getAbstract());
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007,2014 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -71,6 +71,7 @@ public class RESTDataStore {
|
|||||||
public enum DBType {
|
public enum DBType {
|
||||||
|
|
||||||
POSTGIS("postgis"),
|
POSTGIS("postgis"),
|
||||||
|
ORACLE("oracle"),
|
||||||
SHP("shp"),
|
SHP("shp"),
|
||||||
UNKNOWN(null);
|
UNKNOWN(null);
|
||||||
private final String restName;
|
private final String restName;
|
||||||
|
|||||||
@ -53,6 +53,12 @@ import org.jdom.Namespace;
|
|||||||
<name>capitals</name>
|
<name>capitals</name>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/capitals.xml" type="application/xml"/>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/capitals.xml" type="application/xml"/>
|
||||||
</defaultStyle>
|
</defaultStyle>
|
||||||
|
<styles class="linked-hash-set">
|
||||||
|
<style>
|
||||||
|
<name>green</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/green.xml" type="application/xml"/>
|
||||||
|
</style>
|
||||||
|
</styles>
|
||||||
<resource class="featureType">
|
<resource class="featureType">
|
||||||
<name>tasmania_cities</name>
|
<name>tasmania_cities</name>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/datastores/taz_shapes/featuretypes/tasmania_cities.xml" type="application/xml"/>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/datastores/taz_shapes/featuretypes/tasmania_cities.xml" type="application/xml"/>
|
||||||
@ -150,6 +156,15 @@ public class RESTLayer {
|
|||||||
return defaultStyle == null? null : defaultStyle.getChildText("name");
|
return defaultStyle == null? null : defaultStyle.getChildText("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RESTStyleList getStyles() {
|
||||||
|
RESTStyleList styleList = null;
|
||||||
|
final Element stylesRoot = layerElem.getChild("styles");
|
||||||
|
if (stylesRoot != null) {
|
||||||
|
styleList = new RESTStyleList(stylesRoot);
|
||||||
|
}
|
||||||
|
return styleList;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDefaultStyleWorkspace() {
|
public String getDefaultStyleWorkspace() {
|
||||||
Element defaultStyle = layerElem.getChild("defaultStyle");
|
Element defaultStyle = layerElem.getChild("defaultStyle");
|
||||||
return defaultStyle == null? null : defaultStyle.getChildText("workspace");
|
return defaultStyle == null? null : defaultStyle.getChildText("workspace");
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007,2014 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -42,7 +42,7 @@ import org.jdom.Namespace;
|
|||||||
/**
|
/**
|
||||||
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
||||||
*
|
*
|
||||||
* @author etj
|
* @author Emanuele Tajariol <etj at geo-solutions.it>
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* @author Henry Rotzoll
|
* @author Henry Rotzoll
|
||||||
*
|
*
|
||||||
@ -110,30 +110,47 @@ public class RESTResource {
|
|||||||
return atom.getAttributeValue("href");
|
return atom.getAttributeValue("href");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCRS() {
|
public String getNativeCRS() {
|
||||||
Element elBBox = rootElem.getChild("latLonBoundingBox");
|
return rootElem.getChildText("nativeCRS");
|
||||||
return elBBox.getChildText("crs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getLatLonEdge(String edge) {
|
public RESTBoundingBox getNativeBoundingBox() {
|
||||||
Element elBBox = rootElem.getChild("latLonBoundingBox");
|
RESTBoundingBox bbox = null;
|
||||||
return Double.parseDouble(elBBox.getChildText(edge));
|
Element bboxElement = rootElem.getChild("nativeBoundingBox");
|
||||||
|
if (bboxElement != null) {
|
||||||
|
bbox = new RESTBoundingBox(bboxElement);
|
||||||
|
}
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RESTBoundingBox getLatLonBoundingBox() {
|
||||||
|
RESTBoundingBox bbox = null;
|
||||||
|
Element bboxElement = rootElem.getChild("latLonBoundingBox");
|
||||||
|
if (bboxElement != null) {
|
||||||
|
bbox = new RESTBoundingBox(bboxElement);
|
||||||
|
}
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCRS() {
|
||||||
|
RESTBoundingBox bbox = this.getLatLonBoundingBox();
|
||||||
|
return bbox.getCRS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMinX() {
|
public double getMinX() {
|
||||||
return getLatLonEdge("minx");
|
return this.getLatLonBoundingBox().getMinX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxX() {
|
public double getMaxX() {
|
||||||
return getLatLonEdge("maxx");
|
return this.getLatLonBoundingBox().getMaxX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMinY() {
|
public double getMinY() {
|
||||||
return getLatLonEdge("miny");
|
return this.getLatLonBoundingBox().getMinY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxY() {
|
public double getMaxY() {
|
||||||
return getLatLonEdge("maxy");
|
return this.getLatLonBoundingBox().getMaxY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -225,6 +225,25 @@ public class RESTStructuredCoverageGranulesList implements Iterable<RESTStructur
|
|||||||
public String getFid() {
|
public String getFid() {
|
||||||
return fid;
|
return fid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(this.getClass().getSimpleName()).append('[');
|
||||||
|
|
||||||
|
for (Element c : (List<Element>)granule.getChildren()) {
|
||||||
|
String text = c.getText();
|
||||||
|
if(text!= null) {
|
||||||
|
text = text.replace("\n", "");
|
||||||
|
text = text.trim();
|
||||||
|
}
|
||||||
|
sb.append('(').append(c.getName()).append("=").append(text).append(')');
|
||||||
|
}
|
||||||
|
sb.append(']');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,306 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse <TT>WMS</TT>s returned as XML REST objects.
|
||||||
|
*
|
||||||
|
* <P>This is the XML REST representation:
|
||||||
|
* <PRE>
|
||||||
|
*{@code
|
||||||
|
<wmsLayer>
|
||||||
|
<name>comunilazio</name>
|
||||||
|
<nativeName>lait:comunilazio</nativeName>
|
||||||
|
<namespace>
|
||||||
|
<name>arit</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/namespaces/arit.xml" type="application/xml"/>
|
||||||
|
</namespace>
|
||||||
|
<title>comunilazio</title>
|
||||||
|
<description/>
|
||||||
|
<keywords>
|
||||||
|
<string>features</string>
|
||||||
|
<string>comunilazio</string>
|
||||||
|
</keywords>
|
||||||
|
<nativeCRS>
|
||||||
|
GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]]
|
||||||
|
</nativeCRS>
|
||||||
|
<srs>EPSG:4326</srs>
|
||||||
|
<nativeBoundingBox>
|
||||||
|
<minx>11.4482128</minx>
|
||||||
|
<maxx>14.0288013</maxx>
|
||||||
|
<miny>40.7848334</miny>
|
||||||
|
<maxy>42.8396541</maxy>
|
||||||
|
<crs>EPSG:4326</crs>
|
||||||
|
</nativeBoundingBox>
|
||||||
|
<latLonBoundingBox>
|
||||||
|
<minx>11.4482128</minx>
|
||||||
|
<maxx>14.0288013</maxx>
|
||||||
|
<miny>40.7848334</miny>
|
||||||
|
<maxy>42.8396541</maxy>
|
||||||
|
<crs>
|
||||||
|
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
|
||||||
|
</crs>
|
||||||
|
</latLonBoundingBox>
|
||||||
|
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<metadata>
|
||||||
|
<entry key="cachingEnabled">false</entry>
|
||||||
|
</metadata>
|
||||||
|
<store class="wmsStore">
|
||||||
|
<name>regione</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione.xml" type="application/xml"/>
|
||||||
|
</store>
|
||||||
|
</wmsLayer>
|
||||||
|
* }</PRE>
|
||||||
|
*
|
||||||
|
* @author cip
|
||||||
|
*/
|
||||||
|
public class RESTWms extends RESTResource {
|
||||||
|
|
||||||
|
|
||||||
|
public static RESTWms build(String response) {
|
||||||
|
Element elem = JDOMBuilder.buildElement(response);
|
||||||
|
return elem == null? null : new RESTWms(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RESTWms(Element resource) {
|
||||||
|
super(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RESTWms(RESTResource resource) {
|
||||||
|
super(resource.rootElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public String getName() {
|
||||||
|
// return rootElem.getChildText("name");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public String getNativeName() {
|
||||||
|
// return rootElem.getChildText("nativeName");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// public String getNameSpace() {
|
||||||
|
// return rootElem.getChild("namespace").getChildText("name");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getTitle() {
|
||||||
|
// return rootElem.getChildText("title");
|
||||||
|
// }
|
||||||
|
|
||||||
|
public String getNativeCRS() {
|
||||||
|
return rootElem.getChildText("nativeCRS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSRS() {
|
||||||
|
return rootElem.getChildText("srs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public RESTMetadataList getMetadataList() {
|
||||||
|
return new RESTMetadataList(rootElem.getChild("metadata"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RESTDimensionInfo> getDimensionInfo() {
|
||||||
|
List<RESTDimensionInfo> listDim = new ArrayList<RESTDimensionInfo>();
|
||||||
|
for (RESTMetadataList.RESTMetadataElement el : getMetadataList()){
|
||||||
|
if(el.getKey().equals(RESTDimensionInfo.TIME) || el.getKey().equals(RESTDimensionInfo.ELEVATION)){
|
||||||
|
listDim.add(new RESTDimensionInfo(el.getMetadataElem()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listDim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of parameters for this wms.
|
||||||
|
*
|
||||||
|
* @return a {@link Map} where the key is the name for the parameter and the value is the value for the parameter.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, String> getParametersList() {
|
||||||
|
Map<String, String> paramsList = new HashMap<String, String>();
|
||||||
|
|
||||||
|
final Element paramsRoot = rootElem.getChild("parameters");
|
||||||
|
if (paramsRoot != null) {
|
||||||
|
final List<Element> params = paramsRoot.getChildren();
|
||||||
|
if (params != null) {
|
||||||
|
for (Element param : params) {
|
||||||
|
final List<Element> values = param.getChildren();
|
||||||
|
assert values.size()==2;
|
||||||
|
paramsList.put(values.get(0).getValue(), values.get(1).getValue()); // save key and value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paramsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("RESTWms [");
|
||||||
|
if (getNativeCRS() != null) {
|
||||||
|
builder.append("getNativeCRS()=");
|
||||||
|
builder.append(getNativeCRS());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getSRS() != null) {
|
||||||
|
builder.append("getSRS()=");
|
||||||
|
builder.append(getSRS());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getMetadataList() != null) {
|
||||||
|
builder.append("getMetadataList()=");
|
||||||
|
builder.append(getMetadataList());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getDimensionInfo() != null) {
|
||||||
|
builder.append("getDimensionInfo()=");
|
||||||
|
builder.append(getDimensionInfo());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getParametersList() != null) {
|
||||||
|
builder.append("getParametersList()=");
|
||||||
|
builder.append(getParametersList());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getName() != null) {
|
||||||
|
builder.append("getName()=");
|
||||||
|
builder.append(getName());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getTitle() != null) {
|
||||||
|
builder.append("getTitle()=");
|
||||||
|
builder.append(getTitle());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getNativeName() != null) {
|
||||||
|
builder.append("getNativeName()=");
|
||||||
|
builder.append(getNativeName());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getAbstract() != null) {
|
||||||
|
builder.append("getAbstract()=");
|
||||||
|
builder.append(getAbstract());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getNameSpace() != null) {
|
||||||
|
builder.append("getNameSpace()=");
|
||||||
|
builder.append(getNameSpace());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getStoreName() != null) {
|
||||||
|
builder.append("getStoreName()=");
|
||||||
|
builder.append(getStoreName());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getStoreType() != null) {
|
||||||
|
builder.append("getStoreType()=");
|
||||||
|
builder.append(getStoreType());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getStoreUrl() != null) {
|
||||||
|
builder.append("getStoreUrl()=");
|
||||||
|
builder.append(getStoreUrl());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getCRS() != null) {
|
||||||
|
builder.append("getCRS()=");
|
||||||
|
builder.append(getCRS());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
builder.append("getMinX()=");
|
||||||
|
builder.append(getMinX());
|
||||||
|
builder.append(", getMaxX()=");
|
||||||
|
builder.append(getMaxX());
|
||||||
|
builder.append(", getMinY()=");
|
||||||
|
builder.append(getMinY());
|
||||||
|
builder.append(", getMaxY()=");
|
||||||
|
builder.append(getMaxY());
|
||||||
|
builder.append(", ");
|
||||||
|
if (getAttributeList() != null) {
|
||||||
|
builder.append("getAttributeList()=");
|
||||||
|
builder.append(getAttributeList());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getEncodedAttributeList() != null) {
|
||||||
|
builder.append("getEncodedAttributeList()=");
|
||||||
|
builder.append(getEncodedAttributeList());
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
if (getEncodedMetadataLinkInfoList() != null) {
|
||||||
|
builder.append("getEncodedMetadataLinkInfoList()=");
|
||||||
|
builder.append(getEncodedMetadataLinkInfoList());
|
||||||
|
}
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public String getStoreName() {
|
||||||
|
// return rootElem.getChild("store").getChildText("name");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getStoreType() {
|
||||||
|
// return rootElem.getChild("store").getAttributeValue("class");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// public String getStoreUrl() {
|
||||||
|
// Element store = rootElem.getChild("store");
|
||||||
|
// Element atom = store.getChild("link", Namespace.getNamespace("atom", "http://www.w3.org/2005/Atom"));
|
||||||
|
// return atom.getAttributeValue("href");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public String getBBCRS() {
|
||||||
|
// Element elBBox = rootElem.getChild("latLonBoundingBox");
|
||||||
|
// return elBBox.getChildText("crs");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected double getLatLonEdge(String edge) {
|
||||||
|
// Element elBBox = rootElem.getChild("latLonBoundingBox");
|
||||||
|
// return Double.parseDouble(elBBox.getChildText(edge));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public double getMinX() {
|
||||||
|
// return getLatLonEdge("minx");
|
||||||
|
// }
|
||||||
|
// public double getMaxX() {
|
||||||
|
// return getLatLonEdge("maxx");
|
||||||
|
// }
|
||||||
|
// public double getMinY() {
|
||||||
|
// return getLatLonEdge("miny");
|
||||||
|
// }
|
||||||
|
// public double getMaxY() {
|
||||||
|
// return getLatLonEdge("maxy");
|
||||||
|
// }
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses list of summary data about Wms.
|
||||||
|
*
|
||||||
|
* <P>This is the XML REST representation:
|
||||||
|
* <PRE>{@code <wmsLayers>
|
||||||
|
<wmsLayer>
|
||||||
|
<name>comunilazio</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione/wmslayers/comunilazio.xml" type="application/xml"/>
|
||||||
|
</wmsLayer>
|
||||||
|
</wmsLayers>
|
||||||
|
*
|
||||||
|
}</PRE>
|
||||||
|
*
|
||||||
|
* @author cip
|
||||||
|
*/
|
||||||
|
public class RESTWmsList extends RESTAbstractList<NameLinkElem> {
|
||||||
|
|
||||||
|
public static RESTWmsList build(String response) {
|
||||||
|
Element elem = JDOMBuilder.buildElement(response);
|
||||||
|
return elem == null? null : new RESTWmsList(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RESTWmsList(Element list) {
|
||||||
|
super(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse <TT>WmsStore</TT>s returned as XML REST objects.
|
||||||
|
* <P>
|
||||||
|
* This is the XML document returned by GeoServer when requesting a WmsStore:
|
||||||
|
* <PRE>
|
||||||
|
* {@code
|
||||||
|
<wmsStore>
|
||||||
|
<name>regione</name>
|
||||||
|
<type>WMS</type>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<workspace>
|
||||||
|
<name>arit</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit.xml" type="application/xml"/>
|
||||||
|
</workspace>
|
||||||
|
<metadata>
|
||||||
|
<entry key="useConnectionPooling">true</entry>
|
||||||
|
</metadata>
|
||||||
|
<__default>false</__default>
|
||||||
|
<capabilitiesURL>http://www.regione.lazio.it/geoserver/wms</capabilitiesURL>
|
||||||
|
<user>admin</user>
|
||||||
|
<password>geoserver</password>
|
||||||
|
<maxConnections>6</maxConnections>
|
||||||
|
<readTimeout>60</readTimeout>
|
||||||
|
<connectTimeout>30</connectTimeout>
|
||||||
|
<wmsLayers>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione/wmslayers.xml" type="application/xml"/>
|
||||||
|
</wmsLayers>
|
||||||
|
</wmsStore>
|
||||||
|
* }
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
|
* <I>Note: the whole XML fragment is stored in memory. At the moment, there are
|
||||||
|
* methods to retrieve only the more useful data.
|
||||||
|
*
|
||||||
|
* @author etj
|
||||||
|
*/
|
||||||
|
public class RESTWmsStore {
|
||||||
|
private final Element cs;
|
||||||
|
|
||||||
|
|
||||||
|
public RESTWmsStore(Element cs) {
|
||||||
|
this.cs = cs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RESTWmsStore build(String response) {
|
||||||
|
if(response == null)
|
||||||
|
return null;
|
||||||
|
if(response.isEmpty())
|
||||||
|
return new RESTWmsStore(new Element("wmsStore")); // TODO check how to response
|
||||||
|
|
||||||
|
Element pb = JDOMBuilder.buildElement(response);
|
||||||
|
if(pb != null)
|
||||||
|
return new RESTWmsStore(pb);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return cs.getChildText("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return cs.getChildText("type");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return Boolean.parseBoolean(cs.getChildText("enabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorkspaceName() {
|
||||||
|
return cs.getChild("workspace").getChildText("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getUseConnectionPooling(){
|
||||||
|
Element entry = cs.getChild("metadata").getChild("entry");
|
||||||
|
return entry.getAttributeValue("key").equals("useConnectionPooling") && Boolean.parseBoolean(entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCapabilitiesURL() {
|
||||||
|
return cs.getChildText("capabilitiesURL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMaxConnections() {
|
||||||
|
return cs.getChildText("maxConnections");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReadTimeout() {
|
||||||
|
return cs.getChildText("readTimeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConnectTimeout() {
|
||||||
|
return cs.getChildText("connectTimeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUser() {
|
||||||
|
return cs.getChildText("user");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return cs.getChildText("password");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder(getClass().getSimpleName())
|
||||||
|
.append('[');
|
||||||
|
if(cs == null)
|
||||||
|
sb.append("null");
|
||||||
|
else
|
||||||
|
sb.append("name:").append(getName())
|
||||||
|
.append(" wsname:").append(getWorkspaceName());
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses list of summary data about WmsStores.
|
||||||
|
*
|
||||||
|
* <P>This is the XML REST representation:
|
||||||
|
* <PRE>{@code
|
||||||
|
<wmsStores>
|
||||||
|
<wmsStore>
|
||||||
|
<name>regione</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/arit/wmsstores/regione.xml" type="application/xml"/>
|
||||||
|
</wmsStore>
|
||||||
|
</wmsStores>
|
||||||
|
*
|
||||||
|
}</PRE>
|
||||||
|
*
|
||||||
|
* @author cip
|
||||||
|
*/
|
||||||
|
public class RESTWmsStoreList extends RESTAbstractList<NameLinkElem> {
|
||||||
|
|
||||||
|
public static RESTWmsStoreList build(String response) {
|
||||||
|
Element elem = JDOMBuilder.buildElement(response);
|
||||||
|
return elem == null? null : new RESTWmsStoreList(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RESTWmsStoreList(Element list) {
|
||||||
|
super(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007,2015 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -147,12 +147,22 @@ public class GSVersionDecoder extends XmlElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum VERSION {
|
public enum VERSION {
|
||||||
UNRECOGNIZED(-1), v22(22), v23(23), v24(24), v25(25), ABOVE(9999);
|
v22(22, "2\\.2([^0-9]|$).*"),
|
||||||
|
v23(23, "2\\.3([^0-9]|$).*"),
|
||||||
|
v24(24, "2\\.4([^0-9]|$).*"),
|
||||||
|
v25(25, "2\\.5([^0-9]|$).*"),
|
||||||
|
v26(26, "2\\.6([^0-9]|$).*"),
|
||||||
|
v27(27, "2\\.7([^0-9]|$).*"),
|
||||||
|
v28(28, "2\\.8([^0-9]|$).*"),
|
||||||
|
ABOVE(9999, "2\\..+"),
|
||||||
|
UNRECOGNIZED(-1, null);
|
||||||
|
|
||||||
final private int version;
|
final private int version;
|
||||||
|
final private String pattern;
|
||||||
|
|
||||||
private VERSION(int val) {
|
private VERSION(int val, String pattern) {
|
||||||
version = val;
|
version = val;
|
||||||
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersion() {
|
public int getVersion() {
|
||||||
@ -166,23 +176,25 @@ public class GSVersionDecoder extends XmlElement {
|
|||||||
public static VERSION getVersion(String v) {
|
public static VERSION getVersion(String v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
} else if (v.matches("2\\.2.*")) {
|
|
||||||
return v22;
|
|
||||||
} else if (v.matches("2\\.3.*")) {
|
|
||||||
return v23;
|
|
||||||
} else if (v.matches("2\\.4.*")) {
|
|
||||||
return v24;
|
|
||||||
} else if (v.matches("2\\.5.*")) {
|
|
||||||
return v25;
|
|
||||||
} else if (v.matches("2\\..+")) {
|
|
||||||
return ABOVE;
|
|
||||||
} else {
|
|
||||||
return UNRECOGNIZED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (VERSION version : VERSION.values()) {
|
||||||
|
if(version.pattern != null && v.matches(version.pattern)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String print(){
|
public static String print(){
|
||||||
return "["+v22+", "+v23+", "+v24+", "+v25+", "+ABOVE+", "+UNRECOGNIZED+"]";
|
|
||||||
|
StringBuilder sb = new StringBuilder("[");
|
||||||
|
for (VERSION v : VERSION.values()) {
|
||||||
|
sb.append(v.toString()).append(' ');
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public abstract class GSAbstractStoreEncoder extends PropertyXMLEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return ElementUtils.contains(getRoot(), "name").getTextTrim();
|
return ElementUtils.contains(getRoot(), "type").getTextTrim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
|||||||
@ -75,8 +75,10 @@ public class GSLayerEncoder extends PropertyXMLEncoder {
|
|||||||
public final static String STYLES = "styles";
|
public final static String STYLES = "styles";
|
||||||
public final static String AUTHORITY_URLS="authorityURLs";
|
public final static String AUTHORITY_URLS="authorityURLs";
|
||||||
public final static String IDENTIFIERS="identifiers";
|
public final static String IDENTIFIERS="identifiers";
|
||||||
|
public final static String DEFAULT_STYLE = "defaultStyle";
|
||||||
|
|
||||||
final private Element stylesEncoder = new Element(STYLES);
|
final private Element stylesEncoder = new Element(STYLES);
|
||||||
|
final private Element defaultStyleEncoder = new Element(DEFAULT_STYLE);
|
||||||
final private Element authorityURLListEncoder = new Element(AUTHORITY_URLS);
|
final private Element authorityURLListEncoder = new Element(AUTHORITY_URLS);
|
||||||
final private Element identifierListEncoder = new Element(IDENTIFIERS);
|
final private Element identifierListEncoder = new Element(IDENTIFIERS);
|
||||||
|
|
||||||
@ -165,6 +167,20 @@ public class GSLayerEncoder extends PropertyXMLEncoder {
|
|||||||
add("defaultStyle", defaultStyle);
|
add("defaultStyle", defaultStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {@link GSLayerEncoder#setDefaultStyle(String)}
|
||||||
|
* @param defaultStyle
|
||||||
|
*/
|
||||||
|
protected void addDefaultStyle(String workspace, String defaultStyle) {
|
||||||
|
addContent(defaultStyleEncoder);
|
||||||
|
Element el = new Element("name");
|
||||||
|
el.setText(defaultStyle);
|
||||||
|
defaultStyleEncoder.addContent(el);
|
||||||
|
el = new Element("workspace");
|
||||||
|
el.setText(workspace);
|
||||||
|
defaultStyleEncoder.addContent(el);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param defaultStyle The style that will be applied if no style is specified.
|
* @param defaultStyle The style that will be applied if no style is specified.
|
||||||
* @throws IllegalArgumentException if defaultStyle is null or empty
|
* @throws IllegalArgumentException if defaultStyle is null or empty
|
||||||
@ -175,6 +191,15 @@ public class GSLayerEncoder extends PropertyXMLEncoder {
|
|||||||
set("defaultStyle", defaultStyle);
|
set("defaultStyle", defaultStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {@link GSLayerEncoder#setDefaultStyle(String)}
|
||||||
|
* @param defaultStyle
|
||||||
|
*/
|
||||||
|
public void setDefaultStyle(String workspace, String defaultStyle) {
|
||||||
|
remove("defaultStyle");
|
||||||
|
addDefaultStyle(workspace, defaultStyle);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a style
|
* Add a style
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007-2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -26,7 +26,6 @@
|
|||||||
package it.geosolutions.geoserver.rest.encoder;
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -37,6 +36,7 @@ import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder
|
|||||||
import it.geosolutions.geoserver.rest.encoder.identifier.IdentifierInfo;
|
import it.geosolutions.geoserver.rest.encoder.identifier.IdentifierInfo;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.NestedElementEncoder;
|
import it.geosolutions.geoserver.rest.encoder.utils.NestedElementEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer encoder for Geoserver = 2.1
|
* Layer encoder for Geoserver = 2.1
|
||||||
@ -102,7 +102,7 @@ public class GSLayerEncoder21 extends GSLayerEncoder {
|
|||||||
*/
|
*/
|
||||||
public void addAuthorityURL(GSAuthorityURLInfoEncoder authorityURLInfo){
|
public void addAuthorityURL(GSAuthorityURLInfoEncoder authorityURLInfo){
|
||||||
if(authorityURLList == null){
|
if(authorityURLList == null){
|
||||||
authorityURLList = new HashMap<String,String>();
|
authorityURLList = new LinkedHashMap<String,String>();
|
||||||
}
|
}
|
||||||
authorityURLList.put(authorityURLInfo.getHref(), authorityURLInfo.getName());
|
authorityURLList.put(authorityURLInfo.getHref(), authorityURLInfo.getName());
|
||||||
String jsonStr = "";
|
String jsonStr = "";
|
||||||
@ -152,7 +152,7 @@ public class GSLayerEncoder21 extends GSLayerEncoder {
|
|||||||
*/
|
*/
|
||||||
public void addIdentifier(GSIdentifierInfoEncoder identifierInfo){
|
public void addIdentifier(GSIdentifierInfoEncoder identifierInfo){
|
||||||
if(identifierList == null){
|
if(identifierList == null){
|
||||||
identifierList = new HashMap<String,List<String>>();
|
identifierList = new LinkedHashMap<String,List<String>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
String authority = identifierInfo.getAuthority();
|
String authority = identifierInfo.getAuthority();
|
||||||
|
|||||||
@ -41,12 +41,22 @@ import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
|||||||
*/
|
*/
|
||||||
public class GSCoverageEncoder extends GSResourceEncoder {
|
public class GSCoverageEncoder extends GSResourceEncoder {
|
||||||
|
|
||||||
|
public final static String NATIVECOVERAGENAME = "nativeCoverageName";
|
||||||
|
|
||||||
|
private final static String NATIVE_FORMAT="nativeFormat";
|
||||||
|
private final static String SUPPORTED_FORMATS="supportedFormats";
|
||||||
|
|
||||||
|
private final static String REQUEST_SRS="requestSRS";
|
||||||
|
private final static String RESPONSE_SRS="responseSRS";
|
||||||
|
|
||||||
|
private final Element supportedFormatsListEncoder = new Element(SUPPORTED_FORMATS);
|
||||||
public final static String DIMENSIONS = "dimensions";
|
public final static String DIMENSIONS = "dimensions";
|
||||||
|
|
||||||
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
||||||
|
|
||||||
public GSCoverageEncoder() {
|
public GSCoverageEncoder() {
|
||||||
super("coverage");
|
super("coverage");
|
||||||
|
addContent(supportedFormatsListEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +77,40 @@ public class GSCoverageEncoder extends GSResourceEncoder {
|
|||||||
super.setMetadata(key, dimensionInfo);
|
super.setMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'nativeFormat' node with a text value
|
||||||
|
*/
|
||||||
|
public void setNativeFormat(String format) {
|
||||||
|
set(NATIVE_FORMAT, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'supportedFormat' node with a text value
|
||||||
|
*/
|
||||||
|
public void addSupportedFormats(String format) {
|
||||||
|
final Element el = new Element("string");
|
||||||
|
el.setText(format);
|
||||||
|
supportedFormatsListEncoder.addContent(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'requestSRS' node with a text value
|
||||||
|
*/
|
||||||
|
public void setRequestSRS(String srs) {
|
||||||
|
final Element el = new Element("string");
|
||||||
|
el.setText(srs);
|
||||||
|
set(REQUEST_SRS, el);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'responseSRS' node with a text value
|
||||||
|
*/
|
||||||
|
public void setResponseSRS(String srs) {
|
||||||
|
final Element el = new Element("string");
|
||||||
|
el.setText(srs);
|
||||||
|
set(RESPONSE_SRS, el);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a CoverageDimensionInfo to the GeoServer Resource
|
* Adds a CoverageDimensionInfo to the GeoServer Resource
|
||||||
*
|
*
|
||||||
@ -106,4 +150,36 @@ public class GSCoverageEncoder extends GSResourceEncoder {
|
|||||||
return (dimensionsEncoder.removeContent(GSCoverageDimensionEncoder
|
return (dimensionsEncoder.removeContent(GSCoverageDimensionEncoder
|
||||||
.getFilterByContent(coverageDimensionName))).size() == 0 ? false : true;
|
.getFilterByContent(coverageDimensionName))).size() == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'nativeCoverageName' node with a text value from 'name'
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void addNativeCoverageName(final String nativeCoverageName) {
|
||||||
|
add(NATIVECOVERAGENAME, nativeCoverageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the 'nativeCoverageName' node with a text value from 'name'
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setNativeCoverageName(final String nativeCoverageName) {
|
||||||
|
set(NATIVECOVERAGENAME, nativeCoverageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the nativeCoverageName
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getNativeCoverageName() {
|
||||||
|
final Element nativeCoverageNameNode = ElementUtils.contains(getRoot(), NATIVECOVERAGENAME, 1);
|
||||||
|
if (nativeCoverageNameNode != null)
|
||||||
|
return nativeCoverageNameNode.getText();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import org.jdom.filter.Filter;
|
|||||||
* {@code
|
* {@code
|
||||||
* final GSCoverageDimensionEncoder gsCoverageDimensionEncoder =
|
* final GSCoverageDimensionEncoder gsCoverageDimensionEncoder =
|
||||||
* new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-2.147483648E9,-2.147483648E9]",
|
* new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-2.147483648E9,-2.147483648E9]",
|
||||||
* String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE), "dobson units³", "REAL_32BITS");
|
* String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE), "dobson units", "REAL_32BITS");
|
||||||
* coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
* coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
@ -53,7 +53,7 @@ import org.jdom.filter.Filter;
|
|||||||
* <min>-2.147483648E9</min>
|
* <min>-2.147483648E9</min>
|
||||||
* <max>2.147483647E9</max>
|
* <max>2.147483647E9</max>
|
||||||
* </range>
|
* </range>
|
||||||
* <unit>dobson units³</unit>
|
* <unit>dobson units</unit>
|
||||||
* <dimensionType>
|
* <dimensionType>
|
||||||
* <name>REAL_32BITS</name>
|
* <name>REAL_32BITS</name>
|
||||||
* </dimensionType>
|
* </dimensionType>
|
||||||
|
|||||||
@ -28,6 +28,7 @@ package it.geosolutions.geoserver.rest.encoder.metadata;
|
|||||||
|
|
||||||
public class GSFeatureDimensionInfoEncoder extends GSDimensionInfoEncoder {
|
public class GSFeatureDimensionInfoEncoder extends GSDimensionInfoEncoder {
|
||||||
public final static String ATTRIBUTE="attribute";
|
public final static String ATTRIBUTE="attribute";
|
||||||
|
public final static String END_ATTRIBUTE="endAttribute";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if this dimension is enabled this constructor should be called.
|
* if this dimension is enabled this constructor should be called.
|
||||||
@ -46,6 +47,12 @@ public class GSFeatureDimensionInfoEncoder extends GSDimensionInfoEncoder {
|
|||||||
set(ATTRIBUTE, attribute);
|
set(ATTRIBUTE, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the end attribute used in the dimension (optional)
|
||||||
|
* @param endAttribute the dimension end attribute
|
||||||
|
*/
|
||||||
|
public void setEndAttribute(final String endAttribute){
|
||||||
|
set(END_ATTRIBUTE, endAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,8 +100,8 @@ public abstract class ElementUtils {
|
|||||||
final List<Element> ret = new ArrayList<Element>();
|
final List<Element> ret = new ArrayList<Element>();
|
||||||
// if match add myself
|
// if match add myself
|
||||||
if (filter.matches(root)) {
|
if (filter.matches(root)) {
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isTraceEnabled())
|
||||||
LOGGER.debug("LOCATED-> name:" + root.getName() + " text:"
|
LOGGER.trace("LOCATED-> name:" + root.getName() + " text:"
|
||||||
+ root.getText());
|
+ root.getText());
|
||||||
ret.add(root);
|
ret.add(root);
|
||||||
}
|
}
|
||||||
@ -128,8 +128,8 @@ public abstract class ElementUtils {
|
|||||||
final List<Element> ret = new ArrayList<Element>();
|
final List<Element> ret = new ArrayList<Element>();
|
||||||
// if match add myself
|
// if match add myself
|
||||||
if (filter.matches(root)) {
|
if (filter.matches(root)) {
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isTraceEnabled())
|
||||||
LOGGER.debug("LOCATED-> name:" + root.getName() + " text:"
|
LOGGER.trace("LOCATED-> name:" + root.getName() + " text:"
|
||||||
+ root.getText());
|
+ root.getText());
|
||||||
ret.add(root);
|
ret.add(root);
|
||||||
}
|
}
|
||||||
@ -140,8 +140,8 @@ public abstract class ElementUtils {
|
|||||||
if (obj instanceof Element) {
|
if (obj instanceof Element) {
|
||||||
Element el = (Element) obj;
|
Element el = (Element) obj;
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isTraceEnabled())
|
||||||
LOGGER.debug("LOCATED-> name:" + el.getName() + " text:"
|
LOGGER.trace("LOCATED-> name:" + el.getName() + " text:"
|
||||||
+ el.getText());
|
+ el.getText());
|
||||||
|
|
||||||
ret.add(el);
|
ret.add(el);
|
||||||
|
|||||||
@ -0,0 +1,321 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.manager;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.HTTPUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import net.sf.json.JSON;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
import org.restlet.data.MediaType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alessio Fabiani, GeoSolutions S.A.S.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GeoServerRESTImporterManager extends GeoServerRESTAbstractManager {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoServerRESTImporterManager.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*
|
||||||
|
* @param restURL GeoServer REST API endpoint
|
||||||
|
* @param username GeoServer REST API authorized username
|
||||||
|
* @param password GeoServer REST API password for the former username
|
||||||
|
*/
|
||||||
|
public GeoServerRESTImporterManager(URL restURL, String username, String password)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
super(restURL, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the Import JSON Object given its identifier
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
*/
|
||||||
|
public JSONObject getImport(int imp) throws Exception {
|
||||||
|
JSON json = HTTPUtils.getAsJSON(String.format(buildUrl()+"/%d", imp), gsuser , gspass);
|
||||||
|
return ((JSONObject)json).getJSONObject("import");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the Import Task JSON Object given its identifier and task number
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param task int: Task number
|
||||||
|
*/
|
||||||
|
public JSONObject getTask(int imp, int task) throws Exception {
|
||||||
|
JSON json = HTTPUtils.getAsJSON(String.format(buildUrl()+"/%d/tasks/%d?expand=all", imp, task), gsuser , gspass);
|
||||||
|
return ((JSONObject)json).getJSONObject("task");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example usage:
|
||||||
|
* <pre>
|
||||||
|
* // Creates a new Importer Context and gets back the ID
|
||||||
|
* int i = postNewImport();
|
||||||
|
*
|
||||||
|
* // Attaches to the new Importer Context a Task pointing to a shapefile's zip archive
|
||||||
|
* int t = postNewTaskAsMultiPartForm(i, "/path_to/shape/archsites_no_crs.zip");
|
||||||
|
*
|
||||||
|
* // Check that the Task was actually created and that the CRS has not recognized in this case
|
||||||
|
* JSONObject task = getTask(i, t);
|
||||||
|
* assertEquals("NO_CRS", task.getString("state"));
|
||||||
|
*
|
||||||
|
* // Prepare the JSON String instructing the Task about the SRS to use
|
||||||
|
* String json =
|
||||||
|
* "{" +
|
||||||
|
* "\"task\": {" +
|
||||||
|
* "\"layer\": {" +
|
||||||
|
* "\"srs\": \"EPSG:4326\"" +
|
||||||
|
* "}" +
|
||||||
|
* "}" +
|
||||||
|
* "}";
|
||||||
|
*
|
||||||
|
* // Performing the Task update
|
||||||
|
* putTask(i, t, json);
|
||||||
|
*
|
||||||
|
* // Double check that the Task is in the READY state
|
||||||
|
* task = getTask(i, t);
|
||||||
|
* assertEquals("READY", task.getString("state"));
|
||||||
|
* assertEquals("gs_archsites", task.getJSONObject("layer").getJSONObject("style").getString("name"));
|
||||||
|
*
|
||||||
|
* // Prepare the JSON String instructing the Task avout the SLD to use for the new Layer
|
||||||
|
* json =
|
||||||
|
* "{" +
|
||||||
|
* "\"task\": {" +
|
||||||
|
* "\"layer\": {" +
|
||||||
|
* "\"style\": {" +
|
||||||
|
* "\"name\": \"point\"" +
|
||||||
|
* "}" +
|
||||||
|
* "}" +
|
||||||
|
* "}" +
|
||||||
|
* "}";
|
||||||
|
*
|
||||||
|
* // Performing the Task update
|
||||||
|
* putTask(i, t,json);
|
||||||
|
*
|
||||||
|
* // Double check that the Task is in the READY state and that the Style has been correctly updated
|
||||||
|
* task = getTask(i, t);
|
||||||
|
* assertEquals("READY", task.getString("state"));
|
||||||
|
* assertEquals("point", task.getJSONObject("layer").getJSONObject("style").getString("name"));
|
||||||
|
*
|
||||||
|
* // Finally starts the Import ...
|
||||||
|
* postImport(i);
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param task int: Task number
|
||||||
|
* @param json String: JSON containing the Task properties to be updated
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void putTask(int imp, int task, final String json) throws Exception {
|
||||||
|
//HTTPUtils.putJson(String.format(buildUrl()+"/%d/tasks/%d", imp, task), json, gsuser, gspass);
|
||||||
|
HTTPUtils.put(String.format(buildUrl()+"/%d/tasks/%d", imp, task), json, "text/plain", gsuser, gspass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just update the Layers properties associated to a Task (t) in the Importer Context (i).
|
||||||
|
*
|
||||||
|
* e.g.:
|
||||||
|
* <pre>
|
||||||
|
* putTaskLayer(i, t, "{\"title\":\"Archsites\", \"abstract\":\"Archeological Sites\"}");
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param task int: Task number
|
||||||
|
* @param json String: JSON containing the Layer properties to be updated
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void putTaskLayer(int imp, int task, final String json) throws Exception {
|
||||||
|
HTTPUtils.putJson(String.format(buildUrl()+"/%d/tasks/%d/layer", imp, task), json, gsuser, gspass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just update the Layers properties associated to a Task (t) in the Importer Context (i).
|
||||||
|
*
|
||||||
|
* e.g.:
|
||||||
|
* <pre>
|
||||||
|
* putTaskLayer(i, t, "{\"title\":\"Archsites\", \"abstract\":\"Archeological Sites\"}");
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param task int: Task number
|
||||||
|
* @param json String: JSON containing the Layer properties to be updated
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void postTaskTransform(int imp, int task, final String json) throws Exception {
|
||||||
|
HTTPUtils.postJson(String.format(buildUrl()+"/%d/tasks/%d/transforms", imp, task), json, gsuser, gspass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty Importer Context.
|
||||||
|
*
|
||||||
|
* @return The new Importer Context ID
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int postNewImport() throws Exception {
|
||||||
|
return postNewImport(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g.:
|
||||||
|
* <pre>
|
||||||
|
* String body =
|
||||||
|
* "{" +
|
||||||
|
* "\"import\": { " +
|
||||||
|
* "\"data\": {" +
|
||||||
|
* "\"type\": \"mosaic\", " +
|
||||||
|
* "\"time\": {" +
|
||||||
|
* " \"mode\": \"auto\"" +
|
||||||
|
* "}" +
|
||||||
|
* "}" +
|
||||||
|
* "}" +
|
||||||
|
* "}";
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param body JSON String representing the Importer Context definition
|
||||||
|
* @return The new Importer Context ID
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int postNewImport(String body) throws Exception {
|
||||||
|
String resp = body == null ? HTTPUtils.post(buildUrl(), "", "text/plain", gsuser, gspass)
|
||||||
|
: HTTPUtils.postJson(buildUrl(), body, gsuser, gspass);
|
||||||
|
|
||||||
|
JSONObject json = (JSONObject) HTTPUtils.json(resp);
|
||||||
|
JSONObject imprt = json.getJSONObject("import");
|
||||||
|
return imprt.getInt("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually starts the READY State Import.
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void postImport(int imp) throws Exception {
|
||||||
|
HTTPUtils.post(buildUrl()+"/" + imp + "?exec=true", "", "text/plain", gsuser, gspass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int postNewTaskAsMultiPartForm(int imp, String data) throws Exception {
|
||||||
|
String resp = HTTPUtils.postMultipartForm(buildUrl()+"/" + imp + "/tasks", unpack(data), gsuser, gspass);
|
||||||
|
|
||||||
|
JSONObject json = (JSONObject) HTTPUtils.json(resp);
|
||||||
|
|
||||||
|
JSONObject task = json.getJSONObject("task");
|
||||||
|
return task.getInt("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows to attach a new zip file to an existing Importer Context.
|
||||||
|
*
|
||||||
|
* @param imp int: Import context number ID
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int putNewTask(int imp, String path) throws Exception {
|
||||||
|
File zip = new File(path);
|
||||||
|
|
||||||
|
String resp = HTTPUtils.put(buildUrl()+"/" + imp + "/tasks/" + zip.getName(), zip, MediaType.APPLICATION_ZIP.toString(), gsuser, gspass);
|
||||||
|
|
||||||
|
JSONObject json = (JSONObject) HTTPUtils.json(resp);
|
||||||
|
|
||||||
|
JSONObject task = json.getJSONObject("task");
|
||||||
|
return task.getInt("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
//=========================================================================
|
||||||
|
// Util methods
|
||||||
|
//=========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the base REST URL for the imports
|
||||||
|
*/
|
||||||
|
protected String buildUrl() {
|
||||||
|
StringBuilder sUrl = new StringBuilder(gsBaseUrl.toString()).append("/rest/imports");
|
||||||
|
|
||||||
|
return sUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a temporary file
|
||||||
|
*
|
||||||
|
* @return Path to the temporary file
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static File tmpDir() throws Exception {
|
||||||
|
File dir = File.createTempFile("importer", "data", new File("target"));
|
||||||
|
dir.delete();
|
||||||
|
dir.mkdirs();
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expands a zip archive into the temporary folder.
|
||||||
|
*
|
||||||
|
* @param path The absolute path to the source zip file
|
||||||
|
* @return Path to the temporary folder containing the expanded files
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static File unpack(String path) throws Exception {
|
||||||
|
return unpack(path, tmpDir());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expands a zip archive into the target folder.
|
||||||
|
*
|
||||||
|
* @param path The absolute path to the source zip file
|
||||||
|
* @param dir Full path of the target folder where to expand the archive
|
||||||
|
* @return Path to the temporary folder containing the expanded files
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static File unpack(String path, File dir) throws Exception {
|
||||||
|
|
||||||
|
File file = new File(path);
|
||||||
|
|
||||||
|
//new VFSWorker().extractTo(file, dir);
|
||||||
|
if (!file.delete()) {
|
||||||
|
// fail early as tests will expect it's deleted
|
||||||
|
throw new IOException("deletion failed during extraction");
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007,2015 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -26,13 +26,28 @@ package it.geosolutions.geoserver.rest.manager;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
import it.geosolutions.geoserver.rest.HTTPUtils;
|
import it.geosolutions.geoserver.rest.HTTPUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.Util;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.xpath.XPath;
|
||||||
|
import javax.xml.xpath.XPathConstants;
|
||||||
|
import javax.xml.xpath.XPathExpression;
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
import javax.xml.xpath.XPathFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -61,8 +76,20 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
*/
|
*/
|
||||||
public boolean existsStyle(String name) throws RuntimeException {
|
public boolean existsStyle(String name) throws RuntimeException {
|
||||||
|
return existsStyle(name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Style exists in the configured GeoServer instance. User can choose if log a possible exception or not
|
||||||
|
* @param name the name of the style to check for.
|
||||||
|
* @param quietOnNotFound if true, mute exception if false is returned
|
||||||
|
* @return <TT>true</TT> on HTTP 200, <TT>false</TT> on HTTP 404
|
||||||
|
* @throws RuntimeException if any other HTTP code than 200 or 404 was retrieved.
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String name, boolean quietOnNotFound) {
|
||||||
String url = buildXmlUrl(null, name);
|
String url = buildXmlUrl(null, name);
|
||||||
return HTTPUtils.exists(url, gsuser, gspass);
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed , gsuser, gspass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,8 +138,17 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
*/
|
*/
|
||||||
public boolean existsStyle(String workspace, String name) {
|
public boolean existsStyle(String workspace, String name) {
|
||||||
|
return existsStyle(workspace, name, Util.DEFAULT_QUIET_ON_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since GeoServer 2.6
|
||||||
|
*/
|
||||||
|
public boolean existsStyle(String workspace, String name, boolean quietOnNotFound) {
|
||||||
String url = buildXmlUrl(workspace, name);
|
String url = buildXmlUrl(workspace, name);
|
||||||
return HTTPUtils.exists(url, gsuser, gspass);
|
String composed = Util.appendQuietOnNotFound(quietOnNotFound, url);
|
||||||
|
return HTTPUtils.exists(composed , gsuser, gspass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,6 +274,136 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store and publish a Style, assigning it a name and choosing the raw
|
||||||
|
* format.
|
||||||
|
*
|
||||||
|
* @param sldBody the full SLD document as a String.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
*/
|
||||||
|
public boolean publishStyle(final String sldBody, final String name, final boolean raw) {
|
||||||
|
/*
|
||||||
|
* This is the equivalent call with cUrl:
|
||||||
|
*
|
||||||
|
* {@code curl -u admin:geoserver -XPOST \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \
|
||||||
|
* http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw}
|
||||||
|
*/
|
||||||
|
if (sldBody == null || sldBody.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("The style body may not be null or empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sUrl = new StringBuilder(buildPostUrl(null, name));
|
||||||
|
Util.appendParameter(sUrl, "raw", ""+raw);
|
||||||
|
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
|
||||||
|
if(!this.checkSLD10Version(sldBody)){
|
||||||
|
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
|
||||||
|
}
|
||||||
|
LOGGER.debug("POSTing new style " + name + " to " + sUrl + " using version: " + contentType);
|
||||||
|
String result = HTTPUtils.post(sUrl.toString(), sldBody, contentType, gsuser, gspass);
|
||||||
|
return result != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store and publish a Style, assigning it a name and choosing the raw
|
||||||
|
* format.
|
||||||
|
*
|
||||||
|
* @param sldFile the File containing the SLD document.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
*/
|
||||||
|
public boolean publishStyle(final File sldFile, final String name, final boolean raw) {
|
||||||
|
/*
|
||||||
|
* This is the equivalent call with cUrl:
|
||||||
|
*
|
||||||
|
* {@code curl -u admin:geoserver -XPOST \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \
|
||||||
|
* http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw}
|
||||||
|
*/
|
||||||
|
StringBuilder sUrl = new StringBuilder(buildPostUrl(null, name));
|
||||||
|
Util.appendParameter(sUrl, "raw", ""+raw);
|
||||||
|
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
|
||||||
|
if(!this.checkSLD10Version(sldFile)){
|
||||||
|
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
|
||||||
|
}
|
||||||
|
LOGGER.debug("POSTing new style " + name + " to " + sUrl + " using version: " + contentType);
|
||||||
|
String result = HTTPUtils.post(sUrl.toString(), sldFile, contentType, gsuser, gspass);
|
||||||
|
return result != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a Style.
|
||||||
|
*
|
||||||
|
* @param sldFile the File containing the SLD document.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
* @throws IllegalArgumentException if the style body or name are null or empty.
|
||||||
|
*/
|
||||||
|
public boolean updateStyle(final File sldFile, final String name, final boolean raw)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
/*
|
||||||
|
* This is the equivalent call with cUrl:
|
||||||
|
*
|
||||||
|
* {@code curl -u admin:geoserver -XPUT \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \
|
||||||
|
* http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw}
|
||||||
|
*/
|
||||||
|
if (sldFile == null) {
|
||||||
|
throw new IllegalArgumentException("Unable to updateStyle using a null parameter file");
|
||||||
|
} else if (name == null || name.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("The style name may not be null or empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sUrl = new StringBuilder(buildUrl(null, name, null));
|
||||||
|
Util.appendParameter(sUrl, "raw", ""+raw);
|
||||||
|
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
|
||||||
|
if(!this.checkSLD10Version(sldFile)){
|
||||||
|
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
|
||||||
|
}
|
||||||
|
LOGGER.debug("PUTting style " + name + " to " + sUrl + " using version: " + contentType);
|
||||||
|
String result = HTTPUtils.put(sUrl.toString(), sldFile, contentType, gsuser, gspass);
|
||||||
|
return result != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a Style.
|
||||||
|
*
|
||||||
|
* @param sldBody the new SLD document as a String.
|
||||||
|
* @param name the Style name.
|
||||||
|
* @param raw the raw format
|
||||||
|
*
|
||||||
|
* @return <TT>true</TT> if the operation completed successfully.
|
||||||
|
* @throws IllegalArgumentException if the style body or name are null or empty.
|
||||||
|
*/
|
||||||
|
public boolean updateStyle(final String sldBody, final String name, final boolean raw)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
/*
|
||||||
|
* This is the equivalent call with cUrl:
|
||||||
|
*
|
||||||
|
* {@code curl -u admin:geoserver -XPUT \ -H 'Content-type: application/vnd.ogc.sld+xml' \ -d @$FULLSLD \
|
||||||
|
* http://$GSIP:$GSPORT/$SERVLET/rest/styles?name=$name&raw=$raw}
|
||||||
|
*/
|
||||||
|
if (sldBody == null || sldBody.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("The style body may not be null or empty");
|
||||||
|
} else if (name == null || name.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("The style name may not be null or empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sUrl = new StringBuilder(buildUrl(null, name, null));
|
||||||
|
Util.appendParameter(sUrl, "raw", ""+raw);
|
||||||
|
String contentType = GeoServerRESTPublisher.Format.SLD.getContentType();
|
||||||
|
if(!this.checkSLD10Version(sldBody)){
|
||||||
|
contentType = GeoServerRESTPublisher.Format.SLD_1_1_0.getContentType();
|
||||||
|
}
|
||||||
|
LOGGER.debug("PUTting style " + name + " to " + sUrl + " using version: " + contentType);
|
||||||
|
String result = HTTPUtils.put(sUrl.toString(), sldBody, contentType, gsuser, gspass);
|
||||||
|
return result != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a Style.
|
* Update a Style.
|
||||||
*
|
*
|
||||||
@ -362,7 +528,7 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
*/
|
*/
|
||||||
public boolean publishStyleInWorkspace(final String workspace, String sldBody) {
|
public boolean publishStyleInWorkspace(final String workspace, String sldBody) {
|
||||||
try {
|
try {
|
||||||
return publishStyleInWorkspace(workspace, sldBody);
|
return publishStyleInWorkspace(workspace, sldBody, null);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (LOGGER.isErrorEnabled()) {
|
if (LOGGER.isErrorEnabled()) {
|
||||||
LOGGER.error(e.getLocalizedMessage(), e);
|
LOGGER.error(e.getLocalizedMessage(), e);
|
||||||
@ -574,4 +740,52 @@ public class GeoServerRESTStyleManager extends GeoServerRESTAbstractManager {
|
|||||||
return sUrl.toString();
|
return sUrl.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkSLD10Version(String sldBody) {
|
||||||
|
boolean result = false;
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
try {
|
||||||
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
InputStream stream = new ByteArrayInputStream(sldBody.getBytes(Charset.forName("UTF-8")));
|
||||||
|
Document doc = builder.parse(stream);
|
||||||
|
result = this.checkSLD10Version(doc);
|
||||||
|
} catch (SAXException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkSLD10Version(File fileSLD) {
|
||||||
|
boolean result = false;
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
try {
|
||||||
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
Document doc = builder.parse(fileSLD);
|
||||||
|
result = this.checkSLD10Version(doc);
|
||||||
|
} catch (SAXException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkSLD10Version(Document doc) {
|
||||||
|
boolean result = false;
|
||||||
|
try {
|
||||||
|
XPathFactory xPathfactory = XPathFactory.newInstance();
|
||||||
|
XPath xpath = xPathfactory.newXPath();
|
||||||
|
XPathExpression expr = xpath.compile("//@version='1.0.0'");
|
||||||
|
result = (Boolean)expr.evaluate(doc, XPathConstants.BOOLEAN);
|
||||||
|
} catch (XPathExpressionException ex) {
|
||||||
|
LOGGER.error("Error parsing SLD file: " + ex);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package it.geosolutions.geoserver.decoder;
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer21;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer21;
|
||||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||||
@ -14,6 +13,8 @@ import junit.framework.Assert;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,6 +26,8 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
*/
|
*/
|
||||||
public class LayerDecoder21Test{
|
public class LayerDecoder21Test{
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(LayerDecoder21Test.class);
|
||||||
|
|
||||||
RESTLayer21 layer;
|
RESTLayer21 layer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -43,7 +46,7 @@ public class LayerDecoder21Test{
|
|||||||
public void testAuthorityURLs() {
|
public void testAuthorityURLs() {
|
||||||
List<GSAuthorityURLInfoEncoder> authorityURLs = layer
|
List<GSAuthorityURLInfoEncoder> authorityURLs = layer
|
||||||
.getEncodedAuthorityURLInfoList();
|
.getEncodedAuthorityURLInfoList();
|
||||||
System.out.println(authorityURLs.size());
|
LOGGER.debug("Number of authority URLs: " + authorityURLs.size());
|
||||||
Assert.assertEquals("authority1", authorityURLs.get(0).getName());
|
Assert.assertEquals("authority1", authorityURLs.get(0).getName());
|
||||||
Assert.assertEquals("http://www.authority1.org", authorityURLs.get(0)
|
Assert.assertEquals("http://www.authority1.org", authorityURLs.get(0)
|
||||||
.getHref());
|
.getHref());
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package it.geosolutions.geoserver.decoder;
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTStyleList;
|
||||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||||
|
|
||||||
@ -66,6 +67,14 @@ public class LayerDecoderTest {
|
|||||||
Assert.assertEquals("capitals", layer.getDefaultStyle());
|
Assert.assertEquals("capitals", layer.getDefaultStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStyles() {
|
||||||
|
RESTStyleList styles = layer.getStyles();
|
||||||
|
Assert.assertTrue(styles.size() == 2);
|
||||||
|
Assert.assertEquals("green", styles.get(0).getName());
|
||||||
|
Assert.assertEquals("blue", styles.get(1).getName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResourceUrl() {
|
public void testResourceUrl() {
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
|
|||||||
@ -23,7 +23,6 @@ package it.geosolutions.geoserver.decoder;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
|
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package it.geosolutions.geoserver.decoder;
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTBoundingBox;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
||||||
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
|
||||||
@ -81,6 +82,17 @@ public class ResourceDecoderTest {
|
|||||||
"http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
"http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNativeCRS() {
|
||||||
|
String expectedCrs = "GEOGCS[\"WGS 84\", \r\n DATUM[\"World Geodetic\n System 1984\", \r\n"
|
||||||
|
+" SPHEROID[\"WGS 84\", 6378137.0,\n 298.257223563,\n AUTHORITY[\"EPSG\",\"7030\"]], \r\n"
|
||||||
|
+" AUTHORITY[\"EPSG\",\"6326\"]], \r\n PRIMEM[\"Greenwich\", 0.0,\n AUTHORITY[\"EPSG\",\"8901\"]], \r\n"
|
||||||
|
+" UNIT[\"degree\", 0.017453292519943295], \r\n AXIS[\"Geodetic longitude\", EAST], \r\n"
|
||||||
|
+" AXIS[\"Geodetic\n latitude\", NORTH], \r\n AUTHORITY[\"EPSG\",\"4326\"]]";
|
||||||
|
|
||||||
|
Assert.assertEquals(expectedCrs, coverage.getNativeCRS());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRS() {
|
public void testCRS() {
|
||||||
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
||||||
@ -94,6 +106,28 @@ public class ResourceDecoderTest {
|
|||||||
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLatLonBoundingBox() {
|
||||||
|
RESTBoundingBox bbox = coverage.getLatLonBoundingBox();
|
||||||
|
Assert.assertTrue(bbox != null);
|
||||||
|
Assert.assertEquals("EPSG:4326", bbox.getCRS());
|
||||||
|
Assert.assertEquals(-180.0, bbox.getMinX(), 0);
|
||||||
|
Assert.assertEquals(180.0, bbox.getMaxX(), 0);
|
||||||
|
Assert.assertEquals(-90, bbox.getMinY(), 0);
|
||||||
|
Assert.assertEquals(90, bbox.getMaxY(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNativeBoundingBox() {
|
||||||
|
RESTBoundingBox bbox = coverage.getNativeBoundingBox();
|
||||||
|
Assert.assertTrue(bbox != null);
|
||||||
|
Assert.assertEquals("EPSG:4326", bbox.getCRS());
|
||||||
|
Assert.assertEquals(-180.0, bbox.getMinX(), 0);
|
||||||
|
Assert.assertEquals(180.0, bbox.getMaxX(), 0);
|
||||||
|
Assert.assertEquals(-90, bbox.getMinY(), 0);
|
||||||
|
Assert.assertEquals(90, bbox.getMaxY(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetadataLinkInfo() throws IOException {
|
public void testMetadataLinkInfo() throws IOException {
|
||||||
|
|
||||||
@ -122,7 +156,8 @@ public class ResourceDecoderTest {
|
|||||||
coverageDimension1.getDescription());
|
coverageDimension1.getDescription());
|
||||||
Assert.assertEquals("-inf", coverageDimension1.getRangeMin());
|
Assert.assertEquals("-inf", coverageDimension1.getRangeMin());
|
||||||
Assert.assertEquals("inf", coverageDimension1.getRangeMax());
|
Assert.assertEquals("inf", coverageDimension1.getRangeMax());
|
||||||
Assert.assertEquals("dobson units³", coverageDimension1.getUnit());
|
// Assert.assertEquals("dobson units", coverageDimension1.getUnit());
|
||||||
|
Assert.assertTrue(coverageDimension1.getUnit().startsWith("dobson units"));
|
||||||
Assert.assertEquals("REAL_32BITS", coverageDimension1.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", coverageDimension1.getDimensionTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.decoder;
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
package it.geosolutions.geoserver.decoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTWmsStore;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WmsStoreDecoderTest
|
||||||
|
*
|
||||||
|
* @author cip (cippinofg at gmail.com)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WmsStoreDecoderTest {
|
||||||
|
|
||||||
|
RESTWmsStore wmsstore;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() throws IOException {
|
||||||
|
File wmsstoreFile = new ClassPathResource("testdata/wmsstoreExample.xml").getFile();
|
||||||
|
String wmsstoreContent = FileUtils.readFileToString(wmsstoreFile);
|
||||||
|
wmsstore = RESTWmsStore.build(wmsstoreContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
Assert.assertEquals(wmsstore.getName(), "wmsstore001");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testType() {
|
||||||
|
Assert.assertEquals(wmsstore.getType(), "WMS");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnabled() {
|
||||||
|
Assert.assertEquals(wmsstore.getEnabled(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWorkspace() {
|
||||||
|
Assert.assertEquals(wmsstore.getWorkspaceName(), "ws001");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUseConnectionPooling() {
|
||||||
|
Assert.assertEquals(wmsstore.getUseConnectionPooling(),true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCapabilitiesURL() {
|
||||||
|
Assert.assertEquals(wmsstore.getCapabilitiesURL(), "http://myhost/geoserver/wms");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUser() {
|
||||||
|
Assert.assertEquals(wmsstore.getUser(), "admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPassword() {
|
||||||
|
Assert.assertEquals(wmsstore.getPassword(), "geoserver");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMaxConnections() {
|
||||||
|
Assert.assertEquals(wmsstore.getMaxConnections(), "6");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadTimeout() {
|
||||||
|
Assert.assertEquals(wmsstore.getReadTimeout(), "60");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConnectTimeout() {
|
||||||
|
Assert.assertEquals(wmsstore.getConnectTimeout(), "30");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -64,7 +64,7 @@ public class ConfigTest extends GeoserverRESTTest {
|
|||||||
LOGGER.info("Existing styles: " + reader.getStyles().getNames());
|
LOGGER.info("Existing styles: " + reader.getStyles().getNames());
|
||||||
String basename = FilenameUtils.getBaseName(sldFile.toString());
|
String basename = FilenameUtils.getBaseName(sldFile.toString());
|
||||||
LOGGER.info("Publishing style " + sldFile + " as " + basename);
|
LOGGER.info("Publishing style " + sldFile + " as " + basename);
|
||||||
assertTrue("Cound not publish " + sldFile, publisher.publishStyle(sldFile, basename));
|
assertTrue("Could not publish " + sldFile, publisher.publishStyle(sldFile, basename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple class for testing that the DeleteAllLayerGroups() method behaves correctly.
|
||||||
|
*
|
||||||
|
* @author Nicola Lagomarsini
|
||||||
|
*/
|
||||||
|
public class GeoServerRESTClassTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTTest.class);;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetLayerGroups() {
|
||||||
|
if(!enabled()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> groups = reader.getLayerGroups().getNames();
|
||||||
|
LOGGER.info("Found " + groups.size() + " layerGroups");
|
||||||
|
for (String groupName : groups) {
|
||||||
|
RESTLayerGroup group = reader.getLayerGroup(groupName);
|
||||||
|
if (groups != null) {
|
||||||
|
assertNotNull(group.getPublishedList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,6 +35,9 @@ import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +47,8 @@ import static org.junit.Assert.*;
|
|||||||
*/
|
*/
|
||||||
public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTReaderTest.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of getLayers method, of class GeoServerRESTReader.
|
* Test of getLayers method, of class GeoServerRESTReader.
|
||||||
*/
|
*/
|
||||||
@ -56,16 +61,16 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
// assertEquals(/*CHANGEME*/19, result.getChildren("layer").size()); // value in default gs installation
|
// assertEquals(/*CHANGEME*/19, result.getChildren("layer").size()); // value in default gs installation
|
||||||
|
|
||||||
// System.out.println("Layers:" + result.getChildren("layer").size());
|
// System.out.println("Layers:" + result.getChildren("layer").size());
|
||||||
System.out.println("Layers:" + result.size());
|
LOGGER.debug("Layers: " + result.size());
|
||||||
System.out.print("Layers:" );
|
// LOGGER.debug("Layers:" );
|
||||||
for (NameLinkElem shlayer : result) {
|
for (NameLinkElem shlayer : result) {
|
||||||
assertNotNull(shlayer.getName());
|
assertNotNull(shlayer.getName());
|
||||||
System.out.print(shlayer.getName() + " ");
|
LOGGER.debug(shlayer.getName() + " ");
|
||||||
}
|
}
|
||||||
// for (Element layer : (List<Element>)result.getChildren("layer")) {
|
// for (Element layer : (List<Element>)result.getChildren("layer")) {
|
||||||
// System.out.print(layer.getChildText("name") + " ");
|
// System.out.print(layer.getChildText("name") + " ");
|
||||||
// }
|
// }
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,25 +84,25 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(wslist);
|
assertNotNull(wslist);
|
||||||
// assertEquals(7, wslist.size()); // value in default gs installation
|
// assertEquals(7, wslist.size()); // value in default gs installation
|
||||||
|
|
||||||
System.out.println("Workspaces: " + wslist.size());
|
LOGGER.debug("Workspaces: " + wslist.size());
|
||||||
int dsnum = 0;
|
int dsnum = 0;
|
||||||
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
||||||
System.out.println("Getting DSlist for WS " + ws.getName() + "..." );
|
LOGGER.debug("Getting DSlist for WS " + ws.getName() + "..." );
|
||||||
RESTDataStoreList result = reader.getDatastores(ws.getName());
|
RESTDataStoreList result = reader.getDatastores(ws.getName());
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
dsnum += result.size();
|
dsnum += result.size();
|
||||||
for (NameLinkElem ds : result) {
|
for (NameLinkElem ds : result) {
|
||||||
assertNotNull(ds.getName());
|
assertNotNull(ds.getName());
|
||||||
System.out.print(ds.getName() + " " );
|
LOGGER.debug(ds.getName() + " " );
|
||||||
RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName());
|
RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName());
|
||||||
assertNotNull(datastore);
|
assertNotNull(datastore);
|
||||||
assertEquals(ds.getName(), datastore.getName());
|
assertEquals(ds.getName(), datastore.getName());
|
||||||
assertEquals(ws.getName(), datastore.getWorkspaceName());
|
assertEquals(ws.getName(), datastore.getWorkspaceName());
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
System.out.println("Datastores:" + dsnum); // value in default gs installation
|
LOGGER.debug("Datastores:" + dsnum); // value in default gs installation
|
||||||
// assertEquals(4, dsnum); // value in default gs installation
|
// assertEquals(4, dsnum); // value in default gs installation
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -116,7 +121,6 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
// assertEquals(7, wsnames.size()); // value in default gs installation
|
// assertEquals(7, wsnames.size()); // value in default gs installation
|
||||||
|
|
||||||
// System.out.println("Workspaces: " + wslist.size());
|
// System.out.println("Workspaces: " + wslist.size());
|
||||||
int dsnum = 0;
|
|
||||||
int wscnt = 0;
|
int wscnt = 0;
|
||||||
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
||||||
String wsname = wsnames.get(wscnt++);
|
String wsname = wsnames.get(wscnt++);
|
||||||
@ -158,14 +162,14 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(names);
|
assertNotNull(names);
|
||||||
assertEquals(names.size(), result.size()); // value in default gs installation
|
assertEquals(names.size(), result.size()); // value in default gs installation
|
||||||
|
|
||||||
System.out.println("Namespaces:" + result.size());
|
LOGGER.debug("Namespaces:" + result.size());
|
||||||
System.out.print("Namespaces:" );
|
LOGGER.debug("Namespaces:" );
|
||||||
int namesIdx = 0;
|
int namesIdx = 0;
|
||||||
for (RESTNamespaceList.RESTShortNamespace ns : result) {
|
for (RESTNamespaceList.RESTShortNamespace ns : result) {
|
||||||
assertEquals("namespace mismatch", names.get(namesIdx++), ns.getName());
|
assertEquals("namespace mismatch", names.get(namesIdx++), ns.getName());
|
||||||
System.out.print(ns.getName() + " " );
|
LOGGER.debug(ns.getName() + " " );
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,12 +183,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(names);
|
assertNotNull(names);
|
||||||
// assertEquals(7, names.size()); // value in default gs installation
|
// assertEquals(7, names.size()); // value in default gs installation
|
||||||
|
|
||||||
System.out.println("Namespaces:" + names.size());
|
LOGGER.debug("Namespaces:" + names.size());
|
||||||
System.out.print("Namespaces:");
|
LOGGER.debug("Namespaces:");
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
System.out.print(name + " ");
|
LOGGER.debug(name + " ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,12 +202,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(wslist);
|
assertNotNull(wslist);
|
||||||
// assertEquals(7, wslist.size()); // value in default gs installation
|
// assertEquals(7, wslist.size()); // value in default gs installation
|
||||||
|
|
||||||
System.out.println("Workspaces:" + wslist.size());
|
LOGGER.debug("Workspaces:" + wslist.size());
|
||||||
System.out.print("Workspaces:");
|
LOGGER.debug("Workspaces:");
|
||||||
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
|
||||||
System.out.print(ws.getName() + " ");
|
LOGGER.debug(ws.getName() + " ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
|
|
||||||
assertEquals(wslist.size(), reader.getWorkspaceNames().size());
|
assertEquals(wslist.size(), reader.getWorkspaceNames().size());
|
||||||
}
|
}
|
||||||
@ -218,12 +222,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(names);
|
assertNotNull(names);
|
||||||
// assertEquals(7, names.size()); // value in default gs installation
|
// assertEquals(7, names.size()); // value in default gs installation
|
||||||
|
|
||||||
System.out.println("Workspaces:" + names.size());
|
LOGGER.debug("Workspaces:" + names.size());
|
||||||
System.out.print("Workspaces:");
|
LOGGER.debug("Workspaces:");
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
System.out.print(name + " ");
|
LOGGER.debug(name + " ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
LOGGER.debug("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -41,7 +41,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.jdom.output.EscapeStrategy;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@ -98,7 +97,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
|
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
|
||||||
RESTUSER = getenv("gsmgr_restuser", "admin");
|
RESTUSER = getenv("gsmgr_restuser", "admin");
|
||||||
RESTPW = getenv("gsmgr_restpw", "geoserver");
|
RESTPW = getenv("gsmgr_restpw", "geoserver");
|
||||||
GS_VERSION = getenv("gsmgr_version", "2.4");
|
GS_VERSION = getenv("gsmgr_version", "2.8");
|
||||||
|
|
||||||
// These tests will destroy data, so let's make sure we do want to run them
|
// These tests will destroy data, so let's make sure we do want to run them
|
||||||
enabled = getenv("gsmgr_resttest", "false").equalsIgnoreCase("true");
|
enabled = getenv("gsmgr_resttest", "false").equalsIgnoreCase("true");
|
||||||
@ -136,17 +135,17 @@ public abstract class GeoserverRESTTest {
|
|||||||
+ RESTURL);
|
+ RESTURL);
|
||||||
}
|
}
|
||||||
} else if (existgs == false){
|
} else if (existgs == false){
|
||||||
System.out.println("Failing tests : geoserver not found");
|
LOGGER.debug("Failing tests : geoserver not found");
|
||||||
fail("GeoServer not found");
|
fail("GeoServer not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
GSVersionDecoder v=reader.getGeoserverVersion();
|
GSVersionDecoder v=reader.getGeoserverVersion();
|
||||||
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){
|
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){
|
||||||
System.out.println("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
|
LOGGER.debug("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
|
||||||
fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
|
fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Skipping tests ");
|
LOGGER.debug("Skipping tests ");
|
||||||
LOGGER.warn("Tests are disabled. Please read the documentation to enable them.");
|
LOGGER.warn("Tests are disabled. Please read the documentation to enable them.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +190,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
RESTLayerGroup group = reader.getLayerGroup(groupName);
|
RESTLayerGroup group = reader.getLayerGroup(groupName);
|
||||||
if (groups != null) {
|
if (groups != null) {
|
||||||
StringBuilder sb = new StringBuilder("Group: ").append(groupName).append(":");
|
StringBuilder sb = new StringBuilder("Group: ").append(groupName).append(":");
|
||||||
for (NameLinkElem layer : group.getLayerList()) {
|
for (NameLinkElem layer : group.getPublishedList()) {
|
||||||
sb.append(" ").append(layer);
|
sb.append(" ").append(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +225,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
// RESTCoverageStore store = reader.getCoverageStore(workspace, storename);
|
// RESTCoverageStore store = reader.getCoverageStore(workspace, storename);
|
||||||
|
|
||||||
LOGGER.warn("Deleting CoverageStore " + workspace + " : " + storename);
|
LOGGER.warn("Deleting CoverageStore " + workspace + " : " + storename);
|
||||||
boolean removed = publisher.removeCoverageStore(workspace, storename, false);
|
boolean removed = publisher.removeCoverageStore(workspace, storename, false, GeoServerRESTPublisher.Purge.METADATA);
|
||||||
assertTrue("CoverageStore not removed " + workspace + " : " + storename, removed);
|
assertTrue("CoverageStore not removed " + workspace + " : " + storename, removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +245,7 @@ public abstract class GeoserverRESTTest {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
LOGGER.warn("Deleting DataStore " + workspace + " : " + storename);
|
LOGGER.warn("Deleting DataStore " + workspace + " : " + storename);
|
||||||
boolean removed = publisher.removeDatastore(workspace, storename, false);
|
boolean removed = publisher.removeDatastore(workspace, storename, false, GeoServerRESTPublisher.Purge.METADATA);
|
||||||
assertTrue("DataStore not removed " + workspace + " : " + storename, removed);
|
assertTrue("DataStore not removed " + workspace + " : " + storename, removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -22,20 +22,17 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package it.geosolutions.geoserver.rest;
|
package it.geosolutions.geoserver.rest;
|
||||||
|
|
||||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
|
|
||||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,11 +43,11 @@ public class UtilTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchStyle() throws IOException {
|
public void testSearchStyle() throws IOException {
|
||||||
if (!enabled())
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
final String WORKSPACE = "testWorkspace";
|
final String WORKSPACE = "testWorkspace";
|
||||||
@ -67,7 +64,10 @@ public class UtilTest extends GeoserverRESTTest {
|
|||||||
// insert style in workspace
|
// insert style in workspace
|
||||||
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, STYLENAME));
|
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, STYLENAME));
|
||||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
assertFalse(reader.existsStyle(STYLENAME));
|
|
||||||
|
// GeoServer returns workspace specific names if hte name is not found as global
|
||||||
|
assertTrue(reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
assertEquals(0, reader.getStyles().size());
|
assertEquals(0, reader.getStyles().size());
|
||||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||||
assertEquals(1, Util.searchStyles(reader, STYLENAME).size());
|
assertEquals(1, Util.searchStyles(reader, STYLENAME).size());
|
||||||
@ -78,18 +78,29 @@ public class UtilTest extends GeoserverRESTTest {
|
|||||||
assertTrue(reader.existsStyle(STYLENAME));
|
assertTrue(reader.existsStyle(STYLENAME));
|
||||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
|
|
||||||
assertEquals(2, Util.searchStyles(reader, STYLENAME).size());
|
for(RESTStyle style : Util.searchStyles(reader, STYLENAME))
|
||||||
|
{
|
||||||
|
LOGGER.debug(style.getWorkspace() + " :: " + style.getName());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(1, reader.getStyles().size());
|
// there's a bug in geoserver here: the global style will include workspace info
|
||||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
// https://osgeo-org.atlassian.net/browse/GEOS-7498
|
||||||
|
// Commenting out all the concerned test code
|
||||||
|
|
||||||
List<RESTStyle> styles = Util.searchStyles(reader, STYLENAME);
|
// assertEquals(2, Util.searchStyles(reader, STYLENAME).size());
|
||||||
|
//
|
||||||
assertEquals(STYLENAME, styles.get(0).getName());
|
// assertEquals(1, reader.getStyles().size());
|
||||||
assertEquals(null, styles.get(0).getWorkspace()); // first one is the global one, if any
|
// assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||||
|
//
|
||||||
assertEquals(STYLENAME, styles.get(1).getName());
|
// List<RESTStyle> styles = Util.searchStyles(reader, STYLENAME);
|
||||||
assertEquals(WORKSPACE, styles.get(1).getWorkspace());
|
//
|
||||||
|
// assertEquals(STYLENAME, styles.get(0).getName());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // assertEquals(null, styles.get(0).getWorkspace()); // first one is the global one, if any
|
||||||
|
//
|
||||||
|
// assertEquals(STYLENAME, styles.get(1).getName());
|
||||||
|
// assertEquals(WORKSPACE, styles.get(1).getWorkspace());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.decoder.about;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author etj <etj at geo-solutions dot it>
|
||||||
|
*/
|
||||||
|
public class GSVersionDecoderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetGeoServer() {
|
||||||
|
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v22, GSVersionDecoder.VERSION.getVersion("2.2"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v22, GSVersionDecoder.VERSION.getVersion("2.2-SNAPSHOT"));
|
||||||
|
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v26, GSVersionDecoder.VERSION.getVersion("2.6"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v26, GSVersionDecoder.VERSION.getVersion("2.6-SNAPSHOT"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v26, GSVersionDecoder.VERSION.getVersion("2.6-ENTERPRISE"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.v26, GSVersionDecoder.VERSION.getVersion("2.6-ENTERPRISE-SNAPSHOT"));
|
||||||
|
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.ABOVE, GSVersionDecoder.VERSION.getVersion("2.21"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.ABOVE, GSVersionDecoder.VERSION.getVersion("2.21-SNAPSHOT"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.ABOVE, GSVersionDecoder.VERSION.getVersion("2.42"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.ABOVE, GSVersionDecoder.VERSION.getVersion("2.42-SNAPSHOT"));
|
||||||
|
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.UNRECOGNIZED, GSVersionDecoder.VERSION.getVersion("3.0"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.UNRECOGNIZED, GSVersionDecoder.VERSION.getVersion("anystring"));
|
||||||
|
assertEquals(GSVersionDecoder.VERSION.UNRECOGNIZED, GSVersionDecoder.VERSION.getVersion(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007-2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* GPLv3 + Classpath exception
|
* GPLv3 + Classpath exception
|
||||||
@ -19,7 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.encoder;
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.AuthorityURLInfo;
|
import it.geosolutions.geoserver.rest.encoder.authorityurl.AuthorityURLInfo;
|
||||||
@ -46,16 +45,21 @@ public class GSLayerEncoder21Test {
|
|||||||
public void setup() {
|
public void setup() {
|
||||||
layerEncoder = new GSLayerEncoder21();
|
layerEncoder = new GSLayerEncoder21();
|
||||||
layerEncoder.setAdvertised(true);
|
layerEncoder.setAdvertised(true);
|
||||||
layerEncoder.addAuthorityURL(new GSAuthorityURLInfoEncoder(
|
layerEncoder.addAuthorityURL(
|
||||||
|
new GSAuthorityURLInfoEncoder(
|
||||||
"authority1", "http://www.authority1.org"));
|
"authority1", "http://www.authority1.org"));
|
||||||
layerEncoder.addIdentifier(new GSIdentifierInfoEncoder("authority1",
|
layerEncoder.addIdentifier(
|
||||||
"identifier1"));
|
new GSIdentifierInfoEncoder(
|
||||||
layerEncoder.addAuthorityURL(new GSAuthorityURLInfoEncoder(
|
"authority1", "identifier1"));
|
||||||
|
layerEncoder.addAuthorityURL(
|
||||||
|
new GSAuthorityURLInfoEncoder(
|
||||||
"authority2", "http://www.authority2.org"));
|
"authority2", "http://www.authority2.org"));
|
||||||
layerEncoder.addIdentifier(new GSIdentifierInfoEncoder("authority2",
|
layerEncoder.addIdentifier(
|
||||||
"identifier2"));
|
new GSIdentifierInfoEncoder(
|
||||||
layerEncoder.addIdentifier(new GSIdentifierInfoEncoder("authority2",
|
"authority2", "identifier2"));
|
||||||
"additionalId"));
|
layerEncoder.addIdentifier(
|
||||||
|
new GSIdentifierInfoEncoder(
|
||||||
|
"authority2", "additionalId"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,34 +101,33 @@ public class GSLayerEncoder21Test {
|
|||||||
}else if(key.matches("identifiers")){
|
}else if(key.matches("identifiers")){
|
||||||
String jsonStr = el.getValue();
|
String jsonStr = el.getValue();
|
||||||
jsonStr = jsonStr.substring(2);
|
jsonStr = jsonStr.substring(2);
|
||||||
jsonStr = jsonStr.substring(0,
|
jsonStr = jsonStr.substring(0, jsonStr.length() - 3);
|
||||||
jsonStr.length() - 3);
|
|
||||||
|
|
||||||
String[] items = jsonStr.split("\\}(,)\\{");
|
String[] items = jsonStr.split("\\}(,)\\{");
|
||||||
|
|
||||||
String[] props1 = items[0].split(",");
|
String[] props1 = items[0].split(",");
|
||||||
String[] kvp1_1 = props1[0].split("\":");
|
String[] kvp1_1 = props1[0].split("\":");
|
||||||
String[] kvp1_2 = props1[1].split("\":");
|
String[] kvp1_2 = props1[1].split("\":");
|
||||||
Assert.assertEquals(IdentifierInfo.authority.name(), kvp1_1[0].replace("\"", ""));
|
Assert.assertEquals("idx0", IdentifierInfo.authority.name(), kvp1_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority2", kvp1_1[1].replace("\"", ""));
|
Assert.assertEquals("idx0", "authority1", kvp1_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp1_2[0].replace("\"", ""));
|
Assert.assertEquals("idx0", IdentifierInfo.identifier.name(), kvp1_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("identifier2", kvp1_2[1].replace("\"", ""));
|
Assert.assertEquals("idx0", "identifier1", kvp1_2[1].replace("\"", ""));
|
||||||
|
|
||||||
String[] props2 = items[1].split(",");
|
String[] props2 = items[1].split(",");
|
||||||
String[] kvp2_1 = props2[0].split("\":");
|
String[] kvp2_1 = props2[0].split("\":");
|
||||||
String[] kvp2_2 = props2[1].split("\":");
|
String[] kvp2_2 = props2[1].split("\":");
|
||||||
Assert.assertEquals(IdentifierInfo.authority.name(), kvp2_1[0].replace("\"", ""));
|
Assert.assertEquals("idx1", IdentifierInfo.authority.name(), kvp2_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority2", kvp2_1[1].replace("\"", ""));
|
Assert.assertEquals("idx1", "authority2", kvp2_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp2_2[0].replace("\"", ""));
|
Assert.assertEquals("idx1", IdentifierInfo.identifier.name(), kvp2_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("additionalId", kvp2_2[1].replace("\"", ""));
|
Assert.assertEquals("idx1", "identifier2", kvp2_2[1].replace("\"", ""));
|
||||||
|
|
||||||
String[] props3 = items[2].split(",");
|
String[] props3 = items[2].split(",");
|
||||||
String[] kvp3_1 = props3[0].split("\":");
|
String[] kvp3_1 = props3[0].split("\":");
|
||||||
String[] kvp3_2 = props3[1].split("\":");
|
String[] kvp3_2 = props3[1].split("\":");
|
||||||
Assert.assertEquals(IdentifierInfo.authority.name(), kvp3_1[0].replace("\"", ""));
|
Assert.assertEquals("idx2", IdentifierInfo.authority.name(), kvp3_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority1", kvp3_1[1].replace("\"", ""));
|
Assert.assertEquals("idx2", "authority2", kvp3_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp3_2[0].replace("\"", ""));
|
Assert.assertEquals("idx2", IdentifierInfo.identifier.name(), kvp3_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("identifier1", kvp3_2[1].replace("\"", ""));
|
Assert.assertEquals("idx2", "additionalId", kvp3_2[1].replace("\"", ""));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,4 +111,12 @@ public class GSLayerEncoderTest {
|
|||||||
Assert.assertEquals("authority1", el.getChild("authority").getValue());
|
Assert.assertEquals("authority1", el.getChild("authority").getValue());
|
||||||
Assert.assertEquals("identifier1", el.getChild("identifier").getValue());
|
Assert.assertEquals("identifier1", el.getChild("identifier").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultStyleWithWorkspace(){
|
||||||
|
layerEncoder.setDefaultStyle("ws", "style");
|
||||||
|
Element el = (Element) layerEncoder.getRoot().getChild("defaultStyle");
|
||||||
|
Assert.assertEquals("style", el.getChild("name").getValue());
|
||||||
|
Assert.assertEquals("ws", el.getChild("workspace").getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
groupWriter.addLayer("topp:boundaries");
|
groupWriter.addLayer("topp:boundaries");
|
||||||
groupWriter.addLayer("topp:cities");
|
groupWriter.addLayer("topp:cities");
|
||||||
assertTrue(publisher.createLayerGroup(groupName, groupWriter));
|
assertTrue(publisher.createLayerGroup(groupName, groupWriter));
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsLayerGroup(null, groupName));
|
||||||
try {
|
try {
|
||||||
RESTLayerGroup groupReader = reader.getLayerGroup(groupName);
|
RESTLayerGroup groupReader = reader.getLayerGroup(groupName);
|
||||||
assertNull(groupReader.getWorkspace());
|
assertNull(groupReader.getWorkspace());
|
||||||
@ -114,6 +116,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
assertTrue(publisher.removeLayerGroup(groupName));
|
assertTrue(publisher.removeLayerGroup(groupName));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsLayerGroup(null, groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +133,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
groupWriter.addLayer("topp:boundaries");
|
groupWriter.addLayer("topp:boundaries");
|
||||||
groupWriter.addLayer("topp:cities");
|
groupWriter.addLayer("topp:cities");
|
||||||
assertTrue(publisher.createLayerGroup("topp", groupName, groupWriter));
|
assertTrue(publisher.createLayerGroup("topp", groupName, groupWriter));
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsLayerGroup("topp", groupName));
|
||||||
try {
|
try {
|
||||||
RESTLayerGroup groupReader = reader.getLayerGroup("topp", groupName);
|
RESTLayerGroup groupReader = reader.getLayerGroup("topp", groupName);
|
||||||
assertEquals("topp", groupReader.getWorkspace());
|
assertEquals("topp", groupReader.getWorkspace());
|
||||||
@ -151,6 +157,8 @@ public class GSLayerGroupEncoderTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
assertTrue(publisher.removeLayerGroup("topp", groupName));
|
assertTrue(publisher.removeLayerGroup("topp", groupName));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsLayerGroup("topp", groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -126,12 +126,17 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
// setting dimensions (since gs-2.4.x)
|
// setting dimensions (since gs-2.4.x)
|
||||||
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
"dobson units³", "REAL_32BITS");
|
"dobson units", "REAL_32BITS");
|
||||||
encoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
encoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
|
||||||
|
encoder.setNativeCoverageName("Sample native name");
|
||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
|
|
||||||
|
Element nativeCoverageName = ElementUtils.contains(encoder.getRoot(), GSCoverageEncoder.NATIVECOVERAGENAME);
|
||||||
|
assertNotNull(nativeCoverageName);
|
||||||
|
assertEquals("Sample native name", nativeCoverageName.getText());
|
||||||
|
|
||||||
final Element el2=ElementUtils.contains(encoder.getRoot(),GSDimensionInfoEncoder.PRESENTATION);
|
final Element el2=ElementUtils.contains(encoder.getRoot(),GSDimensionInfoEncoder.PRESENTATION);
|
||||||
Assert.assertNotNull(el2);
|
Assert.assertNotNull(el2);
|
||||||
LOGGER.info("contains_key:"+el2.toString());
|
LOGGER.info("contains_key:"+el2.toString());
|
||||||
|
|||||||
@ -19,12 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.encoder.dimensions;
|
package it.geosolutions.geoserver.rest.encoder.dimensions;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -39,14 +33,14 @@ public class GSCoverageDimensionEncoderTest {
|
|||||||
@Test
|
@Test
|
||||||
public void coverageDimensionTest() {
|
public void coverageDimensionTest() {
|
||||||
GSCoverageDimensionEncoder encoder = new GSCoverageDimensionEncoder("GRAY_INDEX",
|
GSCoverageDimensionEncoder encoder = new GSCoverageDimensionEncoder("GRAY_INDEX",
|
||||||
"GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³",
|
"GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units",
|
||||||
"REAL_32BITS");
|
"REAL_32BITS");
|
||||||
|
|
||||||
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
Assert.assertEquals("-inf", encoder.getRangeMin());
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
Assert.assertEquals("inf", encoder.getRangeMax());
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
Assert.assertEquals("dobson units³", encoder.getUnit());
|
Assert.assertEquals("dobson units", encoder.getUnit());
|
||||||
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
|
|
||||||
Assert.assertTrue(encoder.delName());
|
Assert.assertTrue(encoder.delName());
|
||||||
@ -65,14 +59,14 @@ public class GSCoverageDimensionEncoderTest {
|
|||||||
encoder.setName("GRAY_INDEX");
|
encoder.setName("GRAY_INDEX");
|
||||||
encoder.setDescription("GridSampleDimension[-Infinity,Infinity]");
|
encoder.setDescription("GridSampleDimension[-Infinity,Infinity]");
|
||||||
encoder.setRange("-inf", "inf");
|
encoder.setRange("-inf", "inf");
|
||||||
encoder.setUnit("dobson units³");
|
encoder.setUnit("dobson units");
|
||||||
encoder.setDimensionType("REAL_32BITS");
|
encoder.setDimensionType("REAL_32BITS");
|
||||||
|
|
||||||
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
Assert.assertEquals("-inf", encoder.getRangeMin());
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
Assert.assertEquals("inf", encoder.getRangeMax());
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
Assert.assertEquals("dobson units³", encoder.getUnit());
|
Assert.assertEquals("dobson units", encoder.getUnit());
|
||||||
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2015 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* GPLv3 + Classpath exception
|
* GPLv3 + Classpath exception
|
||||||
@ -23,14 +23,11 @@ import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
|||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTResource;
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
@ -104,11 +101,12 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.addMetadataLinkInfo(metadatalink);
|
fte.addMetadataLinkInfo(metadatalink);
|
||||||
|
|
||||||
GSLayerEncoder layerEncoder = null;
|
GSLayerEncoder layerEncoder = null;
|
||||||
if (VERSION.getVersion(GS_VERSION).compareTo(VERSION.UNRECOGNIZED) > 0) {
|
if (VERSION.getVersion(GS_VERSION) == VERSION.UNRECOGNIZED ) {
|
||||||
layerEncoder = new GSLayerEncoder();
|
|
||||||
} else if (VERSION.getVersion(GS_VERSION).compareTo(VERSION.UNRECOGNIZED) == 0) {
|
|
||||||
layerEncoder = new GSLayerEncoder21();
|
layerEncoder = new GSLayerEncoder21();
|
||||||
|
} else {
|
||||||
|
layerEncoder = new GSLayerEncoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
layerEncoder.setEnabled(true);
|
layerEncoder.setEnabled(true);
|
||||||
layerEncoder.setQueryable(true);
|
layerEncoder.setQueryable(true);
|
||||||
layerEncoder.setAdvertised(true);
|
layerEncoder.setAdvertised(true);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2012 GeoSolutions S.A.S.
|
* Copyright (C) 2007 - 2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -37,6 +37,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test datastore handling (create, read and update):
|
* Test datastore handling (create, read and update):
|
||||||
@ -64,9 +65,11 @@ import static org.junit.Assert.*;
|
|||||||
* <li>Test all new values.
|
* <li>Test all new values.
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
|
* @deprecated ignored since dir of shapes cannot be uploaded
|
||||||
* @author Oscar Fonts
|
* @author Oscar Fonts
|
||||||
*/
|
*/
|
||||||
public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
@Ignore
|
||||||
|
public class DirShapeStoreManagerTest extends StoreIntegrationTest {
|
||||||
|
|
||||||
private static final String WS_NAME = DEFAULT_WS;
|
private static final String WS_NAME = DEFAULT_WS;
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
|||||||
|
|
||||||
private static URL LOCATION_2;
|
private static URL LOCATION_2;
|
||||||
|
|
||||||
public GeoserverRESTDatastoreManagerTest() throws Exception {
|
public DirShapeStoreManagerTest() throws Exception {
|
||||||
super(false);
|
super(false);
|
||||||
LOCATION_1 = new URL("file:data/shapefiles/");
|
LOCATION_1 = new URL("file:data/shapefiles/");
|
||||||
LOCATION_2 = new URL("file:data/2");
|
LOCATION_2 = new URL("file:data/2");
|
||||||
@ -104,7 +107,7 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
|||||||
// Create a directory of spatial files with default parameters
|
// Create a directory of spatial files with default parameters
|
||||||
GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(
|
GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(
|
||||||
DS_NAME, LOCATION_1);
|
DS_NAME, LOCATION_1);
|
||||||
assertTrue(manager.getStoreManager().create(WS_NAME, create));
|
assertTrue("Could not create create store", manager.getStoreManager().create(WS_NAME, create));
|
||||||
|
|
||||||
// Read the store from server; check all parameter values
|
// Read the store from server; check all parameter values
|
||||||
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
|
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
|
||||||
@ -131,14 +134,14 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
|
|||||||
update.setCacheAndReuseMemoryMaps(false);
|
update.setCacheAndReuseMemoryMaps(false);
|
||||||
|
|
||||||
// update the store
|
// update the store
|
||||||
assertTrue(manager.getStoreManager().update(WS_NAME, update));
|
assertTrue("Could not update store " + WS_NAME, manager.getStoreManager().update(WS_NAME, update));
|
||||||
|
|
||||||
// Read again, check that all parameters have changed
|
// Read again, check that all parameters have changed
|
||||||
read = reader.getDatastore(WS_NAME, DS_NAME);
|
read = reader.getDatastore(WS_NAME, DS_NAME);
|
||||||
assertEquals(read.getWorkspaceName(), WS_NAME);
|
assertEquals("Bad workspace name", read.getWorkspaceName(), WS_NAME);
|
||||||
assertEquals(read.isEnabled(), false);
|
assertEquals("Datastore should not be enabled", read.isEnabled(), false);
|
||||||
connParams = read.getConnectionParameters();
|
connParams = read.getConnectionParameters();
|
||||||
assertEquals(connParams.get("url"), LOCATION_2.toString());
|
assertEquals("Bad URL", connParams.get("url"), LOCATION_2.toString());
|
||||||
assertEquals(connParams.get("charset"), "UTF-8");
|
assertEquals(connParams.get("charset"), "UTF-8");
|
||||||
assertEquals(connParams.get("create spatial index"), "false");
|
assertEquals(connParams.get("create spatial index"), "false");
|
||||||
assertEquals(connParams.get("memory mapped buffer"), "true");
|
assertEquals(connParams.get("memory mapped buffer"), "true");
|
||||||
@ -11,12 +11,15 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Iterator;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
@ -34,6 +37,19 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoServerRESTImageMosaicManagerTest.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoServerRESTImageMosaicManagerTest.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test is ignored because it cannot be repeated.
|
||||||
|
* Once the test is run, the index is created for the granules, but it won't be removed,
|
||||||
|
* so next run will still find all the granules in the db.
|
||||||
|
*
|
||||||
|
* Tried with purge=metadata when removing datastores, but removing indices
|
||||||
|
* in shapefiles is not supported by geoserver (which throws an UnsupportedOperation)
|
||||||
|
* Adding a datastore.properties for using an h2 DB won't work as well, because
|
||||||
|
* only postgis is supported at lower levels.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void createAndDelete() throws Exception{
|
public void createAndDelete() throws Exception{
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
@ -41,6 +57,8 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
|
assertFalse("Workspace was not properly removed", reader.existsNamespace(DEFAULT_WS) );
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
|
|
||||||
// crea the manager
|
// crea the manager
|
||||||
@ -52,6 +70,8 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
final String coverageName = "mosaic";
|
final String coverageName = "mosaic";
|
||||||
final String format = "imagemosaic";
|
final String format = "imagemosaic";
|
||||||
|
|
||||||
|
assertFalse("CoverageStore was not properly removed", reader.existsCoveragestore(DEFAULT_WS, coverageStoreName));
|
||||||
|
|
||||||
// upload the mosaic
|
// upload the mosaic
|
||||||
boolean create=manager.create(DEFAULT_WS, coverageStoreName,new ClassPathResource("testdata/granules/mosaic.zip").getFile().getAbsolutePath());
|
boolean create=manager.create(DEFAULT_WS, coverageStoreName,new ClassPathResource("testdata/granules/mosaic.zip").getFile().getAbsolutePath());
|
||||||
assertTrue(create);
|
assertTrue(create);
|
||||||
@ -64,10 +84,15 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
assertNotNull(indexFormat);
|
assertNotNull(indexFormat);
|
||||||
assertFalse(indexFormat.isEmpty());
|
assertFalse(indexFormat.isEmpty());
|
||||||
assertEquals(5, indexFormat.size());
|
assertEquals(5, indexFormat.size());
|
||||||
Iterator<RESTStructuredCoverageIndexAttribute> iterator = indexFormat.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
Set<String> allowedDateFormats = new HashSet<String>(Arrays.asList(
|
||||||
final RESTStructuredCoverageIndexAttribute element = iterator.next();
|
"java.util.Date", // shapefile
|
||||||
|
"java.sql.Timestamp")); // h2
|
||||||
|
|
||||||
|
for (RESTStructuredCoverageIndexAttribute element : indexFormat) {
|
||||||
|
|
||||||
final String elementName = element.getName();
|
final String elementName = element.getName();
|
||||||
|
|
||||||
if (elementName.equals("location")) {
|
if (elementName.equals("location")) {
|
||||||
assertEquals("0", element.getMinOccurs());
|
assertEquals("0", element.getMinOccurs());
|
||||||
assertEquals("1", element.getMaxOccurs());
|
assertEquals("1", element.getMaxOccurs());
|
||||||
@ -77,7 +102,7 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
assertEquals("0", element.getMinOccurs());
|
assertEquals("0", element.getMinOccurs());
|
||||||
assertEquals("1", element.getMaxOccurs());
|
assertEquals("1", element.getMaxOccurs());
|
||||||
assertEquals("true", element.getNillable());
|
assertEquals("true", element.getNillable());
|
||||||
assertEquals("java.util.Date", element.getBinding());
|
assertTrue(allowedDateFormats.contains(element.getBinding()));
|
||||||
} else if (elementName.equals("date")) {
|
} else if (elementName.equals("date")) {
|
||||||
assertEquals("0", element.getMinOccurs());
|
assertEquals("0", element.getMinOccurs());
|
||||||
assertEquals("1", element.getMaxOccurs());
|
assertEquals("1", element.getMaxOccurs());
|
||||||
@ -113,7 +138,12 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
// get with no paging
|
// get with no paging
|
||||||
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(4, granulesList.size());
|
|
||||||
|
for (RESTStructuredCoverageGranule g : granulesList) {
|
||||||
|
LOGGER.info(" GRANULE before delete: " + g);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("At first insertion 4 granules are expected", 4, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
@ -148,7 +178,12 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
assertEquals(4, granulesList.size());
|
|
||||||
|
for (RESTStructuredCoverageGranule g : granulesList) {
|
||||||
|
LOGGER.info(" GRANULE: " + g);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("After deletion only 3 granules are expected", 3, granulesList.size());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
@ -158,7 +193,7 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, null, null, null);
|
granulesList = manager.getGranules(DEFAULT_WS, coverageStoreName, coverageName, null, null, null);
|
||||||
assertNotNull(granulesList);
|
assertNotNull(granulesList);
|
||||||
assertEquals(4, granulesList.size());
|
assertEquals("After harvest 4 granules are expected", 4, granulesList.size());
|
||||||
assertFalse(granulesList.isEmpty());
|
assertFalse(granulesList.isEmpty());
|
||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|||||||
@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.publisher;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType;
|
||||||
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testcase for publishing layers on geoserver.
|
||||||
|
* We need a running GeoServer to properly run the tests.
|
||||||
|
* If such geoserver instance cannot be contacted, tests will be skipped.
|
||||||
|
*
|
||||||
|
* @author Lennart Karsten - lennart.k@thinking-aloud.eu
|
||||||
|
* inspired by: Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
|
*/
|
||||||
|
public class GeoserverRESTArcGridTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTArcGridTest.class);
|
||||||
|
|
||||||
|
private String storeName = "testRESTStoreArcGrid";
|
||||||
|
private String layerName = "resttestdem";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExternalArcGrid() throws FileNotFoundException, IOException {
|
||||||
|
if (!enabled()) return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
File arcgrid = new ClassPathResource("testdata/resttestdem.asc").getFile();
|
||||||
|
|
||||||
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
|
||||||
|
// known state?
|
||||||
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// Test exists
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean pc = publisher.publishExternalArcGrid(DEFAULT_WS, storeName, arcgrid, layerName,"EPSG:4326",ProjectionPolicy.FORCE_DECLARED,"raster");
|
||||||
|
assertTrue("publish() failed", pc);
|
||||||
|
assertTrue(existsLayer(layerName));
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
|
LOGGER.info("Published "+pc);
|
||||||
|
RESTCoverageStore reloadedCS = reader.getCoverageStore(DEFAULT_WS, storeName);
|
||||||
|
|
||||||
|
assertEquals(storeName, reloadedCS.getName());
|
||||||
|
assertEquals(DEFAULT_WS, reloadedCS.getWorkspaceName());
|
||||||
|
|
||||||
|
//test delete
|
||||||
|
assertTrue("Unpublish() failed", publisher.unpublishCoverage(DEFAULT_WS, storeName, layerName));
|
||||||
|
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName));
|
||||||
|
assertFalse("Bad unpublish()", publisher.unpublishCoverage(DEFAULT_WS, storeName, layerName));
|
||||||
|
assertFalse(existsLayer(layerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testArcGrid() throws FileNotFoundException, IOException {
|
||||||
|
if (!enabled()) return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
File arcgrid = new ClassPathResource("testdata/resttestdem.asc").getFile();
|
||||||
|
|
||||||
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
// known state?
|
||||||
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean pub = publisher.publishArcGrid(DEFAULT_WS, storeName, arcgrid);
|
||||||
|
|
||||||
|
assertNotNull("publish() failed", pub);
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||||
|
|
||||||
|
pub = publisher.publishArcGrid(DEFAULT_WS, storeName+"another", "layername", arcgrid);
|
||||||
|
|
||||||
|
assertTrue("publish() failed", pub);
|
||||||
|
|
||||||
|
double[] bbox = {-103.85, 44.38, -103.62, 44.50};
|
||||||
|
pub = publisher.publishArcGrid(DEFAULT_WS, storeName+"another_complex", storeName+"another_complex", arcgrid, "EPSG:4326", ProjectionPolicy.REPROJECT_TO_DECLARED, "raster", bbox);
|
||||||
|
|
||||||
|
assertTrue("publish() failed", pub);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testArcGridWithStyleInWorkspace() throws IOException {
|
||||||
|
if (!enabled()) return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
File arcgrid = new ClassPathResource("testdata/resttestdem.asc").getFile();
|
||||||
|
|
||||||
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
File sldFile = new ClassPathResource("testdata/raster.sld").getFile();
|
||||||
|
|
||||||
|
|
||||||
|
// insert style
|
||||||
|
assertTrue(publisher.publishStyleInWorkspace(DEFAULT_WS, sldFile, "mystyle"));
|
||||||
|
assertTrue(reader.existsStyle(DEFAULT_WS, "mystyle"));
|
||||||
|
|
||||||
|
// known state?
|
||||||
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean pub = publisher.publishArcGrid(DEFAULT_WS, storeName, storeName,
|
||||||
|
arcgrid, "EPSG:4326", ProjectionPolicy.FORCE_DECLARED, DEFAULT_WS + ":" + "mystyle", null);
|
||||||
|
|
||||||
|
assertNotNull("publish() failed", pub);
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||||
|
RESTLayer layer = reader.getLayer(DEFAULT_WS, storeName);
|
||||||
|
assertEquals(DEFAULT_WS + ":mystyle", layer.getDefaultStyle());
|
||||||
|
assertEquals(DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReloadCoverageStore() throws FileNotFoundException, IOException {
|
||||||
|
if (!enabled()) return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
File arcgrid = new ClassPathResource("testdata/resttestdem.asc").getFile();
|
||||||
|
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean pub = publisher.publishArcGrid(DEFAULT_WS, storeName, arcgrid);
|
||||||
|
|
||||||
|
assertNotNull("publish() failed", pub);
|
||||||
|
|
||||||
|
// test reload
|
||||||
|
assertTrue(publisher.reloadStore(DEFAULT_WS, storeName, StoreType.COVERAGESTORES));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,9 +25,14 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.publisher;
|
package it.geosolutions.geoserver.rest.publisher;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -35,7 +40,6 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
@ -68,10 +72,14 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
// known state?
|
// known state?
|
||||||
assertFalse("Cleanup failed", existsLayer(layerName));
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// Test exists
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
boolean pc = publisher.publishExternalGeoTIFF(DEFAULT_WS, storeName, geotiff, layerName,"EPSG:4326",ProjectionPolicy.FORCE_DECLARED,"raster");
|
boolean pc = publisher.publishExternalGeoTIFF(DEFAULT_WS, storeName, geotiff, layerName,"EPSG:4326",ProjectionPolicy.FORCE_DECLARED,"raster");
|
||||||
assertTrue("publish() failed", pc);
|
assertTrue("publish() failed", pc);
|
||||||
assertTrue(existsLayer(layerName));
|
assertTrue(existsLayer(layerName));
|
||||||
|
assertFalse(reader.existsLayer(DEFAULT_WS, layerName));
|
||||||
LOGGER.info("Published "+pc);
|
LOGGER.info("Published "+pc);
|
||||||
RESTCoverageStore reloadedCS = reader.getCoverageStore(DEFAULT_WS, storeName);
|
RESTCoverageStore reloadedCS = reader.getCoverageStore(DEFAULT_WS, storeName);
|
||||||
|
|
||||||
@ -102,6 +110,9 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
boolean pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName, geotiff);
|
boolean pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName, geotiff);
|
||||||
|
|
||||||
assertNotNull("publish() failed", pub);
|
assertNotNull("publish() failed", pub);
|
||||||
|
// Test exists
|
||||||
|
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||||
|
|
||||||
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another", "layername", geotiff);
|
pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another", "layername", geotiff);
|
||||||
|
|
||||||
@ -114,8 +125,43 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
//delete
|
//delete
|
||||||
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
|
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName,true));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGeoTiffWithStyleInWorkspace() throws IOException
|
||||||
|
{
|
||||||
|
if (!enabled()) return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
File geotiff = new ClassPathResource("testdata/resttestdem.tif").getFile();
|
||||||
|
|
||||||
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
File sldFile = new ClassPathResource("testdata/raster.sld").getFile();
|
||||||
|
|
||||||
|
|
||||||
|
// insert style
|
||||||
|
assertTrue(publisher.publishStyleInWorkspace(DEFAULT_WS, sldFile, "mystyle"));
|
||||||
|
assertTrue(reader.existsStyle(DEFAULT_WS, "mystyle"));
|
||||||
|
|
||||||
|
// known state?
|
||||||
|
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName, storeName,
|
||||||
|
geotiff, "EPSG:4326", ProjectionPolicy.FORCE_DECLARED, DEFAULT_WS + ":" + "mystyle", null);
|
||||||
|
|
||||||
|
assertNotNull("publish() failed", pub);
|
||||||
|
// Test exists
|
||||||
|
assertTrue("New coverage not found", reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||||
|
assertTrue("New Store not found", reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||||
|
RESTLayer layer = reader.getLayer(DEFAULT_WS, storeName);
|
||||||
|
assertEquals("Bad default style", DEFAULT_WS + ":mystyle", layer.getDefaultStyle());
|
||||||
|
assertEquals("Bad workspace for style", DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReloadCoverageStore() throws FileNotFoundException, IOException {
|
public void testReloadCoverageStore() throws FileNotFoundException, IOException {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ package it.geosolutions.geoserver.rest.publisher;
|
|||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList;
|
||||||
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
@ -40,6 +41,8 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Pr
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.NameValuePair;
|
import org.apache.commons.httpclient.NameValuePair;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -77,7 +80,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImageMosaicTest.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImageMosaicTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateDeleteImageMosaicDatastore() {
|
public void testCreateDeleteImageMosaicDatastore() throws MalformedURLException, UnsupportedEncodingException {
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,7 +116,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
if (v.compareTo(GSVersionDecoder.VERSION.v24)>=0){
|
if (v.compareTo(GSVersionDecoder.VERSION.v24)>=0){
|
||||||
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
"dobson units³", "REAL_32BITS");
|
"dobson units", "REAL_32BITS");
|
||||||
coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +172,14 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
// Get a Granule
|
||||||
|
String coverageName = "time_geotiff";
|
||||||
|
RESTStructuredCoverageGranulesList granules = reader.getGranules(wsName, coverageStoreName, coverageName, null, null, null);
|
||||||
|
String granuleId = granules.get(0).getFid();
|
||||||
|
// Test Granule Exists
|
||||||
|
assertTrue(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId));
|
||||||
|
// test a Granule does not exists
|
||||||
|
assertFalse(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId.substring(0, granuleId.indexOf(".")) + "." + granules.size() + 1));
|
||||||
|
|
||||||
// removing recursively coveragestore
|
// removing recursively coveragestore
|
||||||
boolean removed = publisher.removeCoverageStore(coverageStore.getWorkspaceName(), coverageStore.getName(), true);
|
boolean removed = publisher.removeCoverageStore(coverageStore.getWorkspaceName(), coverageStore.getName(), true);
|
||||||
|
|||||||
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.geosolutions.geoserver.rest.publisher;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testcase for publishing layers on geoserver.
|
||||||
|
* We need a running GeoServer to properly run the tests.
|
||||||
|
* If such geoserver instance cannot be contacted, tests will be skipped.
|
||||||
|
*
|
||||||
|
* @author Alessio Fabiani, GeoSolutions S.A.S.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GeoserverRESTImporterTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImporterTest.class);
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShapeFileImport() throws Exception {
|
||||||
|
if (!enabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Creates a new Importer Context and gets back the ID
|
||||||
|
int i = publisher.postNewImport();
|
||||||
|
|
||||||
|
// Attaches to the new Importer Context a Task pointing to a shapefile's zip archive
|
||||||
|
String data = new ClassPathResource("testdata/test_noepsg.zip").getFile().getAbsolutePath();
|
||||||
|
int t = publisher.postNewTaskAsMultiPartForm(i, data);
|
||||||
|
|
||||||
|
// Check that the Task was actually created and that the CRS has not recognized in this case
|
||||||
|
JSONObject task = publisher.getTask(i, t);
|
||||||
|
//assertEquals("NO_CRS", task.getString("state"));
|
||||||
|
assertEquals("READY", task.getString("state"));
|
||||||
|
|
||||||
|
// Prepare the JSON String instructing the Task about the SRS to use
|
||||||
|
String json = "{\"layer\":{\"srs\":\"EPSG:26713\"}}";
|
||||||
|
|
||||||
|
// Performing the Task update
|
||||||
|
publisher.putTaskLayer(i, t, json);
|
||||||
|
|
||||||
|
// Double check that the Task is in the READY state
|
||||||
|
task = publisher.getTask(i, t);
|
||||||
|
assertEquals("READY", task.getString("state"));
|
||||||
|
assertEquals("nurc_10m_populated_places", task.getJSONObject("layer").getJSONObject("style").getString("name"));
|
||||||
|
|
||||||
|
// Prepare the JSON String instructing the Task avout the SLD to use for the new Layer
|
||||||
|
json = "{\"layer\":{\"style\":{\"name\": \"point\"}}}";
|
||||||
|
|
||||||
|
// Performing the Task update
|
||||||
|
publisher.putTaskLayer(i, t,json);
|
||||||
|
|
||||||
|
// Double check that the Task is in the READY state and that the Style has been correctly updated
|
||||||
|
task = publisher.getTask(i, t);
|
||||||
|
assertEquals("READY", task.getString("state"));
|
||||||
|
assertEquals("point", task.getJSONObject("layer").getJSONObject("style").getString("name"));
|
||||||
|
|
||||||
|
// Finally starts the Import ...
|
||||||
|
publisher.postImport(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -58,6 +58,10 @@ public class GeoserverRESTNamespaceTest extends GeoserverRESTTest {
|
|||||||
assertTrue(publisher.createNamespace("NS2", URI.create("http://b.example.com")));
|
assertTrue(publisher.createNamespace("NS2", URI.create("http://b.example.com")));
|
||||||
assertEquals(2, reader.getNamespaces().size());
|
assertEquals(2, reader.getNamespaces().size());
|
||||||
|
|
||||||
|
// Test Namespace exists
|
||||||
|
assertTrue(reader.existsNamespace("NS1"));
|
||||||
|
assertTrue(reader.existsNamespace("NS2"));
|
||||||
|
|
||||||
// When creating a namespace, its associated workspace will be automatically created:
|
// When creating a namespace, its associated workspace will be automatically created:
|
||||||
assertEquals(2, reader.getWorkspaces().size());
|
assertEquals(2, reader.getWorkspaces().size());
|
||||||
|
|
||||||
@ -96,5 +100,7 @@ public class GeoserverRESTNamespaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
assertEquals(0, reader.getNamespaces().size());
|
assertEquals(0, reader.getNamespaces().size());
|
||||||
assertEquals(0, reader.getWorkspaces().size());
|
assertEquals(0, reader.getWorkspaces().size());
|
||||||
|
// Test non existens
|
||||||
|
assertFalse(reader.existsNamespace("NS1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,10 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
assertTrue("publish() failed", published);
|
assertTrue("publish() failed", published);
|
||||||
assertTrue(existsLayer(layerName));
|
assertTrue(existsLayer(layerName));
|
||||||
|
// Test exists datastore
|
||||||
|
assertTrue(reader.existsDatastore(DEFAULT_WS, storeName));
|
||||||
|
// Test exists featuretype
|
||||||
|
assertTrue(reader.existsFeatureType(DEFAULT_WS, storeName, layerName));
|
||||||
|
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
|
|
||||||
@ -111,10 +115,16 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
assertTrue("Unpublish() failed", ok);
|
assertTrue("Unpublish() failed", ok);
|
||||||
assertFalse(existsLayer(layerName));
|
assertFalse(existsLayer(layerName));
|
||||||
|
|
||||||
|
// Test not exists featuretype
|
||||||
|
assertFalse(reader.existsFeatureType(DEFAULT_WS, storeName, layerName));
|
||||||
|
|
||||||
// remove also datastore
|
// remove also datastore
|
||||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,false);
|
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,false);
|
||||||
assertTrue("removeDatastore() failed", dsRemoved);
|
assertTrue("removeDatastore() failed", dsRemoved);
|
||||||
|
|
||||||
|
// Test not exists datastore
|
||||||
|
assertFalse(reader.existsDatastore(DEFAULT_WS, storeName));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -231,6 +241,52 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
|||||||
assertFalse(reader.existsStyle(styleName));
|
assertFalse(reader.existsStyle(styleName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPublishDeleteStyledInWorkspaceShapeZip() throws FileNotFoundException, IOException {
|
||||||
|
if (!enabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deleteAllWorkspacesRecursively();
|
||||||
|
// Assume.assumeTrue(enabled);
|
||||||
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
|
String ns = "geosolutions";
|
||||||
|
String storeName = "resttestshp";
|
||||||
|
String layerName = "cities";
|
||||||
|
final String styleName = "restteststyle";
|
||||||
|
|
||||||
|
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||||
|
publisher.removeDatastore(DEFAULT_WS, storeName,true);
|
||||||
|
publisher.removeStyleInWorkspace(DEFAULT_WS, styleName);
|
||||||
|
|
||||||
|
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||||
|
|
||||||
|
// insert style
|
||||||
|
boolean sldpublished = publisher.publishStyleInWorkspace(DEFAULT_WS, sldFile); // Will take the name from sld contents
|
||||||
|
assertTrue("style publish() failed", sldpublished);
|
||||||
|
assertTrue(reader.existsStyle(DEFAULT_WS, styleName));
|
||||||
|
|
||||||
|
// test insert
|
||||||
|
boolean published = publisher.publishShp(ns, storeName, layerName, zipFile, "EPSG:4326", DEFAULT_WS + ":" + styleName);
|
||||||
|
assertTrue("publish() failed", published);
|
||||||
|
assertTrue(existsLayer(layerName));
|
||||||
|
|
||||||
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
|
// RESTLayer layerDecoder = new RESTLayer(layer);
|
||||||
|
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||||
|
assertEquals("Style not assigned properly", DEFAULT_WS + ":" + styleName, layer.getDefaultStyle());
|
||||||
|
assertEquals("Style not assigned properly", DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||||
|
|
||||||
|
// remove also datastore
|
||||||
|
boolean dsRemoved = publisher.removeDatastore(ns, storeName,true);
|
||||||
|
assertTrue("removeDatastore() failed", dsRemoved);
|
||||||
|
|
||||||
|
//test delete style
|
||||||
|
boolean oksld = publisher.removeStyleInWorkspace(DEFAULT_WS, styleName);
|
||||||
|
assertTrue("Unpublish() failed", oksld);
|
||||||
|
assertFalse(reader.existsStyle(styleName));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishDeleteShapeZipWithParams() throws FileNotFoundException, IOException {
|
public void testPublishDeleteShapeZipWithParams() throws FileNotFoundException, IOException {
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007,2013 GeoSolutions S.A.S.
|
* Copyright (C) 2007-2016 GeoSolutions S.A.S.
|
||||||
* http://www.geo-solutions.it
|
* http://www.geo-solutions.it
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -26,8 +26,6 @@
|
|||||||
package it.geosolutions.geoserver.rest.publisher;
|
package it.geosolutions.geoserver.rest.publisher;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
|
|
||||||
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
|
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
|
||||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||||
@ -57,20 +55,20 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
*/
|
*/
|
||||||
public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory
|
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTStyleTest.class);
|
||||||
.getLogger(GeoserverRESTStyleTest.class);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStyles() throws IOException {
|
public void testStyles() throws IOException
|
||||||
if (!enabled())
|
{
|
||||||
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
assertEquals(0, reader.getStyles().size());
|
assertEquals(0, reader.getStyles().size());
|
||||||
|
|
||||||
final String STYLENAME = "restteststyle";
|
final String STYLENAME = "restteststyle";
|
||||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||||
.getFile();
|
|
||||||
|
|
||||||
// insert style
|
// insert style
|
||||||
assertTrue(publisher.publishStyle(sldFile));
|
assertTrue(publisher.publishStyle(sldFile));
|
||||||
@ -79,6 +77,15 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
assertFalse(publisher.publishStyle(sldFile));
|
assertFalse(publisher.publishStyle(sldFile));
|
||||||
assertTrue(reader.existsStyle(STYLENAME));
|
assertTrue(reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
|
// insert style v110
|
||||||
|
final String STYLENAMEV110 = "restteststyleV110";
|
||||||
|
File sldFileV110 = new ClassPathResource("testdata/" + STYLENAMEV110 + ".sld").getFile();
|
||||||
|
|
||||||
|
assertTrue(publisher.publishStyle(sldFileV110, STYLENAMEV110, true));
|
||||||
|
assertTrue(reader.existsStyle(STYLENAMEV110));
|
||||||
|
|
||||||
|
assertFalse(publisher.publishStyle(sldFileV110, STYLENAMEV110, true));
|
||||||
|
|
||||||
RESTStyle style = reader.getStyle(STYLENAME);
|
RESTStyle style = reader.getStyle(STYLENAME);
|
||||||
assertEquals(STYLENAME, style.getName());
|
assertEquals(STYLENAME, style.getName());
|
||||||
assertNull(style.getWorkspace());
|
assertNull(style.getWorkspace());
|
||||||
@ -89,15 +96,12 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||||
assertNotNull(styleEl);
|
assertNotNull(styleEl);
|
||||||
|
|
||||||
Namespace SLDNS = Namespace.getNamespace("sld",
|
Namespace SLDNS = Namespace.getNamespace("sld", "http://www.opengis.net/sld");
|
||||||
"http://www.opengis.net/sld");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||||
.getChild("Name", SLDNS).getText());
|
.getChild("Name", SLDNS).getText());
|
||||||
assertEquals(
|
assertEquals("STYLE FOR TESTING PURPOSES",
|
||||||
"STYLE FOR TESTING PURPOSES",
|
|
||||||
styleEl.getChild("NamedLayer", SLDNS)
|
styleEl.getChild("NamedLayer", SLDNS)
|
||||||
.getChild("UserStyle", SLDNS)
|
.getChild("UserStyle", SLDNS)
|
||||||
.getChild("Title", SLDNS).getText());
|
.getChild("Title", SLDNS).getText());
|
||||||
@ -106,11 +110,11 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assertEquals(1475, sld.length());
|
// assertEquals(1475, sld.length());
|
||||||
|
assertEquals(2, reader.getStyles().size());
|
||||||
assertEquals(1, reader.getStyles().size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanupTestStyle(final String styleName) {
|
protected void cleanupTestStyle(final String styleName)
|
||||||
|
{
|
||||||
// dry run delete to work in a known state
|
// dry run delete to work in a known state
|
||||||
if (reader.existsStyle(styleName)) {
|
if (reader.existsStyle(styleName)) {
|
||||||
LOGGER.info("Clearing stale test style " + styleName);
|
LOGGER.info("Clearing stale test style " + styleName);
|
||||||
@ -134,8 +138,13 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||||
.getFile();
|
.getFile();
|
||||||
|
|
||||||
|
final String STYLENAMEV110 = "restteststyleV110";
|
||||||
|
File sldFileV110 = new ClassPathResource("testdata/" + STYLENAMEV110 + ".sld")
|
||||||
|
.getFile();
|
||||||
|
|
||||||
// known state?
|
// known state?
|
||||||
cleanupTestStyle(styleName);
|
cleanupTestStyle(styleName);
|
||||||
|
cleanupTestStyle(STYLENAMEV110);
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
boolean published = publisher.publishStyle(sldFile); // Will take the
|
boolean published = publisher.publishStyle(sldFile); // Will take the
|
||||||
@ -152,11 +161,25 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
boolean ok = publisher.removeStyle(styleName);
|
boolean ok = publisher.removeStyle(styleName);
|
||||||
assertTrue("Unpublish() failed", ok);
|
assertTrue("Unpublish() failed", ok);
|
||||||
assertFalse(reader.existsStyle(styleName));
|
assertFalse(reader.existsStyle(styleName));
|
||||||
|
|
||||||
|
published = publisher.publishStyle(sldFileV110, STYLENAMEV110, true);
|
||||||
|
|
||||||
|
assertTrue("publish() failed", published);
|
||||||
|
assertTrue(reader.existsStyle(STYLENAMEV110));
|
||||||
|
|
||||||
|
boolean updated = publisher.updateStyle(sldFileV110, STYLENAMEV110, true);
|
||||||
|
assertTrue("update() failed", updated);
|
||||||
|
|
||||||
|
// test delete
|
||||||
|
ok = publisher.removeStyle(STYLENAMEV110);
|
||||||
|
assertTrue("Unpublish() failed", ok);
|
||||||
|
assertFalse(reader.existsStyle(STYLENAMEV110));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishDeleteStyleString() throws FileNotFoundException,
|
public void testPublishDeleteStyleString()
|
||||||
IOException {
|
throws FileNotFoundException, IOException
|
||||||
|
{
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -202,8 +225,9 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDefaultStyle() throws FileNotFoundException,
|
public void testUpdateDefaultStyle()
|
||||||
IOException {
|
throws FileNotFoundException, IOException
|
||||||
|
{
|
||||||
if (!enabled()) {
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -269,9 +293,11 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStylesInWorkspace() throws IOException {
|
public void testStylesInWorkspace() throws IOException
|
||||||
if (!enabled())
|
{
|
||||||
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
final String WORKSPACE = "testWorkspace";
|
final String WORKSPACE = "testWorkspace";
|
||||||
@ -283,16 +309,18 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
assertEquals(0, reader.getStyles().size());
|
assertEquals(0, reader.getStyles().size());
|
||||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||||
|
|
||||||
|
|
||||||
// insert style
|
// insert style
|
||||||
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
assertTrue("Error inserting style", publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
assertTrue("Style does not exist in workspace", reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
assertFalse(reader.existsStyle(STYLENAME));
|
|
||||||
|
// this assertion is not enforced by geoserver, which is quite lenient in searching names
|
||||||
|
//assertFalse("Style should not be global", reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
// insert style again
|
// insert style again
|
||||||
assertFalse(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
assertFalse("Dup style not trapped", publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
assertTrue("Style does not exist in workspace (2)", reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
assertFalse(reader.existsStyle(STYLENAME));
|
// this assertion is not enforced by geoserver, which is quite lenient in searching names
|
||||||
|
//assertFalse("Style should not be global (2)", reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
String sld = reader.getSLD(WORKSPACE, STYLENAME);
|
String sld = reader.getSLD(WORKSPACE, STYLENAME);
|
||||||
assertNotNull(sld);
|
assertNotNull(sld);
|
||||||
@ -304,8 +332,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||||
assertNotNull(styleEl);
|
assertNotNull(styleEl);
|
||||||
|
|
||||||
Namespace SLDNS = Namespace.getNamespace("sld",
|
Namespace SLDNS = Namespace.getNamespace("sld", "http://www.opengis.net/sld");
|
||||||
"http://www.opengis.net/sld");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -321,15 +348,16 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assertEquals(1475, sld.length());
|
// assertEquals(1475, sld.length());
|
||||||
|
|
||||||
assertEquals(0, reader.getStyles().size());
|
assertEquals(0, reader.getStyles().size());
|
||||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveStylesInWorkspace() throws IOException {
|
public void testRemoveStylesInWorkspace() throws IOException
|
||||||
if (!enabled())
|
{
|
||||||
|
if (!enabled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
final String WORKSPACE = "testWorkspace";
|
final String WORKSPACE = "testWorkspace";
|
||||||
|
|||||||
@ -33,8 +33,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,8 +45,6 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
*/
|
*/
|
||||||
public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorkspaceTest.class);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWorkspaces() {
|
public void testWorkspaces() {
|
||||||
if (!enabled()) return;
|
if (!enabled()) return;
|
||||||
@ -78,6 +74,8 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
assertTrue(reader.getWorkspaces().isEmpty());
|
assertTrue(reader.getWorkspaces().isEmpty());
|
||||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||||
|
// test exists
|
||||||
|
assertTrue(reader.existsWorkspace(DEFAULT_WS));
|
||||||
|
|
||||||
File geotiff = new ClassPathResource("testdata/resttestdem.tif").getFile();
|
File geotiff = new ClassPathResource("testdata/resttestdem.tif").getFile();
|
||||||
|
|
||||||
@ -89,5 +87,7 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
|
|||||||
|
|
||||||
// remove workspace and all of its contents
|
// remove workspace and all of its contents
|
||||||
assertTrue(publisher.removeWorkspace(DEFAULT_WS,true));
|
assertTrue(publisher.removeWorkspace(DEFAULT_WS,true));
|
||||||
|
// Test not exists
|
||||||
|
assertFalse(reader.existsWorkspace(DEFAULT_WS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,8 +35,6 @@ import org.apache.commons.httpclient.NameValuePair;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,8 +46,6 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
*/
|
*/
|
||||||
public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
|
public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorldImageTest.class);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishWorldImage() throws IOException {
|
public void testPublishWorldImage() throws IOException {
|
||||||
|
|
||||||
|
|||||||
10
src/test/resources/testdata/layerExample.xml
vendored
10
src/test/resources/testdata/layerExample.xml
vendored
@ -6,6 +6,16 @@
|
|||||||
<name>capitals</name>
|
<name>capitals</name>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/capitals.xml" type="application/xml"/>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/capitals.xml" type="application/xml"/>
|
||||||
</defaultStyle>
|
</defaultStyle>
|
||||||
|
<styles class="linked-hash-set">
|
||||||
|
<style>
|
||||||
|
<name>green</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/green.xml" type="application/xml"/>
|
||||||
|
</style>
|
||||||
|
<style>
|
||||||
|
<name>blue</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/blue.xml" type="application/xml"/>
|
||||||
|
</style>
|
||||||
|
</styles>
|
||||||
<resource class="featureType">
|
<resource class="featureType">
|
||||||
<name>tasmania_cities</name>
|
<name>tasmania_cities</name>
|
||||||
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/datastores/taz_shapes/featuretypes/tasmania_cities.xml" type="application/xml"/>
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/datastores/taz_shapes/featuretypes/tasmania_cities.xml" type="application/xml"/>
|
||||||
|
|||||||
12
src/test/resources/testdata/resttestdem.asc
vendored
Normal file
12
src/test/resources/testdata/resttestdem.asc
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
ncols 4
|
||||||
|
nrows 6
|
||||||
|
xllcorner 0.0
|
||||||
|
yllcorner 0.0
|
||||||
|
cellsize 50.0
|
||||||
|
NODATA_value -9999
|
||||||
|
-9999 -9999 5 2
|
||||||
|
-9999 20 100 36
|
||||||
|
3 8 35 10
|
||||||
|
32 42 50 6
|
||||||
|
88 75 27 9
|
||||||
|
13 5 1 -9999
|
||||||
35
src/test/resources/testdata/restteststyleV110.sld
vendored
Normal file
35
src/test/resources/testdata/restteststyleV110.sld
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<StyledLayerDescriptor version="1.1.0"
|
||||||
|
xmlns="http://www.opengis.net/sld"
|
||||||
|
xmlns:ogc="http://www.opengis.net/ogc"
|
||||||
|
xmlns:se="http://www.opengis.net/se"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
|
||||||
|
<NamedLayer>
|
||||||
|
<se:Name>OCEANSEA_1M:Foundation</se:Name>
|
||||||
|
<UserStyle>
|
||||||
|
<se:Name>GEOSYM</se:Name>
|
||||||
|
<IsDefault>1</IsDefault>
|
||||||
|
<se:FeatureTypeStyle>
|
||||||
|
<se:FeatureTypeName>Foundation</se:FeatureTypeName>
|
||||||
|
<se:Rule>
|
||||||
|
<se:Name>main</se:Name>
|
||||||
|
<se:PolygonSymbolizer uom="http://www.opengeospatial.org/se/units/pixel">
|
||||||
|
<se:Name>MySymbol</se:Name>
|
||||||
|
<se:Description>
|
||||||
|
<se:Title>Example Symbol</se:Title>
|
||||||
|
<se:Abstract>This is just a simple example.</se:Abstract>
|
||||||
|
</se:Description>
|
||||||
|
<se:Geometry>
|
||||||
|
<ogc:PropertyName>GEOMETRY</ogc:PropertyName>
|
||||||
|
</se:Geometry>
|
||||||
|
<se:Fill>
|
||||||
|
<se:SvgParameter name="fill">#96C3F5</se:SvgParameter>
|
||||||
|
</se:Fill>
|
||||||
|
</se:PolygonSymbolizer>
|
||||||
|
</se:Rule>
|
||||||
|
</se:FeatureTypeStyle>
|
||||||
|
</UserStyle>
|
||||||
|
</NamedLayer>
|
||||||
|
</StyledLayerDescriptor>
|
||||||
22
src/test/resources/testdata/wmsstoreExample.xml
vendored
Normal file
22
src/test/resources/testdata/wmsstoreExample.xml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<wmsStore>
|
||||||
|
<name>wmsstore001</name>
|
||||||
|
<type>WMS</type>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<workspace>
|
||||||
|
<name>ws001</name>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/ws001.xml" type="application/xml"/>
|
||||||
|
</workspace>
|
||||||
|
<metadata>
|
||||||
|
<entry key="useConnectionPooling">true</entry>
|
||||||
|
</metadata>
|
||||||
|
<__default>false</__default>
|
||||||
|
<capabilitiesURL>http://myhost/geoserver/wms</capabilitiesURL>
|
||||||
|
<user>admin</user>
|
||||||
|
<password>geoserver</password>
|
||||||
|
<maxConnections>6</maxConnections>
|
||||||
|
<readTimeout>60</readTimeout>
|
||||||
|
<connectTimeout>30</connectTimeout>
|
||||||
|
<wmsLayers>
|
||||||
|
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/ws001/wmsstores/wmsstore001/wmslayers.xml" type="application/xml"/>
|
||||||
|
</wmsLayers>
|
||||||
|
</wmsStore>
|
||||||
Loading…
Reference in New Issue
Block a user