|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import de.anomic.data.bookmarksDB;
|
|
|
|
import de.anomic.data.listManager;
|
|
|
|
import de.anomic.data.userDB;
|
|
|
|
import de.anomic.http.httpRequestHeader;
|
|
|
|
import de.anomic.plasma.plasmaSwitchboard;
|
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
import de.anomic.yacy.yacyNewsPool;
|
|
|
|
import de.anomic.yacy.yacyNewsRecord;
|
|
|
|
|
|
|
|
|
|
|
|
public class add_p {
|
|
|
|
|
|
|
|
private static final serverObjects prop = new serverObjects();
|
|
|
|
private static plasmaSwitchboard sb = null;
|
|
|
|
private static userDB.Entry user = null;
|
|
|
|
private static boolean isAdmin = false;
|
|
|
|
|
|
|
|
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
|
|
|
|
|
|
|
|
sb = (plasmaSwitchboard) env;
|
|
|
|
isAdmin=sb.verifyAuthentication(header, true);
|
|
|
|
user = sb.userDB.getUser(header);
|
|
|
|
|
|
|
|
// set user name
|
|
|
|
String username="";
|
|
|
|
if(user != null) username=user.getUserName();
|
|
|
|
else if(isAdmin) username="admin";
|
|
|
|
|
|
|
|
if(post!= null){
|
|
|
|
if(!isAdmin){
|
|
|
|
// force authentication if desired
|
|
|
|
if(post.containsKey("login")){
|
|
|
|
prop.put("AUTHENTICATE","admin log-in");
|
|
|
|
}
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
final String url=post.get("url","");
|
|
|
|
final String title=post.get("title",url);
|
|
|
|
final String description=post.get("description","");
|
|
|
|
String tagsString = post.get("tags","");
|
|
|
|
String pathString = post.get("path","/unsorted");
|
|
|
|
tagsString=tagsString+","+pathString;
|
|
|
|
final Set<String> tags=listManager.string2set(bookmarksDB.cleanTagsString(tagsString));
|
|
|
|
final bookmarksDB.Bookmark bookmark = sb.bookmarksDB.createBookmark(url, username);
|
|
|
|
if(bookmark != null){
|
|
|
|
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);
|
|
|
|
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);
|
|
|
|
if(user!=null){
|
|
|
|
bookmark.setOwner(user.getUserName());
|
|
|
|
}
|
|
|
|
if((post.get("public")).equals("public")){
|
|
|
|
bookmark.setPublic(true);
|
|
|
|
publishNews(url, title, description, tagsString);
|
|
|
|
}else{
|
|
|
|
bookmark.setPublic(false);
|
|
|
|
}
|
|
|
|
if(post.containsKey("feed") && (post.get("feed")).equals("feed")){
|
|
|
|
bookmark.setFeed(true);
|
|
|
|
}else{
|
|
|
|
bookmark.setFeed(false);
|
|
|
|
}
|
|
|
|
bookmark.setTags(tags, true);
|
|
|
|
sb.bookmarksDB.saveBookmark(bookmark);
|
|
|
|
prop.put("result", "1");
|
|
|
|
} else {
|
|
|
|
// ERROR
|
|
|
|
prop.put("result", "0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
private static void publishNews(final String url, final String title, final String description, final String tagsString) {
|
|
|
|
// create a news message
|
|
|
|
final HashMap<String, String> map = new HashMap<String, String>();
|
|
|
|
map.put("url", url.replace(',', '|'));
|
|
|
|
map.put("title", title.replace(',', ' '));
|
|
|
|
map.put("description", description.replace(',', ' '));
|
|
|
|
map.put("tags", tagsString.replace(',', ' '));
|
replaced old DHT transmission method with new method. Many things have changed! some of them:
- after a index selection is made, the index is splitted into its vertical components
- from differrent index selctions the splitted components can be accumulated before they are placed into the transmission queue
- each splitted chunk gets its own transmission thread
- multiple transmission threads are started concurrently
- the process can be monitored with the blocking queue servlet
To implement that, a new package de.anomic.yacy.dht was created. Some old files have been removed.
The new index distribution model using a vertical DHT was implemented. An abstraction of this model
is implemented in the new dht package as interface. The freeworld network has now a configuration
of two vertial partitions; sixteen partitions are planned and will be configured if the process is bug-free.
This modification has three main targets:
- enhance the DHT transmission speed
- with a vertical DHT, a search will speed up. With two partitions, two times. With sixteen, sixteen times.
- the vertical DHT will apply a semi-dht for URLs, and peers will receive a fraction of the overall URLs they received before.
with two partitions, the fractions will be halve. With sixteen partitions, a 1/16 of the previous number of URLs.
BE CAREFULL, THIS IS A MAJOR CODE CHANGE, POSSIBLY FULL OF BUGS AND HARMFUL THINGS.
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5586 6c8d7289-2bf4-0310-a012-ef5d649a1542
16 years ago
|
|
|
sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));
|
|
|
|
}
|
|
|
|
}
|