Commit 7c6b8973 authored by Günter Hipler's avatar Günter Hipler
Browse files

basic validation for all verbs

parent d684c058
Pipeline #13709 passed with stage
in 2 minutes and 46 seconds
......@@ -34,9 +34,10 @@ class OaiController @Inject()(cc: ControllerComponents,
until = until,
identifier = identifier,
resumptionToken = resumptionToken,
allQueryParameter = qP).checkQueryParameter
allQueryParameter = qP,
configuration = config).checkQueryParameter
val response = userRequest.getRunner(config, repository).run().createResponse
val response = userRequest.createResponse(config, repository)
/*
todo: make Writable for Node[Seq] so toString isn't necessary
......@@ -45,7 +46,7 @@ class OaiController @Inject()(cc: ControllerComponents,
[error] Ok(response.createResponse).as("text/xml")
*/
Ok(response.toString()).as("text/xml")
Ok(response).as("text/xml")
}
def fallback: Action[AnyContent] =
......
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.validation.ListRecordsValidation.checkParameterByName
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, GetRecordReq, ListRecordsReq, ListRecordsReqExclusive}
/*
https://www.openarchives.org/OAI/openarchivesprotocol.html#GetRecord
**identifier** a required argument that specifies the unique identifier of the item in the repository from which the record must be disseminated.
**metadataPrefix** a required argument that specifies the metadataPrefix of the format that should be included in the metadata part of the returned record . A record should only be returned if the format specified by the metadataPrefix can be disseminated from the item identified by the value of the identifier argument. The metadata formats supported by a repository and for a particular record can be retrieved using the ListMetadataFormats request.
Error and Exception Conditions
badArgument - The request includes illegal arguments or is missing required arguments.
cannotDisseminateFormat - The value of the metadataPrefix argument is not supported by the item identified by the value of the identifier argument.
idDoesNotExist - The value of the identifier argument is unknown or illegal in this repository.
*/
object GetRecordValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), None, None, None, Some(ident), None, allParameter, configuration) =>
checkParameterByName(allParameter, AllowedParameter.getRecord) match {
case Seq() => GetRecordReq(CheckedGetRecordParameter(verb.get, ident, mp ))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
//todo: make it right - only for completion here
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, _) =>
val setWithIllegalItems = checkParameterByName(allParameter, AllowedParameter.getRecord)
println(setWithIllegalItems)
val setWithMissingItems = checkMissingParameterByName(AllowedParameter.getRecord, allParameter)
println(setWithMissingItems)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
//todo: additional case cluases to catch other illegal combinations
}
}
\ No newline at end of file
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, IdentifyReq}
object IdentifyValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = {
/*
Error and Exception Conditions
badArgument - The request includes illegal arguments.
Response Format
The response must include one instance of the following elements:
repositoryName : a human readable name for the repository;
baseURL : the base URL of the repository;
protocolVersion : the version of the OAI-PMH supported by the repository;
earliestDatestamp : a UTCdatetime that is the guaranteed lower limit of all datestamps recording changes, modifications, or deletions in the repository. A repository must not use datestamps lower than the one specified by the content of the earliestDatestamp element. earliestDatestamp must be expressed at the finest granularity supported by the repository.
deletedRecord : the manner in which the repository supports the notion of deleted records. Legitimate values are no ; transient ; persistent with meanings defined in the section on deletion.
granularity: the finest harvesting granularity supported by the repository. The legitimate values are YYYY-MM-DD and YYYY-MM-DDThh:mm:ssZ with meanings as defined in ISO8601.
*/
//no additional arguments allowed
v1 match {
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, None, allParameter, configuration) =>
val diffSetParams = checkParameterByName(allParameter, AllowedParameter.identify)
if (diffSetParams.nonEmpty)
BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap))
else
IdentifyReq(CheckedIdentifyParameter(verb.get))
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, configuration) =>
val diffSetParams = checkParameterByName(allParameter, AllowedParameter.identify)
if (diffSetParams.nonEmpty)
BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap))
else
IdentifyReq(CheckedIdentifyParameter(verb.get))
}
}
}
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.validation.GetRecordValidation.{checkMissingParameterByName, checkParameterByName}
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListIdentifiersReq, ListIdentifiersReqExclusive, ListRecordsReq, ListRecordsReqExclusive}
/*
https://www.openarchives.org/OAI/openarchivesprotocol.html#ListIdentifiers
Arguments
**from** an optional argument with a UTCdatetime value, which specifies a lower bound for datestamp-based selective harvesting.
**until** an optional argument with a UTCdatetime value, which specifies a upper bound for datestamp-based selective harvesting.
**metadataPrefix** a required argument, which specifies that headers should be returned only if the metadata format matching the supplied metadataPrefix is available or, depending on the repository's support for deletions, has been deleted. The metadata formats supported by a repository and for a particular item can be retrieved using the ListMetadataFormats request.
**set** an optional argument with a setSpec value , which specifies set criteria for selective harvesting.
**resumptionToken** an exclusive argument with a value that is the flow control token returned by a previous ListIdentifiers request that issued an incomplete list.
Error and Exception Conditions
badArgument - The request includes illegal arguments or is missing required arguments.
badResumptionToken - The value of the resumptionToken argument is invalid or expired.
cannotDisseminateFormat - The value of the metadataPrefix argument is not supported by the repository.
noRecordsMatch- The combination of the values of the from, until, and set arguments results in an empty list.
noSetHierarchy - The repository does not support sets.
*/
object ListIdentifiersValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), set, from, until, None, None, allParameter, configuration) =>
//todo: check valid metadataPrefix
// check for additional illegal parameter
// check until not before from
// check for valid dates
checkParameterByName(allParameter, AllowedParameter.listIdentifiers) match {
case Seq() => ListIdentifiersReq(CheckedListIdentifiersParameter(verb.get, mp, set, from, until))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
//only resumption token with nothing else is possible
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, Some(resumptionToken), allParameter, configuration) =>
//todo: check for valid resumption token
checkParameterByName(allParameter, AllowedParameter.listIdentifiersResumption) match {
case Seq() => ListIdentifiersReqExclusive(CheckedListIdentifiersParameterExclusive(verb.get, resumptionToken))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
//todo: make it right - only for completion here
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter,_ ) =>
//todo: ich muss noch einen Weg finden herauszufinden, welche Kombination dieser Parameter dazu führt, dass diese
// Kombination nicht erlaubt ist
val setWithIllegalItems = checkParameterByName(allParameter, AllowedParameter.listIdentifiersAllAllowed)
println(setWithIllegalItems)
//todo: is this correct?
val setWithMissingItems = checkMissingParameterByName(AllowedParameter.listIdentifiersAllAllowed, allParameter)
println(setWithMissingItems)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
}
\ No newline at end of file
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListMetadataFormatsReq}
/*
Arguments
https://www.openarchives.org/OAI/openarchivesprotocol.html#ListMetadataFormats
identifier an optional argument that specifies the unique identifier of the item for which available metadata formats are being requested. If this argument is omitted, then the response includes all metadata formats supported by this repository. Note that the fact that a metadata format is supported by a repository does not mean that it can be disseminated from all items in the repository.
Error and Exception Conditions
badArgument - The request includes illegal arguments or is missing required arguments.
idDoesNotExist - The value of the identifier argument is unknown or illegal in this repository.
noMetadataFormats - There are no metadata formats available for the specified item.
*/
object ListMetadataFormatsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, None, None, None, None, identifier, None,allQueryParameter, _) =>
//todo: check valid metadataPrefix
// check for additional illegal parameter
// check until not before from
// check for valid dates
checkParameterByName(allQueryParameter, AllowedParameter.listMetadataFormatsAllowed) match {
case Seq() => ListMetadataFormatsReq(CheckedListMetadaFormatsParameter(verb.get,identifier))
case setWithIllegalItems =>
println(setWithIllegalItems)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, _) =>
val setWithIllegalItems = checkParameterByName(allParameter, AllowedParameter.listMetadataFormatsAllowed)
println(setWithIllegalItems)
val setWithMissingItems = checkMissingParameterByName(AllowedParameter.listMetadataFormatsMandatory, allParameter)
println(setWithMissingItems)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
//todo: additional case cluases to catch other illegal combinations
}
}
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.validation.GetRecordValidation.{checkMissingParameterByName, checkParameterByName}
import org.swissbib.memobase.oai.common.verb.OaiVerb
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, IdentifyReq, ListRecordsReq, ListRecordsReqExclusive}
/*
/*
https://www.openarchives.org/OAI/openarchivesprotocol.html#ListRecords
Arguments
**from** an optional argument with a UTCdatetime value, which specifies a lower bound for datestamp-based selective harvesting.
**until** an optional argument with a UTCdatetime value, which specifies a upper bound for datestamp-based selective harvesting.
**set** an optional argument with a setSpec value , which specifies set criteria for selective harvesting.
**resumptionToken** an exclusive argument with a value that is the flow control token returned by a previous ListRecords request that issued an incomplete list.
**metadataPrefix** a required argument (unless the exclusive argument resumptionToken is used) that specifies the metadataPrefix of the format that should be included in the metadata part of the returned records. Records should be included only for items from which the metadata format
matching the metadataPrefix can be disseminated. The metadata formats supported by a repository and for a particular item can be retrieved using the ListMetadataFormats request.
Error and Exception Conditions
badArgument - The request includes illegal arguments or is missing required arguments.
badResumptionToken - The value of the resumptionToken argument is invalid or expired.
cannotDisseminateFormat - The value of the metadataPrefix argument is not supported by the repository.
noRecordsMatch - The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.
noSetHierarchy - The repository does not support sets.
*/
this match {
case OaiRequest(_,Some(mp),set, from,until,None,resumptiontoken,_) => true
case _ => false
}
}
*/
object ListRecordsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), set, from, until, None, None, allParameter, configuration) =>
//todo: check valid metadataPrefix
// check for additional illegal parameter
// check until not before from
// check for valid dates
ListRecordsReq(CheckedListRecordsParameter(verb.get,mp, from, until, set))
//only resumption token with nothing else is possible
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, resumptionToken, allParameter, configuration) =>
//todo: check for valid resumption token
checkParameterByName(allParameter, AllowedParameter.listRecordResumption) match {
case Seq() => ListRecordsReqExclusive(CheckedListRecordsParameterExclusive(verb.get, resumptionToken.get))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, configuration) =>
//todo: das nochmals anschauen
checkParameterByName(allParameter, AllowedParameter.listRecordsAllAllowed) match {
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
}
}
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.validation.GetRecordValidation.checkParameterByName
import org.swissbib.memobase.oai.common.validation.ListRecordsValidation.checkParameterByName
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListRecordsReq, ListRecordsReqExclusive, ListSetsReq}
/*
https://www.openarchives.org/OAI/openarchivesprotocol.html#ListSets
Arguments
resumptionToken an exclusive argument with a value that is the flow control token returned by a previous ListSets request that issued an incomplete list.
GH: guess we do not need this for memobase because there aren't so much sets - probably
Error and Exception Conditions
badArgument - The request includes illegal arguments or is missing required arguments.
badResumptionToken - The value of the resumptionToken argument is invalid or expired.
noSetHierarchy - The repository does not support sets.
*/
object ListSetsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, None, allParameter, configuration) =>
checkParameterByName(allParameter, AllowedParameter.listSetsAllowed) match {
case Seq() => ListSetsReq(CheckedListSetsParameter(verb.get))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, _, allParameter, configuration) =>
checkParameterByName(allParameter, AllowedParameter.listSetsAllowed) match {
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, configuration) =>
//todo: das nochmals anschauen
checkParameterByName(allParameter, AllowedParameter.listSetsAllowed) match {
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import org.swissbib.memobase.oai.common.verb.OaiVerb.{ListSets, OaiVerb}
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, SystemErrorReq}
import scala.util.{Failure, Success}
import play.api.Configuration
case class OaiCheckedVerbWithParameter(verb:Option[OaiVerb],
metadataPrefix: Option[String],
......@@ -13,7 +14,8 @@ case class OaiCheckedVerbWithParameter(verb:Option[OaiVerb],
until:Option[String],
identifier: Option[String],
resumptionToken: Option[String],
allQueryParameter: Map[String, Seq[String]])
allQueryParameter: Map[String, Seq[String]],
configuration: Configuration)
class OaiQueryParameterChecker(verb: Option[String],
metadataPrefix: Option[String],
......@@ -22,36 +24,45 @@ class OaiQueryParameterChecker(verb: Option[String],
until:Option[String],
identifier: Option[String],
resumptionToken: Option[String],
allQueryParameter: Map[String, Seq[String]]) {
allQueryParameter: Map[String, Seq[String]],
configuration: Configuration) {
def checkQueryParameter: BaseUserRequest = {
OaiVerb.getVerb(verb) match {
case Success(value) =>
value match {
case OaiVerb.GetRecord => GetRecordValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.Identify => IdentifyValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListIdentifiers => ListIdentifiersValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListMetadataFormats => ListMetadataFormatsValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListRecords => ListRecordsValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListSets => ListSetsValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken, allQueryParameter))
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
//todo: wie gehe ich hier mit missing vern in der Fehleranzeige um??
case OaiVerb.WrongVerb | OaiVerb.MissingVerb =>
//it is possible that users send these not allowed enum values
//only used as part of the type to round up the workflow
BadArgumentsReq(BadArgumentsParameter(Map("badVerb" -> s"Invalid verb $verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb, Map("badVerb" -> s"Invalid verb $verb in request")))
}
case Failure(_:MissingParameterException) =>
//todo: see WrongVerb or MissingVerb
BadArgumentsReq(BadArgumentsParameter(Map("badVerb" -> s"missing verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb, Map("badVerb" -> s"missing verb in request")))
case Failure(_: NoSuchElementException) =>
//todo: see WrongVerb or MissingVerb
BadArgumentsReq(BadArgumentsParameter(Map("badVerb" -> s"Invalid verb $verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb, Map("badVerb" -> s"Invalid verb $verb in request")))
case Failure(exception) =>
SystemErrorReq(exception)
}
......
......@@ -73,7 +73,7 @@ case class CheckedListSetsParameter (verb:OaiVerb) extends OaiParameterBase {
override def listRequestParameters: Map[String, String] = Map()
}
case class BadArgumentsParameter (badArguments: Map[String,String]) extends OaiParameterBase {
case class BadArgumentsParameter (verb: OaiVerb ,badArguments: Map[String,String]) extends OaiParameterBase {
//require on verb is not possible because could be any out of the Enums type
override def listRequestParameters: Map[String, String] = Map()
......
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.validation.IdentifyValidation.checkParameterByName
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, IdentifyReq}
private object AllowedParameter {
val identify = List("verb")
}
abstract sealed class ParameterValidationFunction () extends Function1[OaiCheckedVerbWithParameter, BaseUserRequest] {
def checkParameterByName(paramsInReq: Map[String, Seq[String]], allowedList:List[String]) = {
paramsInReq.keySet.diff(allowedList.toSet)
val listRecordResumption = List("verb","resumptionToken")
val getRecord = List("verb","identifier","metadataPrefix")
val listMetadataFormatsAllowed = List("verb","identifier")
val listMetadataFormatsMandatory = List("verb")
val listSetsAllowed = List("verb")
val listIdentifiers = List("verb", "from", "until", "metadataPrefix", "set")
val listIdentifiersResumption = List("verb","resumptionToken")
val listIdentifiersAllAllowed = List("verb", "from", "until", "metadataPrefix", "set", "resumptionToken")
val listRecordsAllAllowed = List("verb", "from", "until", "metadataPrefix", "set", "resumptionToken")
/*
**from** an optional argument with a UTCdatetime value, which specifies a lower bound for datestamp-based selective harvesting.
**until** an optional argument with a UTCdatetime value, which specifies a upper bound for datestamp-based selective harvesting.
**metadataPrefix** a required argument, which specifies that headers should be returned only if the metadata format matching the supplied metadataPrefix is available or, depending on the repository's support for deletions, has been deleted. The metadata formats supported by a repository and for a particular item can be retrieved using the ListMetadataFormats request.
**set** an optional argument with a setSpec value , which specifies set criteria for selective harvesting.
**resumptionToken** an exclusive argument with a value that is the flow control token returned by a previous ListIdentifiers request that issued an incomplete list.
*/
}
abstract class ParameterValidationFunction () extends Function1[OaiCheckedVerbWithParameter, BaseUserRequest] {
def checkParameterByName(paramsInReq: Map[String, Seq[String]], allowedList:List[String]): Seq[String] = {
paramsInReq.keySet.diff(allowedList.toSet).toSeq
}
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest
}
object GetRecordValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = ???
}
object ListRecordsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = ???
}
object ListSetsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = ???
}
object IdentifyValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = {
/*
Error and Exception Conditions
badArgument - The request includes illegal arguments.
Response Format
The response must include one instance of the following elements:
repositoryName : a human readable name for the repository;
baseURL : the base URL of the repository;
protocolVersion : the version of the OAI-PMH supported by the repository;
earliestDatestamp : a UTCdatetime that is the guaranteed lower limit of all datestamps recording changes, modifications, or deletions in the repository. A repository must not use datestamps lower than the one specified by the content of the earliestDatestamp element. earliestDatestamp must be expressed at the finest granularity supported by the repository.
deletedRecord : the manner in which the repository supports the notion of deleted records. Legitimate values are no ; transient ; persistent with meanings defined in the section on deletion.
granularity: the finest harvesting granularity supported by the repository. The legitimate values are YYYY-MM-DD and YYYY-MM-DDThh:mm:ssZ with meanings as defined in ISO8601.
*/
//no additional arguments allowed
v1 match {
case OaiCheckedVerbWithParameter(verb,None,None, None,None,None,None,allParameter) =>
val diffSetParams = checkParameterByName(allParameter,AllowedParameter.identify)
if (diffSetParams.nonEmpty)
BadArgumentsReq(BadArgumentsParameter(diffSetParams.map(key => (key,key)).toMap))
else
IdentifyReq(CheckedIdentifyParameter(verb.get))
case OaiCheckedVerbWithParameter(verb,_,_, _,_,_,_,allParameter) =>
val diffSetParams = checkParameterByName(allParameter,AllowedParameter.identify)
if (diffSetParams.nonEmpty)
BadArgumentsReq(BadArgumentsParameter(diffSetParams.map(key => (key,key)).toMap))
else
IdentifyReq(CheckedIdentifyParameter(verb.get))
}
def checkMissingParameterByName(allowedList:List[String], paramsInReq: Map[String, Seq[String]]): Seq[String] = {
allowedList.toSet.diff(paramsInReq.keySet).toSeq
}
//OaiRequest()
}
object ListIdentifiersValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = ???
}
object ListMetadataFormatsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = ???
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest
}
......
package org.swissbib.memobase.oai.common.verb
import org.swissbib.memobase.oai.common.validation.{MissingParameterException, MissingQueryParameter, SystemFailureRequestValidation, WrongQueryParameterValue}
import scala.util.{Try}
import scala.util.Try
object OaiVerb extends Enumeration {
......
......@@ -2,43 +2,51 @@ package org.swissbib.memobase.oai.request
import modules.OaiRepository
import org.swissbib.memobase.oai.common.validation.{BadArgumentsParameter, CheckedGetRecordParameter, CheckedIdentifyParameter, CheckedListIdentifiersParameter, CheckedListIdentifiersParameterExclusive, CheckedListMetadaFormatsParameter, CheckedListRecordsParameter, CheckedListRecordsParameterExclusive, CheckedListSetsParameter, CheckedListSetsParameterExclusive, OaiParameterBase}
import org.swissbib.memobase.oai.common.verb.OaiVerb.OaiVerb
import org.swissbib.memobase.oai.runner.{IdentifyRunner, OaiRequestRunner}
import org.swissbib.memobase.oai.response.OaiResponse
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, GetRecordRunner, IdentifyRunner, ListIdentifiersExclusiveRunner, ListIdentifiersRunner, ListMetadataFormatsRunner, ListRecordsExclusiveRunner, ListRecordsRunner, ListSetsRunner, OaiRequestRunner}
import play.api.Configuration