Changeset 7094
- Timestamp:
- 11/17/16 22:26:04 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java
r7074 r7094 1458 1458 namespaceURI, requestedVersion); 1459 1459 1460 if (NAMESPACES_LEGACY_LOC.foo(namespaceURI)) { 1461 return NAMESPACES_LEGACY_LOC; 1462 } else if (NAMESPACES_OASIS.foo(namespaceURI)) { 1463 return NAMESPACES_OASIS; 1460 SRUNamespaces namespace; 1461 if (NAMESPACES_LEGACY_LOC.matchNamespace(namespaceURI)) { 1462 namespace = NAMESPACES_LEGACY_LOC; 1463 } else if (NAMESPACES_OASIS.matchNamespace(namespaceURI)) { 1464 namespace = NAMESPACES_OASIS; 1464 1465 } else { 1465 1466 throw new SRUClientException( 1466 1467 "invalid namespace '" + reader.getNamespaceURI() + "'"); 1467 1468 } 1469 1470 if (requestedVersion != null) { 1471 if (!namespace.compatibleWithVersion(requestedVersion)) { 1472 throw new SRUClientException("Server did not honour " + 1473 "requested SRU version and responded with " + 1474 "different version (requested version was " + 1475 requestedVersion + ")"); 1476 } 1477 } 1478 return namespace; 1468 1479 } catch (XMLStreamException e) { 1469 1480 throw new SRUClientException("error detecting namespace", e); … … 1473 1484 1474 1485 private interface SRUNamespaces { 1486 public boolean compatibleWithVersion(SRUVersion version); 1487 1475 1488 public String sruNS(); 1476 1489 … … 1479 1492 public String diagnosticNS(); 1480 1493 1481 public boolean foo(String namespaceURI);1494 public boolean matchNamespace(String namespaceURI); 1482 1495 1483 1496 } // interface SRUNamespace … … 1492 1505 1493 1506 @Override 1507 public boolean compatibleWithVersion(SRUVersion version) { 1508 return SRUVersion.VERSION_1_1.equals(version) || 1509 SRUVersion.VERSION_1_2.equals(version); 1510 } 1511 1512 1513 @Override 1494 1514 public String sruNS() { 1495 1515 return SRU_NS; … … 1510 1530 1511 1531 @Override 1512 public boolean foo(String namespaceURI) {1532 public boolean matchNamespace(String namespaceURI) { 1513 1533 return SRU_NS.equals(namespaceURI); 1514 1534 } … … 1526 1546 1527 1547 @Override 1548 public boolean compatibleWithVersion(SRUVersion version) { 1549 return SRUVersion.VERSION_2_0.equals(version); 1550 } 1551 1552 1553 @Override 1528 1554 public String sruNS() { 1529 1555 return SRU_NS; … … 1545 1571 1546 1572 @Override 1547 public boolean foo(String namespaceURI) {1573 public boolean matchNamespace(String namespaceURI) { 1548 1574 return SRU_NS.equals(namespaceURI) || SRU_SCAN_NS.equals(namespaceURI); 1549 1575 }
Note: See TracChangeset
for help on using the changeset viewer.