1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opencastproject.oaipmh.server;
22
23 import static org.apache.commons.lang3.StringUtils.trimToNull;
24 import static org.opencastproject.util.data.Option.eq;
25 import static org.opencastproject.util.data.Option.option;
26
27 import org.opencastproject.oaipmh.OaiPmhConstants;
28 import org.opencastproject.util.data.Option;
29
30
31
32
33 public abstract class Params {
34
35
36
37
38
39 abstract String getParameter(String key);
40
41
42
43
44
45 abstract String getRepositoryUrl();
46
47 boolean isVerbGetRecord() {
48 return getVerb().map(eq(OaiPmhConstants.VERB_GET_RECORD)).getOrElse(false);
49 }
50
51 boolean isVerbIdentify() {
52 return getVerb().map(eq(OaiPmhConstants.VERB_IDENTIFY)).getOrElse(false);
53 }
54
55 boolean isVerbListMetadataFormats() {
56 return getVerb().map(eq(OaiPmhConstants.VERB_LIST_METADATA_FORMATS)).getOrElse(false);
57 }
58
59 boolean isVerbListSets() {
60 return getVerb().map(eq(OaiPmhConstants.VERB_LIST_SETS)).getOrElse(false);
61 }
62
63 boolean isVerbListIdentifiers() {
64 return getVerb().map(eq(OaiPmhConstants.VERB_LIST_IDENTIFIERS)).getOrElse(false);
65 }
66
67 boolean isVerbListRecords() {
68 return getVerb().map(eq(OaiPmhConstants.VERB_LIST_RECORDS)).getOrElse(false);
69 }
70
71 Option<String> getVerb() {
72 return option(trimToNull(getParameter("verb")));
73 }
74
75 Option<String> getIdentifier() {
76 return option(trimToNull(getParameter("identifier")));
77 }
78
79 Option<String> getMetadataPrefix() {
80 return option(trimToNull(getParameter("metadataPrefix")));
81 }
82
83 Option<String> getFrom() {
84 return option(trimToNull(getParameter("from")));
85 }
86
87 Option<String> getUntil() {
88 return option(trimToNull(getParameter("until")));
89 }
90
91 Option<String> getSet() {
92 return option(trimToNull(getParameter("set")));
93 }
94
95 Option<String> getResumptionToken() {
96 return option(trimToNull(getParameter("resumptionToken")));
97 }
98
99 @Override
100 public String toString() {
101 final StringBuilder sb = new StringBuilder();
102 sb.append("Params");
103 sb.append("{verb=");
104 sb.append(getVerb());
105 sb.append("}");
106 return sb.toString();
107 }
108 }