Changeset 5546 for FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/utils/SimpleEndpointDescription.java
- Timestamp:
- 08/09/14 20:45:17 (10 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/utils/SimpleEndpointDescription.java
r5485 r5546 1 1 package eu.clarin.sru.server.fcs.utils; 2 2 3 import java.net.URI; 3 4 import java.util.Collections; 4 5 import java.util.List; 5 6 6 import eu.clarin.sru.server.fcs.ResourceInfoInventory; 7 import eu.clarin.sru.server.SRUException; 8 import eu.clarin.sru.server.fcs.DataView; 9 import eu.clarin.sru.server.fcs.EndpointDescription; 7 10 import eu.clarin.sru.server.fcs.ResourceInfo; 8 11 9 12 10 13 /** 11 * A very simple resource info inventory that is initialized with a static list12 * of resource info records. Mostly used together with13 * {@link SimpleResourceInfoInventoryParser}, but it is agnostic how the static14 * list of resource info records is generated.15 * 16 * @see ResourceInfoInventory17 * @see Simple ResourceInfoInventoryParser14 * A very simple implementation of an endpoint description that is initialized 15 * from static information supplied at construction time. Mostly used together 16 * with {@link SimpleEndpointDescriptionParser}, but it is agnostic how the 17 * static list of resource info records is generated. 18 * 19 * @see EndpointDescription 20 * @see SimpleEndpointDescriptionParser 18 21 */ 19 public class Simple ResourceInfoInventory implements ResourceInfoInventory{22 public class SimpleEndpointDescription extends AbstractEndpointDescriptionBase { 20 23 private final boolean pidCaseSensitive; 21 24 private final List<ResourceInfo> entries; … … 25 28 * Constructor. 26 29 * 27 * @param entries 30 * @param capabilities 31 * a list of capabilities supported by this endpoint 32 * @param supportedDataViews 33 * a list of data views that are supported by this endpoint 34 * @param resources 28 35 * a static list of resource info records 29 36 * @param pidCaseSensitive 30 37 * <code>true</code> if comparison of persistent identifiers 31 * should be performed case-sensitive, <code>false</code> otherwise 38 * should be performed case-sensitive, <code>false</code> 39 * otherwise 32 40 */ 33 public SimpleResourceInfoInventory(List<ResourceInfo> entries, 41 public SimpleEndpointDescription(List<URI> capabilities, 42 List<DataView> supportedDataViews, List<ResourceInfo> resources, 34 43 boolean pidCaseSensitive) { 35 if (entries == null) { 44 super(capabilities, supportedDataViews); 45 46 if (resources == null) { 36 47 throw new NullPointerException("entries == null"); 37 48 } 38 this.entries = Collections.unmodifiableList( entries);49 this.entries = Collections.unmodifiableList(resources); 39 50 this.pidCaseSensitive = pidCaseSensitive; 40 51 } … … 47 58 48 59 @Override 49 public List<ResourceInfo> getResource InfoList(String id){50 if ( id == null) {51 throw new NullPointerException(" id == null");60 public List<ResourceInfo> getResourceList(String pid) throws SRUException { 61 if (pid == null) { 62 throw new NullPointerException("pid == null"); 52 63 } 53 if ( id.isEmpty()) {54 throw new IllegalArgumentException(" id is empty");64 if (pid.isEmpty()) { 65 throw new IllegalArgumentException("pid is empty"); 55 66 } 56 67 if (!pidCaseSensitive) { 57 id =id.toLowerCase();68 pid = pid.toLowerCase(); 58 69 } 59 if ( id.equals(PID_ROOT)) {70 if (pid.equals(PID_ROOT)) { 60 71 return entries; 61 72 } else { 62 ResourceInfo ri = findRecursive(entries, id);73 ResourceInfo ri = findRecursive(entries, pid); 63 74 if (ri != null) { 64 75 return ri.getSubResources(); … … 93 104 } 94 105 95 } // class Simple ResourceInfoInventory106 } // class SimpleEndpointDescription
Note: See TracChangeset
for help on using the changeset viewer.