Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/scala/org/dbpedia/databus/ApiImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ import virtuoso.jdbc4.VirtuosoException

import scala.util.{Failure, Success, Try}
import scala.xml.Node
import org.slf4j.LoggerFactory
import collection.JavaConverters._


class ApiImpl(config: Config) extends DatabusApi {

import ApiImpl._

private lazy val log = LoggerFactory.getLogger(this.getClass)

private val client: GitClient = initGitClient(config)
private val defaultLang = Lang.JSONLD
private lazy val sparqlClient: SparqlClient = SparqlClient.get(config)
Expand Down Expand Up @@ -165,6 +168,15 @@ class ApiImpl(config: Config) extends DatabusApi {
} else {
Success(Unit)
}).flatMap(_ => client.commitSeveralFiles(username, fullFilenamesAndData))
.recoverWith {
case err: Throwable =>
try {
log.error(s"Failed to save files for user '$username' (${fullFilenamesAndData.keys.mkString(",")})", err)
} catch {
case _: Throwable => // ignore logging failures
}
Failure(err)
}


private def deleteFileFromGit(username: String, path: String)(request: HttpServletRequest): Try[String] = {
Expand Down
7 changes: 7 additions & 0 deletions src/main/scala/org/dbpedia/databus/JettyLauncher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ object JettyLauncher { // this is my entry object as specified in sbt project de
.map(ApiImpl.Config.fromWebXml)
.getOrElse(ApiImpl.Config.default)

if (config.gitLocalDir.isDefined) {
log.info(s"Using local git directory: ${config.gitLocalDir.get.toAbsolutePath}")
log.info("Attempting to cache local development context (if present)")
} else {
log.info("No local git directory configured; using remote git API (if configured)")
}

val browserPath = "/file"
val fileListHandler = config.gitLocalDir
.flatMap(p => Try(fileBrowserContext(p, browserPath)).toOption)
Expand Down
11 changes: 9 additions & 2 deletions src/main/scala/org/dbpedia/databus/SparqlClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,21 @@ class FusekiJDBCClient(host: String, port: Int, user: String, pass: String, data
}

object RdfConversions {
private lazy val log = LoggerFactory.getLogger(this.getClass)

private val DefaultShaclLang = Lang.TTL

def readModel(data: Array[Byte], lang: Lang): Try[Model] = Try {
val model = ModelFactory.createDefaultModel()
val dataStream = new ByteArrayInputStream(data)
RDFDataMgr.read(model, dataStream, lang)
model
try {
RDFDataMgr.read(model, dataStream, lang)
model
} catch {
case e: Throwable =>
log.error(s"Failed to parse input as ${lang.getName}: ${e.getMessage}")
throw e
}
}

def validateWithShacl(model: Model, shacl: Graph): Try[ValidationReport] =
Expand Down