# nikiroo-utils
+## Version 3.1.5
+
+- Fix Cache with no-parent file
+- Fix Progress (Error <> RuntimeException)
+
## Version 3.1.4
- Fix error handling for tracers in Server
if (name == null || name.isEmpty()) {
// File
File file = new File(url.getFile());
- subdir = new File(file.getParent().replace("..", "__"));
+ if (file.getParent() == null) {
+ subdir = new File("+");
+ } else {
+ subdir = new File(file.getParent().replace("..", "__"));
+ }
subdir = new File(dir, allowedChars(subdir.getPath()));
name = allowedChars(url.getFile());
} else {
* @author niki
*/
public class Progress {
+ /**
+ * This event listener is designed to report progress events from
+ * {@link Progress}.
+ *
+ * @author niki
+ */
public interface ProgressListener extends EventListener {
/**
* A progression event.
* the min to set
*
*
- * @throws Error
+ * @throws RuntimeException
* if min < 0 or if min > max
*/
public void setMin(int min) {
if (min < 0) {
- throw new Error("negative values not supported");
+ throw new RuntimeException("negative values not supported");
}
synchronized (getLock()) {
if (min > max) {
- throw new Error(
+ throw new RuntimeException(
"The minimum progress value must be <= the maximum progress value");
}
* the max to set
*
*
- * @throws Error
+ * @throws RuntimeException
* if max < min
*/
public void setMax(int max) {
* @param max
* the max
*
- * @throws Error
+ * @throws RuntimeException
* if min < 0 or if min > max
*/
public void setMinMax(int min, int max) {
if (min < 0) {
- throw new Error("negative values not supported");
+ throw new RuntimeException("negative values not supported");
}
if (min > max) {
- throw new Error(
+ throw new RuntimeException(
"The minimum progress value must be <= the maximum progress value");
}
* {@link Progress#getMax()} scale) of this child
* {@link Progress} in relation to its parent
*
- * @throws Error
+ * @throws RuntimeException
* if weight exceed {@link Progress#getMax()} or if progress
* already has a parent
*/
public void addProgress(Progress progress, double weight) {
if (weight < min || weight > max) {
- throw new Error(String.format(
+ throw new RuntimeException(String.format(
"Progress object %s cannot have a weight of %f, "
+ "it is outside of its parent (%s) range (%f)",
progress.name, weight, name, max));
}
if (progress.parent != null) {
- throw new Error(String.format(
+ throw new RuntimeException(String.format(
"Progress object %s cannot be added to %s, "
+ "as it already has a parent (%s)", progress.name,
name, progress.parent.name));
if (snap instanceof Map) {
changeMap = (Map<String, String>) snap;
} else {
- throw new Error(
+ throw new RuntimeException(
"Restoring changes in a Bundle must be done on a changes snapshot, "
+ "or NULL to discard current changes");
}
if (file.exists()) {
break;
}
-
+
file = null;
}
onSend(serverVersion, fromServer);
bridge.send(fromServer);
}
+
+ getTraceHandler().trace("=== DONE", 1);
+ getTraceHandler().trace("", 1);
}
@Override
protected void onError(Exception e) {
- getTraceHandler().error(e);
+ ServerBridge.this.onError(e);
}
}.connect();
}
* the client version
*/
protected void onClientContact(Version clientVersion) {
- getTraceHandler().trace("<<< CLIENT " + clientVersion);
+ getTraceHandler().trace(">>> CLIENT " + clientVersion);
}
/**
* the server version
*/
protected void onServerContact(Version serverVersion) {
- getTraceHandler().trace(">>> SERVER " + serverVersion);
+ getTraceHandler().trace("<<< SERVER " + serverVersion);
getTraceHandler().trace("");
}
* the data sent by the client
*/
protected void onRec(Version clientVersion, String data) {
- trace("<<< CLIENT (" + clientVersion + ")", data);
+ trace(">>> CLIENT (" + clientVersion + ")", data);
}
/**
* the data sent by the client
*/
protected void onSend(Version serverVersion, String data) {
- trace(">>> SERVER (" + serverVersion + ")", data);
+ trace("<<< SERVER (" + serverVersion + ")", data);
}
/**
@Override
protected void onError(Exception e) {
- getTraceHandler().error(e);
+ ServerObject.this.onError(e);
}
};
}
@Override
protected void onError(Exception e) {
- getTraceHandler().error(e);
+ ServerString.this.onError(e);
}
};
}
throws Exception {
return null;
}
+
+ @Override
+ protected void onError(Exception e) {
+ }
};
int port = server.getPort();
throws Exception {
return null;
}
+
+ @Override
+ protected void onError(Exception e) {
+ }
};
int port = server.getPort();
ServerBridge br = null;
if (bridge) {
- br = new ServerBridge(0, ssl, "", port, ssl);
+ br = new ServerBridge(0, ssl, "", port, ssl) {
+ @Override
+ protected void onError(Exception e) {
+ }
+ };
port = br.getPort();
br.start();
}
throws Exception {
rec[0] = true;
}
+
+ @Override
+ protected void onError(Exception e) {
+ }
}.connect();
} finally {
server.stop();