Skip to content

Commit

Permalink
"RDFViewer button for SPARQL construct queries" #149 : FIX activation…
Browse files Browse the repository at this point in the history
… only if serveur hosted on Internet
  • Loading branch information
jmvanel committed Mar 22, 2017
1 parent ac802b4 commit 1dcc9ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ trait URIManagement extends URIHelpers {
* "There is no started application"
*/
def servicesURIPrefix: String = {
val hostNameUsed =
servicesURIPrefix2._1
}

/** @return services URI Prefix, is DNS (not IP) */
def servicesURIPrefix2: (String, Boolean) = {

val (hostNameUsed, isDNS: Boolean) =
if (useLocalHostPrefixForURICreation) {
val hostNameFromAPI = InetAddress.getLocalHost().getCanonicalHostName // getHostName()
println( s"hostNameFromAPI $hostNameFromAPI")
Expand Down Expand Up @@ -133,22 +139,22 @@ trait URIManagement extends URIHelpers {
}
println1(s"intranetAdresses $intranetAdresses")
println1(s"internetAdresses $internetAdresses")
val adresses2 = if (!internetAdresses.isEmpty) {
val (adresses2, isDNS) = if (!internetAdresses.isEmpty) {
if (internetAdresses.size > 1)
System.err.println(s"CAUTION: several Internet Adresses: $internetAdresses")
internetAdresses
(internetAdresses, true)
} else {
if (intranetAdresses.size > 1)
System.err.println(s"CAUTION: several Intranet Adresses: $intranetAdresses")
intranetAdresses
(intranetAdresses, false)
}
val result = "http://" + adresses2.toList.headOption.getOrElse("127.0.0.1")
// "http://" + InetAddress.getLocalHost().getHostAddress()
result
(result, isDNS)
}
} else defaultInstanceURIHostPrefix
} else (defaultInstanceURIHostPrefix, true)
println1(s"hostNameUsed $hostNameUsed")
hostNameUsed + ":" + serverPort + "/"
( hostNameUsed + ":" + serverPort + "/" , isDNS)
}

def instanceURIPrefix: String = servicesURIPrefix + relativeURIforCreatedResourcesByForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ trait ToolsPage extends EnterButtons

val sparqlServicePrefix = URLEncoder.encode("/sparlq?query=", "UTF-8")
val buttonId = textareaId+"-button"
println(s"servicesURIPrefix $servicesURIPrefix")
val ( servicesURIPrefix, isDNS) = servicesURIPrefix2
println(s"servicesURIPrefix $servicesURIPrefix, is DNS $isDNS")
val servicesURIPrefixEncoded = URLEncoder.encode(servicesURIPrefix, "UTF-8")
val servicesURL = s"$toolURLprefix$servicesURIPrefixEncoded$sparqlServicePrefix"
println(s"servicesURL $servicesURL")
Expand All @@ -116,7 +117,7 @@ trait ToolsPage extends EnterButtons
var url = '$servicesURL' + window.encodeURIComponent(query) ;
console.log( 'URL ' + url );
// console.log( 'startsWith ' + ( '$sparqlServicePrefix' . startsWith ('/') ) );
if( ! ${servicesURIPrefix.contains(":")} )
if( $isDNS )
window.open( url , '_blank' );
else
console.log( 'RDFViewer works only on a hosted Internet serverURL !!!' );
Expand Down

0 comments on commit 1dcc9ed

Please sign in to comment.