Giter VIP home page Giter VIP logo

Comments (4)

labra avatar labra commented on September 28, 2024 1

OK, let's try to publish all these libraries in Java 1.8...in principle it should be doable.

from shex-s.

thewillyhuman avatar thewillyhuman commented on September 28, 2024

I think that in #4 the build.sbt file was modified to compile within Java 1.8 version. But 6 months ago in commit ea59afe the line

// javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
was commented.

from shex-s.

thewillyhuman avatar thewillyhuman commented on September 28, 2024

The code depending on Java 1.11 is:

def derefRDFJava(iri: IRI): IO[Resource[IO,RDFAsJenaModel]] = for {
str <- IO {
val client = HttpClient.newBuilder().followRedirects(Redirect.ALWAYS).build()
val request: HttpRequest = HttpRequest.newBuilder()
.uri(iri.uri)
.timeout(Duration.ofMinutes(4))
.header("Accept", "text/turtle").GET.build()
println(s"Request: ${request}")
val response = client.send(request, BodyHandlers.ofString)
// println(s"Body: ${response.body()}\nEND BODY (drefJava)")
response.body()
}
rdf <- RDFAsJenaModel.fromString(str,"TURTLE")
} yield rdf
}

from shex-s.

thewillyhuman avatar thewillyhuman commented on September 28, 2024

Looks like this was fixed changing previous lines by the following ones:

def derefRDFJava(iri: IRI): IO[Resource[IO,RDFAsJenaModel]] = for {
str <- IO {
// This code is commented because it depends on Java 1.11
/* val client = HttpClient.newBuilder().followRedirects(Redirect.ALWAYS).build()
val request: HttpRequest = HttpRequest.newBuilder()
.uri(iri.uri)
.timeout(Duration.ofMinutes(4))
.header("Accept", "text/turtle").GET.build()
println(s"Request: ${request}")
val response = client.send(request, BodyHandlers.ofString)
// println(s"Body: ${response.body()}\nEND BODY (drefJava)")
response.body() */
// Java 1.8 code
val url: URL = iri.uri.toURL
val conn: HttpURLConnection = url.openConnection().asInstanceOf[HttpURLConnection]
conn.setRequestMethod("GET")
conn.setRequestProperty("Accept", "text/turtle")
conn.setInstanceFollowRedirects(true)
// I think redirects still are required to be done manually. See: https://mkyong.com/java/java-httpurlconnection-follow-redirect-example/
conn.setReadTimeout(5000)
val in = new BufferedReader(new InputStreamReader(conn.getInputStream()))
val str = in.lines().iterator.asScala.mkString
conn.connect()
str
}
rdf <- RDFAsJenaModel.fromString(str,"TURTLE")
} yield rdf

So this issue looks like is fixed.

from shex-s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.