Merge branch 'master' of gitorious.org:yacy/rc1

pull/1/head
Michael Christen 14 years ago
commit cc5c00cc0f

@ -32,9 +32,11 @@
<li>
<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;Select a language for the interface:<br />
<fieldset>
<input type="radio" name="language" id="lang_de" value="de" onchange="this.form.submit()" #(langDeutsch)#::checked="checked"#(/langDeutsch)# /><label for="lang_de">Deutsch</label>&nbsp;
<input type="radio" name="language" id="lang_fr" value="fr" onchange="this.form.submit()" #(langFrancais)#::checked="checked"#(/langFrancais)# /><label for="lang_fr">Fran&ccedil;ais</label>&nbsp;
<input type="radio" name="language" value="default" id="lang_en" onchange="this.form.submit()" #(langEnglish)#::checked="checked"#(/langEnglish)# /><label for="lang_en">English</label>
<input type="radio" name="language" value="de" id="lang_de" onchange="this.form.submit()" #(lang_de)#::checked="checked"#(/lang_de)# /><label for="lang_de">Deutsch</label>&nbsp;
<input type="radio" name="language" value="fr" id="lang_fr" onchange="this.form.submit()" #(lang_fr)#::checked="checked"#(/lang_fr)# /><label for="lang_fr">Fran&ccedil;ais</label>&nbsp;
<input type="radio" name="language" value="cn" id="lang_cn" onchange="this.form.submit()" #(lang_cn)#::checked="checked"#(/lang_cn)# /><label for="lang_cn">&#27721;&#35821;/&#28450;&#35486</label>
<input type="radio" name="language" value="ru" id="lang_ru" onchange="this.form.submit()" #(lang_ru)#::checked="checked"#(/lang_ru)# /><label for="lang_ru">Russian</label>
<input type="radio" name="language" value="default" id="lang_en" onchange="this.form.submit()" #(lang_en)#::checked="checked"#(/lang_en)# /><label for="lang_en">English</label>
</fieldset>
</li>
<!-- take care that no other items are changed, but also change the former if no js is enabled -->

@ -263,22 +263,15 @@ public class ConfigBasic {
prop.putHTML("defaultName", sb.peers.mySeed().getName());
prop.putHTML("defaultPort", env.getConfig("port", "8090"));
lang = env.getConfig("locale.language", "default"); // re-assign lang, may have changed
prop.put("lang_de", "0");
prop.put("lang_fr", "0");
prop.put("lang_cn", "0");
prop.put("lang_ru", "0");
prop.put("lang_en", "0");
if ("default".equals(lang)) {
prop.put("langDeutsch", "0");
prop.put("langFrancais", "0");
prop.put("langEnglish", "1");
} else if ("fr".equals(lang)) {
prop.put("langDeutsch", "0");
prop.put("langFrancais", "1");
prop.put("langEnglish", "0");
} else if ("de".equals(lang)) {
prop.put("langDeutsch", "1");
prop.put("langFrancais", "0");
prop.put("langEnglish", "0");
prop.put("lang_en", "1");
} else {
prop.put("langDeutsch", "0");
prop.put("langFrancais", "0");
prop.put("langEnglish", "0");
prop.put("lang_" + lang, "1");
}
return prop;
}

@ -41,12 +41,20 @@ public enum CreativeCommons implements Vocabulary {
// License Properties
permits(new Literal[]{
PermitLiteral.Reproduction,
PermitLiteral.Distribution,
PermitLiteral.DerivativeWorks,
PermitLiteral.Sharing}),
requires,
prohibits,
PermitLiteral.Reproduction,
PermitLiteral.Distribution,
PermitLiteral.DerivativeWorks,
PermitLiteral.Sharing}),
requires(new Literal[]{
RequirementLiteral.Notice,
RequirementLiteral.Attribution,
RequirementLiteral.ShareAlike,
RequirementLiteral.SourceCode,
RequirementLiteral.Copyleft,
RequirementLiteral.LesserCopyleft}),
prohibits(new Literal[]{
ProhibitionLiteral.CommercialUse,
ProhibitionLiteral.HighIncomeNationUse}),
jurisdiction,
legalcode,
deprecatedOn,
@ -58,13 +66,12 @@ public enum CreativeCommons implements Vocabulary {
attributionURL,
useGuidelines;
enum PermitLiteral implements Literal {
Reproduction("Reproduction", null, ".*"),
Distribution("Distribution", null, ".*"),
DerivativeWorks("Derivative Works",null, ".*"),
Sharing("Sharing", null, ".*");
Reproduction("Reproduction", "http://creativecommons.org/ns#Permission", ".*"),
Distribution("Distribution", "http://creativecommons.org/ns#Permission", ".*"),
DerivativeWorks("Derivative Works", "http://creativecommons.org/ns#Permission", ".*"),
Sharing("Sharing", "http://creativecommons.org/ns#Permission", ".*");
String terminal;
MultiProtocolURI subject;
@ -84,22 +91,84 @@ public enum CreativeCommons implements Vocabulary {
}
@Override
public String getTerminal() {
return this.terminal;
}
public String getTerminal() { return this.terminal; }
@Override
public MultiProtocolURI getSubject() { return this.subject; }
@Override
public MultiProtocolURI getSubject() {
return this.subject;
public Pattern getDiscoveryPattern() { return this.discoveryPattern; }
}
enum RequirementLiteral implements Literal {
Notice("Notice", "http://creativecommons.org/ns#Requirement", ".*"),
Attribution("Attribution", "http://creativecommons.org/ns#Requirement", ".*"),
ShareAlike("Share Alike", "http://creativecommons.org/ns#Requirement", ".*"),
SourceCode("Source Code", "http://creativecommons.org/ns#Requirement", ".*"),
Copyleft("Copyleft", "http://creativecommons.org/ns#Requirement", ".*"),
LesserCopyleft("Lesser Copyleft", "http://creativecommons.org/ns#Requirement", ".*");
String terminal;
MultiProtocolURI subject;
Pattern discoveryPattern;
private RequirementLiteral(
String terminal,
String subject,
String discoveryPattern) {
this.terminal = terminal;
try {
this.subject = subject == null ? null : new MultiProtocolURI(subject);
} catch (MalformedURLException e) {
this.subject = null;
}
this.discoveryPattern = Pattern.compile(discoveryPattern == null ? ".*" : discoveryPattern);
}
@Override
public String getTerminal() { return this.terminal; }
@Override
public MultiProtocolURI getSubject() { return this.subject; }
@Override
public Pattern getDiscoveryPattern() {
return this.discoveryPattern;
public Pattern getDiscoveryPattern() { return this.discoveryPattern; }
}
enum ProhibitionLiteral implements Literal {
CommercialUse("Commercial Use", "http://creativecommons.org/ns#Prohibition", ".*"),
HighIncomeNationUse("High Income Nation Use", "http://creativecommons.org/ns#Prohibition", ".*");
String terminal;
MultiProtocolURI subject;
Pattern discoveryPattern;
private ProhibitionLiteral(
String terminal,
String subject,
String discoveryPattern) {
this.terminal = terminal;
try {
this.subject = subject == null ? null : new MultiProtocolURI(subject);
} catch (MalformedURLException e) {
this.subject = null;
}
this.discoveryPattern = Pattern.compile(discoveryPattern == null ? ".*" : discoveryPattern);
}
@Override
public String getTerminal() { return this.terminal; }
@Override
public MultiProtocolURI getSubject() { return this.subject; }
@Override
public Pattern getDiscoveryPattern() { return this.discoveryPattern; }
}
public final static String IDENTIFIER = "http://dublincore.org/documents/2010/10/11/dces/";
public final static String IDENTIFIER = "http://creativecommons.org/ns#";
public final static String PREFIX = "cc";
private final String predicate;

@ -36,7 +36,6 @@ import net.yacy.cora.lod.Vocabulary;
public enum YaCyMetadata implements Vocabulary {
hash, // the url's hash
comp, // components: the url, description, author and tags. As 5th element, an ETag is possible
mod, // last-modified from the httpd
load, // time when the url was loaded
fresh, // time until this url is fresh
@ -56,7 +55,6 @@ public enum YaCyMetadata implements Vocabulary {
/*
"String hash-12, " + // the url's hash
"String comp-360, " + // components: the url, description, author and tags. As 5th element, an ETag is possible
"Cardinal mod-4 {b256}, " + // last-modified from the httpd
"Cardinal load-4 {b256}, " + // time when the url was loaded
"Cardinal fresh-4 {b256}, " + // time until this url is fresh

@ -47,11 +47,19 @@
*/
package net.yacy.upnp;
import java.io.*;
import java.net.*;
import java.util.*;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class can be used to listen for UPNP devices responses when a search message is sent by a control point
@ -73,7 +81,7 @@ public class DiscoveryListener implements Runnable {
private static final int DEFAULT_TIMEOUT = 250;
private Map<String, Set<DiscoveryResultsHandler>> registeredHandlers = new HashMap<String, Set<DiscoveryResultsHandler>>();
private final Map<String, Set<DiscoveryResultsHandler>> registeredHandlers = new HashMap<String, Set<DiscoveryResultsHandler>>();
private final Object REGISTRATION_PROCESS = new Object();
@ -107,12 +115,12 @@ public class DiscoveryListener implements Runnable {
* @throws IOException if some errors occurs during SSDP search response messages listener thread startup
*/
public void registerResultsHandler( DiscoveryResultsHandler resultsHandler, String searchTarget ) throws IOException {
synchronized( REGISTRATION_PROCESS ) {
if ( !inService ) startDevicesListenerThread();
Set<DiscoveryResultsHandler> handlers = registeredHandlers.get( searchTarget );
synchronized( this.REGISTRATION_PROCESS ) {
if ( !this.inService ) startDevicesListenerThread();
Set<DiscoveryResultsHandler> handlers = this.registeredHandlers.get( searchTarget );
if ( handlers == null ) {
handlers = new HashSet<DiscoveryResultsHandler>();
registeredHandlers.put( searchTarget, handlers );
this.registeredHandlers.put( searchTarget, handlers );
}
handlers.add( resultsHandler );
}
@ -124,15 +132,15 @@ public class DiscoveryListener implements Runnable {
* @param searchTarget the search target
*/
public void unRegisterResultsHandler( DiscoveryResultsHandler resultsHandler, String searchTarget ) {
synchronized( REGISTRATION_PROCESS ) {
Set<DiscoveryResultsHandler> handlers = registeredHandlers.get( searchTarget );
synchronized( this.REGISTRATION_PROCESS ) {
Set<DiscoveryResultsHandler> handlers = this.registeredHandlers.get( searchTarget );
if ( handlers != null ) {
handlers.remove( resultsHandler );
if (handlers.isEmpty()) {
registeredHandlers.remove( searchTarget );
this.registeredHandlers.remove( searchTarget );
}
}
if (registeredHandlers.isEmpty()) {
if (this.registeredHandlers.isEmpty()) {
stopDevicesListenerThread();
}
}
@ -140,13 +148,13 @@ public class DiscoveryListener implements Runnable {
private void startDevicesListenerThread() throws IOException {
synchronized( singleton ) {
if ( !inService ) {
if ( !this.inService ) {
this.startMultiCastSocket();
Thread deamon = new Thread( this, "DiscoveryListener daemon" );
deamon.setDaemon( daemon );
deamon.setDaemon( this.daemon );
deamon.start();
while ( !inService ) {
while ( !this.inService ) {
// wait for the thread to be started let's wait a few ms
try {
Thread.sleep( 2 );
@ -160,7 +168,7 @@ public class DiscoveryListener implements Runnable {
private void stopDevicesListenerThread() {
synchronized( singleton ) {
inService = false;
this.inService = false;
}
}
@ -171,38 +179,39 @@ public class DiscoveryListener implements Runnable {
bindPort = Integer.parseInt( port );
}
skt = new java.net.MulticastSocket( null );
skt.bind( new InetSocketAddress( InetAddress.getByName( "0.0.0.0" ), bindPort ) );
skt.setTimeToLive( Discovery.DEFAULT_TTL );
skt.setSoTimeout( DEFAULT_TIMEOUT );
skt.joinGroup( InetAddress.getByName( Discovery.SSDP_IP ) );
this.skt = new java.net.MulticastSocket( null );
this.skt.bind( new InetSocketAddress( InetAddress.getByName( "0.0.0.0" ), bindPort ) );
this.skt.setTimeToLive( Discovery.DEFAULT_TTL );
this.skt.setSoTimeout( DEFAULT_TIMEOUT );
this.skt.joinGroup( InetAddress.getByName( Discovery.SSDP_IP ) );
byte[] buf = new byte[2048];
input = new DatagramPacket( buf, buf.length );
this.input = new DatagramPacket( buf, buf.length );
}
public void run() {
@Override
public void run() {
if ( !Thread.currentThread().getName().equals( "DiscoveryListener daemon" ) ) {
throw new RuntimeException( "No right to call this method" );
}
inService = true;
while ( inService ) {
this.inService = true;
while ( this.inService ) {
try {
listenBroadCast();
} catch ( SocketTimeoutException ex ) {
// ignoring
} catch ( IOException ioEx ) {
log.error( "IO Exception during UPNP DiscoveryListener messages listening thread", ioEx );
log.error( "IO Exception during UPNP DiscoveryListener messages listening thread" );
} catch( Exception ex ) {
log.error( "Fatal Error during UPNP DiscoveryListener messages listening thread, thread will exit", ex );
inService = false;
log.error( "Fatal Error during UPNP DiscoveryListener messages listening thread, thread will exit" );
this.inService = false;
}
}
try {
skt.leaveGroup( InetAddress.getByName( Discovery.SSDP_IP ) );
skt.close();
this.skt.leaveGroup( InetAddress.getByName( Discovery.SSDP_IP ) );
this.skt.close();
} catch ( Exception ex ) {
// ignoring
}
@ -210,9 +219,9 @@ public class DiscoveryListener implements Runnable {
private void listenBroadCast() throws IOException {
skt.receive( input );
InetAddress from = input.getAddress();
String received = new String( input.getData(), input.getOffset(), input.getLength() );
this.skt.receive( this.input );
InetAddress from = this.input.getAddress();
String received = new String( this.input.getData(), this.input.getOffset(), this.input.getLength() );
HttpResponse msg = null;
try {
msg = new HttpResponse( received );
@ -265,11 +274,10 @@ public class DiscoveryListener implements Runnable {
String udn = usn;
int index = udn.indexOf( "::" );
if ( index != -1 ) udn = udn.substring( 0, index );
synchronized( REGISTRATION_PROCESS ) {
Set<DiscoveryResultsHandler> handlers = registeredHandlers.get( st );
synchronized( this.REGISTRATION_PROCESS ) {
Set<DiscoveryResultsHandler> handlers = this.registeredHandlers.get( st );
if ( handlers != null ) {
for ( Iterator<DiscoveryResultsHandler> i = handlers.iterator(); i.hasNext(); ) {
DiscoveryResultsHandler handler = i.next();
for ( DiscoveryResultsHandler handler : handlers ) {
handler.discoveredDevice( usn, udn, st, maxAge, loc, server );
}
}

Loading…
Cancel
Save