Changeset 350


Ignore:
Timestamp:
04/14/10 12:39:22 (14 years ago)
Author:
oschonef
Message:
Location:
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai/OAIProvider.java

    r349 r350  
    1515import eu.clarin.cmdi.virtualcollectionregistry.oai.verb.GetRecordVerb;
    1616import eu.clarin.cmdi.virtualcollectionregistry.oai.verb.IdentifyVerb;
     17import eu.clarin.cmdi.virtualcollectionregistry.oai.verb.ListMetadataFormatsVerb;
    1718import eu.clarin.cmdi.virtualcollectionregistry.oai.verb.Verb;
    1819
     
    2829                verbs = new ArrayList<Verb>();
    2930                verbs.add(new IdentifyVerb());
     31                verbs.add(new ListMetadataFormatsVerb());
    3032                verbs.add(new GetRecordVerb());
    3133        }
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai/OAIRepository.java

    r345 r350  
    55
    66public interface OAIRepository {
    7         public static enum Deleted {
     7        public static enum DeletedNotion {
    88                NO,
    99                PERSISTENT,
    1010                TRANSIENT;
    11         }
     11        } // enum DeletedNotion
     12       
    1213        public static enum Granularity {
    1314                DAYS,
    1415                SECONDS;
    15         }
     16        } // enum Granularity
     17
     18        public static class MetadataFormat {
     19                private final String prefix;
     20                private final String namespaceURI;
     21                private final String schemaLocation;
     22               
     23                public MetadataFormat(String prefix, String namespaceURI, String schemaLocation) {
     24                        if (prefix == null) {
     25                                throw new NullPointerException("prefix == null");
     26                        }
     27                        this.prefix = prefix;
     28                        if (namespaceURI == null) {
     29                                throw new NullPointerException("namespaceURI == null");
     30                        }
     31                        this.namespaceURI = namespaceURI;
     32                        if (schemaLocation == null) {
     33                                throw new NullPointerException("schemaLocation == null");
     34                        }
     35                        this.schemaLocation = schemaLocation;
     36                }
     37               
     38                public String getPrefix() {
     39                        return prefix;
     40                }
     41               
     42                public String getNamespaceURI() {
     43                        return namespaceURI;
     44                }
     45               
     46                public String getSchemaLocation() {
     47                        return schemaLocation;
     48                }
     49        } // class MetadataFormat
     50
    1651        public String getId();
    1752       
     
    2257        public Date getEarliestTimestamp();
    2358       
    24         public Deleted getDeletedNotion();
     59        public DeletedNotion getDeletedNotion();
    2560       
    2661        public Granularity getGranularity();
    2762
    28         public List<String> getSupportedMetadataPrefixes();
     63        public List<MetadataFormat> getSupportedMetadataFormats();
    2964
    3065        public String getDescription();
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai/OAIRepositoryAdapter.java

    r345 r350  
    66import java.util.TimeZone;
    77
    8 import eu.clarin.cmdi.virtualcollectionregistry.oai.OAIRepository.Deleted;
     8import eu.clarin.cmdi.virtualcollectionregistry.oai.OAIRepository.DeletedNotion;
    99import eu.clarin.cmdi.virtualcollectionregistry.oai.OAIRepository.Granularity;
     10import eu.clarin.cmdi.virtualcollectionregistry.oai.OAIRepository.MetadataFormat;
    1011
    1112
     
    2526                this.provider   = provider;
    2627                this.repository = repository;
     28
     29                // check of repository supports oai_dc format
     30                if (!supportsMetadataFormat("oai_dc")) {
     31                        throw new OAIException("repository does not supported " +
     32                                        "mandatory \"oai_dc\" format");
     33                }
    2734
    2835                // cache earliest timestamp
     
    5360        }
    5461
    55         public Deleted getDeletedNotion() {
     62        public DeletedNotion getDeletedNotion() {
    5663                return repository.getDeletedNotion();
    5764        }
     
    6168        }
    6269
    63         public List<String> getSupportedMetadataPrefixes() {
    64                 return repository.getSupportedMetadataPrefixes();
     70        public List<MetadataFormat> getSupportedMetadataFormats() {
     71                return repository.getSupportedMetadataFormats();
    6572        }
    6673
     
    8188        }
    8289
     90        public boolean supportsMetadataFormat(String prefix) {
     91                for (MetadataFormat format : repository.getSupportedMetadataFormats()) {
     92                        if (prefix.equals(format.getPrefix())) {
     93                                return true;
     94                        }
     95                }
     96                return false;
     97        }
     98
    8399        private static SimpleDateFormat createDateFormat(OAIRepository repository) {
    84100                SimpleDateFormat sdf = null;
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai/VerbContext.java

    r344 r350  
    2020        // XXX: add method for fetching request timestamp
    2121
     22        public boolean hasArgument(Argument.Name name);
     23
    2224        public String getArgument(Argument.Name name);
    2325
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/oai/impl/VerbContextImpl.java

    r342 r350  
    115115
    116116        @Override
     117        public boolean hasArgument(Argument.Name name) {
     118                boolean result = false;
     119                if (arguments != null) {
     120                        result = arguments.containsKey(name);
     121                }
     122                return result;
     123        }
     124
     125        @Override
    117126        public String getArgument(Argument.Name name) {
    118127                String value = null;
Note: See TracChangeset for help on using the changeset viewer.