import net.pterodactylus.sone.data.Profile.Field;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.data.TemporaryImage;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.IdentityListener;
import net.pterodactylus.sone.freenet.wot.IdentityManager;
/** All known images. */
private Map<String, Image> images = new HashMap<String, Image>();
+ /** All temporary images. */
+ private Map<String, TemporaryImage> temporaryImages = new HashMap<String, TemporaryImage>();
+
/**
* Creates a new core.
*
}
}
+ /**
+ * Returns the temporary image with the given ID.
+ *
+ * @param imageId
+ * The ID of the temporary image
+ * @return The temporary image, or {@code null} if there is no temporary
+ * image with the given ID
+ */
+ public TemporaryImage getTemporaryImage(String imageId) {
+ synchronized (temporaryImages) {
+ return temporaryImages.get(imageId);
+ }
+ }
+
//
// ACTIONS
//
}
/* load albums. */
- Map<String, Album> albums = new HashMap<String, Album>();
List<Album> topLevelAlbums = new ArrayList<Album>();
while (true) {
String albumPrefix = sonePrefix + "/Albums/" + albums.size();
if (albumId == null) {
break;
}
- String albumName = configuration.getStringValue(albumPrefix + "/Name").getValue(null);
+ String albumTitle = configuration.getStringValue(albumPrefix + "/Title").getValue(null);
String albumDescription = configuration.getStringValue(albumPrefix + "/Description").getValue(null);
String albumParentId = configuration.getStringValue(albumPrefix + "/Parent").getValue(null);
- if ((albumName == null) || (albumDescription == null)) {
+ if ((albumTitle == null) || (albumDescription == null)) {
logger.log(Level.WARNING, "Invalid album found, aborting load!");
return;
}
- Album album = new Album(albumId).setSone(sone).setName(albumName).setDescription(albumDescription);
- albums.put(albumId, album);
+ Album album = getAlbum(albumId).setSone(sone).setTitle(albumTitle).setDescription(albumDescription);
if (albumParentId != null) {
- Album parentAlbum = albums.get(albumParentId);
+ Album parentAlbum = getAlbum(albumParentId, false);
if (parentAlbum == null) {
logger.log(Level.WARNING, "Invalid parent album ID: " + albumParentId);
return;
for (Album album : albums) {
String albumPrefix = sonePrefix + "/Albums/" + albumCounter++;
configuration.getStringValue(albumPrefix + "/ID").setValue(album.getId());
- configuration.getStringValue(albumPrefix + "/Name").setValue(album.getName());
+ configuration.getStringValue(albumPrefix + "/Title").setValue(album.getTitle());
configuration.getStringValue(albumPrefix + "/Description").setValue(album.getDescription());
configuration.getStringValue(albumPrefix + "/Parent").setValue(album.getParent() == null ? null : album.getParent().getId());
}
}
/**
+ * Creates a new temporary image.
+ *
+ * @param mimeType
+ * The MIME type of the temporary image
+ * @param imageData
+ * The encoded data of the image
+ * @return The temporary image
+ */
+ public TemporaryImage createTemporaryImage(String mimeType, byte[] imageData) {
+ TemporaryImage temporaryImage = new TemporaryImage();
+ temporaryImage.setMimeType(mimeType).setImageData(imageData);
+ synchronized (temporaryImages) {
+ temporaryImages.put(temporaryImage.getId(), temporaryImage);
+ }
+ return temporaryImage;
+ }
+
+ /**
+ * Deletes the given temporary image.
+ *
+ * @param temporaryImage
+ * The temporary image to delete
+ */
+ public void deteleTemporaryImage(TemporaryImage temporaryImage) {
+ Validation.begin().isNotNull("Temporary Image", temporaryImage).check();
+ deleteTemporaryImage(temporaryImage.getId());
+ }
+
+ /**
+ * Deletes the temporary image with the given ID.
+ *
+ * @param imageId
+ * The ID of the temporary image to delete
+ */
+ public void deleteTemporaryImage(String imageId) {
+ Validation.begin().isNotNull("Temporary Image ID", imageId).check();
+ synchronized (temporaryImages) {
+ temporaryImages.remove(imageId);
+ }
+ }
+
+ /**
* Starts the core.
*/
public void start() {