Skip to content

Commit

Permalink
OK-736 Improve massaluovutus query handling, add retries, general imp…
Browse files Browse the repository at this point in the history
…rovements
  • Loading branch information
msiukola committed Jan 9, 2025
1 parent 2952e57 commit 7bd36b7
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,24 @@ class VirkailijaRestClient(
case (Some(un), Some(pw), true) if koskiMassaluovutusResult =>
for (
result <- {
//logger.info(s"Sending basic authed koskiMassaluovutusResult query! $url")
cookies += new DefaultCookie("CSRF", Config.csrf)
val requestWithCookies =
addCookies(requestWithPostHeaders, cookies).toRequest
val realm = new Realm.Builder(un, pw)
.setUsePreemptiveAuth(false)
.setScheme(Realm.AuthScheme.NTLM)
.setScheme(
Realm.AuthScheme.NTLM
) //Tämä tarvitaan, jotta basic authilla toimivat Koski -> s3 ohjautuvat pyynnöt toimivat
val basicAuthHeader =
"Basic " + Base64.getEncoder.encodeToString((un + ":" + pw).getBytes)
val requestWithRealm = requestWithCookies.toBuilder
.setRealm(realm)
.setHeader("Authorization", basicAuthHeader)
.build()
//logger.info(s"Request before sending: ${requestWithRealm.getRealm}, ${requestWithRealm.getHeaders}, $requestWithRealm")
internalClient(requestWithRealm, handler)
}
) yield result
case (Some(un), Some(pw), true) =>
//logger.info(s"Sending basic authed query! $url")
for (
result <- {
cookies += new DefaultCookie("CSRF", Config.csrf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ trait IKoskiService {

def syncHaunHakijat(
hakuOid: String,
params: KoskiSuoritusHakuParams,
params: KoskiSuoritusTallennusParams,
personOidsForHakuFn: String => Future[Set[String]]
): Future[Unit]

def syncHaunHakijat(hakuOid: String, params: KoskiSuoritusHakuParams): Future[Unit]
def syncHaunHakijat(hakuOid: String, params: KoskiSuoritusTallennusParams): Future[Unit]

def updateHenkilot(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
params: KoskiSuoritusTallennusParams
): Future[(Seq[String], Seq[String])]

def updateHenkilotWithAliases(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
params: KoskiSuoritusTallennusParams
): Future[(Seq[String], Seq[String])]

def fetchKoulusivistyskielet(oppijaOids: Seq[String]): Future[Map[String, Seq[String]]]
Expand All @@ -49,13 +49,13 @@ trait IKoskiService {

def updateHenkilotNew(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
): Future[(Seq[String], Seq[String])]
params: KoskiSuoritusTallennusParams
): Future[KoskiProcessingResults]

def updateHenkilotNewMuuttunutJalkeen(
muuttunutJalkeen: String,
params: KoskiSuoritusHakuParams
): Future[(Seq[String], Seq[String])]
params: KoskiSuoritusTallennusParams
): Future[KoskiProcessingResults]
}

class KoskiServiceMock extends IKoskiService {
Expand All @@ -68,11 +68,11 @@ class KoskiServiceMock extends IKoskiService {
override def updateAktiivisetToisenAsteenJatkuvatHaut(): () => Unit = () => ()
override def updateHenkilot(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
params: KoskiSuoritusTallennusParams
): Future[(Seq[String], Seq[String])] = Future.successful(Seq[String](), Seq[String]())
override def updateHenkilotWithAliases(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
params: KoskiSuoritusTallennusParams
): Future[(Seq[String], Seq[String])] = Future.successful(Seq[String](), Seq[String]())

override def fetchOppivelvollisuusTietos(
Expand All @@ -89,19 +89,22 @@ class KoskiServiceMock extends IKoskiService {
): Future[Map[String, Seq[String]]] = Future.successful(Map[String, Seq[String]]())
override def syncHaunHakijat(
hakuOid: String,
params: KoskiSuoritusHakuParams,
params: KoskiSuoritusTallennusParams,
personOidsForHakuFn: String => Future[Set[String]]
): Future[Unit] = ???

override def syncHaunHakijat(hakuOid: String, params: KoskiSuoritusHakuParams): Future[Unit] = ???
override def syncHaunHakijat(
hakuOid: String,
params: KoskiSuoritusTallennusParams
): Future[Unit] = ???

override def updateHenkilotNew(
oppijaOids: Set[String],
params: KoskiSuoritusHakuParams
): Future[(Seq[String], Seq[String])] = ???
params: KoskiSuoritusTallennusParams
): Future[KoskiProcessingResults] = ???

override def updateHenkilotNewMuuttunutJalkeen(
muuttunutJalkeen: String,
params: KoskiSuoritusHakuParams
): Future[(Seq[String], Seq[String])] = ???
params: KoskiSuoritusTallennusParams
): Future[KoskiProcessingResults] = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class KoskiDataHandler(
henkiloOid: String,
viimeisimmatSuoritukset: Seq[SuoritusArvosanat],
personOidsWithAliases: PersonOidsWithAliases,
params: KoskiSuoritusHakuParams
params: KoskiSuoritusTallennusParams
): Future[Seq[Either[Exception, Option[SuoritusArvosanat]]]] =
fetchExistingSuoritukset(henkiloOid, personOidsWithAliases).flatMap(fetchedSuoritukset => {
//OY-227 : Check and delete if there is suoritus which is not included on new suoritukset.
Expand Down Expand Up @@ -852,7 +852,7 @@ class KoskiDataHandler(
def processHenkilonTiedotKoskesta(
koskihenkilöcontainer: KoskiHenkiloContainer,
personOidsWithAliases: PersonOidsWithAliases,
params: KoskiSuoritusHakuParams,
params: KoskiSuoritusTallennusParams,
henkilo: Option[Henkilo] = None
): Future[Seq[Either[Exception, Option[SuoritusArvosanat]]]] = {
val henkiloOid = koskihenkilöcontainer.henkilö.oid.get
Expand Down
Loading

0 comments on commit 7bd36b7

Please sign in to comment.