Skip to content

Commit

Permalink
a fix related with previous mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Sep 8, 2017
1 parent 3fc855b commit 4b43a7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/org/mmisw/cf2rdf/Registerer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.json4s.native.Serialization.writePretty
import scalaj.http.{Http, HttpResponse, MultiPart}


class Registerer(orr: OrrCfg, userName: String, password: String) {
class Registerer(orr: OrrCfg) {
private implicit val jsonFormats: Formats = DefaultFormats ++ JodaTimeSerializers.all

def registerOntologies(): Unit = {
Expand Down Expand Up @@ -57,7 +57,7 @@ class Registerer(orr: OrrCfg, userName: String, password: String) {
val response: HttpResponse[String] = Http(route)
.timeout(connTimeoutMs = 5*1000, readTimeoutMs = 60*1000)
.postMulti(MultiPart("file", "filename", "text/plain", contents.getBytes))
.auth(userName, password)
.auth(orr.userName, orr.password)
.method(method)
.asString

Expand All @@ -77,7 +77,7 @@ class Registerer(orr: OrrCfg, userName: String, password: String) {
"iri" iri
, "name" name
, "log" log
, "userName" userName
, "userName" orr.userName
, "orgName" orr.orgName
, "visibility" orr.visibility
, "status" orr.status
Expand All @@ -92,7 +92,7 @@ class Registerer(orr: OrrCfg, userName: String, password: String) {

val response: HttpResponse[String] = Http(route)
.timeout(connTimeoutMs = 5*1000, readTimeoutMs = 60*1000)
.auth(userName, password)
.auth(orr.userName, orr.password)
.postData(data)
.header("Content-type", "application/json")
.method(method)
Expand Down
11 changes: 2 additions & 9 deletions src/main/scala/org/mmisw/cf2rdf/cf2rdf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,8 @@ object cf2rdf {
println(s"\nSummary: (saved in ${cfg.destStats})\n\t" + statsStr.replaceAll("\n", "\n\t"))
}

private def registerOntologies(): Unit = {
def requiredEnvVar(name: String): String = {
val value = sys.env.getOrElse(name, throw new Exception(s"Undefined $name env var"))
value
}
val userName = requiredEnvVar("ORR_USERNAME")
val password = requiredEnvVar("ORR_PASSWORD")
cfg.orr foreach { new Registerer(_, userName, password).registerOntologies() }
}
private def registerOntologies(): Unit =
cfg.orr foreach { new Registerer(_).registerOntologies() }

private def download(url: String, filename: String): Unit = {
println(s"Downloading $url")
Expand Down

0 comments on commit 4b43a7d

Please sign in to comment.