Skip to content

Commit

Permalink
resolve #55 with also handling "file type extension" for term request
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Oct 12, 2017
1 parent 9fda415 commit 1c51633
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
14 changes: 12 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
## change log ##

* 2017-10-11: 3.6.7
- toward #55 "any additional mechanisms for format/serialization resolution?"
- resolve #55 "any additional mechanisms for format/serialization resolution?"
- implement "file type extension" for ontology request
- TODO implement "file type extension" for term request
- implement "file type extension" for term request.
Order of precedence to determine desired format:
1. 'format' parameter
2. "file extension"
3. Accept header
Note: in contrast to the *ontology request* case, here we immediately try
resolution of the uri excluding the file extension in the case of absent
'format' parameter' and uri with file extension.
Part of the reason is that it's a bit tricky to determine whether the
resolution with the file extension is actually successful or not in the sense
of the term actually having triples associated or simply being non existing.

* 2017-10-04: 3.6.6
- for ttl term request, also handle explicit accept header "text/turtle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.json4s.{DefaultFormats, Formats}
import org.json4s.native.JsonParser
import org.mmisw.orr.ont.{Setup, TripleStoreResult}
import org.mmisw.orr.ont.auth.authUtil
import org.mmisw.orr.ont.swld.ontUtil
import org.mmisw.orr.ont.swld.{FileExt, ontUtil}
import org.mmisw.orr.ont.util.FileUtils

import scala.concurrent.Promise
Expand Down Expand Up @@ -369,17 +369,31 @@ with TripleStoreService with Logging {
): Either[Error, TermResponse] = {

formatOpt match {
case Some(format) =>
// 1. highest precedence for 'format' parameter:
case Some(format)
format2accept(format) match {
case Some((accept, isSelect)) =>
case Some((accept, isSelect))
doRequest(uri, accept, isSelect)
case None =>
case None
Left(NoSuchTermFormat(uri, format))
}

case None =>
val (accept, isSelect) = accept2AcceptAndSelect(acceptHeader)
doRequest(uri, accept, isSelect)
case None
ontUtil.recognizedFileExtension(uri) match {
// 2. then, "file extension" if any:
case Some((uri2, FileExt(fileExt)))
format2accept(fileExt) match {
case Some((accept, isSelect))
doRequest(uri2, accept, isSelect)
case None
Left(NoSuchTermFormat(uri, fileExt))
}

// 3. Accept header:
case _
val (accept, isSelect) = accept2AcceptAndSelect(acceptHeader)
doRequest(uri, accept, isSelect)
}
}
}

Expand Down

0 comments on commit 1c51633

Please sign in to comment.