import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.pterodactylus.util.logging.Logging;
/**
* {@link Shell} around a {@link Post} that has not yet been retrieved from
*/
public class PostShell extends Post implements Shell<Post> {
+ /** The logger. */
+ private static final Logger logger = Logging.getLogger(PostShell.class);
+
/** The shell creator. */
public static final ShellCreator<Post> creator = new ShellCreator<Post>() {
@Override
public Shell<Post> createShell(String id) {
- return new PostShell().setId(UUID.fromString(id));
+ return new PostShell().setId(id);
}
};
* The ID of the post
* @return This post shell (for method chaining)
*/
- public PostShell setId(UUID id) {
- this.id = id;
+ public PostShell setId(String id) {
+ try {
+ this.id = UUID.fromString(id);
+ } catch (IllegalArgumentException iae1) {
+ logger.log(Level.WARNING, "Invalid ID: “" + id + "”.", iae1);
+ this.id = UUID.randomUUID();
+ }
return this;
}
package net.pterodactylus.sone.data;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.pterodactylus.util.logging.Logging;
/**
* A shell around a {@link Reply} for replies that have not yet been retrieved
*/
public class ReplyShell extends Reply implements Shell<Reply> {
+ /** The logger. */
+ private static final Logger logger = Logging.getLogger(ReplyShell.class);
+
/** The shell creator. */
public static final ShellCreator<Reply> creator = new ShellCreator<Reply>() {
@Override
public Shell<Reply> createShell(String id) {
- return new ReplyShell().setId(UUID.fromString(id));
+ return new ReplyShell().setId(id);
}
};
* The ID of this reply
* @return This reply shell (for method chaining)
*/
- public ReplyShell setId(UUID id) {
- this.id = id;
+ public ReplyShell setId(String id) {
+ try {
+ this.id = UUID.fromString(id);
+ } catch (IllegalArgumentException iae1) {
+ logger.log(Level.WARNING, "Invalid ID: “" + id + "”.", iae1);
+ this.id = UUID.randomUUID();
+ }
return this;
}
import java.util.List;
import java.util.Set;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
/**
*/
public class SoneShell extends Sone implements Shell<Sone> {
+ /** The logger. */
+ private static final Logger logger = Logging.getLogger(SoneShell.class);
+
/** The shell creator. */
public static final ShellCreator<Sone> creator = new ShellCreator<Sone>() {
@Override
public Shell<Sone> createShell(String id) {
- return new SoneShell().setId(UUID.fromString(id));
+ return new SoneShell().setId(id);
}
};
* The ID of the Sone
* @return This Sone shell (for method chaining)
*/
- public SoneShell setId(UUID id) {
- this.id = id;
+ public SoneShell setId(String id) {
+ try {
+ this.id = UUID.fromString(id);
+ } catch (IllegalArgumentException iae1) {
+ logger.log(Level.WARNING, "Invalid ID: “" + id + "”.", iae1);
+ this.id = UUID.randomUUID();
+ }
return this;
}