Skip to content

Commit

Permalink
- simplified code (removed exception handling where not necessary)
Browse files Browse the repository at this point in the history
- added confirmation dialog for shutdown and restart

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3962 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jul 13, 2007
1 parent a4e8ad9 commit 7c5c814
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 29 deletions.
5 changes: 1 addition & 4 deletions htroot/DetailedSearch.java
Expand Up @@ -47,7 +47,6 @@
// javac -classpath .:../classes index.java
// if the shell's current path is HTROOT

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
Expand Down Expand Up @@ -266,9 +265,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("num-results_globalresults", results.getGlobalresults());
for(int i=0;i<results.numResults();i++){
plasmaSearchResults.searchResult result=results.getResult(i);
try {
prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.getUrl()) == null) ? 1 : 0);
} catch (IOException e) {}
prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.getUrl()) == null) ? 1 : 0);
prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + results.getFormerSearch() + "&Enter=Search&count=" + results.getQuery().wantedResults + "&order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&resource=local&time=3&deleteref=" + result.getUrlhash() + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_authorized_recommend_recommendlink", "/yacysearch.html?search=" + results.getFormerSearch() + "&Enter=Search&count=" + results.getQuery().wantedResults + "&order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&resource=local&time=3&recommendref=" + result.getUrlhash() + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_authorized_urlhash", result.getUrlhash());
Expand Down
9 changes: 2 additions & 7 deletions htroot/Supporter.java
Expand Up @@ -132,13 +132,8 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
description = row.getColString(2,"UTF-8");
if ((url == null) || (title == null) || (description == null)) continue;
refid = row.getColString(3, null);
voted = false;
try {
voted = (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||
(yacyCore.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);
} catch (IOException e) {
e.printStackTrace();
}
voted = (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||
(yacyCore.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);
prop.put("supporter_results_" + i + "_authorized", (authenticated) ? 1 : 0);
prop.put("supporter_results_" + i + "_authorized_recommend", (voted) ? 0 : 1);

Expand Down
9 changes: 2 additions & 7 deletions htroot/Surftips.java
Expand Up @@ -140,13 +140,8 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
description = row.getColString(2,"UTF-8");
if ((url == null) || (title == null) || (description == null)) continue;
refid = row.getColString(3, null);
voted = false;
try { // performance problem if published news is too full
voted = (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||
(yacyCore.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);
} catch (IOException e) {
e.printStackTrace();
}
voted = (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||
(yacyCore.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);
prop.put("surftips_results_" + i + "_authorized", (authenticated) ? 1 : 0);
prop.put("surftips_results_" + i + "_authorized_recommend", (voted) ? 0 : 1);

Expand Down
4 changes: 2 additions & 2 deletions htroot/env/templates/header.template
Expand Up @@ -47,8 +47,8 @@
<h3>Peer Control</h3>
<ul class="menu">
<li><a href="/Status.html" accesskey="t" class="MenuItemLink">Admin Console</a></li>
<li><a href="/Steering.html?restart=" class="MenuItemLink lock">Re-Start</a></li>
<li><a href="/Steering.html?shutdown=" class="MenuItemLink lock">Shutdown</a></li>
<li><a href="/Steering.html?restart=" class="MenuItemLink lock" onclick="return confirm('Confirm Restart')">Re-Start</a></li>
<li><a href="/Steering.html?shutdown=" class="MenuItemLink lock" onclick="return confirm('Confirm Shutdown')">Shutdown</a></li>
</ul>
</li>
<li class="menugroup" id="menugroupTheProjekt">
Expand Down
4 changes: 1 addition & 3 deletions htroot/yacysearch.java
Expand Up @@ -313,9 +313,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("num-results_globalresults", results.getGlobalresults());
for(int i=0;i<results.numResults();i++){
plasmaSearchResults.searchResult result=results.getResult(i);
try {
prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.getUrl()) == null) ? 1 : 0);
} catch (IOException e) {}
prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.getUrl()) == null) ? 1 : 0);
//prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + results.getFormerSearch() + "&amp;Enter=Search&amp;count=" + results.getQuery().wantedResults + "&amp;order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&amp;resource=local&amp;time=3&amp;deleteref=" + result.getUrlhash() + "&amp;urlmaskfilter=.*");
//prop.put("type_results_" + i + "_authorized_recommend_recommendlink", "/yacysearch.html?search=" + results.getFormerSearch() + "&amp;Enter=Search&amp;count=" + results.getQuery().wantedResults + "&amp;order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&amp;resource=local&amp;time=3&amp;recommendref=" + result.getUrlhash() + "&amp;urlmaskfilter=.*");
prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + results.getFormerSearch() + "&Enter=Search&count=" + results.getQuery().wantedResults + "&order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&resource=local&time=3&deleteref=" + result.getUrlhash() + "&urlmaskfilter=.*");
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/plasma/plasmaSwitchboardQueue.java
Expand Up @@ -124,7 +124,7 @@ public synchronized Entry pop() throws IOException {
return new Entry(b);
}

public synchronized Entry remove(String urlHash) throws IOException {
public synchronized Entry remove(String urlHash) {
Iterator i = sbQueueStack.stackIterator(true);
kelondroRow.Entry rowentry;
Entry entry;
Expand Down
6 changes: 3 additions & 3 deletions source/de/anomic/yacy/yacyNewsPool.java
Expand Up @@ -403,7 +403,7 @@ private boolean automaticProcessP(yacyNewsRecord record) {
return false;
}

public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException {
public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) {
yacyNewsQueue queue = switchQueue(dbKey);
yacyNewsRecord record;
String s;
Expand All @@ -418,7 +418,7 @@ record = (yacyNewsRecord) i.next();
return null;
}

public synchronized yacyNewsRecord getByOriginator(int dbKey, String category, String originatorHash) throws IOException {
public synchronized yacyNewsRecord getByOriginator(int dbKey, String category, String originatorHash) {
yacyNewsQueue queue = switchQueue(dbKey);
yacyNewsRecord record;
Iterator i = queue.records(true);
Expand All @@ -433,7 +433,7 @@ record = (yacyNewsRecord) i.next();
return null;
}

public synchronized yacyNewsRecord getByID(int dbKey, String id) throws IOException {
public synchronized yacyNewsRecord getByID(int dbKey, String id) {
switch (dbKey) {
case INCOMING_DB: return incomingNews.get(id);
case PROCESSED_DB: return processedNews.get(id);
Expand Down
4 changes: 2 additions & 2 deletions source/de/anomic/yacy/yacyNewsQueue.java
Expand Up @@ -120,7 +120,7 @@ public synchronized yacyNewsRecord topInc() throws IOException {
return entry;
}

public synchronized yacyNewsRecord get(String id) throws IOException {
public synchronized yacyNewsRecord get(String id) {
yacyNewsRecord record;
Iterator i = records(true);
while (i.hasNext()) {
Expand All @@ -130,7 +130,7 @@ record = (yacyNewsRecord) i.next();
return null;
}

public synchronized yacyNewsRecord remove(String id) throws IOException {
public synchronized yacyNewsRecord remove(String id) {
yacyNewsRecord record;
Iterator i = records(true);
while (i.hasNext()) {
Expand Down

0 comments on commit 7c5c814

Please sign in to comment.