introduced, it was also used for search facets. The generic search facets are now deduced from generic solr fields which makes jena as tool for facet semantics superfluous.pull/1/head
parent
0e6729f9bc
commit
6e59ca4ebf
|
@ -1,120 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<title>YaCy '#[clientname]#': Triplestore</title>
|
|
||||||
#%env/templates/metas.template%#
|
|
||||||
|
|
||||||
#%env/templates/jqueryheader.template%#
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body id="Experiments">
|
|
||||||
|
|
||||||
#%env/templates/header.template%#
|
|
||||||
#%env/templates/submenuSemantic.template%#
|
|
||||||
|
|
||||||
|
|
||||||
#(mode)#
|
|
||||||
<div class="AddSection">
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
function xyz() {
|
|
||||||
|
|
||||||
$.getJSON('yacysearch.json?query=rdfdatasource&Enter=Search&verify=never&contentdom=text&nav=hosts%2Cauthors%2Cnamespace%2Ctopics%2Cfiletype%2Cprotocol&startRecord=0&indexof=off&meanCount=5&resource=global&urlmaskfilter=.*&prefermaskfilter=&maximumRecords=10', null, function(data) {
|
|
||||||
|
|
||||||
$('#rdffileslist').val(data.channels[0].items[0].urlname);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<h2>Search RDF</h2>
|
|
||||||
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
|
|
||||||
|
|
||||||
<input id="rdfsearch" name="rdfsearch" type="text" size="50" value="rdfdatasource" />
|
|
||||||
<input type="submit" value="Search" onclick="xyz(); return false;"/>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<textarea id="rdffileslist" name="rdffileslist" cols="100" rows="10">
|
|
||||||
|
|
||||||
</textarea>
|
|
||||||
|
|
||||||
<input type="submit" value="Import Triples" />
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="AddSection">
|
|
||||||
<h2>or import RDF from local filesystem</h2>
|
|
||||||
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
|
|
||||||
|
|
||||||
<input name="rdffile" type="file" size="50" maxlength="10000000" />
|
|
||||||
|
|
||||||
<input type="submit" value="Add Triples" />
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="AddSection">
|
|
||||||
<h2>Query</h2>
|
|
||||||
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
|
|
||||||
|
|
||||||
<textarea name="query" cols="100" rows="10">
|
|
||||||
#[query]#
|
|
||||||
</textarea>
|
|
||||||
|
|
||||||
<input type="submit" value="Query" />
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<br></br>
|
|
||||||
<!-- 0: viewing -->
|
|
||||||
|
|
||||||
#{entries}#
|
|
||||||
<div class="Experiment">
|
|
||||||
|
|
||||||
<a href="./experiments/#[link]#/" target="_blank"><h2 class="PostSubject">#[subject]#</h2></a>
|
|
||||||
<p class="PostInfo">
|
|
||||||
<a href="/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=subpath&indexMedia=on&xdstopw=off&storeHTCache=off&sitemapURL=&repeat_time=1&cachePolicy=never&indexText=on&crawlingMode=url&crawlingURL=#[publiclink]#&bookmarkTitle=&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&crawlingDepth=0" target="_blank">Publish</a> |
|
|
||||||
<a href="/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=subpath&indexMedia=on&xdstopw=off&storeHTCache=off&sitemapURL=&repeat_time=1&cachePolicy=never&indexText=on&crawlingMode=url&crawlingURL=#[publiclink_ip]#&bookmarkTitle=&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&crawlingDepth=0" target="_blank">Publish using IP-Adress</a>
|
|
||||||
| <a href="UnpublishExperiment_p.html?experiment=#[subject]#&urlstring=#[publiclink]#">Unpublish and remove</a> | <a href="#[publiclinkproxy]#">Preview via inbuilt proxy</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
#{/entries}#
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <applet
|
|
||||||
code="org.openscience.jchempaint.applet.JChemPaintEditorApplet"
|
|
||||||
archive="/applets/jchempaint-applet-core.jar"
|
|
||||||
name="Editor"
|
|
||||||
width="600" height="500">
|
|
||||||
<param name="load" value="a-pinene.mol">
|
|
||||||
</applet> -->
|
|
||||||
|
|
||||||
<div class="AddSection">
|
|
||||||
<h2>Result</h2>
|
|
||||||
|
|
||||||
#[rdfdump]#
|
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
#{output}##[caption]#
|
|
||||||
#{/output}#
|
|
||||||
</div>
|
|
||||||
|
|
||||||
::
|
|
||||||
<!-- 3: Access Denied (no rights) -->
|
|
||||||
<h3>Access denied</h3>
|
|
||||||
<p>To edit or create experiment entries you need to be logged in as Administrator.</p>
|
|
||||||
|
|
||||||
|
|
||||||
#(/mode)#
|
|
||||||
#%env/templates/footer.template%#
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,155 +0,0 @@
|
|||||||
/**
|
|
||||||
* Triple_p
|
|
||||||
* Copyright 2012 by Michael Peter Christen, mc@yacy.net, Frankfurt am Main, Germany
|
|
||||||
* First released 14.09.2011 at http://yacy.net
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program in the file lgpl21.txt
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
|
|
||||||
import net.yacy.cora.document.id.DigestURL;
|
|
||||||
import net.yacy.cora.lod.JenaTripleStore;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.cora.util.ConcurrentLog;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
import net.yacy.server.http.HTTPDemon;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
|
||||||
import com.hp.hpl.jena.query.ResultSetFormatter;
|
|
||||||
|
|
||||||
|
|
||||||
public class Triple_p {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header,
|
|
||||||
final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
prop.put("display", 1); // Fixed to 1
|
|
||||||
prop.putHTML("mode_output", "no query performed");
|
|
||||||
|
|
||||||
String q = "PREFIX lln: <http://virtual.x/>\n"+
|
|
||||||
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+
|
|
||||||
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"+
|
|
||||||
"SELECT ?resource ?pa\n"+
|
|
||||||
"WHERE {\n"+
|
|
||||||
"?resource lln:hasvalue ?pa .\n"+
|
|
||||||
"FILTER (xsd:float (?pa) > 21.000)\n"+
|
|
||||||
"}";
|
|
||||||
|
|
||||||
if (post != null) {
|
|
||||||
|
|
||||||
if (post.containsKey("submit")) {
|
|
||||||
//
|
|
||||||
System.out.println (post.get("submit"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.containsKey("rdffileslist")) {
|
|
||||||
|
|
||||||
String list = post.get("rdffileslist");
|
|
||||||
|
|
||||||
for (String s: list.split("\n")) {
|
|
||||||
String newurl = s;
|
|
||||||
try {
|
|
||||||
DigestURL d = new DigestURL (s);
|
|
||||||
|
|
||||||
if (d.getHost().endsWith(".yacy")) {
|
|
||||||
newurl = d.getProtocol()+"://"+HTTPDemon.getAlternativeResolver().resolve(d.getHost())+d.getPath();
|
|
||||||
System.out.println (newurl);
|
|
||||||
}
|
|
||||||
JenaTripleStore.load(newurl);
|
|
||||||
} catch (final MalformedURLException e) {
|
|
||||||
ConcurrentLog.logException(e);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
ConcurrentLog.logException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.containsKey("rdffile")) {
|
|
||||||
|
|
||||||
JenaTripleStore.addFile(post.get("rdffile$file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.containsKey("query")) {
|
|
||||||
|
|
||||||
// Create a new query
|
|
||||||
String queryString = post.get("query");
|
|
||||||
|
|
||||||
q = queryString;
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
|
|
||||||
|
|
||||||
// Execute the query and obtain results
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, JenaTripleStore.model);
|
|
||||||
ResultSet resultSet = qe.execSelect();
|
|
||||||
|
|
||||||
ByteArrayOutputStream sos = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
ResultSetFormatter.outputAsRDF(sos, "", resultSet);
|
|
||||||
|
|
||||||
prop.putHTML("mode_rdfdump", sos.toString());
|
|
||||||
|
|
||||||
int scount = 0;
|
|
||||||
while (resultSet.hasNext()) {
|
|
||||||
QuerySolution s = resultSet.next();
|
|
||||||
prop.put("entries_"+scount+"_s", s.getResource(null).getURI());
|
|
||||||
prop.put("entries_"+scount+"_p", s.getResource(null).getURI());
|
|
||||||
prop.put("entries_"+scount+"_o", s.getResource(null).getURI());
|
|
||||||
scount ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.putHTML("entries", ""+scount);
|
|
||||||
|
|
||||||
for (String s: resultSet.getResultVars()) {
|
|
||||||
|
|
||||||
prop.putHTML("mode_output_"+count+"_caption", s);
|
|
||||||
count ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} catch (final Exception e) {
|
|
||||||
prop.putHTML("mode_rdfdump", "error");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
prop.putHTML("mode_output", ""+count);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.putHTML("mode_query", q);
|
|
||||||
|
|
||||||
|
|
||||||
// return rewrite properties
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<title>YaCy '#[clientname]#': Triplestore</title>
|
|
||||||
#%env/templates/metas.template%#
|
|
||||||
</head>
|
|
||||||
<body id="Settings">
|
|
||||||
|
|
||||||
<div id="api">
|
|
||||||
<a href="/interaction/GetRDF.xml?global=" id="apilink"><img src="/env/grafics/api.png" width="60" height="40" alt="API"/></a>
|
|
||||||
<span>The information that is presented on this page can also be retrieved as XML
|
|
||||||
Click the API icon to see the Triplestore.
|
|
||||||
To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de/wiki/index.php/Dev:API" target="_blank">API wiki page</a>.</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
#%env/templates/header.template%#
|
|
||||||
#%env/templates/submenuSemantic.template%#
|
|
||||||
<h2>Triplestore</h2>
|
|
||||||
|
|
||||||
<form id="parsersettings" action="Triplestore_p.html" method="post" enctype="multipart/form-data">
|
|
||||||
<fieldset><legend id="urlproxy">Triplestore</legend>
|
|
||||||
<p>
|
|
||||||
With this settings you change the behavior of the jena-based Triplestore.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<dl>
|
|
||||||
|
|
||||||
<dt>Triplestore size:</dt>
|
|
||||||
<dd>
|
|
||||||
#[size]#
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt><label for="content">Persistent store:</label></dt>
|
|
||||||
<dd>
|
|
||||||
<input type="checkbox" name="tspersistentenabled" id="tspersistentenabled" #(tspersistentenabled_checked)#:: checked="checked"#(/tspersistentenabled_checked)# />Enabled<br/>
|
|
||||||
<p class="help">
|
|
||||||
If enabled, the Triplestore will save its content on shutdown on the filesystem and load it again on startup.
|
|
||||||
</p>
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<!-- <dt><label for="author">Forward feedback to peer:</label></dt>
|
|
||||||
<dd>
|
|
||||||
<input type="text" name="feedbackforward" value="#[feedbackforward]#" size="60" /><br/><br/>
|
|
||||||
<p class="help">
|
|
||||||
Feedback is forwarded to this peer.
|
|
||||||
</p>
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt><label for="content">Store Feedback on this peer:</label></dt>
|
|
||||||
<dd>
|
|
||||||
<input type="checkbox" name="acceptfeedbackenabled" id="acceptfeedbackenabled" #(acceptfeedbackenabled_checked)#:: checked="checked"#(/acceptfeedbackenabled_checked)# />Enabled<br/>
|
|
||||||
<p class="help">
|
|
||||||
If enabled, this peer will accept Feedback items and will NOT forward them.
|
|
||||||
</p>
|
|
||||||
</dd> -->
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
<input type="submit" name="tsSettings" value="Submit"/>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
#%env/templates/footer.template%#
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* Triplestore_p
|
|
||||||
* Copyright 2012 by Michael Peter Christen, mc@yacy.net, Frankfurt am Main, Germany
|
|
||||||
* First released 14.09.2011 at http://yacy.net
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program in the file lgpl21.txt
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import net.yacy.cora.lod.JenaTripleStore;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public final class Triplestore_p {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header,
|
|
||||||
final serverObjects post, final serverSwitch env) {
|
|
||||||
// return variable that accumulates replacements
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
if (post != null) {
|
|
||||||
|
|
||||||
if (post.containsKey("tsSettings")) {
|
|
||||||
|
|
||||||
env.setConfig("triplestore.persistent",
|
|
||||||
"on".equals(post.get("tspersistentenabled")) ? true : false);
|
|
||||||
|
|
||||||
// env.setConfig("interaction.feedback.accept",
|
|
||||||
// "on".equals(post.get("acceptfeedbackenabled")) ? true : false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.put("tspersistentenabled_checked",
|
|
||||||
env.getConfigBool("triplestore.persistent", false) ? "1" : "0");
|
|
||||||
|
|
||||||
// prop.put("acceptfeedbackenabled_checked",
|
|
||||||
// env.getConfigBool("interaction.feedback.accept", false) ? "1" : "0");
|
|
||||||
prop.put("size", JenaTripleStore.size());
|
|
||||||
|
|
||||||
// return rewrite properties
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
#[rdf]#
|
|
@ -1,101 +0,0 @@
|
|||||||
package interaction;
|
|
||||||
|
|
||||||
//ViewLog_p.java
|
|
||||||
//-----------------------
|
|
||||||
//part of the AnomicHTTPD caching proxy
|
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
|
||||||
//first published on http://www.anomic.de
|
|
||||||
//Frankfurt, Germany, 2004
|
|
||||||
//
|
|
||||||
//This File is contributed by Alexander Schier
|
|
||||||
//last major change: 14.12.2004
|
|
||||||
//
|
|
||||||
//This program is free software; you can redistribute it and/or modify
|
|
||||||
//it under the terms of the GNU General Public License as published by
|
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
|
||||||
//(at your option) any later version.
|
|
||||||
//
|
|
||||||
//This program is distributed in the hope that it will be useful,
|
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
//GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
//You should have received a copy of the GNU General Public License
|
|
||||||
//along with this program; if not, write to the Free Software
|
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
|
||||||
//if the shell's current path is HTROOT
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import net.yacy.cora.document.encoding.UTF8;
|
|
||||||
import net.yacy.cora.lod.JenaTripleStore;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.interaction.Interaction;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
|
|
||||||
|
|
||||||
public class GetRDF {
|
|
||||||
|
|
||||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
Boolean global = false;
|
|
||||||
|
|
||||||
if(post != null){
|
|
||||||
|
|
||||||
global = post.containsKey("global");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (global) {
|
|
||||||
|
|
||||||
ByteArrayOutputStream fout;
|
|
||||||
|
|
||||||
|
|
||||||
fout = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
JenaTripleStore.model.write(fout);
|
|
||||||
|
|
||||||
try {
|
|
||||||
prop.put("resultXML", fout.toString(UTF8.charset.name()));
|
|
||||||
} catch (final UnsupportedEncodingException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Model tmp = JenaTripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));
|
|
||||||
|
|
||||||
if (tmp != null) {
|
|
||||||
|
|
||||||
ByteArrayOutputStream fout;
|
|
||||||
fout = new ByteArrayOutputStream();
|
|
||||||
tmp.write(fout);
|
|
||||||
|
|
||||||
try {
|
|
||||||
prop.put("resultXML", fout.toString(UTF8.charset.name()));
|
|
||||||
} catch (final UnsupportedEncodingException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
prop.put("resultXML", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"result": "#[result]#"
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
#[resultXML]#
|
|
@ -1,94 +0,0 @@
|
|||||||
package interaction;
|
|
||||||
|
|
||||||
//ViewLog_p.java
|
|
||||||
//-----------------------
|
|
||||||
//part of the AnomicHTTPD caching proxy
|
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
|
||||||
//first published on http://www.anomic.de
|
|
||||||
//Frankfurt, Germany, 2004
|
|
||||||
//
|
|
||||||
//This File is contributed by Alexander Schier
|
|
||||||
//last major change: 14.12.2004
|
|
||||||
//
|
|
||||||
//This program is free software; you can redistribute it and/or modify
|
|
||||||
//it under the terms of the GNU General Public License as published by
|
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
|
||||||
//(at your option) any later version.
|
|
||||||
//
|
|
||||||
//This program is distributed in the hope that it will be useful,
|
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
//GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
//You should have received a copy of the GNU General Public License
|
|
||||||
//along with this program; if not, write to the Free Software
|
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
|
||||||
//if the shell's current path is HTROOT
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
|
|
||||||
import net.yacy.cora.lod.JenaTripleStore;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.interaction.Interaction;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
|
|
||||||
|
|
||||||
public class PutRDF {
|
|
||||||
|
|
||||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
|
||||||
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
Boolean global = false;
|
|
||||||
|
|
||||||
if(post != null){
|
|
||||||
|
|
||||||
global = post.containsKey("global");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (global) {
|
|
||||||
|
|
||||||
ByteArrayOutputStream fout;
|
|
||||||
|
|
||||||
|
|
||||||
fout = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
JenaTripleStore.model.write(fout);
|
|
||||||
|
|
||||||
prop.put("resultXML", fout.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Model tmp = JenaTripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));
|
|
||||||
|
|
||||||
if (tmp != null) {
|
|
||||||
|
|
||||||
ByteArrayOutputStream fout;
|
|
||||||
fout = new ByteArrayOutputStream();
|
|
||||||
tmp.write(fout);
|
|
||||||
|
|
||||||
prop.put("resultXML", fout.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
prop.put("resultXML", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"result": "#[result]#"
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
package interaction;
|
|
||||||
|
|
||||||
//ViewLog_p.java
|
|
||||||
//-----------------------
|
|
||||||
//part of the AnomicHTTPD caching proxy
|
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
|
||||||
//first published on http://www.anomic.de
|
|
||||||
//Frankfurt, Germany, 2004
|
|
||||||
//
|
|
||||||
//This File is contributed by Alexander Schier
|
|
||||||
//last major change: 14.12.2004
|
|
||||||
//
|
|
||||||
//This program is free software; you can redistribute it and/or modify
|
|
||||||
//it under the terms of the GNU General Public License as published by
|
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
|
||||||
//(at your option) any later version.
|
|
||||||
//
|
|
||||||
//This program is distributed in the hope that it will be useful,
|
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
//GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
//You should have received a copy of the GNU General Public License
|
|
||||||
//along with this program; if not, write to the Free Software
|
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
|
||||||
//if the shell's current path is HTROOT
|
|
||||||
|
|
||||||
import net.yacy.cora.protocol.HeaderFramework;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.data.UserDB;
|
|
||||||
import net.yacy.interaction.Interaction;
|
|
||||||
import net.yacy.search.Switchboard;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class Table {
|
|
||||||
|
|
||||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
||||||
|
|
||||||
final Switchboard sb = (Switchboard) env;
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
UserDB.Entry entry=null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//default values
|
|
||||||
prop.put("enabled_logged_in", "0");
|
|
||||||
prop.put("enabled_logged-in_limit", "0");
|
|
||||||
String username = "anonymous";
|
|
||||||
prop.put("enabled_status", "0");
|
|
||||||
//identified via HTTPPassword
|
|
||||||
entry=sb.userDB.proxyAuth((header.get(RequestHeader.AUTHORIZATION, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "1");
|
|
||||||
//try via cookie
|
|
||||||
}else{
|
|
||||||
entry=sb.userDB.cookieAuth(header.getHeaderCookies());
|
|
||||||
prop.put("enabled_logged-in_identified-by", "2");
|
|
||||||
//try via ip
|
|
||||||
if(entry == null){
|
|
||||||
entry=sb.userDB.ipAuth((header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//identified via userDB
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in", "1");
|
|
||||||
username = entry.getUserName();
|
|
||||||
if(entry.getTimeLimit() > 0){
|
|
||||||
prop.put("enabled_logged-in_limit", "1");
|
|
||||||
final long limit=entry.getTimeLimit();
|
|
||||||
final long used=entry.getTimeUsed();
|
|
||||||
prop.put("enabled_logged-in_limit_timelimit", limit);
|
|
||||||
prop.put("enabled_logged-in_limit_timeused", used);
|
|
||||||
int percent=0;
|
|
||||||
if(limit!=0 && used != 0)
|
|
||||||
percent=(int)((float)used/(float)limit*100);
|
|
||||||
prop.put("enabled_logged-in_limit_percent", percent/3);
|
|
||||||
prop.put("enabled_logged-in_limit_percent2", (100-percent)/3);
|
|
||||||
}
|
|
||||||
//logged in via static Password
|
|
||||||
}else if(sb.verifyAuthentication(header)){
|
|
||||||
prop.put("enabled_logged-in", "2");
|
|
||||||
username = "staticadmin";
|
|
||||||
//identified via form-login
|
|
||||||
//TODO: this does not work for a static admin, yet.
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = "";
|
|
||||||
String p = "";
|
|
||||||
String o = "";
|
|
||||||
|
|
||||||
Boolean global = false;
|
|
||||||
|
|
||||||
if(post != null){
|
|
||||||
|
|
||||||
if(post.containsKey("s")){
|
|
||||||
s = post.get("s");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(post.containsKey("p")){
|
|
||||||
p = post.get("p");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(post.containsKey("o")){
|
|
||||||
o = post.get("o");
|
|
||||||
}
|
|
||||||
|
|
||||||
global = post.containsKey("global");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.containsKey("load")) {
|
|
||||||
o = Interaction.GetTableentry(s, p, global ? "global" : username);
|
|
||||||
} else {
|
|
||||||
Interaction.Tableentry(s, p, o, global ? "global" : username, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.put("result", o);
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"result": "#[result]#"
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
package interaction;
|
|
||||||
|
|
||||||
//ViewLog_p.java
|
|
||||||
//-----------------------
|
|
||||||
//part of the AnomicHTTPD caching proxy
|
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
|
||||||
//first published on http://www.anomic.de
|
|
||||||
//Frankfurt, Germany, 2004
|
|
||||||
//
|
|
||||||
//This File is contributed by Alexander Schier
|
|
||||||
//last major change: 14.12.2004
|
|
||||||
//
|
|
||||||
//This program is free software; you can redistribute it and/or modify
|
|
||||||
//it under the terms of the GNU General Public License as published by
|
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
|
||||||
//(at your option) any later version.
|
|
||||||
//
|
|
||||||
//This program is distributed in the hope that it will be useful,
|
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
//GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
//You should have received a copy of the GNU General Public License
|
|
||||||
//along with this program; if not, write to the Free Software
|
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
|
||||||
//if the shell's current path is HTROOT
|
|
||||||
|
|
||||||
import net.yacy.cora.lod.JenaTripleStore;
|
|
||||||
import net.yacy.cora.protocol.HeaderFramework;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.data.UserDB;
|
|
||||||
import net.yacy.search.Switchboard;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class Triple {
|
|
||||||
|
|
||||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
||||||
|
|
||||||
final Switchboard sb = (Switchboard) env;
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
UserDB.Entry entry=null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//default values
|
|
||||||
prop.put("enabled_logged_in", "0");
|
|
||||||
prop.put("enabled_logged-in_limit", "0");
|
|
||||||
String username = "anonymous";
|
|
||||||
prop.put("enabled_status", "0");
|
|
||||||
//identified via HTTPPassword
|
|
||||||
entry=sb.userDB.proxyAuth((header.get(RequestHeader.AUTHORIZATION, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "1");
|
|
||||||
//try via cookie
|
|
||||||
}else{
|
|
||||||
entry=sb.userDB.cookieAuth(header.getHeaderCookies());
|
|
||||||
prop.put("enabled_logged-in_identified-by", "2");
|
|
||||||
//try via ip
|
|
||||||
if(entry == null){
|
|
||||||
entry=sb.userDB.ipAuth((header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//identified via userDB
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in", "1");
|
|
||||||
username = entry.getUserName();
|
|
||||||
if(entry.getTimeLimit() > 0){
|
|
||||||
prop.put("enabled_logged-in_limit", "1");
|
|
||||||
final long limit=entry.getTimeLimit();
|
|
||||||
final long used=entry.getTimeUsed();
|
|
||||||
prop.put("enabled_logged-in_limit_timelimit", limit);
|
|
||||||
prop.put("enabled_logged-in_limit_timeused", used);
|
|
||||||
int percent=0;
|
|
||||||
if(limit!=0 && used != 0)
|
|
||||||
percent=(int)((float)used/(float)limit*100);
|
|
||||||
prop.put("enabled_logged-in_limit_percent", percent/3);
|
|
||||||
prop.put("enabled_logged-in_limit_percent2", (100-percent)/3);
|
|
||||||
}
|
|
||||||
//logged in via static Password
|
|
||||||
}else if(sb.verifyAuthentication(header)){
|
|
||||||
prop.put("enabled_logged-in", "2");
|
|
||||||
username = "staticadmin";
|
|
||||||
//identified via form-login
|
|
||||||
//TODO: this does not work for a static admin, yet.
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = "";
|
|
||||||
String p = "";
|
|
||||||
String o = "";
|
|
||||||
String result = "";
|
|
||||||
|
|
||||||
Boolean global = false;
|
|
||||||
|
|
||||||
if (post != null) {
|
|
||||||
|
|
||||||
s = post.get("s", "");
|
|
||||||
p = post.get("p", "");
|
|
||||||
o = post.get("o", "");
|
|
||||||
|
|
||||||
if (post.containsKey("sp")) s = post.get("sp") + "#" + s;
|
|
||||||
if (post.containsKey("pp")) p = post.get("pp") + "#" + p;
|
|
||||||
|
|
||||||
global = post.containsKey("global");
|
|
||||||
|
|
||||||
if (post.containsKey("load")) {
|
|
||||||
if (global) {
|
|
||||||
result = JenaTripleStore.getObject(s, p);
|
|
||||||
} else {
|
|
||||||
result = JenaTripleStore.getPrivateObject(s, p, username);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (global) {
|
|
||||||
JenaTripleStore.addTriple(s, p, o);
|
|
||||||
} else {
|
|
||||||
JenaTripleStore.addTriple(s, p, o, username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.put("result", result);
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"result": "#[result]#"
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<style type="text/css" >
|
|
||||||
|
|
||||||
.sci_doc {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
width: 150px;
|
|
||||||
height: 20px;
|
|
||||||
z-index:99998;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<span id="sci_doc_#[hash]#" class="sci_doc" style="display: none;">
|
|
||||||
|
|
||||||
<img id="sci_doc_#[hash]#_img" src="/currentyacypeer/interaction_elements/document.png" width="16px" height="16px" alt="0" onclick="/* $('#sci_doc_#[hash]#_box').toggle();*/ return false"> <span style="font-size: x-small; position: absolute; margin-top: 4px;"><span id="sci_doc_#[hash]#_title"></span></span>
|
|
||||||
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div id="sci_doc_#[hash]#_box" class="sci_panel" style="top: 50px; display: none;">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
|
|
||||||
document.getElementById('sci_doc_#[hash]#').style.display = "";
|
|
||||||
var metajson = getMetadata('#[url]#');
|
|
||||||
var title = metajson.item.title.substring(0, 20)+"...";
|
|
||||||
|
|
||||||
document.getElementById('sci_doc_#[hash]#_title').innerHTML = title;
|
|
||||||
|
|
||||||
</script>
|
|
@ -1,19 +0,0 @@
|
|||||||
package interaction_elements;
|
|
||||||
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class Document_part {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
prop.put("hash", post.get("hash", ""));
|
|
||||||
prop.put("url", post.get("url", ""));
|
|
||||||
prop.put("action", post.get("action", ""));
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
#(enabled)#::
|
|
||||||
<!-- BEGIN Footer.html -->
|
|
||||||
<style type="text/css">
|
|
||||||
|
|
||||||
|
|
||||||
.SubMenuFooter h3 {
|
|
||||||
-webkit-border-radius: 5px;
|
|
||||||
-khtml-border-radius: 5px;
|
|
||||||
-moz-border-radius: 5px;
|
|
||||||
border-radius: 5px;
|
|
||||||
|
|
||||||
background-color:#[color]#;
|
|
||||||
color:white;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.MenuItemLinkFooter, ul.SubMenuFooter em {
|
|
||||||
background-color: #[color]#;
|
|
||||||
color:#[color]#;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover.MenuItemLinkFooter {
|
|
||||||
background-color:#[color]#;
|
|
||||||
color:#[color]#;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.SubMenuFooter a.MenuItemLinkFooter {
|
|
||||||
margin-top:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.MenuItemLinkFooter{
|
|
||||||
display:block;
|
|
||||||
text-decoration:none;
|
|
||||||
margin-top:1px;
|
|
||||||
margin-bottom:1px;
|
|
||||||
padding:1px 10px 1px 15px;
|
|
||||||
font-size:0.9em;
|
|
||||||
white-space:nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
a:hover.MenuItemLinkFooter {
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ul.SubMenuFooter em {
|
|
||||||
margin-top:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ul.SubMenuFooter em {
|
|
||||||
display:block;
|
|
||||||
text-decoration:none;
|
|
||||||
margin-top:1px;
|
|
||||||
margin-bottom:1px;
|
|
||||||
padding:1px 10px 1px 15px;
|
|
||||||
font-size:0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.SubMenuFooter {
|
|
||||||
clear:left;
|
|
||||||
padding:0;
|
|
||||||
margin:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.SubMenuFooter li {
|
|
||||||
list-style:none;
|
|
||||||
margin:0;
|
|
||||||
margin-top:1px;
|
|
||||||
padding:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.SubMenuFooter li {
|
|
||||||
float:left;
|
|
||||||
margin-right:1px;
|
|
||||||
margin-top:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div style="position: fixed; bottom: 0px; width: 100%;">
|
|
||||||
<ul class="SubMenuFooter">
|
|
||||||
#(userlogonenabled)#::<li style="width:#[ratio]#%;"><!--#include virtual="/currentyacypeer/interaction_elements/Loginstatus_part.html" --></li>#(/userlogonenabled)#
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<!-- END Footer.html -->
|
|
||||||
#(/enabled)#
|
|
@ -1,32 +0,0 @@
|
|||||||
package interaction_elements;
|
|
||||||
|
|
||||||
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class Footer {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader requestHeader, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
prop.put("enabled_color", env.getConfig("color_tableheader", ""));
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
prop.put("enabled_userlogonenabled", env.getConfigBool("interaction.userlogon.enabled", false) ? "1" : "0");
|
|
||||||
if (env.getConfigBool("interaction.userlogon.enabled", false)) count++;
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
prop.put("enabled", "1");
|
|
||||||
prop.put("enabled_userlogonenabled_ratio", Math.round(100/count)-1);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
prop.put("enabled", "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
#(enabled)#::
|
|
||||||
<!-- Loginbutton_part -->
|
|
||||||
#(logged-in)#
|
|
||||||
<a id="logon_trigger" href="" class="MenuItemLinkFooter" style="color: #fff; background-color: #[color]#;" onclick="return false;"><img src="/currentyacypeer/interaction_elements/login_empty.png"> #[username]#</a>
|
|
||||||
::
|
|
||||||
<a id="logon_trigger" href="" class="MenuItemLinkFooter" style="color: #fff; background-color: #[color]#;" onclick="return false;"><img src="/currentyacypeer/interaction_elements/login_user.png"> #[username]#</a>
|
|
||||||
::
|
|
||||||
<a id="logon_trigger" href="" class="MenuItemLinkFooter" style="color: #fff; background-color: #[color]#;" onclick="return false;"><img src="/currentyacypeer/interaction_elements/login_admin.png"> #[username]#</a>
|
|
||||||
#(/logged-in)#
|
|
||||||
#(/enabled)#
|
|
@ -1,114 +0,0 @@
|
|||||||
package interaction_elements;
|
|
||||||
|
|
||||||
//ViewLog_p.java
|
|
||||||
//-----------------------
|
|
||||||
//part of the AnomicHTTPD caching proxy
|
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
|
||||||
//first published on http://www.anomic.de
|
|
||||||
//Frankfurt, Germany, 2004
|
|
||||||
//
|
|
||||||
//This File is contributed by Alexander Schier
|
|
||||||
//last major change: 14.12.2004
|
|
||||||
//
|
|
||||||
//This program is free software; you can redistribute it and/or modify
|
|
||||||
//it under the terms of the GNU General Public License as published by
|
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
|
||||||
//(at your option) any later version.
|
|
||||||
//
|
|
||||||
//This program is distributed in the hope that it will be useful,
|
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
//GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
//You should have received a copy of the GNU General Public License
|
|
||||||
//along with this program; if not, write to the Free Software
|
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
|
||||||
//if the shell's current path is HTROOT
|
|
||||||
|
|
||||||
import net.yacy.cora.protocol.HeaderFramework;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.data.UserDB;
|
|
||||||
import net.yacy.search.Switchboard;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
import net.yacy.server.servletProperties;
|
|
||||||
|
|
||||||
public class Loginstatus_part {
|
|
||||||
|
|
||||||
public static serverObjects respond(final RequestHeader requestHeader, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
|
|
||||||
|
|
||||||
final Switchboard sb = (Switchboard) env;
|
|
||||||
|
|
||||||
final servletProperties prop = new servletProperties();
|
|
||||||
|
|
||||||
prop.put("enabled", env.getConfigBool("interaction.userlogon.enabled", false) ? "1" : "0");
|
|
||||||
|
|
||||||
prop.put("enabled_color", env.getConfig("color_tableheader", ""));
|
|
||||||
|
|
||||||
prop.put("enabled_logged-in_registrationenabled", env.getConfigBool("interaction.userselfregistration.enabled", false) ? "1" : "0");
|
|
||||||
|
|
||||||
//
|
|
||||||
// final String address = sb.peers.mySeed().getPublicAddress();
|
|
||||||
|
|
||||||
prop.put("enabled_peer", sb.peers.myName());
|
|
||||||
|
|
||||||
prop.put("enabled_logged-in_returnto", "/index.html");
|
|
||||||
|
|
||||||
|
|
||||||
UserDB.Entry entry=null;
|
|
||||||
|
|
||||||
//default values
|
|
||||||
prop.put("enabled_logged_in", "0");
|
|
||||||
prop.put("enabled_logged-in_limit", "0");
|
|
||||||
prop.put("enabled_logged-in_username", "anonymous");
|
|
||||||
prop.put("enabled_status", "0");
|
|
||||||
//identified via HTTPPassword
|
|
||||||
entry=sb.userDB.proxyAuth((requestHeader.get(RequestHeader.AUTHORIZATION, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "1");
|
|
||||||
//try via cookie
|
|
||||||
}else{
|
|
||||||
entry=sb.userDB.cookieAuth(requestHeader.getHeaderCookies());
|
|
||||||
prop.put("enabled_logged-in_identified-by", "2");
|
|
||||||
//try via ip
|
|
||||||
if(entry == null){
|
|
||||||
entry=sb.userDB.ipAuth((requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in_identified-by", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//identified via userDB
|
|
||||||
if(entry != null){
|
|
||||||
prop.put("enabled_logged-in", "1");
|
|
||||||
prop.put("enabled_logged-in_username", entry.getUserName());
|
|
||||||
if(entry.getTimeLimit() > 0){
|
|
||||||
prop.put("enabled_logged-in_limit", "1");
|
|
||||||
final long limit=entry.getTimeLimit();
|
|
||||||
final long used=entry.getTimeUsed();
|
|
||||||
prop.put("enabled_logged-in_limit_timelimit", limit);
|
|
||||||
prop.put("enabled_logged-in_limit_timeused", used);
|
|
||||||
int percent=0;
|
|
||||||
if(limit!=0 && used != 0)
|
|
||||||
percent=(int)((float)used/(float)limit*100);
|
|
||||||
prop.put("enabled_logged-in_limit_percent", percent/3);
|
|
||||||
prop.put("enabled_logged-in_limit_percent2", (100-percent)/3);
|
|
||||||
}
|
|
||||||
//logged in via static Password
|
|
||||||
}else if(sb.verifyAuthentication(requestHeader)){
|
|
||||||
prop.put("enabled_logged-in", "2");
|
|
||||||
prop.put("enabled_logged-in_username", "staticadmin");
|
|
||||||
//identified via form-login
|
|
||||||
//TODO: this does not work for a static admin, yet.
|
|
||||||
}
|
|
||||||
|
|
||||||
// return rewrite properties
|
|
||||||
return prop;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,195 +0,0 @@
|
|||||||
#(enabled)#::
|
|
||||||
|
|
||||||
<style type="text/css" >
|
|
||||||
|
|
||||||
.sci_headerbar {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 0px;;
|
|
||||||
width: 100%;
|
|
||||||
height: 37px;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
background: #ffffff;
|
|
||||||
|
|
||||||
padding: 0px 0px 0px 0px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.sci_bar {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 35px;;
|
|
||||||
width: 100%;
|
|
||||||
height: 2px;
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
background: #[color]#;
|
|
||||||
|
|
||||||
padding: 0px 0px 0px 0px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.sci_icon {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
left: 10px;
|
|
||||||
top: 0;
|
|
||||||
margin-top: 1px;
|
|
||||||
padding-left: 50px;
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
width: 250px;
|
|
||||||
height: 19px;
|
|
||||||
padding: 9px 5px 5px 5px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
color: #5a346e;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.sci_left {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
left: 60px;
|
|
||||||
top: 0;
|
|
||||||
margin-top: 1px;
|
|
||||||
padding-left: 50px;
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
width: 250px;
|
|
||||||
height: 19px;
|
|
||||||
padding: 9px 5px 5px 5px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
color: #5a346e;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.sci_right {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
right: 200px;
|
|
||||||
top: 0;
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
width: 200px;
|
|
||||||
height: 20px;
|
|
||||||
padding: 5px 5px 5px 5px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
color: #[color]#;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.sci_panel {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
position: fixed;
|
|
||||||
right: 0;
|
|
||||||
background: #ffffff;
|
|
||||||
border:1px solid #[color]#;
|
|
||||||
|
|
||||||
width: 210px;
|
|
||||||
height: auto;
|
|
||||||
padding: 30px 110px 30px 30px;
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
color: #[color]#;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.sci_panel p{
|
|
||||||
margin: 0 0 15px 0;
|
|
||||||
padding: 0;
|
|
||||||
color: #cccccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sci_panel a, .sci_panel a:visited{
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
color: #9FC54E;
|
|
||||||
text-decoration: none;
|
|
||||||
border-bottom: 1px solid #9FC54E;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sci_panel a:hover, .sci_panel a:visited:hover{
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
color: #ffffff;
|
|
||||||
text-decoration: none;
|
|
||||||
border-bottom: 1px solid #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="sci_headerbar" class="sci_headerbar">
|
|
||||||
|
|
||||||
<div id="sidebar-bar" class="sci_bar" style="">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="sidebar-logo" class="sci_icon" style="">
|
|
||||||
|
|
||||||
<img src="/currentyacypeer/env/grafics/yacy.png" height="20px" width="36px"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="sidebar-logo" class="sci_left" style="">
|
|
||||||
|
|
||||||
<!--#include virtual="/currentyacypeer/interaction_elements/Tag_part.html?action=#[action]#&hash=#[urlhash]#&url=#[url]#" -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="sidebar-document" class="sci_right" style="">
|
|
||||||
|
|
||||||
<!--#include virtual="/currentyacypeer/interaction_elements/Document_part.html?action=#[action]#&hash=#[urlhash]#&url=#[url]#" -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
#(/enabled)#
|
|
@ -1,25 +0,0 @@
|
|||||||
package interaction_elements;
|
|
||||||
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class OverlayInteraction {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
prop.put("enabled", env.getConfigBool("interaction.overlayinteraction.enabled", false) ? "1" : "0");
|
|
||||||
|
|
||||||
prop.put("enabled_url", post.get("url", ""));
|
|
||||||
|
|
||||||
prop.put("enabled_urlhash", post.get("urlhash", ""));
|
|
||||||
|
|
||||||
prop.put("enabled_action", post.get("action", ""));
|
|
||||||
|
|
||||||
prop.put("enabled_color", env.getConfig("color_tableheader", ""));
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
<style type="text/css" >
|
|
||||||
|
|
||||||
.sci_tag {
|
|
||||||
|
|
||||||
font: arial,helvetica,sans-serif;
|
|
||||||
font-size: 10px;
|
|
||||||
background: #ffffff;
|
|
||||||
border:0px;
|
|
||||||
|
|
||||||
width: 65px;
|
|
||||||
height: 20px;
|
|
||||||
|
|
||||||
|
|
||||||
z-index:99998;
|
|
||||||
|
|
||||||
color: #5a346e;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<span id="sci_tags_#[hash]#" class="sci_tag" style="display: none;">
|
|
||||||
<img id="sci_tags_#[hash]#_img" src="/currentyacypeer/interaction_elements/tag.png" width="16px" height="16px" alt="0" onclick="/* $('#sci_tags_#[hash]#_box').toggle();*/ return false"> <span style="font-size: x-small; position: absolute; margin-top: 4px;"><span id="sci_tags_#[hash]#_tags"></span></span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div id="sci_tags_#[hash]#_box" class="sci_panel" style="top: 50px; display: none;">
|
|
||||||
|
|
||||||
<div id="rdfcontent_#[hash]#" class="rdfcontent_#[hash]#" style="display:none;"></div>
|
|
||||||
|
|
||||||
<input type="text" id="tags_#[hash]#" name="tags_#[hash]#" class="bm_input" size="80" />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
|
|
||||||
var vocabularies_string = '#[vocabularies]#';
|
|
||||||
|
|
||||||
var vocs = vocabularies_string.split (",");
|
|
||||||
|
|
||||||
var existingtags = "";
|
|
||||||
|
|
||||||
var resultstring = "";
|
|
||||||
|
|
||||||
if (vocabularies_string != "") {
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/api/yacydoc.json?urlhash=#[hash]#', function(data) {
|
|
||||||
|
|
||||||
resultstring = data.result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vocs.forEach (function(voc) {
|
|
||||||
|
|
||||||
var currenttags = triple_get_prefix ('http://yacy.net/url', '#[hash]#', 'http://yacy.net/autotagging', voc);
|
|
||||||
|
|
||||||
var finaltags = "";
|
|
||||||
|
|
||||||
currenttags.split(',').forEach (function(tag) {
|
|
||||||
var link = "";
|
|
||||||
|
|
||||||
resultstring.split(',').forEach (function(hyperlink) {
|
|
||||||
|
|
||||||
var h_url = hyperlink.substring (0, hyperlink.indexOf('#'));
|
|
||||||
var h_tag = hyperlink.substring (hyperlink.indexOf('#')+1);
|
|
||||||
|
|
||||||
if (h_tag == tag) {
|
|
||||||
link = h_url;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (link != "") {
|
|
||||||
finaltags = finaltags + "<a href='"+link +"' target='_blank'>" + tag + "</a> ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
finaltags = finaltags + tag + ' ';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (existingtags != "" && currenttags != "") existingtags += " - ";
|
|
||||||
if (currenttags != "") existingtags += voc+":"+ finaltags;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (existingtags != "") {
|
|
||||||
document.getElementById('sci_tags_#[hash]#').style.display = "";
|
|
||||||
document.getElementById('sci_tags_#[hash]#_tags').innerHTML = existingtags;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* document.getElementById('tags_#[hash]#').value = existingtags;
|
|
||||||
|
|
||||||
$('#tags_#[hash]#').tagsInput({
|
|
||||||
'height':'105px',
|
|
||||||
'width':'270px',
|
|
||||||
'interactive':true,
|
|
||||||
'removeWithBackspace' : true,
|
|
||||||
'minChars' : 0,
|
|
||||||
'maxChars' : 0,
|
|
||||||
'placeholderColor' : '#666666',
|
|
||||||
'onChange' : function () {
|
|
||||||
storevalue_t ('http://yacy.net/url#[hash]#', 'http://yacy.net/autotagging#manual', document.getElementById('tags_#[hash]#').value);
|
|
||||||
}
|
|
||||||
}); */
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
|||||||
package interaction_elements;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import net.yacy.cora.lod.vocabulary.Tagging;
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
|
||||||
import net.yacy.document.LibraryProvider;
|
|
||||||
import net.yacy.server.serverObjects;
|
|
||||||
import net.yacy.server.serverSwitch;
|
|
||||||
|
|
||||||
public class Tag_part {
|
|
||||||
|
|
||||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
|
||||||
|
|
||||||
final serverObjects prop = new serverObjects();
|
|
||||||
|
|
||||||
prop.put("hash", post.get("hash", ""));
|
|
||||||
prop.put("url", post.get("url", ""));
|
|
||||||
prop.put("action", post.get("action", ""));
|
|
||||||
|
|
||||||
String vocabularies = "";
|
|
||||||
|
|
||||||
Collection<Tagging> vocs = LibraryProvider.autotagging.getVocabularies();
|
|
||||||
|
|
||||||
for (Tagging v: vocs) {
|
|
||||||
vocabularies += v.getName()+",";
|
|
||||||
}
|
|
||||||
|
|
||||||
vocabularies += "manual";
|
|
||||||
|
|
||||||
prop.put("vocabularies", vocabularies);
|
|
||||||
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 4.7 KiB |
@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
function newload (name, div) {
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.get(name, function(data) {
|
|
||||||
document.getElementById(div).innerHTML = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function xmlToString (xmlData) {
|
|
||||||
|
|
||||||
var xmlString;
|
|
||||||
|
|
||||||
if (window.ActiveXObject) {
|
|
||||||
xmlString = xmlData.xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
xmlString = (new XMLSerializer()).serializeToString(xmlData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return xmlString;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function rdfload (datastore) {
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type : "GET",
|
|
||||||
url: "/currentyacypeer/interaction/GetRDF.xml?global=true",
|
|
||||||
dataType: "xml",
|
|
||||||
success: function(xml) {
|
|
||||||
datastore.load(xml);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function feedback (url, comment, from) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Feedback.json?url='+url+'&comment='+comment+'&from='+from, function(data) {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function suggest (url) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Suggest.json?url='+url, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function contribution (url, comment, username) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Contribution.json?url='+url+'&comment='+comment+'&from='+username, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function triple (url, s, p, o, username) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?url='+url+'&s='+s+'&p='+p+'&o='+o+'&from='+username, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function storevalue_t (s, p, o) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Table.json?url='+document.location.href+'&s='+s+'&p='+p+'&o='+o, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function storevalueglobal_t (s, p, o) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Table.json?global=true&url='+s+'&s='+s+'&p='+p+'&o='+o, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function storevalue (s, p, o) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?url='+document.location.href+'&s='+s+'&p='+p+'&o='+o, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function storevalueglobal (s, p, o) {
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?global=true&url='+document.location.href+'&s='+s+'&p='+p+'&o='+o, function(data) {
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadvalue (s, p) {
|
|
||||||
|
|
||||||
var res = {result: ""};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?s='+s+'&p='+p+'&load=true', function (data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res.result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadvalue_t (s, p) {
|
|
||||||
|
|
||||||
var res = {result: ""};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Table.json?s='+s+'&p='+p+'&load=true', function (data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res.result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadvalueglobal_t (s, p) {
|
|
||||||
|
|
||||||
var res = {result: ""};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Table.json?global=true&s='+s+'&p='+p+'&load=true', function (data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res.result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadvalueglobal (s, p) {
|
|
||||||
|
|
||||||
var res = {result: ""};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?global=true&s='+s+'&p='+p+'&load=true', function (data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res.result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function triple_get_prefix (sp, s, pp, p) {
|
|
||||||
|
|
||||||
var res = {result: ""};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/interaction/Triple.json?sep=true&global=true&sp='+sp+'&s='+s+'&pp='+pp+'&p='+p+'&load=true', function (data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res.result;
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
function getMetadata (url) {
|
|
||||||
|
|
||||||
|
|
||||||
var res = {"item": {"title": "no title"}};
|
|
||||||
|
|
||||||
$.ajaxSetup({async: false});
|
|
||||||
|
|
||||||
$.getJSON('/currentyacypeer/api/getpageinfo.json?url='+url, function(data) {
|
|
||||||
|
|
||||||
res = data;
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return res;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
@ -1,332 +0,0 @@
|
|||||||
// Author: DL
|
|
||||||
|
|
||||||
package net.yacy.cora.lod;
|
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import net.yacy.cora.document.encoding.UTF8;
|
|
||||||
import net.yacy.cora.lod.vocabulary.DCTerms;
|
|
||||||
import net.yacy.cora.lod.vocabulary.Geo;
|
|
||||||
import net.yacy.cora.lod.vocabulary.HttpHeader;
|
|
||||||
import net.yacy.cora.lod.vocabulary.Tagging;
|
|
||||||
import net.yacy.cora.lod.vocabulary.YaCyMetadata;
|
|
||||||
import net.yacy.cora.util.ConcurrentLog;
|
|
||||||
import net.yacy.search.Switchboard;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Property;
|
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ResIterator;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Selector;
|
|
||||||
import com.hp.hpl.jena.rdf.model.SimpleSelector;
|
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
|
||||||
import com.hp.hpl.jena.util.FileManager;
|
|
||||||
|
|
||||||
|
|
||||||
public class JenaTripleStore {
|
|
||||||
|
|
||||||
private final static ConcurrentLog log = new ConcurrentLog(JenaTripleStore.class.getName());
|
|
||||||
|
|
||||||
public static Model model = ModelFactory.createDefaultModel();
|
|
||||||
static {
|
|
||||||
init(model);
|
|
||||||
|
|
||||||
}
|
|
||||||
private final static void init(Model model) {
|
|
||||||
model.setNsPrefix(YaCyMetadata.PREFIX, YaCyMetadata.NAMESPACE);
|
|
||||||
model.setNsPrefix(Tagging.DEFAULT_PREFIX, Tagging.DEFAULT_NAMESPACE);
|
|
||||||
model.setNsPrefix(HttpHeader.PREFIX, HttpHeader.NAMESPACE);
|
|
||||||
model.setNsPrefix(Geo.PREFIX, Geo.NAMESPACE);
|
|
||||||
model.setNsPrefix("pnd", "http://dbpedia.org/ontology/individualisedPnd");
|
|
||||||
model.setNsPrefix(DCTerms.PREFIX, DCTerms.NAMESPACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long size() {
|
|
||||||
return model.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcurrentHashMap<String, Model> privatestorage = null;
|
|
||||||
|
|
||||||
public static void load(String filename) throws IOException {
|
|
||||||
if (filename.endsWith(".nt")) LoadNTriples(filename);
|
|
||||||
else loadRDF(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadRDF(String fileNameOrUri) throws IOException {
|
|
||||||
Model tmp = ModelFactory.createDefaultModel();
|
|
||||||
log.info("Loading from " + fileNameOrUri);
|
|
||||||
InputStream is = FileManager.get().open(fileNameOrUri);
|
|
||||||
if (is != null) {
|
|
||||||
// read the RDF/XML file
|
|
||||||
tmp.read(is, null);
|
|
||||||
log.info("loaded " + tmp.size() + " triples from " + fileNameOrUri);
|
|
||||||
model = model.union(tmp);
|
|
||||||
} else {
|
|
||||||
throw new IOException("cannot read " + fileNameOrUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void LoadNTriples(String fileNameOrUri) throws IOException {
|
|
||||||
log.info("Loading N-Triples from " + fileNameOrUri);
|
|
||||||
InputStream is = FileManager.get().open(fileNameOrUri);
|
|
||||||
LoadNTriples(is);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadNTriples(InputStream is) throws IOException {
|
|
||||||
Model tmp = ModelFactory.createDefaultModel();
|
|
||||||
if (is != null) {
|
|
||||||
tmp.read(is, null, "N-TRIPLE");
|
|
||||||
log.info("loaded " + tmp.size() + " triples");
|
|
||||||
model = model.union(tmp);
|
|
||||||
//model.write(System.out, "TURTLE");
|
|
||||||
} else {
|
|
||||||
throw new IOException("cannot read input stream");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addFile(String rdffile) {
|
|
||||||
Model tmp = ModelFactory.createDefaultModel();
|
|
||||||
try {
|
|
||||||
InputStream in = new ByteArrayInputStream(UTF8.getBytes(rdffile));
|
|
||||||
|
|
||||||
// read the RDF/XML file
|
|
||||||
tmp.read(in, null);
|
|
||||||
} finally {
|
|
||||||
model = model.union(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveFile(String filename) {
|
|
||||||
saveFile(filename, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveFile(String filename, Model model) {
|
|
||||||
File f = new File(filename);
|
|
||||||
File ftmp = new File(filename + "." + System.currentTimeMillis());
|
|
||||||
if (model.isEmpty() && !f.exists()) {
|
|
||||||
// we don't store zero-size models if they did not exist before
|
|
||||||
log.info("NOT saving triplestore with " + model.size() + " triples to " + filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.info("Saving triplestore with " + model.size() + " triples to " + filename);
|
|
||||||
OutputStream fout;
|
|
||||||
try {
|
|
||||||
fout = new BufferedOutputStream(new FileOutputStream(ftmp));
|
|
||||||
model.write(fout);
|
|
||||||
fout.close();
|
|
||||||
// if something went wrong until here, the original file is not overwritten
|
|
||||||
// since we are happy here, we can remove the old file and replace it with the new one
|
|
||||||
f.delete();
|
|
||||||
if (!f.exists()) {
|
|
||||||
ftmp.renameTo(f);
|
|
||||||
}
|
|
||||||
log.info("Saved triplestore with " + model.size() + " triples to " + filename);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
log.warn("Saving to " + filename+" failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear the triplestore
|
|
||||||
*/
|
|
||||||
public static void clear() {
|
|
||||||
model = ModelFactory.createDefaultModel();
|
|
||||||
init(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a Resource instance with the given URI in this model.
|
|
||||||
* @param uri
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static Resource getResource(String uri) {
|
|
||||||
return model.getResource(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteObjects(String subject, String predicate) {
|
|
||||||
Resource r = subject == null ? null : getResource(subject);
|
|
||||||
Property pr = model.getProperty(predicate);
|
|
||||||
JenaTripleStore.model.removeAll(r, pr, (Resource) null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addTriple(String subject, String predicate, String object, String username) {
|
|
||||||
if (privatestorage != null && privatestorage.containsKey(username)) {
|
|
||||||
addTriple (subject, predicate, object, privatestorage.get(username));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addTriple(String subject, String predicate, String object) {
|
|
||||||
addTriple (subject, predicate, object, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addTriple(String subject, String predicate, String object, Model model) {
|
|
||||||
Resource r = model.getResource(subject);
|
|
||||||
Property pr = model.getProperty(predicate);
|
|
||||||
r.addProperty(pr, object);
|
|
||||||
log.info("ADD " + subject + " - " + predicate + " - " + object);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getObject(final String subject, final String predicate) {
|
|
||||||
Iterator<RDFNode> ni = JenaTripleStore.getObjects(subject, predicate);
|
|
||||||
String object = "";
|
|
||||||
if (ni.hasNext()) object = ni.next().toString();
|
|
||||||
log.info("GET " + subject + " - " + predicate + " - " + object);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator<RDFNode> getObjects(final String subject, final String predicate) {
|
|
||||||
final Resource r = subject == null ? null : JenaTripleStore.getResource(subject);
|
|
||||||
return getObjects(r, predicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPrivateObject(final String subject, final String predicate, final String username) {
|
|
||||||
Iterator<RDFNode> ni = JenaTripleStore.getPrivateObjects(subject, predicate, username);
|
|
||||||
String object = "";
|
|
||||||
if (ni.hasNext()) object = ni.next().toString();
|
|
||||||
log.info("GET (" + username + ") " + subject + " - " + predicate + " - " + object);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Iterator<RDFNode> getPrivateObjects(final String subject, final String predicate, final String username) {
|
|
||||||
if (privatestorage != null && privatestorage.containsKey(username)) {
|
|
||||||
return getObjects(privatestorage.get(username).getResource(subject), predicate, privatestorage.get(username));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Iterator<RDFNode> getObjects(final Resource r, final String predicate) {
|
|
||||||
return getObjects(r, predicate, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Iterator<RDFNode> getObjects(final Resource r, final String predicate, final Model model) {
|
|
||||||
final Property pr = model.getProperty(predicate);
|
|
||||||
final StmtIterator iter = model.listStatements(r, pr, (Resource) null);
|
|
||||||
|
|
||||||
return new Iterator<RDFNode>() {
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return iter.hasNext();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public RDFNode next() {
|
|
||||||
return iter.nextStatement().getObject();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator<Resource> getSubjects(final String predicate) {
|
|
||||||
return getSubjects(predicate, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Iterator<Resource> getSubjects(final String predicate, final Model model) {
|
|
||||||
final Property pr = model.getProperty(predicate);
|
|
||||||
final ResIterator iter = model.listSubjectsWithProperty(pr);
|
|
||||||
|
|
||||||
return new Iterator<Resource>() {
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return iter.hasNext();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Resource next() {
|
|
||||||
return iter.nextResource();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Model getSubmodelBySubject(String subject) {
|
|
||||||
Selector q = new SimpleSelector(model.getResource(subject), (Property) null, (RDFNode) null);
|
|
||||||
final Model m = model.query(q);
|
|
||||||
m.setNsPrefix(Tagging.DEFAULT_PREFIX, Tagging.DEFAULT_NAMESPACE);
|
|
||||||
m.setNsPrefix(DCTerms.PREFIX, DCTerms.NAMESPACE);
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getRDFByModel(Model model) {
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
model.write(baos, "RDF/XML-ABBREV");
|
|
||||||
return UTF8.String(baos.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initPrivateStores() {
|
|
||||||
Switchboard switchboard = Switchboard.getSwitchboard();
|
|
||||||
log.info("Init private stores");
|
|
||||||
if (privatestorage == null) privatestorage = new ConcurrentHashMap<String, Model>();
|
|
||||||
if (privatestorage != null) privatestorage.clear();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Iterator<net.yacy.data.UserDB.Entry> it = switchboard.userDB.iterator(true);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
net.yacy.data.UserDB.Entry e = it.next();
|
|
||||||
String username = e.getUserName();
|
|
||||||
File triplestore = new File(switchboard.getConfig("triplestore", new File(switchboard.getDataPath(), "DATA/TRIPLESTORE").getAbsolutePath()));
|
|
||||||
File currentuserfile = new File(triplestore, "private_store_"+username+".rdf");
|
|
||||||
log.info("Init " + username + " from "+currentuserfile.getAbsolutePath());
|
|
||||||
Model tmp = ModelFactory.createDefaultModel();
|
|
||||||
init (tmp);
|
|
||||||
|
|
||||||
if (currentuserfile.exists()) {
|
|
||||||
log.info("Loading from " + currentuserfile.getAbsolutePath());
|
|
||||||
InputStream is = FileManager.get().open(currentuserfile.getAbsolutePath());
|
|
||||||
if (is != null) {
|
|
||||||
// read the RDF/XML file
|
|
||||||
tmp.read(is, null);
|
|
||||||
log.info("loaded " + tmp.size() + " triples from " + currentuserfile.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
throw new IOException("cannot read " + currentuserfile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmp != null) {
|
|
||||||
privatestorage.put(username, tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Exception anyex) {
|
|
||||||
log.warn(anyex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void savePrivateStores() {
|
|
||||||
Switchboard switchboard = Switchboard.getSwitchboard();
|
|
||||||
log.info("Saving user triplestores");
|
|
||||||
if (privatestorage == null) return;
|
|
||||||
for (Entry<String, Model> s : privatestorage.entrySet()) {
|
|
||||||
File triplestore = new File(switchboard.getConfig("triplestore", new File(switchboard.getDataPath(), "DATA/TRIPLESTORE").getAbsolutePath()));
|
|
||||||
File currentuserfile = new File(triplestore, "private_store_"+s.getKey()+".rdf");
|
|
||||||
saveFile (currentuserfile.getAbsolutePath(), s.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long lastModelSizeStored = -1;
|
|
||||||
|
|
||||||
public static void saveAll() {
|
|
||||||
Switchboard sb = Switchboard.getSwitchboard();
|
|
||||||
File triplestore = new File(sb.getConfig("triplestore", new File(sb.dataPath, "DATA/TRIPLESTORE").getAbsolutePath()));
|
|
||||||
if (model.size() != lastModelSizeStored){
|
|
||||||
JenaTripleStore.saveFile(new File(triplestore, "local.rdf").getAbsolutePath());
|
|
||||||
lastModelSizeStored = model.size();
|
|
||||||
}
|
|
||||||
JenaTripleStore.savePrivateStores();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
package net.yacy.data.ymark;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.yacy.cora.document.encoding.UTF8;
|
|
||||||
import net.yacy.cora.lod.vocabulary.AnnoteaA;
|
|
||||||
import net.yacy.cora.lod.vocabulary.AnnoteaB;
|
|
||||||
import net.yacy.cora.lod.vocabulary.DCElements;
|
|
||||||
import net.yacy.cora.lod.vocabulary.Rdf;
|
|
||||||
import net.yacy.kelondro.blob.Tables;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Bag;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Property;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
|
||||||
|
|
||||||
public class YMarkRDF {
|
|
||||||
|
|
||||||
public final Model model;
|
|
||||||
|
|
||||||
public final static String USER = "USER";
|
|
||||||
public final static String TYPE = "TYPE";
|
|
||||||
public final static String SUBTOPIC = "SUBTOPIC";
|
|
||||||
|
|
||||||
private final Map<String, Property> property;
|
|
||||||
|
|
||||||
public final static String BOOKMARK = "/YMarks.rdf?id=";
|
|
||||||
private final StringBuilder resourceURI;
|
|
||||||
private final int len;
|
|
||||||
|
|
||||||
public YMarkRDF(final String peerURI) {
|
|
||||||
this.model = ModelFactory.createDefaultModel();
|
|
||||||
this.property = new HashMap<String, Property>();
|
|
||||||
|
|
||||||
this.len = peerURI.length()+BOOKMARK.length();
|
|
||||||
this.resourceURI = new StringBuilder(len+20);
|
|
||||||
this.resourceURI.append(peerURI);
|
|
||||||
this.resourceURI.append(BOOKMARK);
|
|
||||||
|
|
||||||
model.setNsPrefix(Rdf.PREFIX, Rdf.IDENTIFIER);
|
|
||||||
model.setNsPrefix(DCElements.PREFIX, DCElements.IDENTIFIER);
|
|
||||||
model.setNsPrefix(AnnoteaA.PREFIX, AnnoteaA.NAMESPACE);
|
|
||||||
model.setNsPrefix(AnnoteaB.PREFIX, AnnoteaB.NAMESPACE);
|
|
||||||
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.URL.key(), this.model.createProperty(AnnoteaB.recalls.getNamespace(), AnnoteaB.recalls.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.FOLDERS.key(), this.model.createProperty(AnnoteaB.hasTopic.getNamespace(), AnnoteaB.hasTopic.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.TITLE.key(), this.model.createProperty(DCElements.title.getNamespace(), DCElements.title.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.DESC.key(), this.model.createProperty(DCElements.description.getNamespace(), DCElements.description.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.DATE_ADDED.key(), this.model.createProperty(AnnoteaA.created.getNamespace(), AnnoteaA.created.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.DATE_MODIFIED.key(), this.model.createProperty(DCElements.date.getNamespace(), DCElements.date.name()));
|
|
||||||
this.property.put(YMarkEntry.BOOKMARK.TAGS.key(), this.model.createProperty(DCElements.subject.getNamespace(), DCElements.subject.name()));
|
|
||||||
|
|
||||||
this.property.put(USER, this.model.createProperty(DCElements.creator.getNamespace(), DCElements.creator.name()));
|
|
||||||
this.property.put(TYPE, this.model.createProperty(Rdf.type.getNamespace(), Rdf.type.name()));
|
|
||||||
this.property.put(SUBTOPIC, this.model.createProperty(AnnoteaB.subTopicOf.getNamespace(), AnnoteaB.subTopicOf.name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param format {RDF/XML, RDF/XML-ABBREV, N-TRIPLE, N3, N3-PP, N3-PLAIN, N3-TRIPLE, TURTLE}
|
|
||||||
* @return RDF
|
|
||||||
*/
|
|
||||||
public String getRDF(final String format) {
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
this.model.write(baos, format);
|
|
||||||
try {
|
|
||||||
return baos.toString("UTF-8");
|
|
||||||
} catch (final UnsupportedEncodingException e) {
|
|
||||||
return new String();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTopic(final String bmk_user, final String folder) {
|
|
||||||
this.resourceURI.append(bmk_user);
|
|
||||||
this.resourceURI.append(":f:");
|
|
||||||
this.resourceURI.append(UTF8.String(YMarkUtil.getKeyId(folder)));
|
|
||||||
final Resource topic = this.model.createResource(this.resourceURI.toString());
|
|
||||||
this.resourceURI.setLength(this.len);
|
|
||||||
|
|
||||||
topic.addProperty(this.property.get(YMarkEntry.BOOKMARK.DATE_MODIFIED.key()), YMarkUtil.EMPTY_STRING);
|
|
||||||
topic.addProperty(this.property.get(YMarkEntry.BOOKMARK.DATE_ADDED.key()), YMarkUtil.EMPTY_STRING);
|
|
||||||
topic.addProperty(this.property.get(USER), bmk_user);
|
|
||||||
topic.addProperty(this.property.get(YMarkEntry.BOOKMARK.DESC.key()), YMarkUtil.EMPTY_STRING);
|
|
||||||
final int i = folder.lastIndexOf(YMarkUtil.FOLDERS_SEPARATOR);
|
|
||||||
if(i>0)
|
|
||||||
topic.addProperty(this.property.get(SUBTOPIC), folder.substring(0, i));
|
|
||||||
topic.addProperty(this.property.get(YMarkEntry.BOOKMARK.TITLE.key()), folder);
|
|
||||||
topic.addProperty(this.property.get(TYPE), AnnoteaB.Topic.getPredicate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBookmark (final String bmk_user, final Tables.Row bmk_row) {
|
|
||||||
if(bmk_row == null || bmk_row.get(YMarkEntry.BOOKMARK.PUBLIC.key(), YMarkEntry.BOOKMARK.PUBLIC.deflt()).equals("false"))
|
|
||||||
return;
|
|
||||||
// create an annotea bookmark resource
|
|
||||||
this.resourceURI.append(bmk_user);
|
|
||||||
this.resourceURI.append(":b:");
|
|
||||||
this.resourceURI.append(UTF8.String(bmk_row.getPK()));
|
|
||||||
final Resource bmk = this.model.createResource(this.resourceURI.toString());
|
|
||||||
this.resourceURI.setLength(this.len);
|
|
||||||
|
|
||||||
// add properties
|
|
||||||
bmk.addProperty(this.property.get(USER), bmk_user);
|
|
||||||
for (final YMarkEntry.BOOKMARK b : YMarkEntry.BOOKMARK.values()) {
|
|
||||||
switch(b) {
|
|
||||||
case FOLDERS:
|
|
||||||
final String[] folders = bmk_row.get(b.key(), b.deflt()).split(b.seperator());
|
|
||||||
if(folders.length > 1) {
|
|
||||||
Bag topics = this.model.createBag();
|
|
||||||
for(String folder : folders) {
|
|
||||||
topics.add(folder);
|
|
||||||
this.addTopic(bmk_user, folder);
|
|
||||||
}
|
|
||||||
bmk.addProperty(this.property.get(b.key()), topics);
|
|
||||||
} else {
|
|
||||||
bmk.addProperty(this.property.get(b.key()), folders[0]);
|
|
||||||
this.addTopic(bmk_user, folders[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TAGS:
|
|
||||||
final String[] tags = bmk_row.get(b.key(), b.deflt()).split(b.seperator());
|
|
||||||
if(tags.length > 1) {
|
|
||||||
Bag subjects = this.model.createBag();
|
|
||||||
for(String tag : tags) {
|
|
||||||
subjects.add(tag);
|
|
||||||
}
|
|
||||||
bmk.addProperty(this.property.get(b.key()), subjects);
|
|
||||||
} else {
|
|
||||||
bmk.addProperty(this.property.get(b.key()), tags[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DATE_ADDED:
|
|
||||||
case DATE_MODIFIED:
|
|
||||||
final YMarkDate date = new YMarkDate(bmk_row.get(b.key()));
|
|
||||||
bmk.addProperty(this.property.get(b.key()), date.toISO8601());
|
|
||||||
break;
|
|
||||||
// these cases are inserted for better readable RDF output
|
|
||||||
case DESC:
|
|
||||||
case URL:
|
|
||||||
case TITLE:
|
|
||||||
bmk.addProperty(this.property.get(b.key()), bmk_row.get(b.key(), b.deflt()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if(this.property.containsKey(b.key())) {
|
|
||||||
bmk.addProperty(this.property.get(b.key()), bmk_row.get(b.key(), b.deflt()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bmk.addProperty(this.property.get(TYPE), AnnoteaB.Bookmark.getPredicate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBookmarks(final String bmk_user, final Iterator<Tables.Row> riter) {
|
|
||||||
while(riter.hasNext()) {
|
|
||||||
this.addBookmark(bmk_user, riter.next());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue