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

better handling for request parameters - additional base for better

error handling
a little bit code refactoring
parent 7166db9f
Pipeline #23341 passed with stage
in 2 minutes and 48 seconds
......@@ -47,17 +47,20 @@ object GetRecordValidation extends ParameterValidationFunction {
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))
case Seq() => GetRecordReq(CheckedGetRecordParameter(verb.get, ident, mp, allParameter ))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
//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))
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap, allParameter ))
//todo: additional case cluases to catch other illegal combinations
}
......
......@@ -46,17 +46,19 @@ object IdentifyValidation extends ParameterValidationFunction {
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))
if (diffSetParams.nonEmpty) {
BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter))
} else {
IdentifyReq(CheckedIdentifyParameter(verb.get, allParameter))
}
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))
if (diffSetParams.nonEmpty) {
BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter))
} else {
IdentifyReq(CheckedIdentifyParameter(verb.get, allParameter))
}
}
}
}
......
......@@ -59,8 +59,10 @@ object ListIdentifiersValidation extends ParameterValidationFunction {
// 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))
case Seq() => ListIdentifiersReq(CheckedListIdentifiersParameter(verb.get, mp, set, from, until, allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
//only resumption token with nothing else is possible
......@@ -70,22 +72,26 @@ object ListIdentifiersValidation extends ParameterValidationFunction {
ESResumptionTokenHelper.createResumptionTokenFromOaiToken(resumptionToken) match {
case Success(rt) =>
checkParameterByName(allParameter, AllowedParameter.listIdentifiersResumption) match {
case Seq() => ListIdentifiersReqExclusive(CheckedListIdentifiersParameterExclusive(verb.get, rt))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
case Seq() => ListIdentifiersReqExclusive(CheckedListIdentifiersParameterExclusive(verb.get
,rt
,allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
case Failure(exceptionRT) =>
BadArgumentsReq(BadArgumentsParameter(verb.get, Map("resumptionToken" -> exceptionRT.getMessage)))
BadArgumentsReq(BadArgumentsParameter(verb.get, Map("resumptionToken" -> exceptionRT.getMessage)
, allParameter))
}
//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))
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
......
......@@ -51,18 +51,18 @@ object ListMetadataFormatsValidation extends ParameterValidationFunction {
// check for valid dates
checkParameterByName(allQueryParameter, AllowedParameter.listMetadataFormatsAllowed) match {
case Seq() => ListMetadataFormatsReq(CheckedListMetadaFormatsParameter(verb.get,identifier))
case Seq() => ListMetadataFormatsReq(CheckedListMetadaFormatsParameter(verb.get,identifier
,allQueryParameter))
case setWithIllegalItems =>
println(setWithIllegalItems)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allQueryParameter))
}
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))
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
//todo: additional case cluases to catch other illegal combinations
}
......
......@@ -69,18 +69,24 @@ object ListRecordsValidation extends ParameterValidationFunction {
// check for additional illegal parameter
// check until not before from
// check for valid dates
ListRecordsReq(CheckedListRecordsParameter(verb.get,mp, from, until, set))
ListRecordsReq(CheckedListRecordsParameter(verb.get,mp, from, until, set
,allParameter))
//only resumption token with nothing else is possible
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, resumptionToken, allParameter, configuration) =>
ESResumptionTokenHelper.createResumptionTokenFromOaiToken(resumptionToken.get) match {
case Success(rt) =>
checkParameterByName(allParameter, AllowedParameter.listRecordResumption) match {
case Seq() => ListRecordsReqExclusive(CheckedListRecordsParameterExclusive(verb.get, rt))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
case Seq() => ListRecordsReqExclusive(CheckedListRecordsParameterExclusive(verb.get, rt
, allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
case Failure(exceptionRT) =>
BadArgumentsReq(BadArgumentsParameter(verb.get, Map("resumptionToken" -> exceptionRT.getMessage)))
BadArgumentsReq(BadArgumentsParameter(verb.get,
Map("resumptionToken" -> exceptionRT.getMessage),
allParameter))
}
......@@ -89,7 +95,9 @@ object ListRecordsValidation extends ParameterValidationFunction {
//todo: das nochmals anschauen
checkParameterByName(allParameter, AllowedParameter.listRecordsAllAllowed) match {
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
}
......
......@@ -45,19 +45,26 @@ object ListSetsValidation extends ParameterValidationFunction {
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 Seq() => ListSetsReq(CheckedListSetsParameter(verb.get
, allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
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 setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
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))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
......
......@@ -48,6 +48,7 @@ class OaiQueryParameterChecker(verb: Option[String],
resumptionToken: Option[String],
allQueryParameter: Map[String, Seq[String]],
configuration: Configuration) {
//noinspection ScalaStyle
def checkQueryParameter: BaseUserRequest = {
OaiVerb.getVerb(verb) match {
......@@ -76,15 +77,21 @@ class OaiQueryParameterChecker(verb: Option[String],
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(OaiVerb.MissingVerb, Map("badVerb" -> s"Invalid verb $verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb
, Map("badVerb" -> s"Invalid verb $verb in request")
, allQueryParameter))
}
case Failure(_:MissingParameterException) =>
//todo: see WrongVerb or MissingVerb
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb, Map("badVerb" -> s"missing verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb
, Map("badVerb" -> s"missing verb in request")
, allQueryParameter))
case Failure(_: NoSuchElementException) =>
//todo: see WrongVerb or MissingVerb
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb, Map("badVerb" -> s"Invalid verb $verb in request")))
BadArgumentsReq(BadArgumentsParameter(OaiVerb.MissingVerb
, Map("badVerb" -> s"Invalid verb $verb in request")
, allQueryParameter))
case Failure(exception) =>
SystemErrorReq(exception)
}
......
......@@ -26,7 +26,7 @@ import org.swissbib.memobase.oai.common.util.ResumptionToken
import org.swissbib.memobase.oai.common.verb.OaiVerb.{GetRecord, Identify, ListIdentifiers, ListMetadataFormats, ListRecords, ListSets, OaiVerb}
sealed abstract class OaiParameterBase() extends Product with Serializable {
def listRequestParameters: Map[String,String]
val allQueryParameter: Map[String, Seq[String]]
}
case class ParameterToCheck(verb:Option[OaiVerb],
......@@ -37,67 +37,69 @@ case class ParameterToCheck(verb:Option[OaiVerb],
identifier: Option[String],
resumptionToken: Option[String],
allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedIdentifyParameter (verb:OaiVerb) extends OaiParameterBase {
case class CheckedIdentifyParameter (verb:OaiVerb, allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == Identify)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedGetRecordParameter (verb:OaiVerb, identifier: String, metadataPrefix: String) extends OaiParameterBase {
case class CheckedGetRecordParameter (verb:OaiVerb, identifier: String, metadataPrefix: String
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == GetRecord)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedListIdentifiersParameter (verb:OaiVerb, metadataPrefix: String, set:Option[String],
from:Option[String], until:Option[String]) extends OaiParameterBase {
case class CheckedListIdentifiersParameter (verb:OaiVerb, metadataPrefix: String, set:Option[String]
,from:Option[String], until:Option[String]
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListIdentifiers)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedListIdentifiersParameterExclusive (verb:OaiVerb, resumptionToken: ResumptionToken) extends OaiParameterBase {
case class CheckedListIdentifiersParameterExclusive (verb:OaiVerb
,resumptionToken: ResumptionToken
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListIdentifiers)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedListMetadaFormatsParameter(verb:OaiVerb, identifier: Option[String]) extends OaiParameterBase {
case class CheckedListMetadaFormatsParameter(verb:OaiVerb
,identifier: Option[String]
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListMetadataFormats)
override def listRequestParameters: Map[String, String] = Map()
}
final case class CheckedListRecordsParameter (verb:OaiVerb,
metadataPrefix: String,
from: Option[String],
until: Option[String],
set: Option[String]) extends OaiParameterBase {
until: Option[String]
,set: Option[String]
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListRecords)
override def listRequestParameters: Map[String, String] = Map()
}
final case class CheckedListRecordsParameterExclusive (verb:OaiVerb, resumptionToken: ResumptionToken) extends OaiParameterBase {
final case class CheckedListRecordsParameterExclusive (verb:OaiVerb
,resumptionToken: ResumptionToken
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListRecords)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedListSetsParameterExclusive (verb:OaiVerb, resumptionToken: String) extends OaiParameterBase {
case class CheckedListSetsParameterExclusive (verb:OaiVerb
,resumptionToken: String
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListSets)
override def listRequestParameters: Map[String, String] = Map()
}
case class CheckedListSetsParameter (verb:OaiVerb) extends OaiParameterBase {
case class CheckedListSetsParameter (verb:OaiVerb,
allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
require(verb == ListSets)
override def listRequestParameters: Map[String, String] = Map()
}
case class BadArgumentsParameter (verb: OaiVerb ,badArguments: Map[String,String]) extends OaiParameterBase {
case class BadArgumentsParameter (verb: OaiVerb
,badArguments: Map[String,String]
,allQueryParameter: Map[String, Seq[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()
}
......@@ -26,14 +26,13 @@ package org.swissbib.memobase.oai.response
import java.time.Instant
import com.typesafe.config.{ConfigObject, ConfigValue}
import modules.OAIContent
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, GetRecordRunner, IdentifyRunner, OaiRequestRunner,
ResultList}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, GetRecordRunner, IdentifyRunner, OaiRequestRunner, ResultList}
import scala.collection.immutable
import scala.xml.{Elem, Node, Text, XML}
import scala.xml.transform.{RewriteRule, RuleTransformer}
import scala.xml.{UnprefixedAttribute, MetaData, TopScope, Text, Elem, Null, Node, XML}
sealed abstract class OaiResponse {
sealed abstract class OaiResponse (runner: OaiRequestRunner) {
def makeHeader (del:Boolean = false,
set: String = "memobaseSet",
......@@ -46,6 +45,35 @@ sealed abstract class OaiResponse {
</header>
def createRequestTag: Elem = {
//completely scala xml voodoo...
//https://stackoverflow.com/questions/43751677/how-to-create-xml-attributes-dynamic-via-map-in-scala
//take some time to understand this...
val seed: MetaData = Null
val meta: MetaData = runner.request.parameterBase.allQueryParameter.toList.foldLeft(seed) {
case (acc, (s1, s2)) =>
new UnprefixedAttribute(
//filter out characters used for multiple parameter
key = s1.replaceAll("""[\[\]]""",""),
value = s2.mkString(","),
next = acc
)
}
//first try
//<request verb={runner.request.parameter.verb.toString}>{runner.repository.oaiConfig.identify.baseUrl}</request>
//noinspection ScalaStyle
Elem(
prefix = null,
label = "request",
attributes = meta,
scope = TopScope,
minimizeEmpty = false,
child = Text(runner.repository.oaiConfig.identify.baseUrl)
)
}
protected def createOaiFrame: Elem = {
/*
val oaiFrame =
......@@ -56,11 +84,8 @@ sealed abstract class OaiResponse {
*/
val oaiFrame =
/*<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" >*/
// <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" >
//noinspection ScalaStyle
<OAI-PMH xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns="http://www.openarchives.org/OAI/2.0/" >
<responseDate>{Instant.now()}</responseDate>
{createRequestTag}
</OAI-PMH>
......@@ -71,7 +96,6 @@ sealed abstract class OaiResponse {
}
def createResponse:Seq[Node]
def createRequestTag: Elem
override def toString: String = s"Ich bin eine OAI response mit Header für : $getVerb} "
......@@ -79,13 +103,9 @@ sealed abstract class OaiResponse {
}
case class GetRecordResponse(runner: GetRecordRunner, result: OAIContent) extends OaiResponse {
case class GetRecordResponse(runner: GetRecordRunner, result: OAIContent) extends OaiResponse(runner) {
override def toString: String = s"Ich bin eine GetRecord response mit Header für : GetRecord "
override def createRequestTag: Elem = {
<request verb="GetRecord">{runner.repository.oaiConfig.identify.baseUrl}</request>
}
override def createResponse: Seq[Node] = {
......@@ -117,11 +137,9 @@ case class GetRecordResponse(runner: GetRecordRunner, result: OAIContent) extend
case class IdentifyResponse(runner: IdentifyRunner) extends OaiResponse{
case class IdentifyResponse(runner: IdentifyRunner) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine Identify response mit Header für : Identify "
override def createRequestTag: Elem =
<request verb="Identify">{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......@@ -156,11 +174,9 @@ case class IdentifyResponse(runner: IdentifyRunner) extends OaiResponse{
}
case class ListIdentifiersResponse(runner: OaiRequestRunner, resultList: ResultList) extends OaiResponse {
case class ListIdentifiersResponse(runner: OaiRequestRunner, resultList: ResultList) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine ListIdentifiers response mit Header für : ListIdentifiers"
override def createRequestTag: Elem =
<request verb="ListIdentifiers">{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......@@ -193,11 +209,9 @@ case class ListIdentifiersResponse(runner: OaiRequestRunner, resultList: ResultL
}
}
case class ListMetadaFormatsResponse(runner: OaiRequestRunner) extends OaiResponse {
case class ListMetadaFormatsResponse(runner: OaiRequestRunner) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine ListMetadaFormats response mit Header für : ListMetadaFormats "
override def createRequestTag: Elem =
<request verb="ListMetadataFormats">{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......@@ -229,11 +243,9 @@ case class ListMetadaFormatsResponse(runner: OaiRequestRunner) extends OaiRespon
}
}
case class ListRecordsResponse(runner: OaiRequestRunner, resultList: ResultList) extends OaiResponse {
case class ListRecordsResponse(runner: OaiRequestRunner, resultList: ResultList) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine ListRecords response mit Header für : ListRecords "
override def createRequestTag: Elem =
<request verb="ListRecords">{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......@@ -269,8 +281,6 @@ case class ListRecordsResponse(runner: OaiRequestRunner, resultList: ResultList)
}}
}
</ListRecords>
case n => n
}
......@@ -279,11 +289,9 @@ case class ListRecordsResponse(runner: OaiRequestRunner, resultList: ResultList)
}
}
case class ListSetsResponse(runner: OaiRequestRunner) extends OaiResponse {
case class ListSetsResponse(runner: OaiRequestRunner) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine ListSets response mit Header für : ListSets "
override def createRequestTag: Elem =
<request verb="ListSets">{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......@@ -312,11 +320,9 @@ case class ListSetsResponse(runner: OaiRequestRunner) extends OaiResponse {
}
}
case class BadArgumentsResponse(runner: BadArgumentsErrorRunner) extends OaiResponse {
case class BadArgumentsResponse(runner: BadArgumentsErrorRunner) extends OaiResponse (runner) {
override def toString: String = s"Ich bin eine BadArguments response "
override def createRequestTag: Elem =
<request verb={runner.request.parameter.verb.toString}>{runner.repository.oaiConfig.identify.baseUrl}</request>
override def createResponse: Seq[Node] = {
......
......@@ -23,9 +23,9 @@
package org.swissbib.memobase.oai.runner
import modules.OaiRepository
import org.swissbib.memobase.oai.request.{BadArgumentsReq, GetRecordReq, IdentifyReq, ListIdentifiersReq,
ListIdentifiersReqExclusive, ListMetadataFormatsReq, ListRecordsReq, ListRecordsReqExclusive,
ListSetsReq, ListSetsReqExclusive}
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, GetRecordReq, IdentifyReq,
ListIdentifiersReq, ListIdentifiersReqExclusive, ListMetadataFormatsReq,
ListRecordsReq, ListRecordsReqExclusive, ListSetsReq, ListSetsReqExclusive}
import org.swissbib.memobase.oai.response.{BadArgumentsResponse, GetRecordResponse, IdentifyResponse,
ListIdentifiersResponse, ListMetadaFormatsResponse, ListRecordsResponse, ListSetsResponse, OaiResponse}
import play.api.Configuration
......@@ -37,6 +37,7 @@ sealed abstract class OaiRequestRunner {
def run(): OaiResponse
val config: Configuration
val repository: OaiRepository
val request: BaseUserRequest
}
......@@ -171,6 +172,7 @@ case class GetExceptionRunner(config: Configuration, repository: OaiRepository,
case class BadArgumentsErrorRunner(config: Configuration, repository: OaiRepository, request:
BadArgumentsReq) extends OaiRequestRunner {
override def run(): OaiResponse = BadArgumentsResponse(this)
}
......
GET memobase-old-data-direct-v2/_search
{
"size": 20,
"from": 20,
"query": {
"match_all": {}
},
"sort": [
{
"title.ns2:title": {
"order": "desc"
}
}
]
}
GET memobase-old-data-direct-v2/_search