publish style to workspace raw, preserve attribute order, removed recursion problem
This commit is contained in:
parent
a4268dda60
commit
3decadc243
@ -486,6 +486,14 @@ public class GeoServerRESTPublisher {
|
|||||||
public boolean publishStyleInWorkspace(String workspace, String sldBody, String name) throws IllegalArgumentException {
|
public boolean publishStyleInWorkspace(String workspace, String sldBody, String name) throws IllegalArgumentException {
|
||||||
return styleManager.publishStyleInWorkspace(workspace, sldBody, name);
|
return styleManager.publishStyleInWorkspace(workspace, sldBody, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since GeoServer 2.2
|
||||||
|
* @see GeoServerRESTStyleManager#
|
||||||
|
*/
|
||||||
|
public boolean publishStyleInWorkspace(String workspace, String sldBody, String name, boolean raw) throws IllegalArgumentException {
|
||||||
|
return styleManager.publishStyleInWorkspace(workspace, sldBody, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
@ -502,6 +510,14 @@ public class GeoServerRESTPublisher {
|
|||||||
public boolean publishStyleInWorkspace(String workspace, File sldFile, String name) {
|
public boolean publishStyleInWorkspace(String workspace, File sldFile, String name) {
|
||||||
return styleManager.publishStyleInWorkspace(workspace, sldFile, name);
|
return styleManager.publishStyleInWorkspace(workspace, sldFile, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since GeoServer 2.2
|
||||||
|
* @see GeoServerRESTStyleManager#publishStyleInWorkspace(java.lang.String, java.io.File, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean publishStyleInWorkspace(String workspace, File sldFile, String name, boolean raw) {
|
||||||
|
return styleManager.publishStyleInWorkspace(workspace, sldFile, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
@ -510,6 +526,14 @@ public class GeoServerRESTPublisher {
|
|||||||
public boolean updateStyleInWorkspace(String workspace, String sldBody, String name) throws IllegalArgumentException {
|
public boolean updateStyleInWorkspace(String workspace, String sldBody, String name) throws IllegalArgumentException {
|
||||||
return styleManager.updateStyleInWorkspace(workspace, sldBody, name);
|
return styleManager.updateStyleInWorkspace(workspace, sldBody, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since GeoServer 2.2
|
||||||
|
* @see GeoServerRESTStyleManager#updateStyleInWorkspace(java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean updateStyleInWorkspace(String workspace, String sldBody, String name, boolean raw) throws IllegalArgumentException {
|
||||||
|
return styleManager.updateStyleInWorkspace(workspace, sldBody, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
@ -518,6 +542,14 @@ public class GeoServerRESTPublisher {
|
|||||||
public boolean updateStyleInWorkspace(String workspace, File sldFile, String name) throws IllegalArgumentException {
|
public boolean updateStyleInWorkspace(String workspace, File sldFile, String name) throws IllegalArgumentException {
|
||||||
return styleManager.updateStyleInWorkspace(workspace, sldFile, name);
|
return styleManager.updateStyleInWorkspace(workspace, sldFile, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since GeoServer 2.2
|
||||||
|
* @see GeoServerRESTStyleManager#updateStyleInWorkspace(java.lang.String, java.io.File, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean updateStyleInWorkspace(String workspace, File sldFile, String name, boolean raw) throws IllegalArgumentException {
|
||||||
|
return styleManager.updateStyleInWorkspace(workspace, sldFile, name, raw);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since GeoServer 2.2
|
* @since GeoServer 2.2
|
||||||
|
|||||||
@ -37,6 +37,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 +103,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 +153,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();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -106,9 +106,9 @@ public class GSLayerEncoder21Test {
|
|||||||
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(IdentifierInfo.authority.name(), kvp1_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority2", kvp1_1[1].replace("\"", ""));
|
Assert.assertEquals("authority1", kvp1_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp1_2[0].replace("\"", ""));
|
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp1_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("identifier2", kvp1_2[1].replace("\"", ""));
|
Assert.assertEquals("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("\":");
|
||||||
@ -116,15 +116,15 @@ public class GSLayerEncoder21Test {
|
|||||||
Assert.assertEquals(IdentifierInfo.authority.name(), kvp2_1[0].replace("\"", ""));
|
Assert.assertEquals(IdentifierInfo.authority.name(), kvp2_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority2", kvp2_1[1].replace("\"", ""));
|
Assert.assertEquals("authority2", kvp2_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp2_2[0].replace("\"", ""));
|
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp2_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("additionalId", kvp2_2[1].replace("\"", ""));
|
Assert.assertEquals("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(IdentifierInfo.authority.name(), kvp3_1[0].replace("\"", ""));
|
||||||
Assert.assertEquals("authority1", kvp3_1[1].replace("\"", ""));
|
Assert.assertEquals("authority2", kvp3_1[1].replace("\"", ""));
|
||||||
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp3_2[0].replace("\"", ""));
|
Assert.assertEquals(IdentifierInfo.identifier.name(), kvp3_2[0].replace("\"", ""));
|
||||||
Assert.assertEquals("identifier1", kvp3_2[1].replace("\"", ""));
|
Assert.assertEquals("additionalId", kvp3_2[1].replace("\"", ""));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -351,6 +351,64 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
|||||||
assertEquals(0, reader.getStyles().size());
|
assertEquals(0, reader.getStyles().size());
|
||||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStylesInWorkspaceRaw() throws IOException {
|
||||||
|
if (!enabled())
|
||||||
|
return;
|
||||||
|
deleteAll();
|
||||||
|
|
||||||
|
final String WORKSPACE = "testWorkspace";
|
||||||
|
final String STYLENAME = "restteststyle";
|
||||||
|
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||||
|
|
||||||
|
publisher.createWorkspace(WORKSPACE);
|
||||||
|
|
||||||
|
assertEquals(0, reader.getStyles().size());
|
||||||
|
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||||
|
|
||||||
|
|
||||||
|
// insert style
|
||||||
|
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, null, true));
|
||||||
|
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
|
assertFalse(reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
|
// insert style again
|
||||||
|
assertFalse(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, null, true));
|
||||||
|
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||||
|
assertFalse(reader.existsStyle(STYLENAME));
|
||||||
|
|
||||||
|
String sld = reader.getSLD(WORKSPACE, STYLENAME);
|
||||||
|
assertNotNull(sld);
|
||||||
|
|
||||||
|
RESTStyle style = reader.getStyle(WORKSPACE, STYLENAME);
|
||||||
|
assertEquals(STYLENAME, style.getName());
|
||||||
|
assertEquals(WORKSPACE, style.getWorkspace());
|
||||||
|
|
||||||
|
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||||
|
assertNotNull(styleEl);
|
||||||
|
|
||||||
|
Namespace SLDNS = Namespace.getNamespace("sld",
|
||||||
|
"http://www.opengis.net/sld");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||||
|
.getChild("Name", SLDNS).getText());
|
||||||
|
assertEquals(
|
||||||
|
"STYLE FOR TESTING PURPOSES",
|
||||||
|
styleEl.getChild("NamedLayer", SLDNS)
|
||||||
|
.getChild("UserStyle", SLDNS)
|
||||||
|
.getChild("Title", SLDNS).getText());
|
||||||
|
} catch (NullPointerException npe) {
|
||||||
|
fail("Error in SLD");
|
||||||
|
}
|
||||||
|
|
||||||
|
// assertEquals(1475, sld.length());
|
||||||
|
|
||||||
|
assertEquals(0, reader.getStyles().size());
|
||||||
|
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveStylesInWorkspace() throws IOException {
|
public void testRemoveStylesInWorkspace() throws IOException {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user