- updated opensearchdescription text and icon

- removed automatic setting of maxitems during search (can be set now elsewhere)
- updated RSSMessage.java

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8009 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 13 years ago
parent ba41a869a7
commit 94eab08794

File diff suppressed because one or more lines are too long

@ -183,11 +183,6 @@ public class yacysearch {
int itemsPerPage = Math.min((authenticated) ? (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 100 : 5000) : (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 20 : 1000), post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative int itemsPerPage = Math.min((authenticated) ? (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 100 : 5000) : (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 20 : 1000), post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative
int offset = (newsearch) ? 0 : post.getInt("startRecord", post.getInt("offset", 0)); int offset = (newsearch) ? 0 : post.getInt("startRecord", post.getInt("offset", 0));
final int newcount;
if ( authenticated && (newcount = post.getInt("count", 0)) > 0 ) {
sb.setConfig(SwitchboardConstants.SEARCH_ITEMS, newcount);
} // set new default maximumRecords if search with "more options"
boolean global = post.get("resource", "local").equals("global") && sb.peers.sizeConnected() > 0; boolean global = post.get("resource", "local").equals("global") && sb.peers.sizeConnected() > 0;
final boolean indexof = (post != null && post.get("indexof","").equals("on")); final boolean indexof = (post != null && post.get("indexof","").equals("on"));

@ -11,12 +11,12 @@
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program in the file lgpl21.txt * along with this program in the file lgpl21.txt
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
@ -58,158 +58,162 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
lon("geo:long,geo:lon"), lon("geo:long,geo:lon"),
lat("geo:lat"); lat("geo:lat");
//point("gml:pos,georss:point,coordinates"); //point("gml:pos,georss:point,coordinates");
private Set<String> keys; private Set<String> keys;
private Token(String keylist) { private Token(final String keylist) {
String[] k = keylist.split(","); final String[] k = keylist.split(",");
this.keys = new HashSet<String>(); this.keys = new HashSet<String>();
this.keys.addAll(Arrays.asList(k)); this.keys.addAll(Arrays.asList(k));
} }
public String valueFrom(Map<String, String> map, String dflt) { public String valueFrom(final Map<String, String> map, final String dflt) {
String value; String value;
for (String key: this.keys) { for (final String key: this.keys) {
value = map.get(key); value = map.get(key);
if (value != null) return value; if (value != null) return value;
} }
return dflt; return dflt;
} }
public Set<String> keys() { public Set<String> keys() {
return this.keys; return this.keys;
} }
public String toString() {
return this.keys.iterator().next();
}
} }
private static String artificialGuidPrefix = "c0_"; private static String artificialGuidPrefix = "c0_";
public static final RSSMessage POISON = new RSSMessage("", "", ""); public static final RSSMessage POISON = new RSSMessage("", "", "");
public static final HashSet<String> tags = new HashSet<String>(); public static final HashSet<String> tags = new HashSet<String>();
static { static {
for (Token token: Token.values()) { for (final Token token: Token.values()) {
tags.addAll(token.keys()); tags.addAll(token.keys());
} }
} }
private final Map<String, String> map; private final Map<String, String> map;
public RSSMessage(final String title, final String description, final String link) { public RSSMessage(final String title, final String description, final String link) {
this.map = new ConcurrentHashMap<String, String>(); this.map = new ConcurrentHashMap<String, String>();
map.put("title", title); this.map.put("title", title);
map.put("description", description); this.map.put("description", description);
map.put("link", link); this.map.put("link", link);
map.put("pubDate", ISO8601Formatter.FORMATTER.format()); this.map.put("pubDate", ISO8601Formatter.FORMATTER.format());
map.put("guid", artificialGuidPrefix + Integer.toHexString((title + description + link).hashCode())); this.map.put("guid", artificialGuidPrefix + Integer.toHexString((title + description + link).hashCode()));
} }
public RSSMessage() { public RSSMessage() {
this.map = new ConcurrentHashMap<String, String>(); this.map = new ConcurrentHashMap<String, String>();
} }
public void setValue(final String name, final String value) { public void setValue(final String name, final String value) {
map.put(name, value); this.map.put(name, value);
// if possible generate a guid if not existent so far // if possible generate a guid if not existent so far
if ((name.equals("title") || name.equals("description") || name.equals("link")) && if ((name.equals("title") || name.equals("description") || name.equals("link")) &&
(!map.containsKey("guid") || map.get("guid").startsWith(artificialGuidPrefix))) { (!this.map.containsKey("guid") || this.map.get("guid").startsWith(artificialGuidPrefix))) {
map.put("guid", artificialGuidPrefix + Integer.toHexString((getTitle() + getDescription() + getLink()).hashCode())); this.map.put("guid", artificialGuidPrefix + Integer.toHexString((getTitle() + getDescription() + getLink()).hashCode()));
} }
} }
public String getTitle() { public String getTitle() {
return Token.title.valueFrom(this.map, ""); return Token.title.valueFrom(this.map, "");
} }
public String getLink() { public String getLink() {
return Token.link.valueFrom(this.map, ""); return Token.link.valueFrom(this.map, "");
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(final Object o) {
return (o instanceof RSSMessage) && ((RSSMessage) o).getLink().equals(this.getLink()); return (o instanceof RSSMessage) && ((RSSMessage) o).getLink().equals(getLink());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return getLink().hashCode(); return getLink().hashCode();
} }
@Override @Override
public int compareTo(RSSMessage o) { public int compareTo(final RSSMessage o) {
if (!(o instanceof RSSMessage)) return 1; if (!(o instanceof RSSMessage)) return 1;
return this.getLink().compareTo(o.getLink()); return getLink().compareTo(o.getLink());
} }
@Override @Override
public int compare(RSSMessage o1, RSSMessage o2) { public int compare(final RSSMessage o1, final RSSMessage o2) {
return o1.compareTo(o2); return o1.compareTo(o2);
} }
public String getDescription() { public String getDescription() {
return Token.description.valueFrom(this.map, ""); return Token.description.valueFrom(this.map, "");
} }
public String getAuthor() { public String getAuthor() {
return Token.author.valueFrom(this.map, ""); return Token.author.valueFrom(this.map, "");
} }
public String getCopyright() { public String getCopyright() {
return Token.copyright.valueFrom(this.map, ""); return Token.copyright.valueFrom(this.map, "");
} }
public String getCategory() { public String getCategory() {
return Token.category.valueFrom(this.map, ""); return Token.category.valueFrom(this.map, "");
} }
public String[] getSubject() { public String[] getSubject() {
String subject = Token.subject.valueFrom(this.map, ""); final String subject = Token.subject.valueFrom(this.map, "");
if (subject.indexOf(',') >= 0) return subject.split(","); if (subject.indexOf(',') >= 0) return subject.split(",");
if (subject.indexOf(';') >= 0) return subject.split(";"); if (subject.indexOf(';') >= 0) return subject.split(";");
return subject.split(" "); return subject.split(" ");
} }
public String getReferrer() { public String getReferrer() {
return Token.referrer.valueFrom(this.map, ""); return Token.referrer.valueFrom(this.map, "");
} }
public String getLanguage() { public String getLanguage() {
return Token.language.valueFrom(this.map, ""); return Token.language.valueFrom(this.map, "");
} }
public Date getPubDate() { public Date getPubDate() {
String dateString = Token.pubDate.valueFrom(this.map, ""); final String dateString = Token.pubDate.valueFrom(this.map, "");
Date date; Date date;
try { try {
date = ISO8601Formatter.FORMATTER.parse(dateString); date = ISO8601Formatter.FORMATTER.parse(dateString);
} catch (ParseException e) { } catch (final ParseException e) {
try { try {
date = GenericFormatter.SHORT_SECOND_FORMATTER.parse(dateString); date = GenericFormatter.SHORT_SECOND_FORMATTER.parse(dateString);
} catch (ParseException e1) { } catch (final ParseException e1) {
date = HeaderFramework.parseHTTPDate(dateString); date = HeaderFramework.parseHTTPDate(dateString);
} }
} }
return date; return date;
} }
public String getGuid() { public String getGuid() {
return Token.guid.valueFrom(this.map, ""); return Token.guid.valueFrom(this.map, "");
} }
public String getTTL() { public String getTTL() {
return Token.ttl.valueFrom(this.map, ""); return Token.ttl.valueFrom(this.map, "");
} }
public String getDocs() { public String getDocs() {
return Token.docs.valueFrom(this.map, ""); return Token.docs.valueFrom(this.map, "");
} }
public long getSize() { public long getSize() {
String size = Token.size.valueFrom(this.map, "-1"); final String size = Token.size.valueFrom(this.map, "-1");
return (size == null || size.length() == 0) ? -1 : Long.parseLong(size); return (size == null || size.length() == 0) ? -1 : Long.parseLong(size);
} }
public String getFulltext() { public String getFulltext() {
StringBuilder sb = new StringBuilder(300); final StringBuilder sb = new StringBuilder(300);
for (String s: map.values()) sb.append(s).append(' '); for (final String s: this.map.values()) sb.append(s).append(' ');
return sb.toString(); return sb.toString();
} }
@ -220,64 +224,64 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
public float getLat() { public float getLat() {
return Float.parseFloat(Token.lat.valueFrom(this.map, "0.0")); return Float.parseFloat(Token.lat.valueFrom(this.map, "0.0"));
} }
@Override @Override
public String toString() { public String toString() {
return this.map.toString(); return this.map.toString();
} }
public void setAuthor(String author) { public void setAuthor(final String author) {
setValue("author", author); setValue("author", author);
} }
public void setCategory(String category) { public void setCategory(final String category) {
setValue("category", category); setValue("category", category);
} }
public void setCopyright(String copyright) { public void setCopyright(final String copyright) {
setValue("copyright", copyright); setValue("copyright", copyright);
} }
public void setSubject(String[] tags) { public void setSubject(final String[] tags) {
StringBuilder sb = new StringBuilder(tags.length * 10); final StringBuilder sb = new StringBuilder(tags.length * 10);
for (String tag: tags) sb.append(tag).append(','); for (final String tag: tags) sb.append(tag).append(',');
if (sb.length() > 0) sb.setLength(sb.length() - 1); if (sb.length() > 0) sb.setLength(sb.length() - 1);
setValue("subject", sb.toString()); setValue("subject", sb.toString());
} }
public void setDescription(String description) { public void setDescription(final String description) {
setValue("description", description); setValue("description", description);
} }
public void setDocs(String docs) { public void setDocs(final String docs) {
setValue("docs", docs); setValue("docs", docs);
} }
public void setGuid(String guid) { public void setGuid(final String guid) {
setValue("guid", guid); setValue("guid", guid);
} }
public void setLanguage(String language) { public void setLanguage(final String language) {
setValue("language", language); setValue("language", language);
} }
public void setLink(String link) { public void setLink(final String link) {
setValue("link", link); setValue("link", link);
} }
public void setPubDate(Date pubdate) { public void setPubDate(final Date pubdate) {
setValue("pubDate", ISO8601Formatter.FORMATTER.format(pubdate)); setValue("pubDate", ISO8601Formatter.FORMATTER.format(pubdate));
} }
public void setReferrer(String referrer) { public void setReferrer(final String referrer) {
setValue("referrer", referrer); setValue("referrer", referrer);
} }
public void setSize(long size) { public void setSize(final long size) {
setValue("size", Long.toString(size)); setValue("size", Long.toString(size));
} }
public void setTitle(String title) { public void setTitle(final String title) {
setValue("title", title); setValue("title", title);
} }
} }

Loading…
Cancel
Save