2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.photos.wicket;
18 import java.util.List;
19 import java.util.logging.Logger;
20 import javax.inject.Inject;
22 import org.apache.wicket.PageParameters;
23 import org.apache.wicket.markup.html.link.Link;
24 import org.wamblee.photos.model.Album;
25 import org.wamblee.photos.model.Photo;
26 import org.wamblee.photos.model.PhotoEntry;
27 import org.wamblee.photos.model.plumbing.AllPhotos;
28 import org.wamblee.photos.model.plumbing.AuthorizedPhotos;
29 import org.wamblee.security.authentication.User;
30 import org.wamblee.security.authentication.UserAdministration;
35 public class HomePage extends BasePage {
37 private static final Logger LOGGER = Logger.getLogger(HomePage.class.getName());
39 private static final long serialVersionUID = 1L;
42 private transient User user;
45 private transient UserAdministration userAdmin;
47 // TODO the state should be stored as a path.
51 private transient Album album;
55 private transient Album authorized;
57 private class SerializableEntryLink extends Link {
61 public SerializableEntryLink(String aId, String aPath) {
67 public void onClick() {
68 PageParameters pars = new PageParameters();
69 pars.put("path", path);
70 setResponsePage(HomePage.class, pars);
77 * Constructor that is invoked when page is invoked without a session.
79 * @param parameters Page parameters
81 public HomePage(final PageParameters parameters) throws Exception {
84 path = parameters.getString("path", "/");
85 if (!path.startsWith("/")) {
86 info("Invalid album '" + path + "', showing root album instead");
90 System.out.println("Currently logged in user: " + user);
92 List<String> usernames = userAdmin.getUsers();
93 System.out.println("All user names: " + usernames);
95 usernames = userAdmin.getUsers("public");
96 System.out.println("Users in group public: " + usernames);
98 System.out.println("Entries: " + album.size());
99 for (int i = 0; i < album.size(); i++) {
100 PhotoEntry entry = album.getEntry(i);
101 System.out.println("Entry " + i + " " + entry.getId() + " " + entry.getPath());
104 System.out.println("Authorized Entries: " + authorized.size());
105 for (int i = 0; i < authorized.size(); i++) {
106 PhotoEntry entry = authorized.getEntry(i);
107 System.out.println("Entry " + i + " " + entry.getId() + " " + entry.getPath());
110 PhotoEntry current = authorized.getEntry(path);
112 if (current instanceof Photo) {
113 add(new PhotoPanel("content", parameters));
115 add(new AlbumPanel("content", parameters));