Added ImageMosaic pubblicatiobn JUnit test. Fixed Unpublish issue. Various publisher enhancements.

This commit is contained in:
ccancellieri 2011-11-11 12:44:05 +01:00
parent 3fa1545019
commit 69f4abd849
16 changed files with 1341 additions and 832 deletions

View File

@ -68,7 +68,9 @@ public class RESTCoverageStore {
public static RESTCoverageStore build(String response) { public static RESTCoverageStore build(String response) {
if(response == null) if(response == null)
return null; return null;
if(response.isEmpty())
return new RESTCoverageStore(new Element("coverageStore")); // TODO check how to response
Element pb = JDOMBuilder.buildElement(response); Element pb = JDOMBuilder.buildElement(response);
if(pb != null) if(pb != null)
return new RESTCoverageStore(pb); return new RESTCoverageStore(pb);

View File

@ -48,10 +48,11 @@ import org.jdom.filter.Filter;
*/ */
public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder> public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
extends PropertyXMLEncoder { extends PropertyXMLEncoder {
private final static String NAME="name"; private final static String NAME = "name";
final private GSMetadataEncoder<T> metadata = new GSMetadataEncoder<T>(); final private GSMetadataEncoder<T> metadata = new GSMetadataEncoder<T>();
final private Element keywordsListEncoder = new Element("keywords"); final private Element keywordsListEncoder = new Element("keywords");
/** /**
* @param rootName * @param rootName
* Actually 'feature' or 'coverage' * Actually 'feature' or 'coverage'
@ -66,9 +67,9 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
addContent(metadata.getRoot()); addContent(metadata.getRoot());
addContent(keywordsListEncoder); addContent(keywordsListEncoder);
} }
public void setEnabled(boolean enabled){ public void setEnabled(boolean enabled) {
set("enabled",(enabled)?"true":"false"); set("enabled", (enabled) ? "true" : "false");
} }
/** /**
@ -79,28 +80,29 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
public void addMetadata(String key, T dimensionInfo) { public void addMetadata(String key, T dimensionInfo) {
metadata.add(key, dimensionInfo.getRoot()); metadata.add(key, dimensionInfo.getRoot());
} }
/** /**
* @param key the name of the metadata to add (f.e.: elevation, time) * @param key
* the name of the metadata to add (f.e.: elevation, time)
* @return true if something is removed, false otherwise * @return true if something is removed, false otherwise
*/ */
public boolean delMetadata(String key) { public boolean delMetadata(String key) {
return metadata.remove(key); return metadata.remove(key);
} }
public void setMetadata(String key, T dimensionInfo) { public void setMetadata(String key, T dimensionInfo) {
metadata.set(key, dimensionInfo.getRoot()); metadata.set(key, dimensionInfo.getRoot());
} }
public void addKeyword(String keyword) { public void addKeyword(String keyword) {
final Element el = new Element("string"); final Element el = new Element("string");
el.setText(keyword); el.setText(keyword);
keywordsListEncoder.addContent(el); keywordsListEncoder.addContent(el);
} }
/** /**
* delete a keyword from the list * delete a keyword from the list
*
* @param keyword * @param keyword
* @return true if something is removed, false otherwise * @return true if something is removed, false otherwise
*/ */
@ -109,13 +111,14 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
el.setText(keyword); el.setText(keyword);
return (keywordsListEncoder.removeContent(new Filter() { return (keywordsListEncoder.removeContent(new Filter() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public boolean matches(Object obj) { public boolean matches(Object obj) {
if (((Element)obj).getText().equals(keyword)){ if (((Element) obj).getText().equals(keyword)) {
return true; return true;
} }
return false; return false;
} }
})).size()==0?false:true; })).size() == 0 ? false : true;
} }
/** /**
@ -125,7 +128,8 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
REPROJECT_TO_DECLARED, FORCE_DECLARED, NONE REPROJECT_TO_DECLARED, FORCE_DECLARED, NONE
} }
private final static String PROJECTIONPOLICY="projectionPolicy"; private final static String PROJECTIONPOLICY = "projectionPolicy";
/** /**
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED * NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
* *
@ -153,6 +157,7 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
public void addName(final String name) { public void addName(final String name) {
add(NAME, name); add(NAME, name);
} }
/** /**
* Set or modify the 'name' node with a text value from 'name' * Set or modify the 'name' node with a text value from 'name'
* *
@ -161,16 +166,17 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
public void setName(final String name) { public void setName(final String name) {
set(NAME, name); set(NAME, name);
} }
public String getName(){ public String getName() {
final Element nameNode=get(NAME); final Element nameNode = get(NAME);
if (nameNode!=null) if (nameNode != null)
return nameNode.getText(); return nameNode.getText();
else else
return null; return null;
} }
private final static String TITLE="title"; private final static String TITLE = "title";
/** /**
* Add the 'title' node with a text value from 'title' * Add the 'title' node with a text value from 'title'
* *
@ -180,7 +186,7 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
public void addTitle(final String title) { public void addTitle(final String title) {
add(TITLE, title); add(TITLE, title);
} }
/** /**
* Set or modify the 'title' node with a text value from 'title' * Set or modify the 'title' node with a text value from 'title'
*/ */
@ -188,7 +194,8 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
set(TITLE, title); set(TITLE, title);
} }
private final static String SRS="srs"; private final static String SRS = "srs";
/** /**
* Add the 'SRS' node with a text value from 'srs' * Add the 'SRS' node with a text value from 'srs'
* *
@ -198,7 +205,7 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
public void addSRS(final String srs) { public void addSRS(final String srs) {
add(SRS, srs); add(SRS, srs);
} }
/** /**
* Set or modify the 'SRS' node with a text value from 'srs' * Set or modify the 'SRS' node with a text value from 'srs'
*/ */
@ -206,67 +213,67 @@ public abstract class GSResourceEncoder<T extends GSDimensionInfoEncoder>
set(SRS, srs); set(SRS, srs);
} }
private final static String LATLONBBMINX="latLonBoundingBox/minx"; private final static String LATLONBBMINX = "latLonBoundingBox/minx";
private final static String LATLONBBMAXX="latLonBoundingBox/maxx"; private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
private final static String LATLONBBMINY="latLonBoundingBox/miny"; private final static String LATLONBBMINY = "latLonBoundingBox/miny";
private final static String LATLONBBMAXY="latLonBoundingBox/maxy"; private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
private final static String LATLONBBCRS="latLonBoundingBox/crs"; private final static String LATLONBBCRS = "latLonBoundingBox/crs";
/** /**
* @deprecated use the setSRS. <br> * @deprecated use the setSRS. <br>
* This method will be set as protected in the next release * This method will be set as protected in the next release
* *
* @param minx * @param minx
* @param maxy * @param maxy
* @param maxx * @param maxx
* @param miny * @param miny
* @param crs * @param crs
*/ */
public void addLatLonBoundingBox(double minx, double maxy, double maxx, public void addLatLonBoundingBox(double minx, double miny, double maxx,
double miny, final String crs) { double maxy, final String crs) {
add(LATLONBBMINX, String.valueOf(minx)); add(LATLONBBMINX, String.valueOf(minx));
add(LATLONBBMINY, String.valueOf(miny));
add(LATLONBBMAXY, String.valueOf(maxy)); add(LATLONBBMAXY, String.valueOf(maxy));
add(LATLONBBMAXX, String.valueOf(maxx)); add(LATLONBBMAXX, String.valueOf(maxx));
add(LATLONBBMINY, String.valueOf(miny));
add(LATLONBBCRS, crs); add(LATLONBBCRS, crs);
} }
public void setLatLonBoundingBox(double minx, double maxy, double maxx, public void setLatLonBoundingBox(double minx, double miny, double maxx,
double miny, final String crs) { double maxy, final String crs) {
set(LATLONBBMINX, String.valueOf(minx)); set(LATLONBBMINX, String.valueOf(minx));
set(LATLONBBMAXY, String.valueOf(maxy)); set(LATLONBBMAXY, String.valueOf(maxy));
set(LATLONBBMAXX, String.valueOf(maxx)); set(LATLONBBMAXX, String.valueOf(maxx));
set(LATLONBBMINY, String.valueOf(miny)); set(LATLONBBMINY, String.valueOf(miny));
set(LATLONBBCRS, crs); set(LATLONBBCRS, crs);
} }
private final static String NATIVEBBMINX="nativeBoundingBox/minx"; private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
private final static String NATIVEBBMAXX="nativeBoundingBox/maxx"; private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
private final static String NATIVEBBMINY="nativeBoundingBox/miny"; private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
private final static String NATIVEBBMAXY="nativeBoundingBox/maxy"; private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
private final static String NATIVEBBCRS="nativeBoundingBox/crs"; private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
/** /**
* @deprecated use the setSRS. <br> * @deprecated use the setSRS. <br>
* This method will be set as protected in the next release * This method will be set as protected in the next release
* *
* @param minx * @param minx
* @param maxy * @param maxy
* @param maxx * @param maxx
* @param miny * @param miny
* @param crs * @param crs
*/ */
public void addNativeBoundingBox(double minx, double maxy, double maxx, public void addNativeBoundingBox(double minx, double miny, double maxx,
double miny, final String crs) { double maxy, final String crs) {
add(NATIVEBBMINX, String.valueOf(minx)); add(NATIVEBBMINX, String.valueOf(minx));
add(NATIVEBBMAXY, String.valueOf(maxy)); add(NATIVEBBMAXY, String.valueOf(maxy));
add(NATIVEBBMAXX, String.valueOf(maxx)); add(NATIVEBBMAXX, String.valueOf(maxx));
add(NATIVEBBMINY, String.valueOf(miny)); add(NATIVEBBMINY, String.valueOf(miny));
add(NATIVEBBCRS, crs); add(NATIVEBBCRS, crs);
} }
public void setNativeBoundingBox(double minx, double maxy, double maxx, public void setNativeBoundingBox(double minx, double miny, double maxx,
double miny, final String crs) { double maxy, final String crs) {
set(NATIVEBBMINX, String.valueOf(minx)); set(NATIVEBBMINX, String.valueOf(minx));
set(NATIVEBBMAXY, String.valueOf(maxy)); set(NATIVEBBMAXY, String.valueOf(maxy));
set(NATIVEBBMAXX, String.valueOf(maxx)); set(NATIVEBBMAXX, String.valueOf(maxx));

View File

@ -110,10 +110,10 @@ public class GSImageMosaicEncoder extends GSCoverageEncoder {
* @param val * @param val
*/ */
public void addFilter(final String val){ public void addFilter(final String val){
final Element param=new Element(ENTRY); final List<Element> list=new ArrayList<Element>(2);
param.addContent(new Element(STRING).setText(filter)); list.add(new Element(STRING).setText(filter));
param.addContent(new Element(STRING).setText(val)); list.add(new Element(STRING).setText(val));
parameters.add(null,param); parameters.add(null,list);
} }
private final static Filter filterFilter=new parametersFilter(filter); private final static Filter filterFilter=new parametersFilter(filter);

View File

@ -50,7 +50,7 @@ import org.springframework.core.io.ClassPathResource;
public class ConfigTest extends GeoserverRESTTest { public class ConfigTest extends GeoserverRESTTest {
private final static Logger LOGGER = Logger.getLogger(ConfigTest.class); private final static Logger LOGGER = Logger.getLogger(ConfigTest.class);
private static final String DEFAULT_WS = "it.geosolutions"; private static final String DEFAULT_WS = "geosolutions";
public ConfigTest(String testName) { public ConfigTest(String testName) {

View File

@ -175,7 +175,6 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
deleteAllWorkspaces(); deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS)); assertTrue(publisher.createWorkspace(DEFAULT_WS));
// String ns = "it.geosolutions";
String storeName = "resttestshp"; String storeName = "resttestshp";
String layerName = "cities"; String layerName = "cities";

View File

@ -0,0 +1,3 @@
TimeAttribute=time
Schema= the_geom:Polygon,location:String,time:java.util.Date
PropertyCollectors=TimestampFileNameExtractorSPI[timeregex](time)

View File

@ -0,0 +1 @@
regex=[a-z]{5,5}

View File

@ -0,0 +1 @@
regex=[0-9]{6}