Some cleanup work, prepared another tab for /ccm/admin which will display several informations about a CCM installation

git-svn-id: https://svn.libreccm.org/ccm/trunk@2221 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-06-19 17:03:42 +00:00
parent 67c7b90ded
commit ecf1f407a6
5 changed files with 242 additions and 218 deletions

View File

@ -67,6 +67,8 @@ interface AdminConstants {
(new GlobalizedMessage("ui.admin.tab.applications.title",
BUNDLE_NAME));
Label INFO_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.info.title", BUNDLE_NAME));
GlobalizedMessage USER_NAVBAR_TITLE =
new GlobalizedMessage("ui.admin.tab.user.navbartitle",
BUNDLE_NAME);

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2013 Jens Pelzetter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.ui.admin;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Label;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class AdminInfoTab extends BoxPanel {
public AdminInfoTab() {
super(BoxPanel.VERTICAL);
final Label placeholder = new Label(GlobalizationUtil.globalize("ui.admin.infotab.placeholder"));
add(placeholder);
}
}

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.ui.admin;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageFactory;
import com.arsdigita.bebop.TabbedPane;
@ -29,24 +28,19 @@ import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.permissions.PermissionDescriptor;
import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.templating.PresentationManager;
import com.arsdigita.templating.Templating;
import com.arsdigita.util.Assert;
import com.arsdigita.web.Application;
import com.arsdigita.web.BaseApplicationServlet;
import com.arsdigita.web.LoginSignal;
import com.arsdigita.xml.Document;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/**
* Web Developer Support Application Servlet class, central entry point to create and process the applications UI.
*
@ -55,21 +49,21 @@ import org.apache.log4j.Logger;
*
* @see com.arsdigita.bebop.page.BebopApplicationServlet}
*
* @author Jens Pelzetter
* @author pb
*/
public class AdminServlet extends BaseApplicationServlet
implements AdminConstants {
public class AdminServlet extends BaseApplicationServlet implements AdminConstants {
private static final long serialVersionUID = -3912367600768871630L;
/**
* Logger instance for debugging
*/
private static final Logger s_log = Logger.getLogger(
AdminServlet.class.getName());
//private static final Logger LOGGER = Logger.getLogger(AdminServlet.class.getName());
/**
* URL (pathinfo) -> Page object mapping. Based on it (and the http request url) the doService method to selects a
* page to display
*/
private final Map m_pages = new HashMap();
private final Map<String, Page> pages = new HashMap<String, Page>();
/**
* User extension point, overwrite this method to setup a URL - page mapping
@ -78,7 +72,6 @@ public class AdminServlet extends BaseApplicationServlet
*/
@Override
public void doInit() throws ServletException {
addPage("/", buildAdminIndexPage()); // index page at address ~/ds
// addPage("/index.jsp", buildIndexPage()); // index page at address ~/ds
@ -87,23 +80,24 @@ public class AdminServlet extends BaseApplicationServlet
/**
* Central service method, checks for required permission, determines the requested page and passes the page object
* to PresentationManager.
*
* @param sreq
* @param sresp
* @param app
* @throws ServletException
* @throws IOException
*/
public final void doService(HttpServletRequest sreq,
HttpServletResponse sresp,
Application app)
throws ServletException, IOException {
public final void doService(final HttpServletRequest sreq,
final HttpServletResponse sresp,
final Application app) throws ServletException, IOException {
// /////// Some preparational steps ///////////////
/* Determine access privilege: only logged in users may access DS */
Party party = Kernel.getContext().getParty();
final Party party = Kernel.getContext().getParty();
if (party == null) {
throw new LoginSignal(sreq);
}
/* Determine access privilege: Admin privileges must be granted */
PermissionDescriptor admin = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, party);
final PermissionDescriptor admin = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, party);
if (!PermissionService.checkPermission(admin)) {
throw new AccessDeniedException("User is not an administrator");
}
@ -112,7 +106,6 @@ public class AdminServlet extends BaseApplicationServlet
// /////// Everything OK here - DO IT ///////////////
String pathInfo = sreq.getPathInfo();
Assert.exists(pathInfo, "String pathInfo");
if (pathInfo.length() > 1 && pathInfo.endsWith("/")) {
@ -124,21 +117,13 @@ public class AdminServlet extends BaseApplicationServlet
pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
}
final Page page = (Page) m_pages.get(pathInfo);
if (page != null) {
final Document doc = page.buildDocument(sreq, sresp);
PresentationManager pm = Templating.getPresentationManager();
pm.servePage(doc, sreq, sresp);
} else {
final Page page = pages.get(pathInfo);
if (page == null) {
sresp.sendError(404, "No such page for path " + pathInfo);
} else {
final Document doc = page.buildDocument(sreq, sresp);
Templating.getPresentationManager().servePage(doc, sreq, sresp);
}
}
/**
@ -148,15 +133,14 @@ public class AdminServlet extends BaseApplicationServlet
* @param page Page object to display
*/
private void addPage(final String pathInfo, final Page page) {
Assert.exists(pathInfo, String.class);
Assert.exists(page, Page.class);
// Current Implementation requires pathInfo to start with a leading '/'
// SUN Servlet API specifies: "PathInfo *may be empty* or will start
// with a '/' character."
Assert.isTrue(pathInfo.startsWith("/"), "path starts not with '/'");
Assert.isTrue(pathInfo.charAt(0) == '/', "path starts not with '/'");
m_pages.put(pathInfo, page);
pages.put(pathInfo, page);
}
/**
@ -164,60 +148,52 @@ public class AdminServlet extends BaseApplicationServlet
*/
private Page buildAdminIndexPage() {
Page p = PageFactory.buildPage("admin", PAGE_TITLE_LABEL);
p.addGlobalStateParam(USER_ID_PARAM);
p.addGlobalStateParam(GROUP_ID_PARAM);
p.addGlobalStateParam(APPLICATIONS_ID_PARAM);
/* Create User split panel. */
AdminSplitPanel userSplitPanel =
new AdminSplitPanel(USER_NAVBAR_TITLE);
UserBrowsePane browsePane = new UserBrowsePane();
userSplitPanel.addTab(USER_TAB_SUMMARY,
new UserSummaryPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_BROWSE,
browsePane);
userSplitPanel.addTab(USER_TAB_SEARCH,
new UserSearchPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_CREATE_USER,
new CreateUserPane(userSplitPanel));
final Page page = PageFactory.buildPage("admin", PAGE_TITLE_LABEL);
page.addGlobalStateParam(USER_ID_PARAM);
page.addGlobalStateParam(GROUP_ID_PARAM);
page.addGlobalStateParam(APPLICATIONS_ID_PARAM);
/*
* Create group administration panel
* Create User split panel.
* Note: Will change soon.
*/
GroupAdministrationTab groupAdministrationTab =
new GroupAdministrationTab();
final AdminSplitPanel userSplitPanel = new AdminSplitPanel(USER_NAVBAR_TITLE);
final UserBrowsePane browsePane = new UserBrowsePane();
userSplitPanel.addTab(USER_TAB_SUMMARY, new UserSummaryPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_BROWSE, browsePane);
userSplitPanel.addTab(USER_TAB_SEARCH, new UserSearchPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_CREATE_USER, new CreateUserPane(userSplitPanel));
// Create the Admin's page tab bar, currently 2 elements: user & groups
final TabbedPane tabbedPane = new TabbedPane();
tabbedPane.setIdAttr("page-body");
/**
* Create and add info tab
*/
tabbedPane.addTab(INFO_TAB_TITLE, new AdminInfoTab());
/*
* Create application administration panel
*/
ApplicationsAdministrationTab appsAdministrationTab =
new ApplicationsAdministrationTab();
tabbedPane.addTab(APPLICATIONS_TAB_TITLE, new ApplicationsAdministrationTab());
/*
* Add user panel.
*/
tabbedPane.addTab(USER_TAB_TITLE, userSplitPanel);
/*
* Create and add group administration panel
*/
final GroupAdministrationTab groupAdminTab = new GroupAdministrationTab();
tabbedPane.addTab(GROUP_TAB_TITLE, groupAdminTab);
//SettingsTab settingsTab = new SettingsTab();
browsePane.setTabbedPane(tabbedPane);
browsePane.setGroupAdministrationTab(groupAdminTab);
page.add(tabbedPane);
page.lock();
// Create the Admin's page tab bar, currently 2 elements: user & groups
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
tb.addTab(USER_TAB_TITLE, userSplitPanel);
tb.addTab(GROUP_TAB_TITLE, groupAdministrationTab);
tb.addTab(APPLICATIONS_TAB_TITLE, appsAdministrationTab);
//tb.addTab("Settings", settingsTab);
browsePane.setTabbedPane(tb);
browsePane.setGroupAdministrationTab(groupAdministrationTab);
//browsePane.setAppsAdministrationTab(appsAdministrationTab);
p.add(tb);
p.lock();
return p;
return page;
}
}

View File

@ -28,7 +28,6 @@ import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.toolbox.ui.LayoutPanel;
import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.ui.admin.applications.ApplicationCreateForm;
import com.arsdigita.ui.admin.applications.ApplicationInstancePane;
import com.arsdigita.ui.admin.applications.ApplicationManager;
import com.arsdigita.ui.admin.applications.BaseApplicationPane;

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.ui.admin;
import com.arsdigita.ui.util.GlobalizationUtil;
import com.arsdigita.bebop.ActionLink;
@ -61,13 +60,10 @@ class GroupAdministrationTab extends BoxPanel
implements AdminConstants,
ChangeListener {
private static final Logger s_log =
Logger.getLogger(GroupAdministrationTab.class);
private static final Logger s_log = Logger.getLogger(GroupAdministrationTab.class);
private Tree m_tree;
private SearchAndList m_subMemberSearch;
private ActionLink m_addSubmemberLink;
private Component m_groupInfoPanel;
private Component m_subGroupPanel;
private Component m_subMemberPanel;
@ -78,7 +74,6 @@ class GroupAdministrationTab extends BoxPanel
private Component m_existingGroupAddPanel;
private ExistingGroupAddPane m_existingGroupAdd;
private ArrayList m_panelList = new ArrayList();
private RequestLocal m_group;
/**
@ -151,6 +146,7 @@ class GroupAdministrationTab extends BoxPanel
}
return group;
}
};
BoxPanel c = new BoxPanel();
@ -258,6 +254,7 @@ class GroupAdministrationTab extends BoxPanel
PageState ps = e.getPageState();
displayEditPanel(ps);
}
});
body.add(link);
@ -293,6 +290,7 @@ class GroupAdministrationTab extends BoxPanel
t.setLabel(String.valueOf(g.countSubgroups()));
}
}
});
ActionLink status = new ActionLink(countLabel);
@ -302,6 +300,7 @@ class GroupAdministrationTab extends BoxPanel
String key = (String) m_tree.getSelectedKey(ps);
m_tree.expand(key, ps);
}
});
labelStatus.add(status);
@ -324,6 +323,7 @@ class GroupAdministrationTab extends BoxPanel
b.add(removeLink);
return b;
}
});
subGroupList.addActionListener(new ActionListener() {
@ -344,6 +344,7 @@ class GroupAdministrationTab extends BoxPanel
}
}
}
});
body.add(subGroupList);
@ -355,6 +356,7 @@ class GroupAdministrationTab extends BoxPanel
displayAddGroupPanel(ps);
}
});
body.add(addLink);
@ -399,6 +401,7 @@ class GroupAdministrationTab extends BoxPanel
public void register(Page p) {
p.setVisibleDefault(m_subMemberSearch, false);
}
};
body.add(new SubMemberPanel(this));
@ -410,6 +413,7 @@ class GroupAdministrationTab extends BoxPanel
m_addSubmemberLink.setVisible(ps, false);
m_subMemberSearch.setVisible(ps, true);
}
});
m_subMemberSearch = new SearchAndList("searchsubmember");
@ -441,6 +445,7 @@ class GroupAdministrationTab extends BoxPanel
m_subMemberSearch.setVisible(ps, false);
m_addSubmemberLink.setVisible(ps, true);
}
});
body.add(m_subMemberSearch);
@ -476,6 +481,7 @@ class GroupAdministrationTab extends BoxPanel
// Select root node
}
});
body.add(deleteLink);
return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER,
@ -494,6 +500,7 @@ class GroupAdministrationTab extends BoxPanel
PageState ps = e.getPageState();
displayGroupInfoPanel(ps);
}
});
link.setClassAttr("actionLink");
@ -513,18 +520,17 @@ class GroupAdministrationTab extends BoxPanel
*/
private void hideAll(PageState ps) {
for (int i = 0; i < m_panelList.size(); i++) {
((Component) m_panelList.get(i)).setVisible
(ps, false);
((Component) m_panelList.get(i)).setVisible(ps, false);
}
}
/**
* Show all components of the in preparation for
* turning visibility of selected components off .
*/
private void showAll(PageState ps) {
for (int i = 0; i < m_panelList.size(); i++) {
((Component) m_panelList.get(i)).setVisible
(ps, true);
((Component) m_panelList.get(i)).setVisible(ps, true);
}
}
@ -534,6 +540,7 @@ class SubGroupListModelBuilder extends LockableImpl
implements ListModelBuilder {
private GroupAdministrationTab m_parent;
public SubGroupListModelBuilder(GroupAdministrationTab parent) {
m_parent = parent;
}
@ -547,6 +554,7 @@ class SubGroupListModelBuilder extends LockableImpl
return new SubGroupListModel(null);
}
}
/**
@ -593,4 +601,5 @@ class SubGroupListModel implements ListModel {
return false;
}
}