Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

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

first package 'remove all useless request - type - only runners'

parent 64e0b807
Pipeline #23443 passed with stage
in 2 minutes and 26 seconds
......@@ -26,13 +26,12 @@ import javax.inject.Inject
import modules.OaiRepository
import org.swissbib.memobase.oai.common.validation.OaiQueryParameterChecker
import org.swissbib.memobase.oai.request.BaseUserRequest
import org.swissbib.memobase.oai.runner.OaiRunner
import play.api.Configuration
import play.api.mvc.{AbstractController, Action, AnyContent, ControllerComponents, Rendering}
class OaiController @Inject()(cc: ControllerComponents,
config: Configuration,
repository:OaiRepository,
) extends AbstractController(cc) with Rendering {
class OaiController @Inject()(cc: ControllerComponents)
(implicit config: Configuration,repository:OaiRepository ) extends AbstractController(cc) with Rendering {
//todo: better way might be to use a so called BindController - have a look into this type part of this package
......@@ -49,7 +48,7 @@ class OaiController @Inject()(cc: ControllerComponents,
Action { implicit request =>
val qP: Map[String, Seq[String]] = request.queryString
val userRequest: BaseUserRequest = new OaiQueryParameterChecker(
val runner: OaiRunner = new OaiQueryParameterChecker(
verb = verb,
metadataPrefix = metadataPrefix,
set = set,
......@@ -60,7 +59,8 @@ class OaiController @Inject()(cc: ControllerComponents,
allQueryParameter = qP,
configuration = config).checkQueryParameter
val response = userRequest.createResponse(config, repository)
val response = runner.run().createResponse.toString()
//val response = userRequest.createResponse(config, repository)
/*
todo: make Writable for Node[Seq] so toString isn't necessary
......
......@@ -23,7 +23,7 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, GetRecordReq}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, GetRecordRunner, OaiRunner}
......@@ -41,14 +41,15 @@ idDoesNotExist - The value of the identifier argument is unknown or illegal in t
object GetRecordValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), None, None, None, Some(ident), None, allParameter, configuration) =>
case OaiCheckedVerbWithParameter(verb, Some(metadataPrefix), None, None, None, Some(ident), None, allParameter, configuration) =>
checkParameterByName(allParameter, AllowedParameter.getRecord) match {
case Seq() => GetRecordReq(CheckedGetRecordParameter(verb.get, ident, mp, allParameter ))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
case Seq() => GetRecordRunner(CheckedGetRecordParameter(verb.get, ident, metadataPrefix, allParameter ))
case setWithIllegalItems =>
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
......@@ -56,11 +57,8 @@ object GetRecordValidation extends ParameterValidationFunction {
//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, allParameter ))
//val setWithMissingItems = checkMissingParameterByName(AllowedParameter.getRecord, allParameter)
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap, allParameter ))
//todo: additional case cluases to catch other illegal combinations
}
......
......@@ -24,9 +24,10 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, IdentifyReq}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, IdentifyRunner, OaiRunner}
object IdentifyValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest = {
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner = {
/*
Error and Exception Conditions
badArgument - The request includes illegal arguments.
......@@ -47,17 +48,20 @@ object IdentifyValidation extends ParameterValidationFunction {
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, allParameter))
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter ))
//BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter))
} else {
IdentifyReq(CheckedIdentifyParameter(verb.get, allParameter))
IdentifyRunner(CheckedIdentifyParameter(verb.get, allParameter))
//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, allParameter))
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter ))
//BadArgumentsReq(BadArgumentsParameter(verb.get, diffSetParams.map(key => (key, key)).toMap, allParameter))
} else {
IdentifyReq(CheckedIdentifyParameter(verb.get, allParameter))
IdentifyRunner(CheckedIdentifyParameter(verb.get, allParameter))
}
}
}
......
......@@ -24,6 +24,7 @@ package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.util.ESResumptionTokenHelper
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListIdentifiersReq, ListIdentifiersReqExclusive}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, ListIdentifiersRunner, OaiRunner}
import scala.util.{Failure, Success}
......@@ -49,7 +50,7 @@ noSetHierarchy - The repository does not support sets.
object ListIdentifiersValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), set, from, until, None, None, allParameter, configuration) =>
......@@ -59,8 +60,8 @@ 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, allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
case Seq() => ListIdentifiersRunner(CheckedListIdentifiersParameter(verb.get, mp, set, from, until, allParameter))
case setWithIllegalItems => BadArgumentsErrorRunner(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
......@@ -72,15 +73,16 @@ object ListIdentifiersValidation extends ParameterValidationFunction {
ESResumptionTokenHelper.createResumptionTokenFromOaiToken(resumptionToken) match {
case Success(rt) =>
checkParameterByName(allParameter, AllowedParameter.listIdentifiersResumption) match {
case Seq() => ListIdentifiersReqExclusive(CheckedListIdentifiersParameterExclusive(verb.get
,rt
,allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
case Seq() => ???
//ListIdentifiersReqExclusive(CheckedListIdentifiersParameterExclusive(verb.get
//,rt
//,allParameter))
case setWithIllegalItems => BadArgumentsErrorRunner(BadArgumentsParameter(verb.get
,setWithIllegalItems.map(key => (key, key)).toMap
,allParameter))
}
case Failure(exceptionRT) =>
BadArgumentsReq(BadArgumentsParameter(verb.get, Map("resumptionToken" -> exceptionRT.getMessage)
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, Map("resumptionToken" -> exceptionRT.getMessage)
, allParameter))
}
//todo: make it right - only for completion here
......@@ -90,7 +92,7 @@ object ListIdentifiersValidation extends ParameterValidationFunction {
val setWithIllegalItems = checkParameterByName(allParameter, AllowedParameter.listIdentifiersAllAllowed)
//todo: is this correct?
val setWithMissingItems = checkMissingParameterByName(AllowedParameter.listIdentifiersAllAllowed, allParameter)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
......
......@@ -24,6 +24,7 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListMetadataFormatsReq}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, ListMetadataFormatsRunner, OaiRunner}
/*
......@@ -40,7 +41,7 @@ import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, List
object ListMetadataFormatsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, None, None, None, None, identifier, None,allQueryParameter, _) =>
......@@ -51,17 +52,17 @@ object ListMetadataFormatsValidation extends ParameterValidationFunction {
// check for valid dates
checkParameterByName(allQueryParameter, AllowedParameter.listMetadataFormatsAllowed) match {
case Seq() => ListMetadataFormatsReq(CheckedListMetadaFormatsParameter(verb.get,identifier
case Seq() => ListMetadataFormatsRunner(CheckedListMetadaFormatsParameter(verb.get,identifier
,allQueryParameter))
case setWithIllegalItems =>
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allQueryParameter))
}
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, _) =>
val setWithIllegalItems = checkParameterByName(allParameter, AllowedParameter.listMetadataFormatsAllowed)
val setWithMissingItems = checkMissingParameterByName(AllowedParameter.listMetadataFormatsMandatory, allParameter)
BadArgumentsReq(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
BadArgumentsErrorRunner(BadArgumentsParameter(verb.get, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
//todo: additional case cluases to catch other illegal combinations
}
......
......@@ -25,6 +25,7 @@ package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.util.ESResumptionTokenHelper
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListRecordsReq, ListRecordsReqExclusive}
import org.swissbib.memobase.oai.runner.{ListRecordsRunner, OaiRunner}
import scala.util.{Failure, Success}
......@@ -60,20 +61,21 @@ import scala.util.{Failure, Success}
*/
object ListRecordsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner =
v1 match {
//possible valid combination
case OaiCheckedVerbWithParameter(verb, Some(mp), set, from, until, None, None, allParameter, configuration) =>
case OaiCheckedVerbWithParameter(verb, Some(metadataPrefix), 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
ListRecordsRunner(CheckedListRecordsParameter(verb.get,metadataPrefix, from, until, set
,allParameter))
//only resumption token with nothing else is possible
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, resumptionToken, allParameter, configuration) =>
case OaiCheckedVerbWithParameter(verb, None, None, None, None, None, resumptionToken, allParameter, configuration) => ???
/*
ESResumptionTokenHelper.createResumptionTokenFromOaiToken(resumptionToken.get) match {
case Success(rt) =>
checkParameterByName(allParameter, AllowedParameter.listRecordResumption) match {
......@@ -90,16 +92,21 @@ object ListRecordsValidation extends ParameterValidationFunction {
}
case OaiCheckedVerbWithParameter(verb, _, _, _, _, _, _, allParameter, configuration) =>
*/
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
, allParameter))
}
*/
}
}
......@@ -23,6 +23,7 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, ListSetsReq}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, ListSetsRunner, OaiRunner}
/*
https://www.openarchives.org/OAI/openarchivesprotocol.html#ListSets
......@@ -39,22 +40,22 @@ noSetHierarchy - The repository does not support sets.
object ListSetsValidation extends ParameterValidationFunction {
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest =
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner =
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 Seq() => ListSetsRunner(CheckedListSetsParameter(verb.get
, allParameter))
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
case setWithIllegalItems => BadArgumentsErrorRunner(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
case setWithIllegalItems => BadArgumentsErrorRunner(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
}
......@@ -62,7 +63,7 @@ object ListSetsValidation extends ParameterValidationFunction {
//todo: das nochmals anschauen
checkParameterByName(allParameter, AllowedParameter.listSetsAllowed) match {
case setWithIllegalItems => BadArgumentsReq(BadArgumentsParameter(verb.get
case setWithIllegalItems => BadArgumentsErrorRunner(BadArgumentsParameter(verb.get
, setWithIllegalItems.map(key => (key, key)).toMap
, allParameter))
......
......@@ -24,7 +24,8 @@ package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.verb.OaiVerb
import org.swissbib.memobase.oai.common.verb.OaiVerb.OaiVerb
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, SystemErrorReq}
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, SystemErrorReq}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, OaiRunner}
import scala.util.{Failure, Success}
import play.api.Configuration
......@@ -39,6 +40,7 @@ case class OaiCheckedVerbWithParameter(verb:Option[OaiVerb],
allQueryParameter: Map[String, Seq[String]],
configuration: Configuration)
/*
class OaiQueryParameterChecker(verb: Option[String],
metadataPrefix: Option[String],
set: Option[String],
......@@ -54,21 +56,23 @@ class OaiQueryParameterChecker(verb: Option[String],
OaiVerb.getVerb(verb) match {
case Success(value) =>
value match {
case OaiVerb.GetRecord => GetRecordValidation(
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, configuration))
case OaiVerb.ListIdentifiers => ListIdentifiersValidation(
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, configuration))
case OaiVerb.ListRecords => ListRecordsValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.GetRecord => ???
//GetRecordValidation(
//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, configuration))
case OaiVerb.ListIdentifiers => ???
//ListIdentifiersValidation(
//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, configuration))
case OaiVerb.ListRecords => ???
case OaiVerb.ListSets => ListSetsValidation(
OaiCheckedVerbWithParameter(Some(value),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
......@@ -100,4 +104,57 @@ class OaiQueryParameterChecker(verb: Option[String],
}
}
*/
class OaiQueryParameterChecker(verb: Option[String],
metadataPrefix: Option[String],
set: Option[String],
from:Option[String],
until:Option[String],
identifier: Option[String],
resumptionToken: Option[String],
allQueryParameter: Map[String, Seq[String]],
configuration: Configuration) {
//noinspection ScalaStyle
def checkQueryParameter: OaiRunner = {
OaiVerb.getVerb(verb) match {
case OaiVerb.GetRecord => GetRecordValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.GetRecord),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.Identify => IdentifyValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.Identify),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListIdentifiers => ListIdentifiersValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.ListIdentifiers),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListMetadataFormats => ListMetadataFormatsValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.ListMetadataFormats),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListRecords => ListRecordsValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.ListRecords),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
case OaiVerb.ListSets => ListSetsValidation(
OaiCheckedVerbWithParameter(Some(OaiVerb.ListSets),metadataPrefix,set,from, until, identifier, resumptionToken,
allQueryParameter, configuration))
//todo: wie gehe ich hier mit missing vern in der Fehleranzeige um??
case OaiVerb.WrongVerb =>
BadArgumentsErrorRunner(BadArgumentsParameter(OaiVerb.WrongVerb
, Map("badVerb" -> s"no verb in request")
, allQueryParameter))
case OaiVerb.MissingVerb =>
BadArgumentsErrorRunner(BadArgumentsParameter(OaiVerb.MissingVerb
, Map("missingVerb" -> s"Invalid verb $verb in request")
, allQueryParameter))
}
}
}
class MissingParameterException(message: String) extends Exception(message)
......@@ -24,6 +24,7 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.request.BaseUserRequest
import org.swissbib.memobase.oai.runner.OaiRunner
private object AllowedParameter {
val identify = List("verb")
......@@ -47,7 +48,9 @@ private object AllowedParameter {
}
abstract class ParameterValidationFunction () extends Function1[OaiCheckedVerbWithParameter, BaseUserRequest] {
abstract class ParameterValidationFunction () extends Function1[OaiCheckedVerbWithParameter, OaiRunner] {
def checkParameterByName(paramsInReq: Map[String, Seq[String]], allowedList:List[String]): Seq[String] = {
paramsInReq.keySet.diff(allowedList.toSet).toSeq
......@@ -58,7 +61,7 @@ abstract class ParameterValidationFunction () extends Function1[OaiCheckedVerbWi
}
override def apply(v1: OaiCheckedVerbWithParameter): BaseUserRequest
override def apply(v1: OaiCheckedVerbWithParameter): OaiRunner
}
......
......@@ -23,7 +23,8 @@
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.{Failure, Success, Try}
object OaiVerb extends Enumeration {
......@@ -47,11 +48,18 @@ object OaiVerb extends Enumeration {
val WrongVerb: OaiVal = OaiVal("WrongVerb")
val MissingVerb: OaiVal = OaiVal("MissingVerb")
private val mv = ".*None\\.get".r
def getVerb(verb: Option[String]): OaiVerb = {
Try[OaiVerb] (OaiVerb.withName(verb.get)) match {
case Success(value) =>
print(value)
value
case Failure(exception) => if (mv.matches(exception.getMessage)) MissingVerb else WrongVerb
}
}
def getVerb(verb: Option[String]): Try[OaiVerb] = {
Try[OaiVerb](OaiVerb.withName(verb.getOrElse(throw
new MissingParameterException("mandatory parameter verb is missing"))))
}
}
......@@ -55,8 +55,8 @@ sealed abstract class UserRequest(val verb:Option[OaiVerb],
case class ListSetsReq(parameter: CheckedListSetsParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
ListSetsRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//ListSetsRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
}
......@@ -71,8 +71,9 @@ case class ListSetsReqExclusive(parameter: CheckedListSetsParameterExclusive) e
case class ListRecordsReq(parameter: CheckedListRecordsParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
ListRecordsRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
// ListRecordsRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
......@@ -89,8 +90,8 @@ case class ListRecordsReqExclusive(parameter: CheckedListRecordsParameterExclusi
case class ListMetadataFormatsReq(parameter: CheckedListMetadaFormatsParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
ListMetadataFormatsRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//ListMetadataFormatsRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
......@@ -100,8 +101,8 @@ case class ListMetadataFormatsReq(parameter: CheckedListMetadaFormatsParameter)
case class ListIdentifiersReq(parameter: CheckedListIdentifiersParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
ListIdentifiersRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//ListIdentifiersRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
}
......@@ -115,18 +116,19 @@ case class ListIdentifiersReqExclusive(parameter: CheckedListIdentifiersParamete
}
case class GetRecordReq(parameter: CheckedGetRecordParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
GetRecordRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//GetRecordRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
}
case class IdentifyReq(parameter: CheckedIdentifyParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
IdentifyRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//IdentifyRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
......@@ -137,8 +139,8 @@ case class IdentifyReq(parameter: CheckedIdentifyParameter) extends BaseUserReq
case class BadArgumentsReq(parameter: BadArgumentsParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
BadArgumentsErrorRunner(config,repository,this).run().createResponse.toString()
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
//BadArgumentsErrorRunner(config,repository,this).run().createResponse.toString()
override def parameterBase: OaiParameterBase = parameter
......