#102 master - encoder for AuthorityURL/Identifier/advertised (GS>=2.2)
This commit is contained in:
parent
3c502c5f58
commit
bc233d4f7a
@ -25,15 +25,19 @@
|
||||
|
||||
package it.geosolutions.geoserver.rest.encoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jdom.filter.Filter;
|
||||
|
||||
/**
|
||||
* Layer encoder for Geoserver >= 2.2
|
||||
*
|
||||
* @author ETj (etj at geo-solutions.it)
|
||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com
|
||||
*
|
||||
* The layer encoder is enabled by default
|
||||
*
|
||||
@ -41,12 +45,19 @@ import org.jdom.filter.Filter;
|
||||
public class GSLayerEncoder extends PropertyXMLEncoder {
|
||||
|
||||
public final static String STYLES = "styles";
|
||||
public final static String AUTHORITY_URLS="authorityURLs";
|
||||
public final static String IDENTIFIERS="identifiers";
|
||||
|
||||
final private Element stylesEncoder = new Element(STYLES);
|
||||
final private Element authorityURLListEncoder = new Element(AUTHORITY_URLS);
|
||||
final private Element identifierListEncoder = new Element(IDENTIFIERS);
|
||||
|
||||
public GSLayerEncoder() {
|
||||
super("layer");
|
||||
addEnabled();
|
||||
addContent(stylesEncoder);
|
||||
addContent(authorityURLListEncoder);
|
||||
addContent(identifierListEncoder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,4 +178,58 @@ public class GSLayerEncoder extends PropertyXMLEncoder {
|
||||
}
|
||||
})).size() == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param advertised
|
||||
* true if the layer should be advertised
|
||||
*/
|
||||
public void setAdvertised(boolean advertised) {
|
||||
if (advertised)
|
||||
set("advertised", "true");
|
||||
else
|
||||
set("advertised", "false");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an authorityURLInfo to the GeoServer layer
|
||||
*
|
||||
* @param authorityURLInfo
|
||||
*/
|
||||
public void addAuthorityURL(GSAuthorityURLInfoEncoder authorityURLInfo) {
|
||||
authorityURLListEncoder.addContent(authorityURLInfo.getRoot());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a AuthorityURLInfo from the list using the authorityURL
|
||||
* (AuthorityURLInfo href)
|
||||
*
|
||||
* @param authorityURL
|
||||
* @return true if something is removed, false otherwise
|
||||
*/
|
||||
public boolean delAuthorityURL(final String authorityURL) {
|
||||
return (authorityURLListEncoder.removeContent(GSAuthorityURLInfoEncoder
|
||||
.getFilterByHref(authorityURL))).size() == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an identifierInfo to the GeoServer layer
|
||||
*
|
||||
* @param identifierInfo
|
||||
*/
|
||||
public void addIdentifier(GSIdentifierInfoEncoder identifierInfo) {
|
||||
identifierListEncoder.addContent(identifierInfo.getRoot());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a IdentifierInfo from the list using the authority name
|
||||
* (IdentifierInfo authority)
|
||||
*
|
||||
* @param authority
|
||||
* @return true if something is removed, false otherwise
|
||||
*/
|
||||
public boolean delIdentifier(final String authority) {
|
||||
return (identifierListEncoder.removeContent(GSIdentifierInfoEncoder
|
||||
.getFilterByHref(authority))).size() == 0 ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||
*
|
||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.authorityurl;
|
||||
|
||||
/**
|
||||
* Enumeration of layer authorityURL members
|
||||
*
|
||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||
* emmanuel.blondel@fao.org
|
||||
*
|
||||
*/
|
||||
public enum AuthorityURLInfo {
|
||||
|
||||
name, href;
|
||||
}
|
||||
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||
*
|
||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.authorityurl;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||
import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jdom.filter.Filter;
|
||||
|
||||
/**
|
||||
* GSAuthorityURLInfoEncoder - encodes an authorityURL for a given GeoServer
|
||||
* layer as follows:
|
||||
* <pre>
|
||||
* {@code
|
||||
* final GSAuthorityURLInfoEncoder ae = new GSAuthorityURLInfoEncoder();
|
||||
* ae.setName("an authority");
|
||||
* ae.setHref("http://www.organization.org");
|
||||
* }
|
||||
* </pre>
|
||||
* For this example, the XML output is:
|
||||
* <pre>
|
||||
* {@code
|
||||
* <AuthorityURL>
|
||||
* <name>an authority</name>
|
||||
* <href>http://www.organization.org</href>
|
||||
* </AuthorityURL>
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||
* emmanuel.blondel@fao.org
|
||||
*
|
||||
*/
|
||||
public class GSAuthorityURLInfoEncoder extends XmlElement {
|
||||
|
||||
/**
|
||||
* A class to filter the AuthorityURL by href
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static class filterByHref implements Filter {
|
||||
|
||||
final private String key;
|
||||
|
||||
public filterByHref(String href) {
|
||||
this.key = href;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public boolean matches(Object obj) {
|
||||
Element el = ((Element) obj).getChild(AuthorityURLInfo.href
|
||||
.toString());
|
||||
if (el != null && el.getTextTrim().equals(key)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Filter using the AuthorityURLInfo href (authorityURL)
|
||||
*
|
||||
* @param href
|
||||
* @return the filter
|
||||
*/
|
||||
public static Filter getFilterByHref(String href) {
|
||||
return new filterByHref(href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new GSAuthorityURLInfoEncoder
|
||||
*
|
||||
*/
|
||||
public GSAuthorityURLInfoEncoder() {
|
||||
super("AuthorityURL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs quickly an AuthorityURL info
|
||||
*
|
||||
* @param name
|
||||
* (required)
|
||||
* @param href
|
||||
* (required)
|
||||
*/
|
||||
public GSAuthorityURLInfoEncoder(String name, String href) {
|
||||
super("AuthorityURL");
|
||||
this.setup(name, href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set-up quickly an AuthorityURL info
|
||||
*
|
||||
* @param name
|
||||
* @param href
|
||||
*/
|
||||
protected void setup(String name, String href) {
|
||||
set(AuthorityURLInfo.name.name(), name);
|
||||
set(AuthorityURLInfo.href.name(), href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an AuthorityURLInfo member (name, href)
|
||||
*
|
||||
* @param type
|
||||
* @param value
|
||||
*/
|
||||
protected void setMember(AuthorityURLInfo type, String value) {
|
||||
set(type.toString(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.setMember(AuthorityURLInfo.name, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the href
|
||||
*
|
||||
* @param href
|
||||
*/
|
||||
public void setHref(String href) {
|
||||
this.setMember(AuthorityURLInfo.href, href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an AuthorityURLInfo member
|
||||
*
|
||||
* @param type
|
||||
* @return true if the AuthorityURLInfo member is removed
|
||||
*/
|
||||
protected boolean delMember(AuthorityURLInfo type) {
|
||||
return ElementUtils.remove(this.getRoot(),
|
||||
this.getRoot().getChild(type.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the authority name
|
||||
*
|
||||
* @return true if removed
|
||||
*/
|
||||
public boolean delName() {
|
||||
return this.delMember(AuthorityURLInfo.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the href
|
||||
*
|
||||
* @return true if removed
|
||||
*/
|
||||
public boolean delHref() {
|
||||
return this.delMember(AuthorityURLInfo.href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the AuthorityURLInfo member
|
||||
*
|
||||
* @param type
|
||||
* @return the value of the AuthorityURLInfo member
|
||||
*/
|
||||
protected String getMember(AuthorityURLInfo type) {
|
||||
Element el = this.getRoot().getChild(type.toString());
|
||||
if (el != null)
|
||||
return el.getTextTrim();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return this.getMember(AuthorityURLInfo.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the href
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getHref() {
|
||||
return this.getMember(AuthorityURLInfo.href);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||
*
|
||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.identifier;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||
import it.geosolutions.geoserver.rest.encoder.utils.XmlElement;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jdom.filter.Filter;
|
||||
|
||||
/**
|
||||
* GSIdentifierInfoEncoder - encodes an Identifier for a given GeoServer
|
||||
* layer as follows:
|
||||
* <pre>
|
||||
* {@code
|
||||
* final GSIdentifierInfoEncoder ie = new GSIdentifierInfoEncoder();
|
||||
* ie.setAuthority("an authority");
|
||||
* ie.setIdentifier("an identifier");
|
||||
* }
|
||||
* </pre>
|
||||
* For this example, the XML output is:
|
||||
* <pre>
|
||||
* {@code
|
||||
* <Identifier>
|
||||
* <authority>an authority</authority>
|
||||
* <identifier>an identifier</identifier>
|
||||
* </Identifier>
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||
* emmanuel.blondel@fao.org
|
||||
*
|
||||
*/
|
||||
public class GSIdentifierInfoEncoder extends XmlElement {
|
||||
|
||||
/**
|
||||
* A class to filter the Idenfiers by authority
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static class filterByAuthority implements Filter {
|
||||
|
||||
final private String key;
|
||||
|
||||
public filterByAuthority(String authority) {
|
||||
this.key = authority;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public boolean matches(Object obj) {
|
||||
Element el = ((Element) obj).getChild(IdentifierInfo.authority
|
||||
.toString());
|
||||
if (el != null && el.getTextTrim().equals(key)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Filter using the IdentifierInfo authority
|
||||
*
|
||||
* @param authority
|
||||
* @return the filter
|
||||
*/
|
||||
public static Filter getFilterByHref(String authority) {
|
||||
return new filterByAuthority(authority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new GSIdentifierInfoEncoder
|
||||
*
|
||||
*/
|
||||
public GSIdentifierInfoEncoder() {
|
||||
super("Identifier");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs quickly an Identifier info
|
||||
*
|
||||
* @param authority
|
||||
* (required)
|
||||
* @param identifier
|
||||
* (required)
|
||||
*/
|
||||
public GSIdentifierInfoEncoder(String authority, String identifier) {
|
||||
super("Identifier");
|
||||
this.setup(authority, identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set-up quickly an Identifier info
|
||||
*
|
||||
* @param authority
|
||||
* @param identifier
|
||||
*/
|
||||
protected void setup(String authority, String identifier) {
|
||||
set(IdentifierInfo.authority.name(), authority);
|
||||
set(IdentifierInfo.identifier.name(), identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an IdentifierInfo member (authority, identifier)
|
||||
*
|
||||
* @param type
|
||||
* @param value
|
||||
*/
|
||||
protected void setMember(IdentifierInfo type, String value) {
|
||||
set(type.toString(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the authority
|
||||
*
|
||||
* @param authority
|
||||
*/
|
||||
public void setAuthority(String authority) {
|
||||
this.setMember(IdentifierInfo.authority, authority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the identifier
|
||||
*
|
||||
* @param identifier
|
||||
*/
|
||||
public void setIdentifier(String identifier) {
|
||||
this.setMember(IdentifierInfo.identifier, identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an IdentifierInfo member
|
||||
*
|
||||
* @param type
|
||||
* @return true if the IdentifierInfo member is removed
|
||||
*/
|
||||
protected boolean delMember(IdentifierInfo type) {
|
||||
return ElementUtils.remove(this.getRoot(),
|
||||
this.getRoot().getChild(type.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the authority
|
||||
*
|
||||
* @return true if removed
|
||||
*/
|
||||
public boolean delAuthority() {
|
||||
return this.delMember(IdentifierInfo.authority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the identifier
|
||||
*
|
||||
* @return true if removed
|
||||
*/
|
||||
public boolean delIdentifier() {
|
||||
return this.delMember(IdentifierInfo.identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the IdentifierInfo member
|
||||
*
|
||||
* @param type
|
||||
* @return the value of the IdentifierInfo member
|
||||
*/
|
||||
protected String getMember(IdentifierInfo type) {
|
||||
Element el = this.getRoot().getChild(type.toString());
|
||||
if (el != null)
|
||||
return el.getTextTrim();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authority
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAuthority() {
|
||||
return this.getMember(IdentifierInfo.authority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the identifier
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return this.getMember(IdentifierInfo.identifier);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||
*
|
||||
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.identifier;
|
||||
|
||||
/**
|
||||
* Enumeration of layer authorityURL members
|
||||
*
|
||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||
* emmanuel.blondel@fao.org
|
||||
*
|
||||
*/
|
||||
public enum IdentifierInfo {
|
||||
|
||||
authority, identifier;
|
||||
}
|
||||
@ -19,6 +19,8 @@
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.jdom.Element;
|
||||
@ -40,9 +42,16 @@ public class GSLayerEncoderTest {
|
||||
layerEncoder = new GSLayerEncoder();
|
||||
layerEncoder.setEnabled(true);
|
||||
layerEncoder.setQueryable(true);
|
||||
layerEncoder.setAdvertised(true);
|
||||
|
||||
layerEncoder.setDefaultStyle("point");
|
||||
layerEncoder.addStyle("additional_style1");
|
||||
layerEncoder.addStyle("additional_style2");
|
||||
|
||||
layerEncoder.addAuthorityURL(new GSAuthorityURLInfoEncoder(
|
||||
"authority1", "http://www.authority1.org"));
|
||||
layerEncoder.addIdentifier(new GSIdentifierInfoEncoder("authority1",
|
||||
"identifier1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -55,6 +64,10 @@ public class GSLayerEncoderTest {
|
||||
true,
|
||||
Boolean.parseBoolean(layerEncoder.getRoot()
|
||||
.getChild("queryable").getValue()));
|
||||
Assert.assertEquals(
|
||||
true,
|
||||
Boolean.parseBoolean(layerEncoder.getRoot()
|
||||
.getChild("advertised").getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -81,5 +94,21 @@ public class GSLayerEncoderTest {
|
||||
Assert.assertEquals("additional_style2", ((Element) layerEncoder
|
||||
.getRoot().getChild("styles").getChildren().get(0)).getText());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAuthorityURL(){
|
||||
Element el = (Element) layerEncoder.getRoot().getChild("authorityURLs")
|
||||
.getChildren().get(0);
|
||||
Assert.assertEquals("authority1", el.getChild("name").getValue());
|
||||
Assert.assertEquals("http://www.authority1.org", el.getChild("href")
|
||||
.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdentifier(){
|
||||
Element el = (Element) layerEncoder.getRoot().getChild("identifiers")
|
||||
.getChildren().get(0);
|
||||
Assert.assertEquals("authority1", el.getChild("authority").getValue());
|
||||
Assert.assertEquals("identifier1", el.getChild("identifier").getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* GPLv3 + Classpath exception
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.authorityurl;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author eblondel
|
||||
*
|
||||
*/
|
||||
public class GSAuthorityURLInfoEncoderTest {
|
||||
|
||||
@Test
|
||||
public void authorityURLInfoTest() {
|
||||
GSAuthorityURLInfoEncoder encoder = new GSAuthorityURLInfoEncoder();
|
||||
encoder.setup("authority1", "http://www.authority1.org");
|
||||
|
||||
Assert.assertEquals("authority1", encoder.getName());
|
||||
Assert.assertEquals("http://www.authority1.org", encoder.getHref());
|
||||
|
||||
Assert.assertTrue(encoder.delHref());
|
||||
Assert.assertNull(encoder.getHref());
|
||||
|
||||
encoder.setName("authority2");
|
||||
encoder.setHref("http://www.authority2.org");
|
||||
Assert.assertEquals("authority2", encoder.getName());
|
||||
Assert.assertEquals("http://www.authority2.org", encoder.getHref());
|
||||
}
|
||||
}
|
||||
@ -25,6 +25,8 @@ import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTResource;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
|
||||
@ -73,6 +75,7 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
||||
String layerName = "cities";
|
||||
|
||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
||||
fte.setNativeName(layerName);
|
||||
fte.setName(layerName + "_NEW");
|
||||
fte.setTitle("title");
|
||||
// fte.addKeyword("TODO");
|
||||
@ -89,10 +92,22 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
||||
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||
layerEncoder.setEnabled(true);
|
||||
layerEncoder.setQueryable(true);
|
||||
layerEncoder.setAdvertised(true);
|
||||
|
||||
layerEncoder.setDefaultStyle("point");
|
||||
layerEncoder.addStyle("point2");
|
||||
layerEncoder.addStyle("point3");
|
||||
|
||||
// authorityURL
|
||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
||||
"authority1", "http://www.authority1.org");
|
||||
layerEncoder.addAuthorityURL(authorityURL);
|
||||
|
||||
// identifier
|
||||
GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder(
|
||||
"authority1", "identifier1");
|
||||
layerEncoder.addIdentifier(identifier);
|
||||
|
||||
|
||||
publisher.createWorkspace(DEFAULT_WS);
|
||||
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* GPLv3 + Classpath exception
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package it.geosolutions.geoserver.rest.encoder.identifier;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author eblondel
|
||||
*
|
||||
*/
|
||||
public class GSIdentifierInfoEncoderTest {
|
||||
|
||||
@Test
|
||||
public void identifierInfoTest() {
|
||||
GSIdentifierInfoEncoder encoder = new GSIdentifierInfoEncoder();
|
||||
encoder.setup("authority1", "identifier1");
|
||||
|
||||
Assert.assertEquals("authority1", encoder.getAuthority());
|
||||
Assert.assertEquals("identifier1", encoder.getIdentifier());
|
||||
|
||||
Assert.assertTrue(encoder.delIdentifier());
|
||||
Assert.assertNull(encoder.getIdentifier());
|
||||
|
||||
encoder.setAuthority("authority2");
|
||||
encoder.setIdentifier("identifier2");
|
||||
Assert.assertEquals("authority2", encoder.getAuthority());
|
||||
Assert.assertEquals("identifier2", encoder.getIdentifier());
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user