diff --git a/htroot/DemoServletInteraction.html b/htroot/DemoServletInteraction.html index 94e81bce8..c455e5d60 100644 --- a/htroot/DemoServletInteraction.html +++ b/htroot/DemoServletInteraction.html @@ -51,6 +51,9 @@

+ + + #%env/templates/footer.template%# diff --git a/htroot/env/templates/jqueryheader.template b/htroot/env/templates/jqueryheader.template index cbe12c4e7..235119203 100644 --- a/htroot/env/templates/jqueryheader.template +++ b/htroot/env/templates/jqueryheader.template @@ -1,7 +1,12 @@ - - - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/htroot/interaction/OverlayInteraction.html b/htroot/interaction/OverlayInteraction.html index d3fea7278..d68b4569a 100644 --- a/htroot/interaction/OverlayInteraction.html +++ b/htroot/interaction/OverlayInteraction.html @@ -58,26 +58,34 @@ document - - - + + + + diff --git a/htroot/interaction/Triple.java b/htroot/interaction/Triple.java index 4dd06ef96..f183049ae 100644 --- a/htroot/interaction/Triple.java +++ b/htroot/interaction/Triple.java @@ -29,9 +29,11 @@ package interaction; //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.interaction.Interaction; import net.yacy.search.Switchboard; +import de.anomic.data.UserDB; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -42,6 +44,56 @@ public class Triple { 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 url = ""; String s = ""; @@ -75,11 +127,11 @@ public class Triple { if (post.containsKey("load")) { - o = Interaction.TripleGet(s, p); + o = Interaction.TripleGet(s, p, username); } else { - Interaction.Triple(url, s, p, o, from); + Interaction.Triple(url, s, p, o, username); } prop.put("result", o); diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index d900983dd..c067919b2 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -177,7 +177,7 @@ public class yacysearchitem { } } prop.putHTML("content_link", modifyURL); - prop.putHTML("content_value", Interaction.TripleGet(result.urlstring(), "http://virtual.x/hasvalue")); + prop.putHTML("content_value", Interaction.TripleGet(result.urlstring(), "http://virtual.x/hasvalue", "anonymous")); // END interaction prop.putHTML("content_target", target); diff --git a/source/net/yacy/interaction/Interaction.java b/source/net/yacy/interaction/Interaction.java index 007bf1cc1..11bd984dc 100644 --- a/source/net/yacy/interaction/Interaction.java +++ b/source/net/yacy/interaction/Interaction.java @@ -449,34 +449,26 @@ public static String Contribution(String url, String comment, String from, Strin return ""; } -public static String Triple(String url, String s, String p, String o, String from) { - - final Switchboard sb = Switchboard.getSwitchboard(); - - Resource r = TripleStore.model.getResource(s); - Property pr = TripleStore.model.createProperty(p); - - r.addProperty(pr, o); - - Log.logInfo ("TRIPLESTORE", "PUT "+s+"-"+p+"-"+o); - - return ""; +public static String Triple(String url, String s, String p, String o, String from) { + Resource r = TripleStore.model.getResource(s+"/"+from); + Property pr = TripleStore.model.getProperty(p); + TripleStore.model.removeAll(r, pr, (Resource) null); + r.addProperty(pr, o); + Log.logInfo ("TRIPLESTORE", "PUT "+from+" / "+s+" - "+p+" - "+o); + return ""; } -public static String TripleGet(String s, String p) { - - final Switchboard sb = Switchboard.getSwitchboard(); - - Resource r = TripleStore.model.getResource(s); +public static String TripleGet(String s, String p, String username) { + Resource r = TripleStore.model.getResource(s+"/"+username); Property pr = TripleStore.model.getProperty(p); StmtIterator iter = TripleStore.model.listStatements(r, pr, (Resource) null); - Log.logInfo ("TRIPLESTORE", "GET "+s+" - "+p); - + while (iter.hasNext()) { - - return (iter.nextStatement().getObject().toString()); + String obj = iter.nextStatement().getObject().toString(); + Log.logInfo ("TRIPLESTORE", "GET "+username+" / "+s+" - "+p+" - "+obj); + return (obj); } return ""; @@ -485,9 +477,6 @@ public static String TripleGet(String s, String p) { public static String GetContribution(String url) { - final Switchboard sb = Switchboard.getSwitchboard(); - - // Boolean processlocal = false; // // if (!sb.getConfig("interaction.contribution.accumulationpeer", "").equals("")) {