X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibraryServer.java;h=0319439c05f012b630bbd422f900232f25a3caa7;hb=95e522ea1a6d23e089e207ea67c1fc0296bf7389;hp=c3933ebb276c65e171546109c59d6daa96df8501;hpb=5db598bc6386aaabe69f2eed55b03625c72c236b;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index c3933eb..0319439 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -2,7 +2,7 @@ package be.nikiroo.fanfix.library; import java.io.IOException; import java.net.URL; -import java.nio.file.AccessDeniedException; +import java.rmi.AccessException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -142,7 +142,8 @@ public class RemoteLibraryServer extends ServerObject { for (Object arg : args) { trace += arg + " "; } - System.out.println(trace); + long now = System.currentTimeMillis(); + System.out.println(StringUtils.fromTime(now) + ": " + trace); Object rep = null; try { @@ -180,9 +181,12 @@ public class RemoteLibraryServer extends ServerObject { String rec = StringUtils.formatNumber(bytesReceived) + "b"; String sent = StringUtils.formatNumber(bytesSent) + "b"; - System.out.println(String.format("%s[>%s]: (%s sent, %s rec) in %d ms", - display(whitelist, rw), commands.get(id), sent, rec, - times.get(id))); + long now = System.currentTimeMillis(); + System.out.println(StringUtils.fromTime(now) + + ": " + + String.format("%s[>%s]: (%s sent, %s rec) in %d ms", + display(whitelist, rw), commands.get(id), sent, rec, + times.get(id))); commands.remove(id); times.remove(id); @@ -262,8 +266,8 @@ public class RemoteLibraryServer extends ServerObject { } } else if ("SAVE_STORY".equals(command)) { if (!rw) { - throw new AccessDeniedException("" + args[0], null, - "Read-Only remote library"); + throw new AccessException("Read-Only remote library: " + + args[0]); } List list = new ArrayList(); @@ -281,8 +285,8 @@ public class RemoteLibraryServer extends ServerObject { return story.getMeta().getLuid(); } else if ("IMPORT".equals(command)) { if (!rw) { - throw new AccessDeniedException("" + args[0], null, - "Read-Only remote library"); + throw new AccessException("Read-Only remote library: " + + args[0]); } Progress pg = createPgForwarder(action); @@ -292,8 +296,8 @@ public class RemoteLibraryServer extends ServerObject { return story.getMeta().getLuid(); } else if ("DELETE_STORY".equals(command)) { if (!rw) { - throw new AccessDeniedException("" + args[0], null, - "Read-Only remote library"); + throw new AccessException("Read-Only remote library: " + + args[0]); } Instance.getLibrary().delete((String) args[0]); @@ -311,8 +315,8 @@ public class RemoteLibraryServer extends ServerObject { } } else if ("SET_COVER".equals(command)) { if (!rw) { - throw new AccessDeniedException("" + args[0], "" + args[1], - "Read-Only remote library"); + throw new AccessException("Read-Only remote library: " + + args[0] + ", " + args[1]); } if ("SOURCE".equals(args[0])) { @@ -324,8 +328,8 @@ public class RemoteLibraryServer extends ServerObject { } } else if ("CHANGE_STA".equals(command)) { if (!rw) { - throw new AccessDeniedException("" + args[0], "" + args[1], - "Read-Only remote library"); + throw new AccessException("Read-Only remote library: " + + args[0] + ", " + args[1]); } Progress pg = createPgForwarder(action); @@ -334,8 +338,8 @@ public class RemoteLibraryServer extends ServerObject { forcePgDoneSent(pg); } else if ("EXIT".equals(command)) { if (!rw) { - throw new AccessDeniedException("EXIT", "", - "Read-Only remote library, cannot close it"); + throw new AccessException( + "Read-Only remote library: EXIT"); } stop(0, false); @@ -347,7 +351,9 @@ public class RemoteLibraryServer extends ServerObject { @Override protected void onError(Exception e) { if (e instanceof SSLException) { - System.out.println("[Client connection refused (bad key)]"); + long now = System.currentTimeMillis(); + System.out.println(StringUtils.fromTime(now) + ": " + + "[Client connection refused (bad key)]"); } else { getTraceHandler().error(e); }