Hi,

Currently, every Photark component (jcr, security, search) exposes its
functionalities as SOA services, so they can be easily wired together. I
think at high level it's working well. However, at low level it's being very
painful to introduce new features, since practically every implementation is
coded directly in the service interface, making it very hardcoded.

Right now, we can see it happening when we try to add a new kind of remote
album, which requires to change the gallery implementation and add a new
condition block to handle each different type of photo provider. That's why
I'm trying to identify each of these components and define common APIs to
them.

At the same time, I'm trying to introduce a tagging system that should, at
least at low level, replace the album system. Just to clarify, the main
difference between tag and album is that photos are not contained in a tag,
as it's contained in an album, instead, photos are contained directly in the
gallery and they may have many tags. This means the same photo may be at the
same time in the album "travel" and " favorite moments", I mean, it may be
tagged by "travel" and "favorite moments". Using this tagging system at low
level, we can still create an application that uses the old album concept,
the application only needs to limit the number of tags applied to a photo to
1 and say "album" instead of "tag" :)

The interfaces below are only for use at low level. How their functionality
will be exposed is up to the services (high level) API. Please, comments and
suggestions about them are welcome :)

/**
 * <p>
 * This interface should be implemented by every gallery implementation. It
 * provides methods to manipulate images' info and tags.
 * </p>
 *
 * <p>
 * The implementation is responsible to store the information about every
tag
 * and image added to the gallery, and optionally its raw data.
 * </p>
 */
public interface Gallery {

/**
 * Add image to the gallery. Only the information about the image, for raw
 * data, use {...@link #uploadImage(byte[], String)}
 *
 * @return an image object containing the new image ID
 */
Image addImage(Image image) throws PhotarkException;

/**
 * Update an image information.
 */
void updateImage(Image image) throws PhotarkException;

/**
 * Update an image if it was previously aded using
 * {...@link #uploadImage(byte[], String)}
 */
void updateImageData(Image image, byte[] data) throws PhotarkException;

/**
 * Remove an image from the gallery
 */
 void removeImage(String imageID) throws PhotarkException;

/**
 * Upload a raw image data to the gallery. It works as
 * {...@link #addImage(Image)}, but it also stores the raw image data for later
 * use.
 */
Image uploadImage(byte[] data, String name) throws PhotarkException;

/**
 * Add a tag to an image. If the tag does not exist in the gallery it's
 * automatically created.
 */
void addTagToImage(String tagName, String imageID) throws PhotarkException;

/**
 * Remove a tag from an image.
 */
 void removeTagFromImage(String tagName, String imageID)
throws PhotarkException;

/**
 * Update a tag info, adding description and a cover image to it. If the tag
 * doesn't exist yet in the gallery, it automatically added, otherwise its
 * information is just updated.
 */
void updateTag(Tag tag) throws PhotarkException;

/**
 * Remove a tag from the gallery. It's removed from every image its added as
 * well as its information (description and cover image).
 */
void removeTag(String tagName) throws PhotarkException;

 /**
 * Returns all images available in the gallery ordered by its posted date.
 */
List<Image> getImages() throws PhotarkException;

/**
 * Returns all images containing the specified tag ordered by its posted
date.
 */
 List<Image> getImagesByTag(String tagName) throws PhotarkException;

/**
 * Returns all tags available in the gallery.
 */
Set<Tag> getTags() throws PhotarkException;

}


/**
 * This interfaces should be implemented by a gallery that supports search
 * queries.
 *
 * @see Gallery
 */
public interface SearchableGallery extends Gallery {

/**
 * Returns a query containing all images matching the given search query.
 * The returned images are ordered by an arbitrary relevance defined by the
 * gallery implementation.
 */
List<Image> search(String query) throws PhotarkException;

}

/**
 * <p>
 * The implementor of this interface is responsible for register/unregister
 * subscriptions to remote photo providers and synchronize the photos
retrieve
 * from the remove providers with a gallery.
 * </p>
 * <p>
 * The implementation may use {...@link PhotoStreamProvider} interface to
access
 * the photo providers. How {...@link PhotoStreamProvider}s are
 * registered is implementation independent.
 * </p>
 */
public interface SubscriptionManager {

/**
 * Adds a new subscription.
 *
 * @return a {...@link SubscriptionConfig} object containing the new
 *         subscription's ID
 */
SubscriptionConfig addSubscription(SubscriptionConfig subscriptionConfig);

/**
 * Updates a subscription information, like password, user, etc.
 */
void updateSubscription(SubscriptionConfig subscriptionConfig);

 /**
 * Removes a subscription
 */
 void removeSubscription(String subscriptionID);

/**
 * Synchronizes the photos retrieved from the given subscription with the
 * gallery.
 */
void syncSubscription(String subscriptionID);

/**
 * Returns the {...@link Gallery} this {...@link SubscriptionManager} 
synchronizes
 * the photos with.
 */
Gallery getGallery();

}

public interface PhotoStreamProvider {

    String getProviderType();

    List<Image> getImages() throws PhotarkException;

}

Reply via email to