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 System.out.println("Entry " + path + " was clicked");
69 PageParameters pars = new PageParameters();
70 pars.put("path", path);
71 setResponsePage(HomePage.class, pars);
78 * Constructor that is invoked when page is invoked without a session.
80 * @param parameters Page parameters
82 public HomePage(final PageParameters parameters) throws Exception {
85 path = parameters.getString("path", "/");
86 if (!path.startsWith("/")) {
87 info("Invalid album '" + path + "', showing root album instead");
91 System.out.println("Currently logged in user: " + user);
93 List<String> usernames = userAdmin.getUsers();
94 System.out.println("All user names: " + usernames);
96 usernames = userAdmin.getUsers("public");
97 System.out.println("Users in group public: " + usernames);
99 System.out.println("Entries: " + album.size());
100 for (int i = 0; i < album.size(); i++) {
101 PhotoEntry entry = album.getEntry(i);
102 System.out.println("Entry " + i + " " + entry.getId() + " " + entry.getPath());
105 System.out.println("Authorized Entries: " + authorized.size());
106 for (int i = 0; i < authorized.size(); i++) {
107 PhotoEntry entry = authorized.getEntry(i);
108 System.out.println("Entry " + i + " " + entry.getId() + " " + entry.getPath());
111 PhotoEntry current = authorized.getEntry(path);
113 if (current instanceof Photo) {
114 throw new RuntimeException("Photo entry viewing not yet implemented");
117 Album album = (Album) current;
119 add(new AlbumPanel("content", parameters));