import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Logger;
-import org.apache.log4j.Logger;
import org.wamblee.cache.Cache;
import org.wamblee.cache.CachedObject;
import org.wamblee.photos.model.Album;
*/
public class AuthorizedAlbum extends AuthorizedPhotoEntry implements Album {
- private static final Logger LOGGER = Logger
- .getLogger(AuthorizedAlbum.class);
+ private static final Logger LOGGER = Logger.getLogger(AuthorizedAlbum.class
+ .getName());
private AuthorizationService _authorizer;
* Album to decorate.
*/
public AuthorizedAlbum(Album aAlbum, AuthorizationService aService,
- Cache aCache, String aSessionId) {
+ Cache aCache, String aSessionId) {
super(aAlbum);
_authorizer = aService;
_authorizedEntries = new CachedObject<String, ArrayList<PhotoEntry>>(
- aCache, aSessionId + "/" + aAlbum.getPath(),
- new CachedObject.Computation<String, ArrayList<PhotoEntry>>() {
- public ArrayList<PhotoEntry> getObject(String aObjectKey) {
- return AuthorizedAlbum.this.compute();
- }
- });
+ aCache, aSessionId + "/" + aAlbum.getPath(),
+ new CachedObject.Computation<String, ArrayList<PhotoEntry>>() {
+ public ArrayList<PhotoEntry> getObject(String aObjectKey) {
+ return AuthorizedAlbum.this.compute();
+ }
+ });
_sessionId = aSessionId;
}
return (T) new AuthorizedPhoto((Photo) aEntry);
} else if (aEntry instanceof Album) {
return (T) new AuthorizedAlbum((Album) aEntry, _authorizer,
- _authorizedEntries.getCache(), _sessionId);
+ _authorizedEntries.getCache(), _sessionId);
} else {
throw new IllegalArgumentException(
- "Entry is neither a photo nor an album: " + aEntry);
+ "Entry is neither a photo nor an album: " + aEntry);
}
}
return entry;
} else {
if (!(entry instanceof Album)) {
- throw new IllegalArgumentException(getPath() + " "
- + aPath);
+ throw new IllegalArgumentException(getPath() + " " +
+ aPath);
}
return ((Album) entry).getEntry(remainder);
}
public void removeEntry(String aId) throws IOException {
// Check whether deletion is allowed.
PhotoEntry entry = _authorizer.check(decorated().getEntry("/" + aId),
- new DeleteOperation());
+ new DeleteOperation());
_authorizedEntries.invalidate();
decorated().removeEntry(aId);
}
public Photo findPhotoBefore(String aId) {
Photo entry = decorated().findPhotoBefore(aId);
- while (entry != null
- && !_authorizer.isAllowed(entry, new AllOperation())) {
+ while (entry != null &&
+ !_authorizer.isAllowed(entry, new AllOperation())) {
entry = decorated().findPhotoBefore(entry.getId());
}
return decorate(entry);
public Photo findPhotoAfter(String aId) {
Photo entry = decorated().findPhotoAfter(aId);
- while (entry != null
- && !_authorizer.isAllowed(entry, new AllOperation())) {
+ while (entry != null &&
+ !_authorizer.isAllowed(entry, new AllOperation())) {
entry = decorated().findPhotoAfter(entry.getId());
}
return decorate(entry);