Merge fea8bec1f6 into ef4e1db865
This commit is contained in:
commit
bac24f4a5e
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest;
|
package it.geosolutions.geoserver.rest;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageList;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageList;
|
||||||
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.RESTStructuredCoverageGranulesList;
|
||||||
@ -2419,7 +2420,7 @@ public class GeoServerRESTPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure an existent coverage in a given workspace and coverage store
|
* Configure an existing coverage in a given workspace and coverage store
|
||||||
*
|
*
|
||||||
* @param ce contains the coverage name to configure and the configuration to apply
|
* @param ce contains the coverage name to configure and the configuration to apply
|
||||||
* @param wsname the workspace to search for existent coverage
|
* @param wsname the workspace to search for existent coverage
|
||||||
@ -2428,8 +2429,21 @@ public class GeoServerRESTPublisher {
|
|||||||
*/
|
*/
|
||||||
public boolean configureCoverage(final GSCoverageEncoder ce, final String wsname,
|
public boolean configureCoverage(final GSCoverageEncoder ce, final String wsname,
|
||||||
final String csname) {
|
final String csname) {
|
||||||
final String cname = ce.getName();
|
return configureCoverage(ce, wsname, csname, ce.getName());
|
||||||
if (cname == null) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure an existing coverage in a given workspace and coverage store
|
||||||
|
*
|
||||||
|
* @param ce contains the coverage name to configure and the configuration to apply
|
||||||
|
* @param wsname the workspace to search for existent coverage
|
||||||
|
* @param csname the coverage store to search for existent coverage
|
||||||
|
* @param coverageName the name of the coverage, useful for changing name for the coverage itself
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean configureCoverage(final GSCoverageEncoder ce, final String wsname,
|
||||||
|
final String csname, final String coverageName) {
|
||||||
|
if (coverageName == null) {
|
||||||
if (LOGGER.isErrorEnabled())
|
if (LOGGER.isErrorEnabled())
|
||||||
LOGGER.error("Unable to configure a coverage with no name try using GSCoverageEncoder.setName(String)");
|
LOGGER.error("Unable to configure a coverage with no name try using GSCoverageEncoder.setName(String)");
|
||||||
return false;
|
return false;
|
||||||
@ -2443,43 +2457,45 @@ public class GeoServerRESTPublisher {
|
|||||||
LOGGER.error(e.getLocalizedMessage(), e);
|
LOGGER.error(e.getLocalizedMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final RESTCoverageList covList = reader.getCoverages(wsname, csname);
|
|
||||||
if (covList.isEmpty()) {
|
// optimized search, left the old code for reference
|
||||||
if (LOGGER.isErrorEnabled())
|
RESTCoverage coverage = reader.getCoverage(wsname, csname, coverageName);
|
||||||
LOGGER.error("No coverages found in new coveragestore " + csname);
|
// final RESTCoverageList covList = reader.getCoverages(wsname, csname);
|
||||||
return false;
|
// if (covList==null||covList.isEmpty()) {
|
||||||
}
|
// if (LOGGER.isErrorEnabled())
|
||||||
final Iterator<NameLinkElem> it = covList.iterator();
|
// LOGGER.error("No coverages found in new coveragestore " + csname);
|
||||||
boolean found = false;
|
// return false;
|
||||||
while (it.hasNext()) {
|
// }
|
||||||
NameLinkElem nameElem = it.next();
|
// final Iterator<NameLinkElem> it = covList.iterator();
|
||||||
if (nameElem.getName().equals(cname)) {
|
// while (it.hasNext()) {
|
||||||
found = true;
|
// NameLinkElem nameElem = it.next();
|
||||||
break;
|
// if (nameElem.getName().equals(coverageName)) {
|
||||||
}
|
// found = true;
|
||||||
}
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// if no coverage to configure is found return false
|
// if no coverage to configure is found return false
|
||||||
if (!found) {
|
if (coverage==null) {
|
||||||
if (LOGGER.isErrorEnabled())
|
if (LOGGER.isErrorEnabled())
|
||||||
LOGGER.error("No coverages found in new coveragestore " + csname + " called "
|
LOGGER.error("No coverages found in new coveragestore " + csname + " called "
|
||||||
+ cname);
|
+ coverageName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure the selected coverage
|
// configure the selected coverage
|
||||||
final String url = restURL + "/rest/workspaces/" + wsname + "/coveragestores/" + csname
|
final String url = restURL + "/rest/workspaces/" + wsname + "/coveragestores/" + csname
|
||||||
+ "/coverages/" + cname + ".xml";
|
+ "/coverages/" + coverageName + ".xml";
|
||||||
|
|
||||||
final String xmlBody = ce.toString();
|
final String xmlBody = ce.toString();
|
||||||
final String sendResult = HTTPUtils.putXml(url, xmlBody, gsuser, gspass);
|
final String sendResult = HTTPUtils.putXml(url, xmlBody, gsuser, gspass);
|
||||||
if (sendResult != null) {
|
if (sendResult != null) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Coverage successfully configured " + wsname + ":" + csname + ":"
|
LOGGER.debug("Coverage successfully configured " + wsname + ":" + csname + ":"
|
||||||
+ cname);
|
+ coverageName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (LOGGER.isWarnEnabled())
|
if (LOGGER.isWarnEnabled())
|
||||||
LOGGER.warn("Error configuring coverage " + wsname + ":" + csname + ":" + cname
|
LOGGER.warn("Error configuring coverage " + wsname + ":" + csname + ":" + coverageName
|
||||||
+ " (" + sendResult + ")");
|
+ " (" + sendResult + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -161,6 +161,9 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
granule = granulesList.get(0);
|
granule = granulesList.get(0);
|
||||||
assertNotNull(granule);
|
assertNotNull(granule);
|
||||||
|
|
||||||
|
|
||||||
|
// delete
|
||||||
|
delete(workspaceName, coverageStoreName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +177,40 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private void fixDimensions(String wsName, String coverageStoreName, String csname) {
|
private void fixDimensions(String wsName, String coverageStoreName, String csname) {
|
||||||
|
final GSImageMosaicEncoder coverageEncoder = copyParameters(wsName, coverageStoreName,
|
||||||
|
csname);
|
||||||
|
|
||||||
|
|
||||||
|
// activate time dimension
|
||||||
|
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
||||||
|
time.setUnit("Seconds");
|
||||||
|
time.setUnitSymbol("s");
|
||||||
|
time.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
||||||
|
coverageEncoder.setMetadataDimension("time", time);
|
||||||
|
|
||||||
|
// activate run which is a custom dimension
|
||||||
|
final GSDimensionInfoEncoder run=new GSDimensionInfoEncoder(true);
|
||||||
|
run.setPresentation(Presentation.LIST);
|
||||||
|
run.setUnit("Hours");
|
||||||
|
run.setUnitSymbol("h");
|
||||||
|
coverageEncoder.setMetadataDimension("run", run,true);
|
||||||
|
|
||||||
|
// persiste the changes
|
||||||
|
boolean config=publisher.configureCoverage(coverageEncoder, wsName, csname);
|
||||||
|
assertTrue(config);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param wsName
|
||||||
|
* @param coverageStoreName
|
||||||
|
* @param csname
|
||||||
|
* @return
|
||||||
|
* @throws NumberFormatException
|
||||||
|
*/
|
||||||
|
private GSImageMosaicEncoder copyParameters(String wsName, String coverageStoreName,
|
||||||
|
String csname) throws NumberFormatException {
|
||||||
// get current config for the coverage to extract the params we want to set again
|
// get current config for the coverage to extract the params we want to set again
|
||||||
final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname);
|
final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname);
|
||||||
final Map<String, String> params = coverage.getParametersList();
|
final Map<String, String> params = coverage.getParametersList();
|
||||||
@ -235,26 +272,23 @@ public class GeoServerRESTImageMosaicManagerTest extends GeoserverRESTTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return coverageEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the provided coverage recursively with purging.
|
||||||
|
* @param workspaceName
|
||||||
|
* @param coverageStoreName
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void delete(String workspaceName, String coverageStoreName) throws Exception {
|
||||||
|
if (!enabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// activate time dimension
|
// delete mosaic
|
||||||
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
boolean result = publisher.removeCoverageStore(workspaceName, coverageStoreName, true);
|
||||||
time.setUnit("Seconds");
|
assertTrue(result);
|
||||||
time.setUnitSymbol("s");
|
|
||||||
time.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
|
||||||
coverageEncoder.setMetadataDimension("time", time);
|
|
||||||
|
|
||||||
// activate run which is a custom dimension
|
|
||||||
final GSDimensionInfoEncoder run=new GSDimensionInfoEncoder(true);
|
|
||||||
run.setPresentation(Presentation.LIST);
|
|
||||||
run.setUnit("Hours");
|
|
||||||
run.setUnitSymbol("h");
|
|
||||||
coverageEncoder.setMetadataDimension("run", run,true);
|
|
||||||
|
|
||||||
// persiste the changes
|
|
||||||
boolean config=publisher.configureCoverage(coverageEncoder, wsName, csname);
|
|
||||||
assertTrue(config);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user