From 518efffdab386d47882aedee35031e66852c2772 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 11 Oct 2013 08:21:34 +0200 Subject: [PATCH] Fix and relax checks. During loading most of the checks fail, effectively preventing loading. --- src/main/java/net/pterodactylus/sone/data/AlbumImpl.java | 4 +--- src/main/java/net/pterodactylus/sone/data/ImageImpl.java | 11 +++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/AlbumImpl.java b/src/main/java/net/pterodactylus/sone/data/AlbumImpl.java index 5422812..f489b0b 100644 --- a/src/main/java/net/pterodactylus/sone/data/AlbumImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/AlbumImpl.java @@ -31,7 +31,6 @@ import java.util.UUID; import com.google.common.base.Function; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.hash.Hasher; @@ -283,7 +282,7 @@ public class AlbumImpl implements Album { @Override public Modifier modify() throws IllegalStateException { - Preconditions.checkState(getSone().isLocal(), "album must belong to a local Sone"); + // TODO: reenable check for local Sones return new Modifier() { private Optional title = absent(); @@ -311,7 +310,6 @@ public class AlbumImpl implements Album { @Override public Album update() throws IllegalStateException { - checkState(!albumImage.isPresent(), "album image must belong to this album"); if (title.isPresent()) { AlbumImpl.this.title = title.get(); } diff --git a/src/main/java/net/pterodactylus/sone/data/ImageImpl.java b/src/main/java/net/pterodactylus/sone/data/ImageImpl.java index 58741c3..c8f7a9b 100644 --- a/src/main/java/net/pterodactylus/sone/data/ImageImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/ImageImpl.java @@ -141,7 +141,7 @@ public class ImageImpl implements Image { } public Modifier modify() throws IllegalStateException { - checkState((sone == null) || sone.isLocal(), "only local images may be modified"); + // TODO: reenable check for local images return new Modifier() { private Optional sone = absent(); @@ -201,12 +201,11 @@ public class ImageImpl implements Image { @Override public Image update() throws IllegalStateException { - checkState(!sone.isPresent() || sone.get().equals(ImageImpl.this.sone), "can not change Sone once set"); + checkState(!sone.isPresent() || (ImageImpl.this.sone == null) || sone.get().equals(ImageImpl.this.sone), "can not change Sone once set"); checkState(!creationTime.isPresent() || (ImageImpl.this.creationTime == 0), "can not change creation time once set"); - checkState(!key.isPresent() || key.get().equals(ImageImpl.this.key), "can not change key once set"); - checkState(!width.isPresent() || width.get().equals(ImageImpl.this.width), "can not change width once set"); - checkState(!height.isPresent() || height.get().equals(ImageImpl.this.height), "can not change height once set"); - + checkState(!key.isPresent() || (ImageImpl.this.key == null) || key.get().equals(ImageImpl.this.key), "can not change key once set"); + checkState(!width.isPresent() || (ImageImpl.this.width == 0) || width.get().equals(ImageImpl.this.width), "can not change width once set"); + checkState(!height.isPresent() || (ImageImpl.this.height == 0) || height.get().equals(ImageImpl.this.height), "can not change height once set"); ImageImpl.this.sone = sone.or(ImageImpl.this.sone); ImageImpl.this.creationTime = creationTime.or(ImageImpl.this.creationTime); ImageImpl.this.key = key.or(ImageImpl.this.key); -- 2.7.4