Index: /FCSSimpleClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSEndpointDescriptionParser.java
===================================================================
--- /FCSSimpleClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSEndpointDescriptionParser.java	(revision 7256)
+++ /FCSSimpleClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSEndpointDescriptionParser.java	(revision 7257)
@@ -288,5 +288,5 @@
         // Resources
         final List<ResourceInfo> resources =
-                parseResources(reader, 0, maxDepth,
+                parseResources(reader, 0, maxDepth, hasAdvancedSearch,
                         supportedDataViews, supportedLayers);
 
@@ -323,6 +323,7 @@
 
     private static List<ResourceInfo> parseResources(XMLStreamReader reader,
-            int depth, int maxDepth, List<DataView> supportedDataviews,
-            List<Layer> supportedLayers) throws XMLStreamException {
+            int depth, int maxDepth, boolean hasAdvancedSearch,
+            List<DataView> supportedDataviews, List<Layer> supportedLayers)
+            throws XMLStreamException {
         List<ResourceInfo> resources = null;
 
@@ -334,5 +335,7 @@
             reader.next(); // consume start tag
 
-            logger.debug("pid = {}", pid);
+            logger.debug("hasAdvSearch: {}", hasAdvancedSearch);
+            
+            logger.debug("parsing resource with pid = {}", pid);
 
             final Map<String, String> title =
@@ -381,14 +384,16 @@
             for (String dv : dvs.split("\\s+")) {
                 boolean found = false;
-                for (DataView dataview : supportedDataviews) {
-                    if (dataview.getIdentifier().equals(dv)) {
-                        found = true;
-                        if (dataviews == null) {
-                            dataviews = new ArrayList<DataView>();
+                if (supportedDataviews != null) {
+                    for (DataView dataview : supportedDataviews) {
+                        if (dataview.getIdentifier().equals(dv)) {
+                            found = true;
+                            if (dataviews == null) {
+                                dataviews = new ArrayList<DataView>();
+                            }
+                            dataviews.add(dataview);
+                            break;
                         }
-                        dataviews.add(dataview);
-                        break;
-                    }
-                } // for
+                    } // for
+                }
                 if (!found) {
                     throw new XMLStreamException("DataView with id '" + dv +
@@ -410,14 +415,16 @@
                 for (String l : ls.split("\\s+")) {
                     boolean found = false;
-                    for (Layer layer : supportedLayers) {
-                        if (layer.getIdentifier().equals(l)) {
-                            found = true;
-                            if (layers == null) {
-                                layers = new ArrayList<Layer>();
+                    if (supportedLayers != null) {
+                        for (Layer layer : supportedLayers) {
+                            if (layer.getIdentifier().equals(l)) {
+                                found = true;
+                                if (layers == null) {
+                                    layers = new ArrayList<Layer>();
+                                }
+                                layers.add(layer);
+                                break;
                             }
-                            layers.add(layer);
-                            break;
-                        }
-                    } // for
+                        } // for
+                    }
                     if (!found) {
                         throw new XMLStreamException("Layer with id '" + l +
@@ -427,4 +434,12 @@
                 } // for
                 logger.debug("Layers: {}", layers);
+            } // for
+            if (hasAdvancedSearch && (layers == null)) {
+                throw new XMLStreamException("Endpoint must declare " +
+                        "all available layers (<AvailableLayers>) on a " +
+                        "resource, if they provide the 'advanced-search' (" +
+                        ClarinFCSConstants.CAPABILITY_ADVANCED_SEARCH +
+                        ") capability. Offending resource id pid=" + pid +
+                        ")", reader.getLocation());
             }
 
@@ -437,5 +452,6 @@
                         (nextDepth < maxDepth)) {
                     subResources = parseResources(reader, nextDepth,
-                            maxDepth, supportedDataviews, supportedLayers);
+                            maxDepth, hasAdvancedSearch, supportedDataviews,
+                            supportedLayers);
                 } else {
                     XmlStreamReaderUtils.skipTag(reader, ED_NS_URI,
