Ignore:
Timestamp:
08/09/14 20:45:17 (10 years ago)
Author:
Oliver Schonefeld
Message:
  • support new FCS specification (with some backwards compatibility for old spec)

HEADS UP: not yet ready for release; needs more testing

File:
1 moved

Legend:

Unmodified
Added
Removed
  • FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/utils/SimpleEndpointDescription.java

    r5485 r5546  
    11package eu.clarin.sru.server.fcs.utils;
    22
     3import java.net.URI;
    34import java.util.Collections;
    45import java.util.List;
    56
    6 import eu.clarin.sru.server.fcs.ResourceInfoInventory;
     7import eu.clarin.sru.server.SRUException;
     8import eu.clarin.sru.server.fcs.DataView;
     9import eu.clarin.sru.server.fcs.EndpointDescription;
    710import eu.clarin.sru.server.fcs.ResourceInfo;
    811
    912
    1013/**
    11  * A very simple resource info inventory that is initialized with a static list
    12  * of resource info records. Mostly used together with
    13  * {@link SimpleResourceInfoInventoryParser}, but it is agnostic how the static
    14  * list of resource info records is generated.
    15  * 
    16  * @see ResourceInfoInventory
    17  * @see SimpleResourceInfoInventoryParser
     14 * 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
    1821 */
    19 public class SimpleResourceInfoInventory implements ResourceInfoInventory {
     22public class SimpleEndpointDescription extends AbstractEndpointDescriptionBase {
    2023    private final boolean pidCaseSensitive;
    2124    private final List<ResourceInfo> entries;
     
    2528     * Constructor.
    2629     *
    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
    2835     *            a static list of resource info records
    2936     * @param pidCaseSensitive
    3037     *            <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
    3240     */
    33     public SimpleResourceInfoInventory(List<ResourceInfo> entries,
     41    public SimpleEndpointDescription(List<URI> capabilities,
     42            List<DataView> supportedDataViews, List<ResourceInfo> resources,
    3443            boolean pidCaseSensitive) {
    35         if (entries == null) {
     44        super(capabilities, supportedDataViews);
     45
     46        if (resources == null) {
    3647            throw new NullPointerException("entries == null");
    3748        }
    38         this.entries = Collections.unmodifiableList(entries);
     49        this.entries = Collections.unmodifiableList(resources);
    3950        this.pidCaseSensitive = pidCaseSensitive;
    4051    }
     
    4758
    4859    @Override
    49     public List<ResourceInfo> getResourceInfoList(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");
    5263        }
    53         if (id.isEmpty()) {
    54             throw new IllegalArgumentException("id is empty");
     64        if (pid.isEmpty()) {
     65            throw new IllegalArgumentException("pid is empty");
    5566        }
    5667        if (!pidCaseSensitive) {
    57             id = id.toLowerCase();
     68            pid = pid.toLowerCase();
    5869        }
    59         if (id.equals(PID_ROOT)) {
     70        if (pid.equals(PID_ROOT)) {
    6071            return entries;
    6172        } else {
    62             ResourceInfo ri = findRecursive(entries, id);
     73            ResourceInfo ri = findRecursive(entries, pid);
    6374            if (ri != null) {
    6475                return ri.getSubResources();
     
    93104    }
    94105
    95 } // class SimpleResourceInfoInventory
     106} // class SimpleEndpointDescription
Note: See TracChangeset for help on using the changeset viewer.