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 edited

Legend:

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

    r5485 r5546  
    99 * This class implements a resource info record, which provides supplementary
    1010 * information about a resource that is available at the endpoint.
    11  * 
    12  * @see ResourceInfoInventory
     11 *
     12 * @see EndpointDescription
    1313 */
    1414public class ResourceInfo {
    1515    private final String pid;
    16     @Deprecated
    17     private final int resourceCount;
    1816    private final Map<String, String> title;
    1917    private final Map<String, String> description;
    2018    private final String landingPageURI;
    2119    private final List<String> languages;
    22     private List<String> availableDataViews;
    23     private List<ResourceInfo> subResources;
    24    
     20    private final List<DataView> availableDataViews;
     21    private final List<ResourceInfo> subResources;
     22
    2523
    2624    /**
     
    2927     * @param pid
    3028     *            the persistent identifier of the resource
    31      * @param resourceCount
    32      *            the number of items within the resource or <code>-1</code> if
    33      *            not applicable
    3429     * @param title
    3530     *            the title of the resource represented as a map with pairs of
     
    4540     *            the languages represented within this resource represented as
    4641     *            a list of ISO-632-3 three letter language codes
     42     * @param availableDataViews
     43     *            the list of available data views for this resource
    4744     * @param subResources
    4845     *            a list of resource sub-ordinate to this resource or
    4946     *            <code>null</code> if not applicable
    5047     */
    51     public ResourceInfo(String pid, int resourceCount,
    52             Map<String, String> title, Map<String, String> description,
    53             String landingPageURI, List<String> languages,
     48    public ResourceInfo(String pid, Map<String, String> title,
     49            Map<String, String> description, String landingPageURI,
     50            List<String> languages, List<DataView> availableDataViews,
    5451            List<ResourceInfo> subResources) {
    5552        if (pid == null) {
    56             throw new NullPointerException("id == null");
     53            throw new NullPointerException("pid == null");
    5754        }
    5855        this.pid = pid;
    59         this.resourceCount = (resourceCount > 0) ? resourceCount : -1;
     56
    6057        if (title == null) {
    6158            throw new NullPointerException("title == null");
     
    7067            this.description = null;
    7168        }
     69
    7270        this.landingPageURI = landingPageURI;
    7371        if (languages == null) {
     
    7876        }
    7977        this.languages = languages;
    80        
     78
     79        if (availableDataViews == null) {
     80            throw new IllegalArgumentException("availableDataViews == null");
     81        }
     82        this.availableDataViews =
     83                Collections.unmodifiableList(availableDataViews);
     84
    8185        if ((subResources != null) && !subResources.isEmpty()) {
    8286            this.subResources = Collections.unmodifiableList(subResources);
    8387        } else {
    8488            this.subResources = null;
    85         }       
     89        }
    8690    }
    8791
    88     public ResourceInfo(String pid, int resourceCount,
    89             Map<String, String> title, Map<String, String> description,
    90             String landingPageURI, List<String> languages,
    91             List<String> availableDataViews,
    92             List<ResourceInfo> subResources) {
    93         this(pid,resourceCount, title, description, landingPageURI, languages, subResources);
    94        
    95         if (availableDataViews == null){
    96                 throw new IllegalArgumentException("available data views == null");
    97         }
    98         if (availableDataViews.isEmpty()){
    99                 throw new IllegalArgumentException("available data views are empty");
    100         }
    101         this.availableDataViews = availableDataViews;       
    102     }
    103    
    10492
    10593    /**
     
    11098    public String getPid() {
    11199        return pid;
    112     }
    113 
    114 
    115     /**
    116      * Get the number of resources within this resource. If this resource has
    117      * sub-ordinate resources, this number should be the sum of all items within
    118      * the sub-ordinate resources plus the number of items within this resource.
    119      *
    120      * @return a number of items or <code>-1</code> if not applicable
    121      */
    122     @Deprecated
    123     public int getResourceCount() {
    124         return resourceCount;
    125100    }
    126101
     
    217192
    218193
    219         public List<String> getAvailableDataViews() {
     194        public List<DataView> getAvailableDataViews() {
    220195                return availableDataViews;
    221196        }
    222197
    223 
    224198} // class ResourceInfo
Note: See TracChangeset for help on using the changeset viewer.