Skip to content

Commit

Permalink
[GEOS-8711] LockFeature using GetFeatureId stored query fails with NP…
Browse files Browse the repository at this point in the history
…E on workspace specific service
  • Loading branch information
aaime committed Apr 20, 2018
1 parent be95ab1 commit b5615a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ void qualifyTypeNames(List names, WorkspaceInfo ws, NamespaceInfo ns) {
}

QName qualifyTypeName(QName name, WorkspaceInfo ws, NamespaceInfo ns) {
return new QName(ns.getURI(), name.getLocalPart(), ws.getName());
if (name != null) {
return new QName(ns.getURI(), name.getLocalPart(), ws.getName());
}
return null;
}

}
16 changes: 10 additions & 6 deletions src/wfs/src/main/java/org/geoserver/wfs/request/Lock.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ public WFS20(EObject adaptee) {
@Override
public QName getTypeName() {
List typeNames = eGet(adaptee, "typeNames", List.class);
if (typeNames.size() == 1) {
return (QName) typeNames.get(0);
} else if(typeNames.size() > 0) {
throw new IllegalArgumentException("Multiple type names on single lock not supported");
if (typeNames != null) {
if (typeNames.size() == 1) {
return (QName) typeNames.get(0);
} else if (typeNames.size() > 0) {
throw new IllegalArgumentException("Multiple type names on single lock not supported");
}
}
// no typenames found, happens with GetFeatureById stored query for example
return null;
Expand All @@ -67,8 +69,10 @@ public QName getTypeName() {
@Override
public void setTypeName(QName typeName) {
List typeNames = eGet(adaptee, "typeNames", List.class);
typeNames.clear();
typeNames.add(typeName);
if (typeNames != null) {
typeNames.clear();
typeNames.add(typeName);
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/wfs/src/test/java/org/geoserver/wfs/v2_0/LockFeatureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,30 @@ public void testRenewUnknownLock() throws Exception {

@Test
public void testLockWithStoredQuery() throws Exception {
lockWithStoredQuery("wfs");
}

@Test
public void testLockWithStoredQueryWorkspaceSpecific() throws Exception {
lockWithStoredQuery("sf/wfs");
}

public void lockWithStoredQuery(String path) throws Exception {
String xml = "<wfs:LockFeature xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" expiry=\"1\" service=\"WFS\"\n" +
" version=\"2.0.0\">\n" +
" <wfs:StoredQuery id=\"urn:ogc:def:query:OGC-WFS::GetFeatureById\">\n" +
" <wfs:Parameter name=\"id\">AggregateGeoFeature.f005</wfs:Parameter>\n" +
" </wfs:StoredQuery>\n" +
"</wfs:LockFeature>";

Document dom = postAsDOM("wfs", xml);
Document dom = postAsDOM(path, xml);
assertEquals("wfs:LockFeatureResponse", dom.getDocumentElement().getNodeName());
assertEquals(1, dom.getElementsByTagNameNS(FES.NAMESPACE, "ResourceId").getLength());

// release the lock
// print(dom);
String lockId = dom.getDocumentElement().getAttribute("lockId");
get("wfs?request=ReleaseLock&version=2.0&lockId=" + lockId);
get(path + "?request=ReleaseLock&version=2.0&lockId=" + lockId);
}

@Test
Expand Down

0 comments on commit b5615a4

Please sign in to comment.