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

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

temporary status before refactoring of requests / runnner structure

parent 30387299
......@@ -23,8 +23,11 @@
package org.swissbib.memobase.oai.common.validation
import org.swissbib.memobase.oai.common.util.ResumptionToken
import org.swissbib.memobase.oai.common.validation.OAIErrorCode.OAIErrorCode
import org.swissbib.memobase.oai.common.verb.OaiVerb.{GetRecord, Identify, ListIdentifiers, ListMetadataFormats, ListRecords, ListSets, OaiVerb}
import scala.util.Try
sealed abstract class OaiParameterBase() extends Product with Serializable {
val allQueryParameter: Map[String, Seq[String]]
}
......@@ -99,7 +102,32 @@ case class CheckedListSetsParameter (verb:OaiVerb,
case class BadArgumentsParameter (verb: OaiVerb
,badArguments: Map[String,String]
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase {
,allQueryParameter: Map[String, Seq[String]]) extends OaiParameterBase
case class NoContentForQueryParameter (verb: OaiVerb
,allQueryParameter: Map[String, Seq[String]]
,errorCode: String ) extends OaiParameterBase
}
object OAIErrorCode extends Enumeration {
type OAIErrorCode = Value
protected case class OAIErrorCodeVal(code: String) extends super.Val {
//https://www.scala-lang.org/api/current/scala/Enumeration.html
}
import scala.language.implicitConversions
implicit def getCode(x: Value): String = x.asInstanceOf[OAIErrorCodeVal].code
val NO_RECORDS_MATCH: OAIErrorCodeVal = OAIErrorCodeVal("noRecordsMatch")
val ID_DOES_NOT_EXIST: OAIErrorCodeVal = OAIErrorCodeVal("idDoesNotExist")
def getErrorCode(code: Option[String]): Try[OAIErrorCode] = {
Try[OAIErrorCode](OAIErrorCode.withName(code.getOrElse(throw
new Exception(s"no code for name $code"))))
}
}
\ No newline at end of file
......@@ -23,13 +23,13 @@
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.runner.{BadArgumentsErrorRunner, GetRecordRunner, IdentifyRunner,
ListIdentifiersExclusiveRunner, ListIdentifiersRunner, ListMetadataFormatsRunner, ListRecordsExclusiveRunner,
ListRecordsRunner, ListSetsRunner}
import org.swissbib.memobase.oai.common.validation.{BadArgumentsParameter, CheckedGetRecordParameter
, CheckedIdentifyParameter, CheckedListIdentifiersParameter, CheckedListIdentifiersParameterExclusive
, CheckedListMetadaFormatsParameter, CheckedListRecordsParameter, CheckedListRecordsParameterExclusive
, CheckedListSetsParameter, CheckedListSetsParameterExclusive, NoContentForQueryParameter, OaiParameterBase}
import org.swissbib.memobase.oai.runner.{BadArgumentsErrorRunner, GetRecordRunner, IdentifyRunner
, ListIdentifiersExclusiveRunner, ListIdentifiersRunner, ListMetadataFormatsRunner, ListRecordsExclusiveRunner
, ListRecordsRunner, ListSetsRunner, NoContentForQueryRunner}
import play.api.Configuration
......@@ -144,6 +144,16 @@ case class BadArgumentsReq(parameter: BadArgumentsParameter) extends BaseUserRe
}
case class NoContentForQueryReq(config: Configuration, repository: OaiRepository
, parameter: NoContentForQueryParameter) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String =
NoContentForQueryRunner(config,repository,this).run().createResponse.toString
override def parameterBase: OaiParameterBase = parameter
}
case class SystemErrorReq(parameter: Throwable) extends BaseUserRequest {
override def createResponse(config: Configuration, repository: OaiRepository): String = ???
......
......@@ -23,11 +23,9 @@
package org.swissbib.memobase.oai.runner
import modules.OaiRepository
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 org.swissbib.memobase.oai.common.validation.{NoContentForQueryParameter, OAIErrorCode}
import org.swissbib.memobase.oai.request.{BadArgumentsReq, BaseUserRequest, GetRecordReq, IdentifyReq, ListIdentifiersReq, ListIdentifiersReqExclusive, ListMetadataFormatsReq, ListRecordsReq, ListRecordsReqExclusive, ListSetsReq, ListSetsReqExclusive, NoContentForQueryReq}
import org.swissbib.memobase.oai.response.{BadArgumentsResponse, GetRecordResponse, IdentifyResponse, ListIdentifiersResponse, ListMetadaFormatsResponse, ListRecordsResponse, ListSetsResponse, OaiResponse}
import play.api.Configuration
import scala.util.{Failure, Success}
......@@ -63,6 +61,14 @@ case class GetRecordRunner(config: Configuration, repository: OaiRepository, req
//todo: handle null
case Failure(exception) =>
GetRecordResponse(this,null)
/*
NoContentForQueryReq(
config
,repository
, NoContentForQueryParameter(request.parameter.verb
,request.parameter.allQueryParameter
, OAIErrorCode.ID_DOES_NOT_EXIST.code)).createResponse(config,repository)
*/
}
}
......@@ -163,6 +169,14 @@ case class ListSetsExclusiveRunner(config: Configuration, repository: OaiReposit
override def run(): OaiResponse = ???
}
case class NoContentForQueryRunner(config: Configuration
, repository: OaiRepository
, request: NoContentForQueryReq) extends OaiRequestRunner {
override def run(): OaiResponse = ???
}
//todo: make more detailed types
case class GetExceptionRunner(config: Configuration, repository: OaiRepository, request:
BadArgumentsReq) extends OaiRequestRunner {
......
......@@ -21,4 +21,25 @@ wenn der record nicht vorhanden ist
- welche error codes verwende ich?
- wie implementiere ich das?
2) ListRecords
<OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2021-03-18T09:49:16Z</responseDate>
<request metadataPrefix="oai_dc" set="dnb-all:online:dissertations:sg300" verb="ListRecords" from="2016-04-01T14:55:00Z" until="2016-07-08T09:54:59Z">https://services.dnb.de/oai/repository</request>
<error code="noRecordsMatch"/>
</OAI-PMH>
mit records
https://services.dnb.de/oai/repository?verb=ListRecords&from=2021-02-01T14:55:00Z&until=2021-02-03T14:55:00Z&metadataPrefix=oai_dc&set=dnb-all:online:dissertations:sg300
3) ListIdentifiers
https://services.dnb.de/oai/repository?verb=ListIdentifiers&from=2021-02-01T14:55:00Z&until=2021-02-03T14:55:00Z&metadataPrefix=oai_dc&set=dnb-all:online:dissertations:sg300
leere Liste
https://services.dnb.de/oai/repository?verb=ListIdentifiers&from=2016-04-01T14:55:00Z&until=2016-07-08T09:54:59Z&metadataPrefix=oai_dc&set=dnb-all:online:dissertations:sg300
wie bei
<OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2021-03-18T09:54:44Z</responseDate>
<request metadataPrefix="oai_dc" set="dnb-all:online:dissertations:sg300" verb="ListIdentifiers" from="2016-04-01T14:55:00Z" until="2016-07-08T09:54:59Z">https://services.dnb.de/oai/repository</request>
<error code="noRecordsMatch"/>
</OAI-PMH>
\ No newline at end of file
......@@ -4,6 +4,7 @@
das Datum muss Protokollgerecht behandelt werden
http://www.openarchives.org/OAI/openarchivesprotocol.html#Dates
Validation Komponente prüft bisher nur, ob die erforderlichen Parameter für die verben vorhanden sind
beschäftige Dich mit Java > v8 Zeit implementierung Joda typen
Fehlerresponse DNB wenn ein Dokument mit GetRecord nicht gefunden werden kann
......
/*
* OAI Server Interface
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.swissbib.memobase.oai.common.validation
import org.scalatestplus.play.PlaySpec
class ContentErrorCodeSpec extends PlaySpec {
/* test this later especially with PlaySpec - actually no time ...
"error code enum" must {
("must be correct") must {
val idNotExist = OAIErrorCode.ID_DOES_NOT_EXIST
println(idNotExist.code)
val ee = OAIErrorCode.getErrorCode(Some("noRecordsMatch"))
println(ee)
}
}
*/
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment