Merge b12a7fb0a5 into bfdeb60ba1
This commit is contained in:
commit
42b2882c00
@ -491,8 +491,8 @@ public class GeoServerRESTPublisher {
|
||||
|
||||
/**
|
||||
* The configure parameter is used to control how the data store is
|
||||
* configured upon file upload. It can take one of the three values “first”,
|
||||
* “none”, or “all”. <br>
|
||||
* configured upon file upload. It can take one of the three values <i>first</i>,
|
||||
* <i>none</i>, or <i>all</i>. <br>
|
||||
* first - Only setup the first feature type available in the data store.
|
||||
* This is the default. <br>
|
||||
* none - Do not configure any feature types.<br>
|
||||
@ -516,7 +516,7 @@ public class GeoServerRESTPublisher {
|
||||
* The update parameter is used to control how existing data is handled when
|
||||
* the file is PUT into a datastore that (a) already exists and (b) already
|
||||
* contains a schema that matches the content of the file. It can take one
|
||||
* of the two values “append”, or “overwrite”.<br>
|
||||
* of the two values <i>append</i>, or <i>overwrite</i>.<br>
|
||||
* append - Data being uploaded is appended to the existing data. This is
|
||||
* the default.<br>
|
||||
* overwrite - Data being uploaded replaces any existing data.<br>
|
||||
@ -1173,8 +1173,8 @@ public class GeoServerRESTPublisher {
|
||||
* The recurse parameter is used to recursively delete all
|
||||
* resources contained by the specified workspace. This includes
|
||||
* data stores, coverage stores, feature types, etc... Allowable
|
||||
* values for this parameter are “true” or “false”. The default
|
||||
* value is “false”.
|
||||
* values for this parameter are “trueâ€<EFBFBD> or “falseâ€<EFBFBD>. The default
|
||||
* value is “falseâ€<EFBFBD>.
|
||||
* @return <TT>true</TT> if the WorkSpace was successfully removed.
|
||||
*/
|
||||
public boolean removeWorkspace(String workspace, boolean recurse) throws IllegalArgumentException {
|
||||
@ -1503,7 +1503,43 @@ public class GeoServerRESTPublisher {
|
||||
cname = ce.getName();
|
||||
return configureCoverage(ce, wsname, csname);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// === WORLDIMAGE
|
||||
// ==========================================================================
|
||||
/**
|
||||
* Publish a zipped worldimage file.
|
||||
*
|
||||
* It is assumed that the the zip-file contain the *.prj to set the srs.
|
||||
*
|
||||
* <P>This is equivalent call with cUrl:
|
||||
* <PRE>{@code
|
||||
*curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' \
|
||||
* --data-binary @$ZIPFILE \
|
||||
* http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$COVERAGESTORE/file.worldimage
|
||||
* </PRE>
|
||||
*
|
||||
* @param workspace Workspace to use
|
||||
* @param coveragestore Name of the coveragestore
|
||||
* @param zipFile zip file to upload
|
||||
* @return true if the operation completed successfully.
|
||||
*/
|
||||
public boolean publishWorldimage(String workspace, String coveragestore, File zipFile) throws FileNotFoundException {
|
||||
// build full URL
|
||||
StringBuilder sbUrl = new StringBuilder(restURL).append("/rest/workspaces/").append(workspace).append("/coveragestores/").append(coveragestore)
|
||||
.append("/file.worldimage");
|
||||
|
||||
String sentResult = HTTPUtils.put(sbUrl.toString(), zipFile, "application/zip", gsuser, gspass);
|
||||
boolean fileSent = sentResult != null;
|
||||
|
||||
if (fileSent) {
|
||||
LOGGER.info("Zipfile successfully uploaded ( zip:" + zipFile + ")");
|
||||
} else {
|
||||
LOGGER.warn("Error in sending zipfile " + zipFile);
|
||||
}
|
||||
return fileSent;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@ -463,6 +463,25 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName);
|
||||
assertTrue("removeDatastore() failed", dsRemoved);
|
||||
}
|
||||
|
||||
public void testPublishWorldImage() throws IOException {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
|
||||
String storeName = "testWorldimage";
|
||||
|
||||
assertTrue(reader.getWorkspaces().isEmpty());
|
||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||
|
||||
File worldImageFile = new ClassPathResource("testdata/worldimagetest.zip").getFile();
|
||||
|
||||
// test publish
|
||||
boolean wp = publisher.publishWorldimage(DEFAULT_WS, storeName, worldImageFile);
|
||||
assertTrue("Publish worldfile failed.",wp);
|
||||
|
||||
}
|
||||
|
||||
// public void testDeleteUnexistingFT() throws FileNotFoundException, IOException {
|
||||
// String wsName = "this_ws_does_not_exist";
|
||||
@ -470,7 +489,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
// String layerName = "this_layer_does_not_exist";
|
||||
//
|
||||
// boolean ok = publisher.unpublishFT(wsName, storeName, layerName);
|
||||
// assertFalse("unpublished not existing layer", ok);
|
||||
// assertFalse("unpublished not existing layer", ok);
|
||||
// }
|
||||
private boolean existsLayer(String layername) {
|
||||
return reader.getLayer(layername) != null;
|
||||
|
||||
BIN
src/test/resources/testdata/worldimagetest.zip
vendored
Normal file
BIN
src/test/resources/testdata/worldimagetest.zip
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user