Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#207 fix - Retrieve all layers in a workspace #227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,20 @@ public RESTLayerList getLayers() {
}
return RESTLayerList.build(load(url));
}

/**
* Get summary info about layers from a given workspace.
*
* @return summary info about Layers as a {@link RESTLayerList}
*/
public RESTLayerList getLayers(String workspace) {
String url = "/rest/workspaces/" + workspace + "/layers.xml";
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("### Retrieving layers from " + url);
}
return RESTLayerList.build(load(url));
}


/**
* Get summary info about all FeatureTypes of a workspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public enum VERSION {
v26(26, "2\\.6([^0-9]|$).*"),
v27(27, "2\\.7([^0-9]|$).*"),
v28(28, "2\\.8([^0-9]|$).*"),
v213(213, "2\\.13([^0-9]|$).*"),
ABOVE(9999, "2\\..+"),
UNRECOGNIZED(-1, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@
import it.geosolutions.geoserver.rest.decoder.RESTLayerList;
import it.geosolutions.geoserver.rest.decoder.RESTNamespaceList;
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.core.io.ClassPathResource;
import static org.junit.Assert.*;


Expand All @@ -48,7 +50,6 @@
public class GeoserverRESTReaderTest extends GeoserverRESTTest {

private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTReaderTest.class);

/**
* Test of getLayers method, of class GeoServerRESTReader.
*/
Expand All @@ -72,6 +73,28 @@ public void testGetLayers() {
// }
LOGGER.debug("");
}

/**
* Test of getLayers method with a given workspace, of class GeoServerRESTReader.
* Requires Geoserver > 2.13
* @throws IOException
*/
@Test
public void testGetLayersWithWorkspace() throws IOException {
if(!enabled()) return;
// Skip the test if Geoserver < 2.13
if(GSVersionDecoder.VERSION.v213.compareTo(GSVersionDecoder.VERSION.getVersion(GS_VERSION)) > 0) {
return;
}
deleteAllWorkspacesRecursively();

assertTrue(publisher.createWorkspace(DEFAULT_WS));
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
// test insert
assertTrue(publisher.publishShp(DEFAULT_WS, "resttestshp", "cities", zipFile));
assertTrue(reader.getLayers(DEFAULT_WS).size() == 1);
LOGGER.debug("");
}

/**
* Test of getDatastores method, of class GeoServerRESTReader.
Expand Down