/* * Copyright 2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wamblee.photos.tapestry; import org.apache.tapestry.engine.IPropertySource; import org.apache.tapestry.request.RequestContext; import org.wamblee.general.BeanKernel; import org.wamblee.photos.model.Album; import org.wamblee.photos.model.Photo; import org.wamblee.photos.model.PhotoEntry; /** * Global object for the photos application representing the photo album. * */ public class PhotoAlbum { /** * Root album. */ private Album _root; // TODO remove this constructor, /** * Constructs the global object. * @param aContext Request context. * @param aProperties Configuration properties. */ public PhotoAlbum(RequestContext aContext, IPropertySource aProperties) { _root = BeanKernel.getBeanFactory().find(Album.class); } /** * Constructs the photo album. * @param aRoot Root album. */ public PhotoAlbum(Album aRoot) { _root = aRoot; } /** * Gets the root album. * @return Root album. */ private synchronized Album getRoot() { return _root; } /** * Gets the album at a specific path. * @param relativePath Relative path. * @return Album. */ public Album getAlbum(String relativePath) { return (Album) getEntry(relativePath); } /** * Gets the photo at the specific path. * @param relativePath Relative path. * @return Photo. */ public Photo getPhoto(String relativePath) { return (Photo) getEntry(relativePath); } /** * Gets the entry at the given relative path. * @param relativePath Relative path. * @return Entry. */ public PhotoEntry getEntry(String relativePath) { return getRoot().getEntry(relativePath); } }