Adding worldfile method.
This commit is contained in:
parent
aca15380ea
commit
ee75f7138e
@ -491,8 +491,8 @@ public class GeoServerRESTPublisher {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The configure parameter is used to control how the data store is
|
* 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”,
|
* configured upon file upload. It can take one of the three values <i>first</i>,
|
||||||
* “none”, or “all”. <br>
|
* <i>none</i>, or <i>all</i>. <br>
|
||||||
* first - Only setup the first feature type available in the data store.
|
* first - Only setup the first feature type available in the data store.
|
||||||
* This is the default. <br>
|
* This is the default. <br>
|
||||||
* none - Do not configure any feature types.<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 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
|
* 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
|
* 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
|
* append - Data being uploaded is appended to the existing data. This is
|
||||||
* the default.<br>
|
* the default.<br>
|
||||||
* overwrite - Data being uploaded replaces any existing data.<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
|
* The recurse parameter is used to recursively delete all
|
||||||
* resources contained by the specified workspace. This includes
|
* resources contained by the specified workspace. This includes
|
||||||
* data stores, coverage stores, feature types, etc... Allowable
|
* data stores, coverage stores, feature types, etc... Allowable
|
||||||
* values for this parameter are “true” or “false”. The default
|
* values for this parameter are “trueâ€<EFBFBD> or “falseâ€<EFBFBD>. The default
|
||||||
* value is “false”.
|
* value is “falseâ€<EFBFBD>.
|
||||||
* @return <TT>true</TT> if the WorkSpace was successfully removed.
|
* @return <TT>true</TT> if the WorkSpace was successfully removed.
|
||||||
*/
|
*/
|
||||||
public boolean removeWorkspace(String workspace, boolean recurse) throws IllegalArgumentException {
|
public boolean removeWorkspace(String workspace, boolean recurse) throws IllegalArgumentException {
|
||||||
@ -1504,6 +1504,51 @@ public class GeoServerRESTPublisher {
|
|||||||
return configureCoverage(ce, wsname, csname);
|
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
|
||||||
|
* @param configure Configure parameter. It may be null.
|
||||||
|
* @param coverageName coverageName parameter to append. Only works if configure is set. It may be null.
|
||||||
|
* @return true if the operation completed successfully.
|
||||||
|
*/
|
||||||
|
public boolean publishWorldimage(String workspace, String coveragestore, File zipFile, String configure, String coverageName) throws FileNotFoundException {
|
||||||
|
// build full URL
|
||||||
|
StringBuilder sbUrl = new StringBuilder(restURL).append("/rest/workspaces/").append(workspace).append("/coveragestores/").append(coveragestore)
|
||||||
|
.append("/file.worldimage");
|
||||||
|
|
||||||
|
if ( configure != null && coverageName != null) {
|
||||||
|
sbUrl.append("?configure").append(configure);
|
||||||
|
if ( coverageName != null) {
|
||||||
|
sbUrl.append("&coverageName=").append(coverageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -464,6 +464,25 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
|||||||
assertTrue("removeDatastore() failed", dsRemoved);
|
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, null, null);
|
||||||
|
assertTrue("Publish worldfile failed.",wp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// public void testDeleteUnexistingFT() throws FileNotFoundException, IOException {
|
// public void testDeleteUnexistingFT() throws FileNotFoundException, IOException {
|
||||||
// String wsName = "this_ws_does_not_exist";
|
// String wsName = "this_ws_does_not_exist";
|
||||||
// String storeName = "this_store_does_not_exist";
|
// String storeName = "this_store_does_not_exist";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user