- Removed several unused classes from the old /ccm/admin UI
- First part of refactored applications admin tab for /ccm/admin/


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4107 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-05-25 17:21:03 +00:00
parent 196af54d2b
commit 6bf9cc8a5d
41 changed files with 439 additions and 4498 deletions

View File

@ -1,413 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.Label;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.LongParameter;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* Centralised place for all constants used in the administration UI.
*
* @author David Dao
*/
@Deprecated
interface AdminConstants {
/**
* The XML namespace used by admin components.
*/
String ADMIN_XML_NS = "http://www.arsdigita.com/admin-ui/1.0";
/**
* Globalization resource for admin ui.
*/
String BUNDLE_NAME = "com.arsdigita.ui.admin.AdminResources";
/**
* Navigational dimension bar labels.
*/
// Label MY_WORKSPACE_LABEL = new Label
// (new GlobalizedMessage("ui.admin.nav.workspace",
// BUNDLE_NAME));
// Label LOG_OUT_LABEL = new Label
// (new GlobalizedMessage("ui.admin.nav.logout",
// BUNDLE_NAME));
/**
* Administration page title
*/
Label PAGE_TITLE_LABEL = new Label(new GlobalizedMessage("ui.admin.dispatcher.title",
BUNDLE_NAME));
/**
* Administration main tab names.
*/
Label USER_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.user",
BUNDLE_NAME));
Label GROUP_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.group",
BUNDLE_NAME));
Label APPLICATIONS_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.applications",
BUNDLE_NAME));
Label SYSINFO_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.sysinfo.title", BUNDLE_NAME));
GlobalizedMessage USER_NAVBAR_TITLE = new GlobalizedMessage("ui.admin.tab.user.navbartitle",
BUNDLE_NAME);
/**
* Tabbed pane indices
*/
int USER_TAB_INDEX = 2;
int GROUP_TAB_INDEX = 3;
/**
* User tab name
*/
Label USER_TAB_SUMMARY = new Label(new GlobalizedMessage("ui.admin.tab.user.summary",
BUNDLE_NAME));
Label USER_TAB_BROWSE = new Label(new GlobalizedMessage("ui.admin.tab.user.browse",
BUNDLE_NAME));
Label USER_TAB_SEARCH = new Label(new GlobalizedMessage("ui.admin.tab.user.search",
BUNDLE_NAME));
Label USER_TAB_CREATE_USER = new Label(new GlobalizedMessage("ui.admin.tab.user.createuser",
BUNDLE_NAME));
int USER_TAB_SUMMARY_INDEX = 0;
int USER_TAB_BROWSE_INDEX = 1;
int USER_TAB_SEARCH_INDEX = 2;
int USER_TAB_CREATE_USER_INDEX = 3;
/**
* Global state parameters.
*/
LongParameter GROUP_ID_PARAM = new LongParameter("group_id");
LongParameter APPLICATIONS_ID_PARAM = new LongParameter("application_id");
LongParameter USER_ID_PARAM = new LongParameter("user_id");
/**
* User summary panel.
*/
Label SUMMARY_PANEL_HEADER = new Label(
new GlobalizedMessage("ui.admin.user.summarypanel.header", BUNDLE_NAME));
Label CREATE_USER_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.summarypanel.createUser", BUNDLE_NAME));
Label TOTAL_USERS_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.summarypanel.totalusers", BUNDLE_NAME));
/**
* User browse panel.
*/
Label BROWSE_USER_PANEL_HEADER = new Label(new GlobalizedMessage(
"ui.admin.user.browsepanel.header",
BUNDLE_NAME));
Label USER_INFO_LABEL = new Label(new GlobalizedMessage("ui.admin.user.userinfo.header",
BUNDLE_NAME));
Label USER_EDIT_PANEL_HEADER = new Label(new GlobalizedMessage("ui.admin.user.useredit.header",
BUNDLE_NAME));
Label USER_GROUP_PANEL_HEADER = new Label(new GlobalizedMessage(
"ui.admin.user.groupmembership.header",
BUNDLE_NAME));
Label USER_DELETE_FAILED_PANEL_HEADER = new Label(new GlobalizedMessage(
"ui.admin.user.action.delete.failed.header",
BUNDLE_NAME));
Label USER_PASSWORD_PANEL_HEADER = new Label(new GlobalizedMessage(
"ui.admin.user.password.header",
BUNDLE_NAME));
Label USER_ACTION_PANEL_HEADER = new Label(new GlobalizedMessage("ui.admin.user.action.header",
BUNDLE_NAME));
Label USER_ACTION_CONTINUE = new Label(new GlobalizedMessage("ui.admin.user.action.continue",
BUNDLE_NAME));
Label USER_DELETE_LABEL = new Label(new GlobalizedMessage("ui.admin.user.delete.label",
BUNDLE_NAME));
Label USER_BAN_LABEL = new Label(new GlobalizedMessage("ui.admin.user.ban.label",
BUNDLE_NAME));
Label USER_UNBAN_LABEL = new Label(new GlobalizedMessage("ui.admin.user.unban.label",
BUNDLE_NAME));
GlobalizedMessage USER_DELETE_CONFIRMATION = new GlobalizedMessage(
"ui.admin.user.delete.confirm", BUNDLE_NAME);
GlobalizedMessage USER_BAN_CONFIRMATION = new GlobalizedMessage("ui.admin.user.ban.confirm",
BUNDLE_NAME);
GlobalizedMessage USER_UNBAN_CONFIRMATION = new GlobalizedMessage("ui.admin.user.unban.confirm",
BUNDLE_NAME);
GlobalizedMessage USER_DELETE_FAILED_MSG = new GlobalizedMessage(
"ui.admin.user.delete.failed.label", BUNDLE_NAME);
Label USER_TAB_EXTREME_ACTION_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.browsepanel.extremeaction",
BUNDLE_NAME));
Label UPDATE_USER_PASSWORD_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.browsepanel.updatePassword",
BUNDLE_NAME));
Label BECOME_USER_LABEL = new Label(
new GlobalizedMessage("ui.admin.user.browsepanel.becomeUser",
BUNDLE_NAME));
/**
* Create new user panel.
*/
Label CREATE_USER_PANEL_HEADER = new Label(new GlobalizedMessage(
"ui.admin.user.createpanel.header",
BUNDLE_NAME));
/**
* User search panel.
*/
Label SEARCH_PANEL_HEADER = new Label(new GlobalizedMessage("ui.admin.user.search.header",
BUNDLE_NAME));
Label PASSWORD_FORM_LABEL_PASSWORD = new Label(new GlobalizedMessage(
"ui.admin.user.userpasswordform.passwordlabel",
BUNDLE_NAME));
Label PASSWORD_FORM_LABEL_CONFIRMATION_PASSWORD = new Label(new GlobalizedMessage(
"ui.admin.user.userpasswordform.confirmpasswordlabel",
BUNDLE_NAME));
Label PASSWORD_FORM_LABEL_QUESTION = new Label(new GlobalizedMessage(
"ui.admin.user.userpasswordform.question",
BUNDLE_NAME), false);
Label PASSWORD_FORM_LABEL_ANSWER = new Label(new GlobalizedMessage(
"ui.admin.user.userpasswordform.answer",
BUNDLE_NAME), false);
GlobalizedMessage PASSWORD_FORM_SUBMIT = new GlobalizedMessage(
"ui.admin.user.userpasswordform.submit",
BUNDLE_NAME);
/**
* Constants for user add/edit form.
*/
String USER_FORM_ADD = "user-add-form";
String USER_FORM_EDIT = "user-edit-form";
String USER_FORM_INPUT_FIRST_NAME = "firstname";
String USER_FORM_INPUT_LAST_NAME = "lastname";
String USER_FORM_INPUT_PASSWORD = "password";
String USER_FORM_INPUT_PASSWORD_CONFIRMATION = "password_confirmation";
String USER_FORM_INPUT_QUESTION = "question";
String USER_FORM_INPUT_ANSWER = "answer";
String USER_FORM_INPUT_PRIMARY_EMAIL = "email";
String USER_FORM_INPUT_ADDITIONAL_EMAIL = "additional_email";
String USER_FORM_INPUT_SCREEN_NAME = "screenname";
String USER_FORM_INPUT_SSO = "sso_login";
String USER_FORM_INPUT_URL = "url";
String USER_FORM_INPUT_URL_DEFAULT = "http://";
Label USER_FORM_LABEL_FIRST_NAME = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.firstname",
BUNDLE_NAME));
Label USER_FORM_LABEL_LAST_NAME = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.lastname",
BUNDLE_NAME));
Label USER_FORM_LABEL_PASSWORD = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.password",
BUNDLE_NAME));
Label USER_FORM_LABEL_PASSWORD_CONFIRMATION = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.confirmation",
BUNDLE_NAME));
Label USER_FORM_LABEL_QUESTION = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.question",
BUNDLE_NAME));
Label USER_FORM_LABEL_ANSWER = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.answer",
BUNDLE_NAME));
Label USER_FORM_LABEL_PRIMARY_EMAIL = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.primaryemail",
BUNDLE_NAME));
Label USER_FORM_LABEL_ADDITIONAL_EMAIL = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.additionalemail",
BUNDLE_NAME));
Label USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.additionalemaillist",
BUNDLE_NAME));
Label USER_FORM_LABEL_SCREEN_NAME = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.screenname",
BUNDLE_NAME));
Label USER_FORM_LABEL_SSO = new Label(new GlobalizedMessage(
"ui.admin.user.addeditform.ssologinname",
BUNDLE_NAME));
Label USER_FORM_LABEL_URL = new Label(new GlobalizedMessage("ui.admin.user.addeditform.url",
BUNDLE_NAME));
Label USER_FORM_DELETE_ADDITIONAL_EMAIL = new Label(
new GlobalizedMessage("ui.admin.user.addeditform.deleteemail",
BUNDLE_NAME));
GlobalizedMessage USER_FORM_SUBMIT = new GlobalizedMessage("ui.admin.user.addeditform.submit",
BUNDLE_NAME);
GlobalizedMessage USER_FORM_ERROR_SCREEN_NAME_NOT_UNIQUE = new GlobalizedMessage(
"ui.admin.user.addeditform.error.screenname.notunique",
BUNDLE_NAME);
GlobalizedMessage USER_FORM_ERROR_PRIMARY_EMAIL_NOT_UNIQUE = new GlobalizedMessage(
"ui.admin.user.addeditform.error.primaryemail.notunique",
BUNDLE_NAME);
GlobalizedMessage USER_FORM_ERROR_PASSWORD_NOT_MATCH = new GlobalizedMessage(
"ui.admin.user.addeditform.error.password.notmatch",
BUNDLE_NAME);
GlobalizedMessage USER_FORM_ERROR_ANSWER_NULL = new GlobalizedMessage(
"ui.admin.user.addeditform.error.answer.null",
BUNDLE_NAME);
GlobalizedMessage USER_FORM_ERROR_ANSWER_WHITESPACE = new GlobalizedMessage(
"ui.admin.user.addeditform.error.answer.whitespace",
BUNDLE_NAME);
/**
* Constants for group add/edit form.
*/
String GROUP_FORM_ADD = "group-add-form";
String GROUP_FORM_EDIT = "group-edit-form";
String GROUP_FORM_INPUT_NAME = "name";
String GROUP_FORM_INPUT_PRIMARY_EMAIL = "email";
Label GROUP_FORM_LABEL_NAME = new Label(new GlobalizedMessage(
"ui.admin.groups.addeditform.namelabel",
BUNDLE_NAME));
Label GROUP_FORM_LABEL_PRIMARY_EMAIL = new Label(new GlobalizedMessage(
"ui.admin.groups.addeditform.primaryemaillabel",
BUNDLE_NAME));
GlobalizedMessage GROUP_FORM_SUBMIT
= new GlobalizedMessage("ui.admin.groups.addeditform.submit", BUNDLE_NAME);
/**
* Constants for group administration tab.
*/
Label GROUP_ACTION_CONTINUE = new Label(new GlobalizedMessage("ui.admin.groups.actioncontinue",
BUNDLE_NAME));
GlobalizedMessage GROUP_DELETE_FAILED_MSG = new GlobalizedMessage(
"ui.admin.groups.groupdeletefailed",
BUNDLE_NAME);
Label GROUP_INFORMATION_HEADER = new Label(new GlobalizedMessage(
"ui.admin.groups.groupinformation",
BUNDLE_NAME));
Label SUBGROUP_HEADER = new Label(new GlobalizedMessage("ui.admin.groups.subgroups",
BUNDLE_NAME));
Label GROUP_EDIT_HEADER = new Label(new GlobalizedMessage("ui.admin.groups.groupedit",
BUNDLE_NAME));
Label ADD_SUBGROUP_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.add",
BUNDLE_NAME));
Label SUBMEMBER_HEADER = new Label(new GlobalizedMessage("ui.admin.groups.submembers",
BUNDLE_NAME));
Label DELETE_GROUP_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.delete",
BUNDLE_NAME));
Label GROUP_EXTREME_ACTIONS_HEADER = new Label(new GlobalizedMessage(
"ui.admin.groups.extremeaction",
BUNDLE_NAME));
Label GROUP_DELETE_FAILED_HEADER = new Label(new GlobalizedMessage(
"ui.admin.groups.deletefailed",
BUNDLE_NAME));
Label ADD_GROUP_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.addgrouplabel",
BUNDLE_NAME));
Label EDIT_GROUP_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.edit",
BUNDLE_NAME));
Label SUBGROUP_COUNT_LABEL = new Label(new GlobalizedMessage(
"ui.admin.groups.subgroupcountlabel",
BUNDLE_NAME));
String GROUP_DELETE_CONFIRMATION = "Are you sure you want to delete this group?";
Label ADD_SUBMEMBER_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.addsubmemberlabel",
BUNDLE_NAME));
Label REMOVE_SUBMEMBER_LABEL = new Label(new GlobalizedMessage(
"ui.admin.groups.removesubmemberlabel",
BUNDLE_NAME));
Label ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL = new Label(new GlobalizedMessage(
"ui.admin.groups.addExisting",
BUNDLE_NAME));
Label REMOVE_SUBGROUP_LABEL = new Label(new GlobalizedMessage("ui.admin.groups.removeExisting",
BUNDLE_NAME));
Label GROUP_SEARCH_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.search", BUNDLE_NAME));
GlobalizedMessage SEARCH_BUTTON = new GlobalizedMessage("ui.admin.groups.button.search",
BUNDLE_NAME);
Label GROUP_NO_RESULTS = new Label(new GlobalizedMessage("ui.admin.groups.searchForm.noResults",
BUNDLE_NAME));
Label FOUND_GROUPS_TITLE = new Label(new GlobalizedMessage("ui.admin.groups.found.title",
BUNDLE_NAME));
Label PICK_GROUPS = new Label(new GlobalizedMessage("ui.admin.groups.select.explanation",
BUNDLE_NAME));
GlobalizedMessage SAVE_BUTTON = new GlobalizedMessage("ui.admin.save", BUNDLE_NAME);
String SEARCH_QUERY = "query";
public final static String ADMIN_PAGE_URL = "/admin/";
public final static String ADMIN_SERVLET_PATH = "/admin/*";
}

View File

@ -71,14 +71,12 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
* @author pb * @author pb
*/ */
@WebServlet(urlPatterns = {ADMIN_SERVLET_PATH}) @WebServlet(urlPatterns = {ADMIN_SERVLET_PATH})
public class AdminServlet public class AdminServlet extends BaseApplicationServlet {
extends BaseApplicationServlet
implements AdminConstants {
private static final long serialVersionUID = -3912367600768871630L; private static final long serialVersionUID = -3912367600768871630L;
private static final Logger LOGGER = LogManager private static final Logger LOGGER = LogManager
.getLogger(AdminServlet.class); .getLogger(AdminServlet.class);
/** /**
* Logger instance for debugging * Logger instance for debugging
@ -114,35 +112,35 @@ public class AdminServlet
tabbedPane.setIdAttr("page-body"); tabbedPane.setIdAttr("page-body");
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage("ui.admin.tab.applications", new Label(new GlobalizedMessage("ui.admin.tab.applications",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new ApplicationsAdminTab()); new ApplicationsAdminTab());
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage( new Label(new GlobalizedMessage(
"ui.admin.tab.users_groups_roles.title", "ui.admin.tab.users_groups_roles.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new UsersGroupsRolesTab()); new UsersGroupsRolesTab());
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage("ui.admin.tab.categories.title", new Label(new GlobalizedMessage("ui.admin.tab.categories.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new CategoriesTab()); new CategoriesTab());
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage("ui.admin.tab.configuration.title", new Label(new GlobalizedMessage("ui.admin.tab.configuration.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new ConfigurationTab()); new ConfigurationTab());
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage("ui.admin.tab.workflows.title", new Label(new GlobalizedMessage("ui.admin.tab.workflows.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new WorkflowAdminTab()); new WorkflowAdminTab());
tabbedPane.addTab( tabbedPane.addTab(
new Label(new GlobalizedMessage("ui.admin.tab.sysinfo.title", new Label(new GlobalizedMessage("ui.admin.tab.sysinfo.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
new SystemInformationTab()); new SystemInformationTab());
//page.add(new Label("admin")); //page.add(new Label("admin"));
adminPage.add(tabbedPane); adminPage.add(tabbedPane);
@ -166,16 +164,16 @@ public class AdminServlet
public final void doService(final HttpServletRequest sreq, public final void doService(final HttpServletRequest sreq,
final HttpServletResponse sresp, final HttpServletResponse sresp,
final CcmApplication app) throws final CcmApplication app) throws
ServletException, IOException { ServletException, IOException {
// /////// Some preparational steps /////////////// // /////// Some preparational steps ///////////////
/* Determine access privilege: only logged in users may access */ /* Determine access privilege: only logged in users may access */
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Subject subject = cdiUtil.findBean(Subject.class); final Subject subject = cdiUtil.findBean(Subject.class);
final PermissionChecker permissionChecker = cdiUtil.findBean( final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class); PermissionChecker.class);
final ConfigurationManager confManager = CDI.current().select( final ConfigurationManager confManager = CDI.current().select(
ConfigurationManager.class).get(); ConfigurationManager.class).get();
if (confManager == null) { if (confManager == null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -187,17 +185,17 @@ public class AdminServlet
subject.getSession().getId().toString()); subject.getSession().getId().toString());
if (!subject.isAuthenticated()) { if (!subject.isAuthenticated()) {
LOGGER.debug( LOGGER.debug(
"Subject {} is not authenticated, redirecting to login...", "Subject {} is not authenticated, redirecting to login...",
subject.toString()); subject.toString());
throw new LoginSignal(sreq); throw new LoginSignal(sreq);
} }
/* Determine access privilege: Admin privileges must be granted */ /* Determine access privilege: Admin privileges must be granted */
LOGGER.debug( LOGGER.debug(
"Subject is loggedin, checking if subject has required permissions..."); "Subject is loggedin, checking if subject has required permissions...");
if (!permissionChecker.isPermitted("admin")) { if (!permissionChecker.isPermitted("admin")) {
LOGGER.debug("Subject does *not* have required permissions. " LOGGER.debug("Subject does *not* have required permissions. "
+ "Access denied."); + "Access denied.");
throw new AccessDeniedException("User is not an administrator"); throw new AccessDeniedException("User is not an administrator");
} }
@ -231,7 +229,7 @@ public class AdminServlet
* Adds one pair of Url - Page to the internal hash map, used as a cache. * Adds one pair of Url - Page to the internal hash map, used as a cache.
* *
* @param pathInfo url stub for a page to display * @param pathInfo url stub for a page to display
* @param page Page object to display * @param page Page object to display
*/ */
// private void addPage(final String pathInfo, final Page page) { // private void addPage(final String pathInfo, final Page page) {
// Assert.exists(pathInfo, String.class); // Assert.exists(pathInfo, String.class);

View File

@ -28,6 +28,8 @@ import com.arsdigita.globalization.GlobalizedMessage;
*/ */
public final class AdminUiConstants { public final class AdminUiConstants {
public static final String ADMIN_APP_TYPE = "com.arsdigita.ui.Admin";
/** /**
* The XML namespace used by administration components. * The XML namespace used by administration components.
*/ */

View File

@ -1,201 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.util.LockableImpl;
import org.libreccm.core.EmailAddress;
import static com.arsdigita.ui.admin.AdminConstants.*;
import java.util.Iterator;
/**
* Used to display and manage the list of additional email addresses
* for a user.
*/
class EmailList extends List
implements ListCellRenderer,
AdminConstants,
ActionListener
{
/**
* Constructor
*/
public EmailList() {
setModelBuilder(new EmailListModelBuilder());
setCellRenderer(this);
addActionListener(this);
}
/**
*
* @param list
* @param state
* @param value
* @param key
* @param index
* @param isSelected
* @return
*/
@Override
public Component getComponent(List list,
PageState state,
Object value,
String key,
int index,
boolean isSelected)
{
SimpleContainer c = new SimpleContainer();
if (value != null) {
ControlLink link =
new ControlLink(USER_FORM_DELETE_ADDITIONAL_EMAIL);
link.setClassAttr("deleteLink");
c.add(new Label(value.toString()));
c.add(link);
}
return c;
}
/**
* This actionlister is executed when the user clicks the "delete"
* link next to an email address.
*/
@Override
public void actionPerformed (final ActionEvent event) {
final PageState state = event.getPageState();
final Long userId = (Long) state.getValue(USER_ID_PARAM);
if (userId != null) {
// final CdiUtil cdiUtil = new CdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
//
// final User user = userRepository.findById(userId);
// if (user == null) {
// return;
// } else {
// final String email = (String) getSelectedKey(state);
//
// for(EmailAddress addr : user.getEmailAddresses()) {
// if (addr.getAddress().equals(email)) {
// user.removeEmailAddress(addr);
// }
// }
//
// userRepository.save(user);
// }
}
}
}
/**
*
*
*/
class EmailListModelBuilder extends LockableImpl
implements ListModelBuilder,
AdminConstants
{
/**
*
*/
private class EmailListModel implements ListModel {
private Iterator m_emails;
private EmailAddress m_currentEmail;
/**
*
* @param emails
*/
public EmailListModel(Iterator emails) {
m_emails = emails;
}
/**
*
* @return
*/
public boolean next() {
if (m_emails.hasNext()) {
m_currentEmail = (EmailAddress) m_emails.next();
return true;
} else {
return false;
}
}
/**
*
* @return
*/
@Override
public String getKey() {
return m_currentEmail.getAddress();
}
@Override
public Object getElement() {
return m_currentEmail.getAddress();
}
}
/**
*
* @param l
* @param state
* @return
*/
@Override
public ListModel makeModel(List l, PageState state) {
return null;
// final Long userId = (Long) state.getValue(USER_ID_PARAM);
// if (userId == null) {
// return null;
// } else {
// final CdiUtil cdiUtil = new CdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// final User user = userRepository.findById(userId);
//
// return new EmailListModel(user.getEmailAddresses().iterator());
// }
}
}

View File

@ -1,197 +0,0 @@
package com.arsdigita.ui.admin;
import org.apache.log4j.Logger;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
//import org.libreccm.core.Group;
//import org.libreccm.core.GroupRepository;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* Series of screens required for adding existing groups as subgroups - based on
* existing functionality for adding permissions to a folder in content/admin
*
* @version $Id: ExistingGroupAddPane.java,v 1.4 2004/06/21 11:34:03 cgyg9330
* Exp $
*/
public class ExistingGroupAddPane extends SimpleContainer implements
AdminConstants {
private static final Logger s_log = Logger.getLogger(
ExistingGroupAddPane.class);
private ParameterModel searchString = new StringParameter(SEARCH_QUERY);
private GroupSearchForm groupSearchForm;
private SimpleContainer selectGroupsPanel;
private SimpleContainer noResultsPanel;
private Tree groupTree;
private GroupAdministrationTab parentPage;
/**
*
*/
private RequestLocal parentGroup = new RequestLocal() {
@Override
protected Object initialValue(final PageState ps) {
String key = (String) groupTree.getSelectedKey(ps);
//
// Group group = null;
//
// if (key != null) {
// final Long id = new Long(key);
//
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
//
// group = groupRepository.findById(id);
// }
//
// return group;
return null;
}
};
/**
* Constructor.
*
* @param groupTree
* @param parentPage
*/
public ExistingGroupAddPane(Tree groupTree,
GroupAdministrationTab parentPage) {
this.groupTree = groupTree;
this.parentPage = parentPage;
}
/**
*
* @param p
*/
@Override
public void register(Page p) {
super.register(p);
add(getGroupSearchForm());
add(getSelectGroupsPanel());
add(getNoSearchResultPanel());
// set initial visibility of components
p.setVisibleDefault(getGroupSearchForm(), true);
p.setVisibleDefault(getSelectGroupsPanel(), false);
p.setVisibleDefault(getNoSearchResultPanel(), false);
p.addGlobalStateParam(searchString);
}
/**
*
* @return
*/
public GroupSearchForm getGroupSearchForm() {
if (groupSearchForm == null) {
groupSearchForm = new GroupSearchForm(this);
}
return groupSearchForm;
}
/**
* Returns a panel with a set of checkboxes for groups fulfilling search
* criteria
*/
public SimpleContainer getSelectGroupsPanel() {
if (selectGroupsPanel == null) {
SelectGroups selectGroups = new SelectGroups(this,
getGroupSearchForm());
selectGroupsPanel = selectGroups.getPanel();
}
return selectGroupsPanel;
}
/**
* Returns a bebop panel indicating that the user search yielded no results.
*/
public SimpleContainer getNoSearchResultPanel() {
if (noResultsPanel == null) {
Label errorMsg = GROUP_NO_RESULTS;
errorMsg.setClassAttr("errorBullet");
BoxPanel bp = new BoxPanel();
bp.add(errorMsg);
bp.add(new GroupSearchForm(this));
noResultsPanel = new SegmentedPanel().addSegment(new Label(" "), bp);
}
return noResultsPanel;
}
/**
* Shows panel with no results to user search.
*/
public void showNoResults(PageState s) {
getGroupSearchForm().setVisible(s, false);
getSelectGroupsPanel().setVisible(s, false);
getNoSearchResultPanel().setVisible(s, true);
}
/**
* Show the select groups to add as subgroups panel
*/
public void showGroups(PageState s) {
getGroupSearchForm().setVisible(s, false);
getSelectGroupsPanel().setVisible(s, true);
getNoSearchResultPanel().setVisible(s, false);
}
/**
*
* show the search form
*/
public void showSearch(PageState s) {
getGroupSearchForm().setVisible(s, true);
getSelectGroupsPanel().setVisible(s, false);
getNoSearchResultPanel().setVisible(s, false);
}
/**
*
* @return
*/
public ParameterModel getSearchString() {
return searchString;
}
/**
*
* @return
*/
public GroupAdministrationTab getParentPage() {
return parentPage;
}
/**
*
* @param ps
*
* @return
*/
// public Group getParentGroup(PageState ps) {
// return (Group) parentGroup.get(ps);
// }
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.FormProcessException;
import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* Add group form.
*
* @author David Dao
* @version $Id$
*/
class GroupAddForm extends GroupForm implements FormProcessListener {
private Tree m_groupTree;
private GroupAdministrationTab m_groupTab;
public GroupAddForm(final Tree groupTree,
final GroupAdministrationTab tab) {
super(GROUP_FORM_ADD);
addProcessListener(this);
m_groupTree = groupTree;
m_groupTab = tab;
}
/**
* Processes the form.
*/
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
// PageState ps = event.getPageState();
//
// // Get super parent group.
// String key = (String) m_groupTree.getSelectedKey(ps);
//
// final Group parentGroup = null;
//// if (key != null) {
//// BigDecimal parentID = new BigDecimal(key);
////
//// try {
//// parentGroup = new Group(parentID);
//// } catch (DataObjectNotFoundException exc) {
//// // Parent group does not exist.
//// // This is normal behavior with the new group
//// // been add with no parent.
//// }
//// }
//
// final Group group = new Group();
//
// String name = (String) m_name.getValue(ps);
// group.setName(name);
//
// // Workaround for bug #189720: there is no way to remove a
// // Party's primary email address, so we set it directly to
// // null if it's value on the form is null.
//// InternetAddress email = (InternetAddress) m_email.getValue(ps);
//// if (email != null) {
//// group.setPrimaryEmail(new EmailAddress(email.getAddress()));
//// } else {
//// //group.set("primaryEmail", null);
//// group.setPrimaryEmail(null);
//// }
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
// groupRepository.save(group);
//
//// if (parentGroup != null) {
//// parentGroup.addSubgroup(group);
//// parentGroup.save();
//// }
// if (m_groupTab != null) {
// m_groupTab.setGroup(ps, group);
// }
throw new UnsupportedOperationException();
}
}

View File

@ -1,668 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.ActionLink;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.LayoutPanel;
import static com.arsdigita.ui.admin.AdminConstants.*;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import java.util.ArrayList;
import org.apache.log4j.Logger;
/**
* Constructs the panel for administration of groups.
*
* @author David Dao
*
*/
class GroupAdministrationTab extends LayoutPanel implements AdminConstants,
ChangeListener {
private static final Logger LOGGER = Logger.getLogger(
GroupAdministrationTab.class);
private final Tree groupTree;
private SearchAndList subMemberSearch;
private ActionLink addSubmemberLink;
private final Component groupInfoPanel;
private final Component subGroupPanel;
private final Component subMemberPanel;
private final Component extremeActionPanel;
private final Component groupAddPanel;
private final Component groupEditPanel;
private final Component groupDeleteFailedPanel;
private final Component existingGroupAddPanel;
private ExistingGroupAddPane m_existingGroupAdd;
private final java.util.List<Component> panelList
= new ArrayList<Component>();
private final RequestLocal requestLocalGroup;
/**
*
* @param page
*/
@Override
public void register(final Page page) {
for (int i = 0; i < panelList.size(); i++) {
page.setVisibleDefault(panelList.get(i), false);
}
page.setVisibleDefault(groupAddPanel, true);
}
/**
*
* @param state
*
* @return
*/
// public Group getGroup(final PageState state) {
// return (Group) requestLocalGroup.get(state);
// }
// public void setGroup(final PageState state, final Group group) {
// final String groupId = Long.toString(group.getSubjectId());
// requestLocalGroup.set(state, group);
// groupTree.setSelectedKey(state, groupId);
//
// if (!"-1".equals(groupId)) {
// expandGroups(state, group);
// groupTree.expand("-1", state);
// }
// }
// private void expandGroups(final PageState state, final Group group) {
//// groupTree.expand(Long.toString(group.getSubjectId()), state);
////
//// final List< superGroups = group.getSupergroups();
//// Group superGroup;
//// while (superGroups.next()) {
//// superGroup = (Group) superGroups.getDomainObject();
//// expandGroups(state, superGroup);
//// }
// }
/**
* Constructor
*/
public GroupAdministrationTab() {
super();
setClassAttr("sidebarNavPanel");
setAttribute("navbar-title", "Groups");
requestLocalGroup = new RequestLocal() {
@Override
protected Object initialValue(final PageState state) {
// String key = (String) groupTree.getSelectedKey(state);
// Group group;
// if (key != null) {
// final long id = Long.parseLong(key);
//
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil
// .findBean(GroupRepository.class);
//
// group = groupRepository.findById(id);
//
// return group;
// }
return null;
}
};
setClassAttr("navbar");
groupTree = new Tree(new GroupTreeModelBuilder());
groupTree.addChangeListener(this);
setLeft(groupTree);
final SegmentedPanel body = new SegmentedPanel();
body.setClassAttr("main");
groupInfoPanel = buildGroupInfoPanel(body);
panelList.add(groupInfoPanel);
groupEditPanel = buildGroupEditPanel(body);
panelList.add(groupEditPanel);
subGroupPanel = buildSubGroupPanel(body);
panelList.add(subGroupPanel);
groupAddPanel = buildGroupAddPanel(body);
panelList.add(groupAddPanel);
existingGroupAddPanel = buildExistingGroupAddPanel(body);
panelList.add(existingGroupAddPanel);
subMemberPanel = buildMemberListPanel(body);
panelList.add(subMemberPanel);
extremeActionPanel = buildExtremeActionPanel(body);
panelList.add(extremeActionPanel);
groupDeleteFailedPanel = buildGroupDeleteFailedPanel(body);
panelList.add(groupDeleteFailedPanel);
setBody(body);
}
public void displayAddGroupPanel(final PageState state) {
hideAll(state);
groupAddPanel.setVisible(state, true);
}
private void displayAddExistingGroupPanel(final PageState state) {
hideAll(state);
existingGroupAddPanel.setVisible(state, true);
}
public void displayEditPanel(final PageState state) {
hideAll(state);
groupEditPanel.setVisible(state, true);
}
public void displayGroupInfoPanel(final PageState state) {
showAll(state);
groupEditPanel.setVisible(state, false);
groupAddPanel.setVisible(state, false);
groupDeleteFailedPanel.setVisible(state, false);
existingGroupAddPanel.setVisible(state, false);
}
public void displayDeleteFailedPanel(final PageState state) {
hideAll(state);
groupDeleteFailedPanel.setVisible(state, true);
}
/**
*
* @param event
*/
public void stateChanged(final ChangeEvent event) {
final PageState ps = event.getPageState();
final String key = (String) groupTree.getSelectedKey(ps);
// added cg - reset existing group add panel to the search screen
// when a new group is selected from the tree
m_existingGroupAdd.showSearch(ps);
if (key == null || key.equals("-1")) {
/**
* If root node is selected then display add panel only.
*/
displayAddGroupPanel(ps);
} else {
displayGroupInfoPanel(ps);
}
ps.setValue(GROUP_ID_PARAM, new BigDecimal(key));
}
/**
* Build a panel to display group basic information.
*/
private Component buildGroupInfoPanel(final SegmentedPanel main) {
final BoxPanel body = new BoxPanel();
//body.add(new GroupInfo(this));
final ColumnPanel infoPanel = new ColumnPanel(2);
infoPanel.add(new Label(new GlobalizedMessage("ui.admin.groups.name",
BUNDLE_NAME)));
final Label nameLabel = new Label();
nameLabel.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
// final Label target = (Label) event.getTarget();
// final PageState state = event.getPageState();
// final Group group = getGroup(state);
//
// target.setLabel(group.getName());
}
});
infoPanel.add(nameLabel);
body.add(infoPanel);
ActionLink link = new ActionLink(EDIT_GROUP_LABEL);
link.setClassAttr("actionLink");
link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
displayEditPanel(ps);
}
});
body.add(link);
return main.addSegment(GROUP_INFORMATION_HEADER, body);
}
/**
* Build group edit form.
*/
private Component buildGroupEditPanel(final SegmentedPanel main) {
return main.addSegment(GROUP_EDIT_HEADER, new GroupEditForm(this));
}
/**
* Build panel to display direct subgroup information.
*/
private Component buildSubGroupPanel(final SegmentedPanel main) {
final BoxPanel body = new BoxPanel();
final BoxPanel labelStatus = new BoxPanel(BoxPanel.HORIZONTAL);
labelStatus.add(SUBGROUP_COUNT_LABEL);
final Label countLabel = new Label("");
countLabel.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
// final PageState ps = event.getPageState();
//
// final Label target = (Label) event.getTarget();
// Group g = getGroup(ps);
// if (g != null) {
// target.setLabel(String.valueOf(g.countSubgroups()));
// }
}
});
final ActionLink status = new ActionLink(countLabel);
status.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
PageState ps = event.getPageState();
String key = (String) groupTree.getSelectedKey(ps);
groupTree.expand(key, ps);
}
});
labelStatus.add(status);
body.add(labelStatus);
final List subGroupList = new List(new SubGroupListModelBuilder(this));
subGroupList.setCellRenderer(new ListCellRenderer() {
@Override
public Component getComponent(final List list,
final PageState state,
final Object value,
final String key,
final int index,
final boolean isSelected) {
throw new UnsupportedOperationException();
// final BoxPanel b = new BoxPanel(BoxPanel.HORIZONTAL);
// b.add(new Label(((Group) value).getName()));
// final ControlLink removeLink = new ControlLink(
// REMOVE_SUBGROUP_LABEL);
// removeLink.setClassAttr("actionLink");
// b.add(removeLink);
// return b;
}
});
subGroupList.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final String key = (String) ((List) event.getSource())
.getSelectedKey(state);
if (key != null) {
// final Long groupId = Long.parseLong(key);
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil
// .findBean(GroupRepository.class);
//
// final Group group = groupRepository.findById(groupId);
// final Group parent = getGroup(state);
// if (parent != null) {
// groupRepository.save(parent);
// }
//
// final BigDecimal groupID = new BigDecimal(key);
// try {
// final Group group = new Group(groupID);
// final Group parent = getGroup(state);
// if (parent != null) {
// parent.removeSubgroup(group);
// parent.save();
// }
// } catch (DataObjectNotFoundException exc) {
// }
}
}
});
body.add(subGroupList);
final ActionLink addLink = new ActionLink(ADD_SUBGROUP_LABEL);
addLink.setClassAttr("actionLink");
addLink.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
PageState ps = event.getPageState();
displayAddGroupPanel(ps);
}
});
body.add(addLink);
// new actionlink and anonymous ActionListener class added cg
final ActionLink addExistingLink = new ActionLink(
ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL);
addExistingLink.setClassAttr("actionLink");
addExistingLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
LOGGER.debug("Add existing group link pressed");
PageState ps = event.getPageState();
displayAddExistingGroupPanel(ps);
}
});
body.add(addExistingLink);
return main.addSegment(SUBGROUP_HEADER, body);
}
/**
* Build group add form.
*/
private Component buildGroupAddPanel(final SegmentedPanel main) {
return main.addSegment(ADD_GROUP_LABEL,
new GroupAddForm(groupTree, this));
}
private Component buildExistingGroupAddPanel(final SegmentedPanel main) {
m_existingGroupAdd = new ExistingGroupAddPane(groupTree, this);
return main.addSegment(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL,
m_existingGroupAdd);
}
/**
* Build group's member panel.
*/
private Component buildMemberListPanel(final SegmentedPanel main) {
BoxPanel body = new BoxPanel() {
@Override
public void register(final Page page) {
page.setVisibleDefault(subMemberSearch, false);
}
};
// body.add(new SubMemberPanel(this));
//
// addSubmemberLink = new ActionLink(ADD_SUBMEMBER_LABEL);
// addSubmemberLink.setClassAttr("actionLink");
// addSubmemberLink.addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(final ActionEvent event) {
// PageState ps = event.getPageState();
// addSubmemberLink.setVisible(ps, false);
// subMemberSearch.setVisible(ps, true);
// }
//
// });
//
// subMemberSearch = new SearchAndList("searchsubmember");
// subMemberSearch.setListModel(new UserSearchAndListModel());
// subMemberSearch.addChangeListener(new ChangeListener() {
//
// @Override
// public void stateChanged(final ChangeEvent event) {
// PageState ps = event.getPageState();
//
// String key = (String) subMemberSearch.getSelectedKey(ps);
// if (key != null) {
// final BigDecimal userID = new BigDecimal(key);
//
// final Group group = getGroup(ps);
//
// if (group != null) {
// try {
// User user = User.retrieve(userID);
// group.addMember(user);
// group.save();
// } catch (DataObjectNotFoundException exc) {
// // Ignore if user id is not valid
// } catch (PersistenceException pexc) {
// // Display error message that user
// // already existed in group.
// }
// }
// }
// subMemberSearch.reset(ps);
// subMemberSearch.setVisible(ps, false);
// addSubmemberLink.setVisible(ps, true);
// }
//
// });
//
// body.add(subMemberSearch);
// body.add(addSubmemberLink);
return main.addSegment(SUBMEMBER_HEADER, body);
}
/**
* Build extreme action panel.
*/
private Component buildExtremeActionPanel(final SegmentedPanel main) {
final BoxPanel body = new BoxPanel();
final ActionLink deleteLink = new ActionLink(DELETE_GROUP_LABEL);
deleteLink.setClassAttr("actionLink");
deleteLink.setConfirmation(GROUP_DELETE_CONFIRMATION);
// deleteLink.addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(final ActionEvent event) {
//
// PageState ps = event.getPageState();
// final Group group = (Group) requestLocalGroup.get(ps);
// if (group != null) {
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
// groupRepository.delete(group);
// try {
// group.delete();
// groupTree.setSelectedKey(ps, "-1");
// } catch (PersistenceException exc) {
// LOGGER.warn("Error deleting subgroup", exc);
// displayDeleteFailedPanel(ps);
// }
// }
// Select root node
// }
//
// });
// body.add(deleteLink);
return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER,
body);
}
/**
* Build a panel to display an error message when unable to delete group.
*/
private Component buildGroupDeleteFailedPanel(final SegmentedPanel main) {
final ActionLink link = new ActionLink(GROUP_ACTION_CONTINUE);
link.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
PageState ps = event.getPageState();
displayGroupInfoPanel(ps);
}
});
link.setClassAttr("actionLink");
final Label label = new Label(GROUP_DELETE_FAILED_MSG);
label.setClassAttr("deleteFailedMessage");
final BoxPanel panel = new BoxPanel();
panel.add(label);
panel.add(link);
return main.addSegment(GROUP_DELETE_FAILED_HEADER, panel);
}
/**
* Hides all components of the in preparation for turning selected
* components back on.
*/
private void hideAll(final PageState state) {
for (int i = 0; i < panelList.size(); i++) {
((Component) panelList.get(i)).setVisible(state, false);
}
}
/**
* Show all components of the in preparation for turning visibility of
* selected components off .
*/
private void showAll(final PageState state) {
for (int i = 0; i < panelList.size(); i++) {
((Component) panelList.get(i)).setVisible(state, true);
}
}
}
class SubGroupListModelBuilder extends LockableImpl implements ListModelBuilder {
private final GroupAdministrationTab parent;
public SubGroupListModelBuilder(final GroupAdministrationTab parent) {
this.parent = parent;
}
public ListModel makeModel(final List list, final PageState state) {
// final Group group = parent.getGroup(state);
// if (group != null) {
// return new SubGroupListModel(group.getSubgroups());
// }
return new SubGroupListModel(null);
}
}
/**
* CLASS
*
*/
class SubGroupListModel implements ListModel {
// private GroupCollection m_coll;
/**
*
* @param collection
*/
public SubGroupListModel(final Object collection) {
// m_coll = collection;
// m_coll.addOrder("lower(" + Group.DISPLAY_NAME + ") asc");
}
/**
*
* @return
*/
public Object getElement() {
// return m_coll.getGroup();
return null;
}
/**
*
* @return
*/
public String getKey() {
// return m_coll.getID().toString();
return null;
}
/**
*
* @return
*/
public boolean next() {
// if (m_coll != null) {
// return m_coll.next();
// }
return false;
}
}

View File

@ -1,115 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.FormProcessException;
import org.libreccm.cdi.utils.CdiUtil;
//import org.libreccm.core.Group;
//import org.libreccm.core.GroupRepository;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* Edit group form.
*
* @author David Dao
* @version $Id$
*/
class GroupEditForm extends GroupForm implements FormInitListener,
FormProcessListener {
private GroupAdministrationTab m_parent;
public GroupEditForm() {
this(null);
}
public GroupEditForm(final GroupAdministrationTab parent) {
super(GROUP_FORM_EDIT);
addInitListener(this);
addProcessListener(this);
m_parent = parent;
}
/**
* Initializes form elements by retrieving their values from the database.
*/
@Override
public void init(final FormSectionEvent event) {
final PageState state = event.getPageState();
final Long id = (Long) state.getValue(USER_ID_PARAM);
// if (id != null) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final GroupRepository groupRepository;
//
// groupRepository = cdiUtil.findBean(
// GroupRepository.class);
//
// final Group group = groupRepository.findById(id);
//
// m_name.setValue(state, group.getName());
// }
}
/**
* Processes the form.
*/
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final Long id = (Long) state.getValue(GROUP_ID_PARAM);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
if (id == null) {
throw new FormProcessException(GlobalizationUtil.globalize(
"ui.admin.groups.ID_is_null"));
}
// final Group group = groupRepository.findById(id);
// if (group == null) {
// throw new FormProcessException(GlobalizationUtil.globalize(
// "ui.admin.groups.couldnt_find_specified_group"));
// }
//
//
// final String name = (String) m_name.getValue(state);
// group.setName(name);
//
// groupRepository.save(group);
//
if (m_parent != null) {
m_parent.displayGroupInfoPanel(state);
}
}
}

View File

@ -1,65 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.Form;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.parameters.EmailParameter;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.ColumnPanel;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* Base form for add/edit group.
*
* @author David Dao
* @version $Id$
*/
class GroupForm extends Form {
protected TextField m_name;
// protected TextField m_email;
public GroupForm(String formName) {
super(formName);
m_name = new TextField(new StringParameter(GROUP_FORM_INPUT_NAME));
m_name.setMaxLength(200);
m_name.addValidationListener(new NotEmptyValidationListener());
m_name.addValidationListener(new StringLengthValidationListener (200));
add(GROUP_FORM_LABEL_NAME);
add(m_name);
// m_email = new TextField(new EmailParameter(GROUP_FORM_INPUT_PRIMARY_EMAIL));
// m_email.setMaxLength(100);
// add(GROUP_FORM_LABEL_PRIMARY_EMAIL);
// add(m_email);
// Submit button
add(new Submit(GROUP_FORM_SUBMIT), ColumnPanel.CENTER |
ColumnPanel.FULL_WIDTH);
}
}

View File

@ -1,119 +0,0 @@
/*
* Copyright (C) 2006 Chris Gilbert. All Rights Reserved.
*
* 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 org.apache.log4j.Logger;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* @author cgyg9330
*
* Search for groups to add as subgroups. Text entered by user is put into a
* groupName like '%......%' query, which also excludes problematic results
* (groups that are already supergroups or subgroups of the current group
*
*/
public class GroupSearchForm extends Form implements FormProcessListener,
AdminConstants {
private ExistingGroupAddPane parentPane;
private TextField m_search;
// private List<Group> results = null;
private static final Logger s_log = Logger.getLogger(GroupSearchForm.class);
public GroupSearchForm(ExistingGroupAddPane parent) {
super("SearchGroups", new SimpleContainer());
parentPane = parent;
setMethod(Form.POST);
addProcessListener(this);
add(GROUP_SEARCH_LABEL);
add(new Label("&nbsp;", false));
StringParameter searchParam = new StringParameter(SEARCH_QUERY);
m_search = new TextField(searchParam);
m_search.addValidationListener(new NotEmptyValidationListener());
m_search.setSize(20);
add(m_search, ColumnPanel.RIGHT);
Submit submit = new Submit("submit");
submit.setButtonLabel(SEARCH_BUTTON);
add(submit, ColumnPanel.LEFT);
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
PageState state = event.getPageState();
// Group parent = parentPane.getParentGroup(state);
// String search = (String) m_search.getValue(state);
//
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
// results = groupRepository.searchGroupByName(search);
//
//
// if (results.isEmpty()) {
// parentPane.showNoResults(state);
// } else {
// // put search string into Page
// state.setValue(getSearchString(), m_search.getValue(state));
// parentPane.showGroups(state);
// }
}
/**
*
* allow other classes to get hold of the results, to avoid constructing the
* same query in several places
*
* @return
*/
// public List<Group> getResults() {
// return Collections.unmodifiableList(results);
// }
private ParameterModel getSearchString() {
return parentPane.getSearchString();
}
}

View File

@ -1,155 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.PageState;
import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeNode;
import org.libreccm.security.Group;
import java.util.Iterator;
/**
*
*
* @author David Dao
*
*/
public class GroupTreeModel implements TreeModel {
// private class GroupIterator implements Iterator {
//
// private List< m_coll;
//
// public GroupIterator(ACSObjectCollection coll) {
// m_coll = coll;
// }
//
// public boolean hasNext() {
// return m_coll.next();
// }
//
// public Object next() {
// return new GroupTreeNode(m_coll.getACSObject());
// }
//
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
/**
* Obtain the root folder of the tree
*
* @param state
*
* @return
*/
@Override
public TreeNode getRoot(final PageState state) {
return new RootTreeNode();
}
/**
* Check whether a given node has children
*
* @param node
* @param state
*
* @return
*/
@Override
public boolean hasChildren(final TreeNode node, final PageState state) {
if (node instanceof RootTreeNode) {
return true;
} else {
return false;
}
}
/**
* Get direct children in this node.
*
* @param node
* @param state
*
* @return
*/
@Override
public Iterator<Group> getChildren(final TreeNode node,
final PageState state) {
//
// if (node instanceof RootTreeNode) {
//
// final CdiUtil cdiUtil = new CdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil.findBean(GroupRepository.class);
// final List<Group> groups = groupRepository.findAll();
//
// return groups.iterator();
// } else {
// return null;
// }
throw new UnsupportedOperationException();
}
//
}
class RootTreeNode implements TreeNode {
@Override
public Object getKey() {
return "-1";
}
@Override
public Object getElement() {
return "/";
}
}
class GroupTreeNode implements TreeNode {
private String m_key;
private String m_name;
public GroupTreeNode(Group group) {
// m_key = Long.toString(group.getSubjectId());
m_name = group.getName();
}
@Override
public Object getKey() {
return m_key;
}
@Override
public Object getElement() {
return m_name;
}
}

View File

@ -1,39 +0,0 @@
/*
* 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.PageState;
import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeModelBuilder;
import com.arsdigita.util.LockableImpl;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class GroupTreeModelBuilder extends LockableImpl implements TreeModelBuilder {
public TreeModel makeModel(final Tree tree, final PageState state) {
tree.expand("-1", state);
return new GroupTreeModel();
}
}

View File

@ -1,83 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.list.ListModel;
import org.libreccm.security.Party;
import java.util.List;
/**
*
* @version $Id$
*/
class PartyListModel implements ListModel {
private final List<Party> m_parties;
private Party m_currentParty = null;
private int index = 0;
/**
* Constructor for the list
* Builds the list of party list model for parties
*
* @param partys the partyCollection
**/
public PartyListModel(final List<Party> parties) {
m_parties = parties;
}
/**
* Check whether is an another party
*
* @return true if another party exist, false otherwise
**/
@Override
public boolean next() {
if (index < m_parties.size()) {
index++;
m_currentParty = m_parties.get(index);
return true;
} else {
return false;
}
}
/**
* Returns the unqiue ID string for current Party
*
* @return the unqiue ID string for current Party
**/
@Override
public String getKey() {
return Long.toString(m_currentParty.getPartyId());
}
/**
* Returns the current Party
*
* @return the current Party
**/
@Override
public Object getElement() {
return m_currentParty.getPartyId();
}
}

View File

@ -1,189 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.ActionLink;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.bebop.event.ChangeListener;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
*
* @author David Dao
*/
class SearchAndList extends SimpleContainer
implements AdminConstants,
Resettable {
/**
* String catalog.
*/
private static final String FORM_INPUT_NAME = "query";
private static final GlobalizedMessage LABEL_SUBMIT = new GlobalizedMessage(
"ui.admin.searchAndList.submit",
BUNDLE_NAME);
private static final GlobalizedMessage SEARCH_AGAIN = new GlobalizedMessage(
"ui.admin.searchAndList.submitAgain",
BUNDLE_NAME);
private Form m_searchForm;
private List m_searchResultList;
private ParameterModel m_queryModel;
private SearchAndListModel m_listModel;
private SimpleContainer m_searchResultContainer;
private class SearchListModelBuilder extends LockableImpl
implements ListModelBuilder {
public ListModel makeModel(List l, PageState state) {
return m_listModel;
}
}
private ListModelBuilder m_listModelBuilder = new SearchListModelBuilder();
private FormProcessListener m_formProcessListener
= new FormProcessListener() {
public void process(FormSectionEvent e) throws FormProcessException {
FormData data = e.getFormData();
PageState state = e.getPageState();
String query = (String) data.get(FORM_INPUT_NAME);
boolean visible = false;
if (query == null || query.equals("")) {
visible = true;
} else {
visible = false;
}
m_listModel.setQuery(query);
m_searchForm.setVisible(state, visible);
m_searchResultContainer.setVisible(state, !visible);
}
};
public SearchAndList(String name) {
super();
/**
* Create a search form.
*/
m_searchForm = new Form(name, new BoxPanel(BoxPanel.HORIZONTAL));
m_queryModel = new StringParameter(FORM_INPUT_NAME);
TextField query = new TextField(m_queryModel);
query.addValidationListener(new NotNullValidationListener());
m_searchForm.add(query);
m_searchForm.add(new Submit(LABEL_SUBMIT));
m_searchForm.addProcessListener(m_formProcessListener);
add(m_searchForm);
/**
* Create a search result container.
*/
m_searchResultContainer = new SimpleContainer();
add(m_searchResultContainer);
m_searchResultList = new List();
m_searchResultList.setClassAttr("SearchResultList");
m_searchResultList.setModelBuilder(m_listModelBuilder);
ActionLink link = new ActionLink(new Label(SEARCH_AGAIN));
link.setClassAttr("actionLink");
link.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState();
m_searchForm.setVisible(state, true);
m_searchResultContainer.setVisible(state, false);
}
});
m_searchResultContainer.add(m_searchResultList);
m_searchResultContainer.add(link);
}
public void addChangeListener(ChangeListener l) {
m_searchResultList.addChangeListener(l);
}
public Object getSelectedKey(PageState ps) {
return m_searchResultList.getSelectedKey(ps);
}
public void clearSelection(PageState ps) {
m_searchResultList.clearSelection(ps);
}
public void setListModel(SearchAndListModel model) {
m_listModel = model;
}
public void setResultCellRenderer(ListCellRenderer r) {
m_searchResultList.setCellRenderer(r);
}
public void register(Page p) {
p.setVisibleDefault(m_searchForm, true);
p.setVisibleDefault(m_searchResultContainer, false);
}
public void reset(PageState ps) {
m_searchResultContainer.setVisible(ps, false);
m_searchForm.setVisible(ps, true);
clearSelection(ps);
}
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.list.ListModel;
/**
*
*
* @author David Dao
* @version $Id$
*/
public interface SearchAndListModel extends ListModel {
/**
* Specify the user's search.
*/
public void setQuery (String query);
}

View File

@ -1,166 +0,0 @@
/*
* Copyright (C) 2006 Chris Gilbert. All Rights Reserved.
*
* 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 java.math.BigDecimal;
import java.util.TooManyListenersException;
import org.apache.log4j.Logger;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.CheckboxGroup;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.OptionGroup;
import com.arsdigita.bebop.form.Submit;
import org.libreccm.security.Group;
import java.util.List;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
* @author cgyg9330
*
* contains a form that allows the user to select desired groups to be added as
* subgroups to the currently selected group
*
* NB could be improved with cancel button - currently need to use browser back
* button
*/
public class SelectGroups {
private static final Logger s_log = Logger.getLogger(SelectGroups.class);
private static final String GROUPS_CBG = "groups_cbg";
private BoxPanel groupPanel;
private CheckboxGroup groups;
private Form form;
private Submit save;
private ExistingGroupAddPane parentPane;
private GroupSearchForm searchForm;
public SelectGroups(ExistingGroupAddPane parent, GroupSearchForm searchForm) {
parentPane = parent;
makeForm();
groupPanel = new BoxPanel();
groupPanel.add(form);
this.searchForm = searchForm;
}
/**
* Builds the form used to select groups.
*/
private void makeForm() {
form = new Form("ChooseGroups", new BoxPanel());
form.setMethod(Form.POST);
form.addSubmissionListener(new AddGroupsSubmissionListener());
form.add(PICK_GROUPS);
groups = new CheckboxGroup(GROUPS_CBG);
groups.setClassAttr("vertical");
try {
groups.addPrintListener(new GroupSearchPrintListener());
} catch (TooManyListenersException e) {
throw new RuntimeException(e.getMessage());
}
form.add(groups);
save = new Submit("save", SAVE_BUTTON);
form.add(save);
}
public BoxPanel getPanel() {
return groupPanel;
}
/**
*
* FormSubmissionListener that sets selected groups to be subgroups of the
* currently selected group
*
*/
private class AddGroupsSubmissionListener
implements FormSubmissionListener {
public void submitted(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
FormData data = e.getFormData();
String[] selectedGroups = (String[]) data.get(GROUPS_CBG);
BigDecimal groupID = null;
Group child = null;
// if (selectedGroups != null) {
// Group parent = parentPane.getParentGroup(state);
// for (int i = 0; i < selectedGroups.length; i++) {
// groupID = new BigDecimal(selectedGroups[i]);
// try {
// child = new Group(groupID);
// } catch (DataObjectNotFoundException e2) {
// s_log.warn("Non existant Group " + child
// + " selected to be child of " + parent);
// }
// parent.addSubgroup(child);
// parent.save();
// }
// }
parentPane.showSearch(state);
parentPane.getParentPage().displayGroupInfoPanel(state);
}
}
/**
*
* @author cgyg9330
*
* Printlistener retrieves query results from the groupsearch form and uses
* them as the entries on the checkbox group
*/
private class GroupSearchPrintListener implements PrintListener {
public void prepare(PrintEvent e) {
PageState state = e.getPageState();
OptionGroup cbg = (CheckboxGroup) e.getTarget();
// List<Group> results = searchForm.getResults();
String groupID;
String groupName;
Group child;
// for(Group group : results) {
// child = group;
// groupID = Long.toString(child.getSubjectId());
// groupName = child.getName();
// cbg.addOption(new Option(groupID, groupName));
// }
}
}
}

View File

@ -1,161 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.list.ListModelBuilder;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ActionEvent;
import org.libreccm.cdi.utils.CdiUtil;
import static com.arsdigita.ui.admin.AdminConstants.*;
/**
*
*
* @author David Dao
*
*/
class SubMemberPanel extends BoxPanel {
private List m_memberList;
private GroupAdministrationTab m_mainTab;
public SubMemberPanel(final GroupAdministrationTab tab) {
m_mainTab = tab;
m_memberList = new List(new SubMemberListModelBuilder(tab));
m_memberList.setCellRenderer(new ListCellRenderer() {
@Override
public Component getComponent(final List list,
final PageState state,
final Object value,
final String key,
final int index,
final boolean isSelected) {
final BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
// Label label = new Label(((User) value).getScreenName());
// panel.add(label);
ControlLink removeLink = new ControlLink(REMOVE_SUBMEMBER_LABEL);
removeLink.setClassAttr("actionLink");
panel.add(removeLink);
return panel;
}
});
m_memberList.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final String key = (String) m_memberList.getSelectedKey(state);
if (key != null) {
final Long userID = new Long(key);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// final GroupManager groupManager;
// final GroupRepository groupRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// groupManager = cdiUtil.findBean(GroupManager.class);
// groupRepository = cdiUtil.findBean(GroupRepository.class);
//
// final User user = userRepository.findById(userID);
// final Group group = m_mainTab.getGroup(state);
// if (group != null) {
// groupManager.removeUserFromGroup(user, group);
// groupRepository.save(group);
// }
}
}
});
add(m_memberList);
}
}
class SubMemberListModelBuilder extends LockableImpl
implements ListModelBuilder {
private GroupAdministrationTab m_mainTab;
public SubMemberListModelBuilder(final GroupAdministrationTab tab) {
m_mainTab = tab;
}
@Override
public ListModel makeModel(final List list, final PageState state) {
// final Group group = m_mainTab.getGroup(state);
// final java.util.List<GroupMembership> members;
// if (group == null) {
// members = null;
// } else {
// members = group.getMembers();
// }
// return new SubMemberListModel(members);
throw new UnsupportedOperationException();
}
}
//class SubMemberListModel implements ListModel {
//
//// private final java.util.List<GroupMembership> members;
// private int index;
//
//
// public SubMemberListModel(final java.util.List<GroupMembership> members) {
// this.members = members;
// }
//
// @Override
// public Object getElement() {
// return members.get(index);
// }
//
// @Override
// public String getKey() {
// return Long.toString(members.get(index).getMembershipId());
// }
//
// @Override
// public boolean next() {
// if (index < members.size()) {
// index++;
// return true;
// } else {
// return false;
// }
// }
//}

View File

@ -41,9 +41,8 @@ import org.xml.sax.SAXException;
/** /**
* *
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id: SystemInformationTab.java 2923 2014-10-27 18:55:26Z jensp $
*/ */
public class SystemInformationTab extends LayoutPanel implements AdminConstants { public class SystemInformationTab extends LayoutPanel {
public SystemInformationTab() { public SystemInformationTab() {
super(); super();
@ -273,9 +272,7 @@ public class SystemInformationTab extends LayoutPanel implements AdminConstants
case SAX_PARSER_INDEX: case SAX_PARSER_INDEX:
try { try {
return SAXParserFactory.newInstance().newSAXParser().getClass().getName(); return SAXParserFactory.newInstance().newSAXParser().getClass().getName();
} catch(ParserConfigurationException ex) { } catch(ParserConfigurationException | SAXException ex) {
return "???";
} catch(SAXException ex) {
return "???"; return "???";
} }
default: default:

View File

@ -1,192 +0,0 @@
/*
* 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.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.TabbedPane;
import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.LayoutPanel;
import static com.arsdigita.ui.admin.AdminConstants.*;
import com.arsdigita.util.Assert;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.xml.Element;
import java.util.ArrayList;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
class UserAdministrationTab extends LayoutPanel {
private final List sections;
private final java.util.List<Component> components = new ArrayList<>();
private final java.util.List<Label> keys = new ArrayList<>();
private final GlobalizedMessage title = USER_NAVBAR_TITLE;
public UserAdministrationTab(final TabbedPane parent, final GroupAdministrationTab groupAdminTab) {
super();
setClassAttr("sidebarNavPanel");
sections = new List(new GlobalizedTabModelBuilder());
sections.addChangeListener(new SectionChangeListener());
sections.setClassAttr("navbar");
setLeft(sections);
// final UserBrowsePane browsePane = new UserBrowsePane();
// final UserSummarySection summarySection = new UserSummarySection(
// this, browsePane);
// final UserSearchSection searchSection = new UserSearchSection(
// this, browsePane);
// final UserCreateSection createSection = new UserCreateSection(this);
//
// browsePane.setTabbedPane(parent);
// browsePane.setGroupAdministrationTab(groupAdminTab);
//
//// final BoxPanel body = new BoxPanel();
////// addSection(USER_TAB_SUMMARY, summarySection, body);
////// addSection(USER_TAB_BROWSE, browsePane, body);
////// addSection(USER_TAB_SEARCH, searchSection, body);
////// addSection(USER_TAB_CREATE_USER, createSection, body);
//
// setBody(body);
}
/**
*
* @pre label != null && c != null
*/
private void addSection(final Label label, final Component component, final BoxPanel panel) {
Assert.isUnlocked(this);
components.add(component);
component.setClassAttr("main");
panel.add(component);
keys.add(label);
}
/**
*
* @param page
*/
@Override
public void register(final Page page) {
Assert.isUnlocked(this);
for (int i = 0; i < components.size(); i++) {
page.setVisibleDefault(components.get(i), false);
}
}
public void setSection(final int index, final PageState state) {
sections.setSelectedKey(state, String.valueOf(index));
for (int i = 0; i < components.size(); i++) {
if (i == index) {
(components.get(i)).setVisible(state, true);
((Resettable) components.get(i)).reset(state);
} else {
(components.get(i)).setVisible(state, false);
}
}
}
@Override
public void generateXML(final PageState state, final Element parent) {
super.generateXML(state, parent);
/**
* Globalized navbar title.
* Why did I override generateXML method to globalize the title?
* Because CMS put title bar as an attribute of element. This
* is the only method I could come up with.
*/
final Element child = (Element) parent.getChildren().get(0);
child.addAttribute("navbar-title",
(String) title.localize(state.getRequest()));
}
private class SectionChangeListener implements ChangeListener {
public SectionChangeListener() {
//Nothing
}
@Override
public void stateChanged(final ChangeEvent event) {
final PageState state = event.getPageState();
final int selectedIndex = Integer.parseInt((String) sections.getSelectedKey(state));
setSection(selectedIndex, state);
}
}
private class GlobalizedTabModelBuilder extends LockableImpl implements ListModelBuilder {
public GlobalizedTabModelBuilder() {
super();
}
@Override
public ListModel makeModel(final List list, final PageState state) {
return new TabNameListModel(state);
}
}
private class TabNameListModel implements ListModel {
private int index = -1;
private final PageState pageState;
public TabNameListModel(final PageState state) {
pageState = state;
}
@Override
public Object getElement() {
return keys.get(index).getLabel(pageState);
}
@Override
public String getKey() {
return String.valueOf(index);
}
public boolean next() {
final boolean result = (index < keys.size() - 1);
//return (index++ < keys.size() - 1);
index++;
return result;
}
}
}

View File

@ -1,758 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.ActionLink;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.List;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.TabbedPane;
// import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionEvent;
// import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.UI;
import com.arsdigita.web.URL;
import com.arsdigita.web.RedirectSignal;
import static com.arsdigita.ui.admin.AdminConstants.*;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.User;
/**
* This pane contains three main segmented panel which only one is visible at
* any given time. The first panel is a table listing all available users in the
* system. The second panel displays read only user information. And the third
* panel is edit form.
*
* @author David Dao
* @author Ron Henderson
* @version $Id$
*/
class UserBrowsePane extends SegmentedPanel
implements TableCellRenderer,
TableActionListener,
Resettable,
ActionListener,
ChangeListener {
private static final Logger s_log = Logger.getLogger(UserBrowsePane.class);
private Component m_userBrowsePanel;
private Component m_userInfoPanel;
private Component m_userEditPanel;
private Component m_userPasswordPanel;
private Component m_groupMembershipPanel;
private Component m_actionPanel;
private Component m_extremeActionPanel;
private Component m_userDeleteFailedPanel;
private GroupAdministrationTab m_groupAdministrationTab;
private TabbedPane m_tabbedPane;
private List m_groupList = null;
private ArrayList m_panelList = new ArrayList();
private RequestLocal m_user;
@Override
public void register(Page p) {
for (int i = 0; i < m_panelList.size(); i++) {
p.setVisibleDefault((Component) m_panelList.get(i), false);
}
p.setVisibleDefault(m_userBrowsePanel, true);
p.addActionListener(this);
}
@Override
public void actionPerformed(final ActionEvent event) {
// final PageState state = event.getPageState();
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final CcmSessionContext sessionContext;
// sessionContext = cdiUtil.findBean(CcmSessionContext.class);
//
// final Subject subject = sessionContext.getCurrentSubject();
//
// final Long userID = (Long) state.getValue(USER_ID_PARAM);
//
// // Bug #167607 remove link for current user
// if (m_userInfoPanel.isVisible(state)) {
// if (subject.getSubjectId() == userID) {
// m_extremeActionPanel.setVisible(state, false);
// } else {
// m_extremeActionPanel.setVisible(state, true);
// }
// }
}
/**
* Creates a new UserBrowsePane with multiple panels to help manage various
* aspects of a user's account.
*/
public UserBrowsePane() {
m_user = new RequestLocal() {
@Override
protected Object initialValue(final PageState state) {
final Long id = (Long) state.getValue(USER_ID_PARAM);
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
//
// final User user = userRepository.findById(id);
// if (user == null) {
// throw new UncheckedWrapperException(String.format(
// "Failed to retrieve user: %d", id));
// }
// return user;
throw new UnsupportedOperationException();
}
};
m_userBrowsePanel = buildUserBrowsePanel();
m_panelList.add(m_userBrowsePanel);
m_userInfoPanel = buildUserInfoPanel();
m_panelList.add(m_userInfoPanel);
m_userEditPanel = buildUserEditPanel();
m_panelList.add(m_userEditPanel);
m_userPasswordPanel = buildUserPasswordPanel();
m_panelList.add(m_userPasswordPanel);
m_groupMembershipPanel = buildGroupMembershipPanel();
m_panelList.add(m_groupMembershipPanel);
m_actionPanel = buildActionPanel();
m_panelList.add(m_actionPanel);
m_extremeActionPanel = buildExtremeActionPanel();
m_panelList.add(m_extremeActionPanel);
m_userDeleteFailedPanel = buildUserDeleteFailedPanel();
m_panelList.add(m_userDeleteFailedPanel);
}
/**
* Get user object for this request.
*/
public User getUser(PageState ps) {
return (User) m_user.get(ps);
}
/**
* Build the User Information panel
*/
private Component buildUserInfoPanel() {
// Edit user link
ActionLink link = new ActionLink(new Label(new GlobalizedMessage(
"ui.admin.user.editlink",
BUNDLE_NAME)));
link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
displayEditPanel(ps);
}
});
link.setClassAttr("actionLink");
BoxPanel panel = new BoxPanel();
// panel.add(new UserInfo(this));
final ColumnPanel colPanel = new ColumnPanel(2);
colPanel.add(new Label(new GlobalizedMessage(
"ui.admin.user.userinfo.name", BUNDLE_NAME)));
final Label userName = new Label();
userName.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final Label target = (Label) event.getTarget();
final PageState state = event.getPageState();
final User user = getUser(state);
target.setLabel(user.getName());
}
});
colPanel.add(userName);
colPanel.add(new Label(new GlobalizedMessage(
"ui.admin.user.userinfo.screenname",
BUNDLE_NAME)));
final Label userScreenname = new Label();
userScreenname.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final Label target = (Label) event.getTarget();
final PageState state = event.getPageState();
final User user = getUser(state);
target.setLabel(user.getName());
}
});
colPanel.add(userScreenname);
colPanel.add(new Label(new GlobalizedMessage(
"ui.admin.user.userinfo.primaryemail",
BUNDLE_NAME)));
final Label userEmail = new Label();
userEmail.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final Label target = (Label) event.getTarget();
final PageState state = event.getPageState();
final User user = getUser(state);
target.setLabel(user.getEmailAddresses().get(0).getAddress());
}
});
colPanel.add(userEmail);
panel.add(colPanel);
panel.add(link);
return addSegment(USER_INFO_LABEL, panel);
}
/**
* Build the User Edit panel
*/
private Component buildUserEditPanel() {
return addSegment(USER_EDIT_PANEL_HEADER, new UserEditForm(this));
}
/**
* Build the User Password Update panel
*/
private Component buildUserPasswordPanel() {
BoxPanel p = new BoxPanel();
p.add(new UserPasswordForm(this));
p.add(new SimpleContainer("admin:PasswordNote", ADMIN_XML_NS));
return addSegment(USER_PASSWORD_PANEL_HEADER, p);
}
/**
* Build the Group Membership panel
*/
private Component buildGroupMembershipPanel() {
m_groupList = new List();
m_groupList.setClassAttr("UserGroupsResultList");
m_groupList.setModelBuilder(new GroupsModelBuilder());
m_groupList.addChangeListener(this);
return addSegment(USER_GROUP_PANEL_HEADER, m_groupList);
}
/**
* Build the Action panel
*/
private Component buildActionPanel() {
BoxPanel p = new BoxPanel();
// Update password link
ActionLink link = new ActionLink(UPDATE_USER_PASSWORD_LABEL);
link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
displayUserPasswordPanel(ps);
}
});
link.setClassAttr("actionLink");
p.add(link);
// Become user link
// This will not be shown when the user is banned to prevent security issues
link = new ActionLink(BECOME_USER_LABEL) {
public boolean isVisible(PageState s) {
if (!super.isVisible(s)) {
return false;
}
User u = getUser(s);
return (!u.isBanned());
}
};
link.setClassAttr("actionLink");
link.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
// final BigDecimal id = (BigDecimal) state.getValue(USER_ID_PARAM);
//
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final LoginManager loginManager;
// loginManager = cdiUtil.findBean(
// LoginManager.class);
//
// loginManager.login(CLASS, CLASS);
//
// try {
// UserContext uc = Web.getUserContext();
// uc.login(id);
// } catch (javax.security.auth.login.LoginException ex) {
// throw new UncheckedWrapperException("access denied", ex);
// }
// Redirect to workspace URL
final String path = UI.getUserRedirectURL(state.getRequest());
final URL url = URL.there(state.getRequest(), path);
throw new RedirectSignal(url, true);
}
});
p.add(link);
// Show all users
link = new ActionLink(new Label(new GlobalizedMessage(
"ui.admin.user.browselink",
BUNDLE_NAME)));
link.setClassAttr("actionLink");
link.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
displayUserBrowsePanel(ps);
}
});
p.add(link);
return addSegment(USER_ACTION_PANEL_HEADER, p);
}
/**
* Build the Extreme Action panel
*/
private Component buildExtremeActionPanel() {
ActionLink deleteLink = new ActionLink(USER_DELETE_LABEL) {
@Override
public boolean isVisible(PageState s) {
if (!super.isVisible(s)) {
return false;
}
// We show the delete link if the user has never published an item
// This implicitly checks whether the user is banned - if they
// are deletable they cannot ever have been banned
User u = getUser(s);
return false;
}
};
deleteLink.setClassAttr("actionLink");
deleteLink.setConfirmation(USER_DELETE_CONFIRMATION.localize()
.toString());
deleteLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final User user = getUser(state);
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// userRepository.delete(user);
displayUserBrowsePanel(state);
} // End ActionPerformed method
} // End of new ActionListener definition
);
// Add link inside a BoxPanel for correct alignment with other
// page elements.
ActionLink banLink = new ActionLink(USER_BAN_LABEL) {
@Override
public boolean isVisible(PageState s) {
if (!super.isVisible(s)) {
return false;
}
// We show the ban link if the user is not already banned and has never published
// an item
User u = getUser(s);
return (!u.isBanned());
}
};
banLink.setClassAttr("actionLink");
banLink.setConfirmation(USER_BAN_CONFIRMATION.localize().toString());
banLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// PageState state = e.getPageState();
// User user = getUser(state);
// user.setBanned(true);
//
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// userRepository.save(user);
} // End ActionPerformed method
} // End of new ActionListener definition
);
ActionLink unbanLink = new ActionLink(USER_UNBAN_LABEL) {
public boolean isVisible(PageState s) {
if (!super.isVisible(s)) {
return false;
}
PageState state = s.getPageState();
User user = getUser(state);
return user.isBanned();
}
};
unbanLink.setClassAttr("actionLink");
unbanLink.setConfirmation(USER_UNBAN_CONFIRMATION.localize().toString());
unbanLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// PageState state = e.getPageState();
// User user = getUser(state);
// user.setBanned(false);
//
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// userRepository.save(user);
} // End ActionPerformed method
} // End of new ActionListener definition
);
// Add link inside a BoxPanel for correct alignment with other
// page elements.
BoxPanel p = new BoxPanel();
p.add(deleteLink);
p.add(banLink);
p.add(unbanLink);
return addSegment(USER_TAB_EXTREME_ACTION_LABEL, p);
}
/**
* Build a panel to display an error message when unable to delete a user.
*/
private Component buildUserDeleteFailedPanel() {
ActionLink link = new ActionLink(USER_ACTION_CONTINUE);
link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState();
displayUserInfoPanel(state);
}
});
Label label = new Label(USER_DELETE_FAILED_MSG);
label.setClassAttr("deleteFailedMessage");
BoxPanel p = new BoxPanel();
p.add(label);
p.add(link);
return addSegment(USER_DELETE_FAILED_PANEL_HEADER, p);
}
/**
* Build the Browse User panel. Displays a list of all registered users.
*/
private Component buildUserBrowsePanel() {
String headers[] = new String[]{
"ID", "Name", "Screen Name", "Email", "SSO login"
};
Table table = new Table(new UserTableModelBuilder(), headers);
table.setClassAttr("AlternateTable");
table.setDefaultCellRenderer(this);
table.addTableActionListener(this);
return addSegment(BROWSE_USER_PANEL_HEADER, table);
}
private class GroupsModelBuilder extends LockableImpl
implements ListModelBuilder {
@Override
public ListModel makeModel(final List list, final PageState state) {
final User user = getUser(state);
// final java.util.List<GroupMembership> memberships = user
// .getGroupMemberships();
// final java.util.List<Subject> groups = new ArrayList<>();
// for (GroupMembership membership : memberships) {
// groups.add(membership.getGroup());
// }
// return new PartyListModel(groups);
throw new UnsupportedOperationException();
}
}
void displayUserInfoPanel(PageState ps) {
hideAll(ps);
m_userInfoPanel.setVisible(ps, true);
m_groupMembershipPanel.setVisible(ps, true);
m_actionPanel.setVisible(ps, true);
m_extremeActionPanel.setVisible(ps, true);
}
void displayEditPanel(PageState ps) {
hideAll(ps);
m_userEditPanel.setVisible(ps, true);
}
public void displayUserBrowsePanel(PageState ps) {
hideAll(ps);
m_userBrowsePanel.setVisible(ps, true);
}
public void displayUserPasswordPanel(PageState ps) {
hideAll(ps);
m_userPasswordPanel.setVisible(ps, true);
}
public void displayUserDeleteFailedPanel(PageState ps) {
hideAll(ps);
m_userDeleteFailedPanel.setVisible(ps, true);
}
/**
* Hides all components of the UserBrowsePane in preparation for turning
* selected components back on.
*/
private void hideAll(PageState ps) {
for (int i = 0; i < m_panelList.size(); i++) {
((Component) m_panelList.get(i)).setVisible(ps, false);
}
}
@Override
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row,
int col) {
if (col == 0) {
ControlLink link = new ControlLink(value.toString());
return link;
} else {
if (value != null) {
return new Label(value.toString());
} else {
return new Label("&nbsp;", false);
}
}
}
@Override
public void cellSelected(TableActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(USER_ID_PARAM, new BigDecimal((String) e.getRowKey()));
displayUserInfoPanel(ps);
}
@Override
public void headSelected(TableActionEvent e) {
// Empty
}
@Override
public void reset(PageState ps) {
displayUserBrowsePanel(ps);
}
public void setTabbedPane(TabbedPane tabbedPane) {
m_tabbedPane = tabbedPane;
}
public void setGroupAdministrationTab(
GroupAdministrationTab groupAdministrationTab) {
m_groupAdministrationTab = groupAdministrationTab;
}
// // This is how we check if a user is banned or not
// private boolean hasUserPublishedItems(User user) {
// DataQuery query = user.getSession().retrieveQuery(
// "com.arsdigita.versioning.UserPublications");
// query.setParameter("value", new Integer(user.getID().intValue()));
// query.next();
// Integer count = (Integer) query.get("theCount");
// query.close();
// return count.intValue() != 0;
// }
/**
* Display group information panel when a group name is clicked.
*/
@Override
public void stateChanged(final ChangeEvent event) {
if (event.getSource() == m_groupList) {
if (m_tabbedPane != null && m_groupAdministrationTab != null) {
PageState ps = event.getPageState();
String id = (String) m_groupList.getSelectedKey(ps);
if (id != null) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final GroupRepository groupRepository;
// groupRepository = cdiUtil
// .findBean(GroupRepository.class);
// final Group group = groupRepository.findById(Long.parseLong(
// id));
// m_groupAdministrationTab.setGroup(ps, group);
m_groupAdministrationTab.displayGroupInfoPanel(ps);
m_tabbedPane.setSelectedIndex(ps, GROUP_TAB_INDEX);
} else {
reset(ps);
}
}
}
}
}
class UserTableModelBuilder extends LockableImpl implements TableModelBuilder {
public TableModel makeModel(Table t, PageState s) {
return new UserTableModel();
}
}
class UserTableModel implements TableModel {
private final java.util.List<User> users;
private int index = 0;
public UserTableModel() {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// users = userRepository.findAll();
users = null;
}
@Override
public int getColumnCount() {
return 5;
}
@Override
public Object getElementAt(final int columnIndex) {
final User user = users.get(index);
// if (columnIndex == 0) {
// return user.getSubjectId();
// } else if (columnIndex == 1) {
// return String.format("%s %s",
// user.getName().getGivenName(),
// user.getName().getFamilyName());
// } else if (columnIndex == 2) {
// return user.getScreenName();
// } else if (columnIndex == 3) {
// return user.getEmailAddresses().get(0).getAddress();
// } else if (columnIndex == 4) {
// return user.getSsoLogin();
// } else {
// return null;
// }
return null;
}
@Override
public Object getKeyAt(final int columnIndex) {
return users.get(index).getPartyId();
}
@Override
public boolean nextRow() {
index++;
return index < users.size();
}
}

View File

@ -1,136 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import static com.arsdigita.ui.admin.AdminConstants.*;
import org.apache.log4j.Logger;
import org.libreccm.core.EmailAddress;
import org.libreccm.security.User;
/**
* Form used to edit the information for a user.
*
* @version $Id$
*/
class UserEditForm extends UserForm
implements FormInitListener,
FormProcessListener {
// Logging
private static final Logger s_log = Logger.getLogger(UserEditForm.class);
private UserBrowsePane m_browsePane;
/**
* Constructor
*/
public UserEditForm(UserBrowsePane browsePane) {
super(USER_FORM_EDIT);
m_browsePane = browsePane;
addInitListener(this);
addProcessListener(this);
}
/**
* Initialize the form
*/
public void init(FormSectionEvent e) {
PageState state = e.getPageState();
hideSecurityInfo(state);
// final User user = m_browsePane.getUser(state);
//
// final PersonName name = user.getName();
// m_firstName.setValue(state, name.getGivenName());
// m_lastName.setValue(state, name.getFamilyName());
//
// m_primaryEmail.setValue(state, user.getEmailAddresses().get(
// 0).getAddress());
//
// m_screenName.setValue(state, user.getScreenName());
//
// USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST.setVisible(state, true);
// m_emailList.setVisible(state, true);
}
/**
* Process the form
*/
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final User user = m_browsePane.getUser(state);
//
// final PersonName name = user.getName();
// name.setGivenName((String) m_firstName.getValue(state));
// name.setFamilyName((String) m_lastName.getValue(state));
//
// user.setScreenName((String) m_screenName.getValue(state));
//
// InternetAddress additional = (InternetAddress) m_additionalEmail
// .getValue(state);
// if (additional != null) {
// final EmailAddress additionalEmail = new EmailAddress();
// additional.setAddress(additional.getAddress());
// user.addEmailAddress(additionalEmail);
// }
// Check to see if the primary email address has changed, and
// if so set it to the new value and delete the association
// with the old. If it hasn't change don't do anything.
final EmailAddress oaddr = user.getEmailAddresses().get(0);
final EmailAddress naddr = new EmailAddress();
naddr.setAddress((String) m_primaryEmail.getValue(state));
if (!oaddr.equals(naddr)) {
if (s_log.isDebugEnabled()) {
s_log.debug("Changing primary email " + oaddr + " to " + naddr);
}
// user.addEmailAddress(naddr);
// user.removeEmailAddress(oaddr);
}
// final CdiUtil cdiUtil = new CdiUtil();
// final UserRepository userRepository;
// try {
// userRepository = cdiUtil.findBean(UserRepository.class);
// } catch(CdiLookupException ex) {
// throw new UncheckedWrapperException(ex);
// }
//
// userRepository.save(user);
m_browsePane.displayUserInfoPanel(state);
}
}

View File

@ -1,301 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.form.Password;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.EmailParameter;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.security.SecurityConfig;
import static com.arsdigita.ui.admin.AdminConstants.*;
import com.arsdigita.ui.login.PasswordValidationListener;
import com.arsdigita.util.StringUtils;
import org.libreccm.cdi.utils.CdiUtil;
import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;
/**
* Generic form for adding and editting user.
*
* @author David Dao
* @version $Id$
*/
class UserForm extends Form implements FormValidationListener, AdminConstants {
protected TextField m_firstName;
protected TextField m_lastName;
protected TextField m_primaryEmail;
protected TextField m_additionalEmail;
protected Password m_password;
protected Password m_confirmPassword;
protected TextField m_question;
protected TextField m_answer;
protected TextField m_screenName;
protected EmailList m_emailList;
private final PasswordValidationListener m_pwListener;
private final NotEmptyValidationListener m_notNullListener;
private final SecurityConfig securityConfig = SecurityConfig.getConfig();
public UserForm(String formName) {
super(formName);
m_pwListener = new PasswordValidationListener();
m_notNullListener = new NotEmptyValidationListener();
addValidationListener(this);
// Bug #163373 add length checking for first/last names. We
// do this with both maximum length parameters in the user/add
// form and with validation of the value that come in for
// processing.
int max = 60;
m_firstName = new TextField(
new StringParameter(USER_FORM_INPUT_FIRST_NAME));
m_firstName.setMaxLength(max);
m_firstName.setSize(20);
m_firstName.addValidationListener(new NotEmptyValidationListener());
m_firstName.addValidationListener(
new StringLengthValidationListener(max));
add(USER_FORM_LABEL_FIRST_NAME);
add(m_firstName);
m_lastName = new TextField(
new StringParameter(USER_FORM_INPUT_LAST_NAME));
m_lastName.setMaxLength(max);
m_lastName.setSize(25);
m_lastName.addValidationListener(new NotEmptyValidationListener());
m_lastName
.addValidationListener(new StringLengthValidationListener(max));
add(USER_FORM_LABEL_LAST_NAME);
add(m_lastName);
// Password
m_password = new Password(new StringParameter(USER_FORM_INPUT_PASSWORD));
add(USER_FORM_LABEL_PASSWORD);
add(m_password);
// Password confirmation
m_confirmPassword = new Password(new StringParameter(
USER_FORM_INPUT_PASSWORD_CONFIRMATION));
add(USER_FORM_LABEL_PASSWORD_CONFIRMATION);
add(m_confirmPassword);
// Password question
m_question
= new TextField(new StringParameter(USER_FORM_INPUT_QUESTION));
m_question.setSize(50);
if (securityConfig.isPasswordRecoveryEnabled()) {
add(USER_FORM_LABEL_QUESTION);
add(m_question);
}
// Password answer
m_answer = new TextField(new StringParameter(USER_FORM_INPUT_ANSWER));
m_answer.setSize(50);
if (securityConfig.isPasswordRecoveryEnabled()) {
add(USER_FORM_LABEL_ANSWER);
add(m_answer);
}
// Primary email address
m_primaryEmail = new TextField(new EmailParameter(
USER_FORM_INPUT_PRIMARY_EMAIL));
m_primaryEmail.addValidationListener(new NotEmptyValidationListener());
m_primaryEmail.setSize(50);
add(USER_FORM_LABEL_PRIMARY_EMAIL);
add(m_primaryEmail);
// Additional email addresses
m_emailList = new EmailList();
add(USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST);
add(m_emailList);
m_additionalEmail = new TextField(new EmailParameter(
USER_FORM_INPUT_ADDITIONAL_EMAIL));
m_additionalEmail.setSize(50);
add(USER_FORM_LABEL_ADDITIONAL_EMAIL);
add(m_additionalEmail);
// Screen name
m_screenName = new TextField(new StringParameter(
USER_FORM_INPUT_SCREEN_NAME));
if (KernelConfig.getConfig().screenNameIsPrimaryIdentifier()) {
m_screenName.addValidationListener(new NotEmptyValidationListener());
}
add(USER_FORM_LABEL_SCREEN_NAME);
add(m_screenName);
// Submit
add(new Label(""));
add(new Submit(USER_FORM_SUBMIT));
}
/**
* Validate the form. Verifies that the password and password-confirm fields
* match. If not it adds an error to the password-confirm field. Also
* verifies that primary email address and screen name are unique amoung all
* users.
*/
@Override
public void validate(FormSectionEvent event)
throws FormProcessException {
PageState ps = event.getPageState();
FormData data = event.getFormData();
HttpServletRequest req = ps.getRequest();
// UserID will be null if this is an add form.
BigDecimal userID = (BigDecimal) ps.getValue(USER_ID_PARAM);
/**
* Verify that password and confirmation match.
*/
if (userID == null) {
m_pwListener.validate(
new ParameterEvent(event.getSource(),
data.getParameter(
USER_FORM_INPUT_PASSWORD)));
m_notNullListener.validate(
new ParameterEvent(event.getSource(),
data.getParameter(
USER_FORM_INPUT_PASSWORD_CONFIRMATION)));
String password = (String) m_password.getValue(ps);
String confirm = (String) m_confirmPassword.getValue(ps);
if (!StringUtils.emptyString(password) && !StringUtils.emptyString(
confirm)) {
if (!password.equals(confirm)) {
data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION,
(String) USER_FORM_ERROR_PASSWORD_NOT_MATCH.
localize(req));
}
}
}
if (securityConfig.isPasswordRecoveryEnabled()) {
// If the password answer is anything but null, make sure it
// contains some non-whitespace characters
String answer = (String) m_answer.getValue(ps);
if (userID == null) {
// Check for add form.
if (answer == null || answer.trim().length() == 0) {
data.addError(USER_FORM_INPUT_ANSWER,
(String) USER_FORM_ERROR_ANSWER_NULL.localize(
req));
}
} else {
// Check for edit form
if (answer != null && answer.length() > 0 && answer.trim().
length()
== 0) {
data.addError(USER_FORM_INPUT_ANSWER,
(String) USER_FORM_ERROR_ANSWER_NULL.localize(
req));
}
}
}
/**
* Verify that primary email and screen name are unique
*/
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
//
// final String screenName = (String) m_screenName.getValue(ps);
// final User userByScreenname = userRepository.findByScreenName(
// screenName);
// final String email;
// if (m_primaryEmail.getValue(ps) != null) {
// email = ((InternetAddress) m_primaryEmail.getValue(ps)).getAddress();
// } else {
// email = null;
// }
// final User userByEmail = userRepository.findByEmailAddress(email);
//
// if (userByScreenname != null && screenName != null && screenName.equals(
// userByScreenname.getScreenName())) {
// data.addError(USER_FORM_INPUT_SCREEN_NAME,
// USER_FORM_ERROR_SCREEN_NAME_NOT_UNIQUE);
// }
//
// if (userByEmail != null
// && email != null
// && email.equals(userByEmail.getEmailAddresses().get(0).getAddress())) {
// data.addError(USER_FORM_INPUT_PRIMARY_EMAIL,
// USER_FORM_ERROR_PRIMARY_EMAIL_NOT_UNIQUE);
// }
}
/**
* Hide all security-related components
*/
protected void hideSecurityInfo(PageState state) {
setSecurityInfo(state, false);
}
/**
* Show all security-related components
*/
protected void showSecurityInfo(PageState state) {
setSecurityInfo(state, true);
}
private void setSecurityInfo(PageState state, boolean isVisible) {
USER_FORM_LABEL_PASSWORD.setVisible(state, isVisible);
USER_FORM_LABEL_PASSWORD_CONFIRMATION.setVisible(state, isVisible);
if (securityConfig.isPasswordRecoveryEnabled()) {
USER_FORM_LABEL_QUESTION.setVisible(state, isVisible);
USER_FORM_LABEL_ANSWER.setVisible(state, isVisible);
}
m_password.setVisible(state, isVisible);
m_confirmPassword.setVisible(state, isVisible);
if (securityConfig.isPasswordRecoveryEnabled()) {
m_question.setVisible(state, isVisible);
m_answer.setVisible(state, isVisible);
}
}
}

View File

@ -1,273 +0,0 @@
/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* 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.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.form.Password;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.mail.Mail;
import static com.arsdigita.ui.admin.AdminConstants.*;
import com.arsdigita.ui.login.PasswordValidationListener;
import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.User;
/**
* Form used to update a user's password. It just provides form elements to
* enter the new password and confirm it. If the user doesn't have an
* authentication record, it will be created as part of setting the new value of
* the password.
*
* @version $Id$
*/
class UserPasswordForm extends Form
implements FormInitListener,
FormProcessListener,
FormValidationListener {
// Logging
private static final Logger s_log = Logger.getLogger(UserPasswordForm.class
.getName());
// Constants
final static String PASSWORD_FORM_NAME = "password-update";
final static String NEW_PASSWORD_PARAM_NAME = "password-new";
final static String CONFIRM_PASSWORD_PARAM_NAME = "password-confirm";
private UserBrowsePane m_userBrowsePane;
private TextField m_question;
private TextField m_answer;
private TextField m_ssoLogin;
/**
* Constructor.
*/
public UserPasswordForm(UserBrowsePane pane) {
super(PASSWORD_FORM_NAME);
m_userBrowsePane = pane;
setMethod(Form.POST);
addInitListener(this);
addValidationListener(this);
addProcessListener(this);
// Password
Password newPassword = new Password(NEW_PASSWORD_PARAM_NAME);
newPassword.addValidationListener(new PasswordValidationListener());
add(PASSWORD_FORM_LABEL_PASSWORD);
add(newPassword);
// Password confirmation
Password confirmPassword = new Password(CONFIRM_PASSWORD_PARAM_NAME);
confirmPassword.addValidationListener(new NotNullValidationListener());
add(PASSWORD_FORM_LABEL_CONFIRMATION_PASSWORD);
add(confirmPassword);
// Password question
m_question
= new TextField(new StringParameter(USER_FORM_INPUT_QUESTION));
m_question.setSize(50);
m_question.addValidationListener(new NotEmptyValidationListener());
add(PASSWORD_FORM_LABEL_QUESTION);
add(m_question);
// Password answer
m_answer = new TextField(new StringParameter(USER_FORM_INPUT_ANSWER));
m_answer.setSize(50);
add(PASSWORD_FORM_LABEL_ANSWER);
add(m_answer);
m_ssoLogin = new TextField(new StringParameter(USER_FORM_INPUT_SSO));
m_ssoLogin.setSize(50);
add(USER_FORM_LABEL_SSO);
add(m_ssoLogin);
// submit button
add(new Label(""));
add(new Submit(PASSWORD_FORM_SUBMIT));
}
/**
* Initialize the form
*/
@Override
public void init(final FormSectionEvent event) {
final PageState state = event.getPageState();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// final User user = userRepository.findById((Long) state.getValue(
// USER_ID_PARAM));
//
// m_question.setValue(state, user.getPasswordQuestion());
// m_ssoLogin.setValue(state, user.getSsoLogin());
m_answer.setValue(state, "");
}
/**
* Validate the form input.
*/
@Override
public void validate(final FormSectionEvent event)
throws FormProcessException {
PageState state = event.getPageState();
FormData data = event.getFormData();
HttpServletRequest req = state.getRequest();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// userRepository = cdiUtil.findBean(UserRepository.class);
// final User user = userRepository.findById((Long) state.getValue(
// USER_ID_PARAM));
// if (user == null) {
// return;
// }
try {
// get parameter values
String newPassword = (String) data.get(NEW_PASSWORD_PARAM_NAME);
String confirmPassword = (String) data.get(
CONFIRM_PASSWORD_PARAM_NAME);
// check new password
if (!newPassword.equals(confirmPassword)) {
data.addError(CONFIRM_PASSWORD_PARAM_NAME,
(String) USER_FORM_ERROR_PASSWORD_NOT_MATCH
.localize(req));
return;
}
} finally {
if (!data.isValid()) {
// clear passwords from form data
data.put(NEW_PASSWORD_PARAM_NAME, "");
data.put(CONFIRM_PASSWORD_PARAM_NAME, "");
}
}
// If the password answer is anything but null, make sure it
// contains some non-whitespace characters
String answer = (String) m_answer.getValue(state);
if (answer != null && answer.length() > 0 && answer.trim().length() == 0) {
data.addError(USER_FORM_INPUT_ANSWER,
(String) USER_FORM_ERROR_ANSWER_NULL.localize(req));
}
}
/**
* Process the form
*/
public void process(FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final UserRepository userRepository;
// final UserManager userManager;
// userRepository = cdiUtil.findBean(UserRepository.class);
// userManager = cdiUtil.findBean(UserManager.class);
// final User user = userRepository.findById((Long) state.getValue(
// USER_ID_PARAM));
// if (user == null) {
// throw new FormProcessException(GlobalizationUtil.globalize(
// "ui.admin.user.userpasswordform.retrieving_user_failed"));
// }
// userManager.updatePassword(user, (String) data.get(NEW_PASSWORD_PARAM_NAME));
// user.setPasswordQuestion((String) m_question.getValue(state));
// final String answer = (String) m_answer.getValue(state);
// if (answer != null && answer.length() > 0) {
// user.setPasswordAnswer(answer);
// }
// user.setSsoLogin((String) m_ssoLogin.getValue(state));
//
// userRepository.save(user);
BigDecimal id = (BigDecimal) state.getValue(USER_ID_PARAM);
s_log.debug("Committed password change");
// notifyUser(user);
m_userBrowsePane.displayUserInfoPanel(state);
}
/**
* Notify user of the change to their password.
*
* TODO:
* <ol>
* <li>Message should be from the syadmin</li>
* <li>Globalize the subject and content</li>
* </ol>
*
* @param user is the User who's password was just changed.
*/
private void notifyUser(final User user) {
String to = user.getEmailAddresses().get(0).getAddress();
String from = to;
String subject = "Your password has been changed";
String nl = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer();
sb.append("Dear ");
sb.append(user.getGivenName());
sb.append(":");
sb.append(nl).append(nl);
sb.append("Your password has been changed by the ");
sb.append("system administrator.");
sb.append(nl);
try {
Mail.send(to, from, subject, sb.toString());
} catch (javax.mail.MessagingException e) {
s_log.error("Failed to notify user of password change");
}
}
}

View File

@ -22,27 +22,31 @@ import com.arsdigita.bebop.Form;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**
* An abstract class providing a default implementation of {@link ApplicationManager#getApplicationCreateForm()}. * An abstract class providing a default implementation of
* * {@link ApplicationManager#getApplicationCreateForm()}.
* @param <T> Type of the application for which this ApplicationManager provides the administration forms. *
* * @param <T> Type of the application for which this ApplicationManager provides
* the administration forms.
*
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$ * @version $Id: AbstractSingletonApplicationManager.java 3703 2015-10-21
* 08:52:39Z jensp $
*/ */
public abstract class AbstractSingletonApplicationManager<T extends CcmApplication> implements ApplicationManager<T>{ public abstract class AbstractSingletonApplicationManager<T extends CcmApplication>
implements ApplicationManager<T> {
/** /**
* Implementation of {@link ApplicationManager#getApplicationCreateForm()} * Implementation of {@link ApplicationManager#getApplicationCreateForm()}
* for singleton applications. * for singleton applications.
* *
* @return {@code} null because it is not possible to create instances * @return {@code} null because it is not possible to create instances of
* of singleton applications. * singleton applications.
*/ */
@SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract")
@Override @Override
public final Form getApplicationCreateForm() { public final Form getApplicationCreateForm() {
return null; return null;
} }
} }

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.applications;
import org.libreccm.web.ApplicationCreator; import org.libreccm.web.ApplicationCreator;
import org.libreccm.web.ApplicationRepository; import org.libreccm.web.ApplicationRepository;
@ -26,7 +26,7 @@ import org.libreccm.web.CcmApplication;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import static com.arsdigita.ui.admin.AdminConstants.*; import static com.arsdigita.ui.admin.AdminUiConstants.*;
/** /**
* *

View File

@ -16,23 +16,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.applications;
import java.util.UUID; import java.util.UUID;
import org.libreccm.modules.InstallEvent; import org.libreccm.modules.InstallEvent;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import org.libreccm.web.AbstractCcmApplicationSetup; import org.libreccm.web.AbstractCcmApplicationSetup;
import javax.persistence.EntityManager; import static com.arsdigita.ui.admin.AdminUiConstants.*;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class AdminApplicationSetup extends AbstractCcmApplicationSetup { public class AdminApplicationSetup extends AbstractCcmApplicationSetup {
public static final String ADMIN_APP_NAME = "CcmAdmin"; public static final String ADMIN_APP_NAME = "CcmAdmin";
public AdminApplicationSetup(final InstallEvent event) { public AdminApplicationSetup(final InstallEvent event) {
super(event); super(event);
} }
@ -41,12 +42,10 @@ public class AdminApplicationSetup extends AbstractCcmApplicationSetup {
public void setup() { public void setup() {
final CcmApplication admin = new CcmApplication(); final CcmApplication admin = new CcmApplication();
admin.setUuid(UUID.randomUUID().toString()); admin.setUuid(UUID.randomUUID().toString());
admin.setApplicationType(ADMIN_APP_NAME); admin.setApplicationType(ADMIN_APP_TYPE);
admin.setPrimaryUrl(AdminConstants.ADMIN_PAGE_URL); admin.setPrimaryUrl(ADMIN_PAGE_URL);
getEntityManager().persist(admin); getEntityManager().persist(admin);
} }
} }

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.tree.TreeNode;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.web.CcmApplication;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ApplicationInstanceTreeNode implements TreeNode {
private final CcmApplication application;
public ApplicationInstanceTreeNode(final CcmApplication application) {
this.application = application;
}
@Override
public Object getKey() {
return application.getObjectId();
}
@Override
public Object getElement() {
final GlobalizationHelper globalizationHelper = CdiUtil.createCdiUtil()
.findBean(GlobalizationHelper.class);
return application.getTitle().getValue(globalizationHelper
.getNegotiatedLocale());
}
public CcmApplication getApplication() {
return application;
}
}

View File

@ -19,8 +19,9 @@
package com.arsdigita.ui.admin.applications; package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**

View File

@ -16,9 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.applications;
import com.arsdigita.ui.admin.applications.ApplicationManager;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -0,0 +1,160 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeNode;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.web.ApplicationRepository;
import org.libreccm.web.ApplicationType;
import org.libreccm.web.CcmApplication;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ApplicationTreeModel implements TreeModel {
public ApplicationTreeModel() {
}
@Override
public TreeNode getRoot(final PageState state) {
return new RootTreeNode();
}
@Override
public boolean hasChildren(final TreeNode node,
final PageState state) {
if (node instanceof RootTreeNode) {
return true;
} else if (node instanceof ApplicationTypeTreeNode) {
final ApplicationTypeTreeNode typeNode
= (ApplicationTypeTreeNode) node;
final ApplicationType appType = typeNode.getApplicationType();
if (appType.singleton()) {
return false;
} else {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplicationRepository appRepo = cdiUtil.findBean(
ApplicationRepository.class);
final List<CcmApplication> apps = appRepo.findByType(appType
.name());
return !apps.isEmpty();
}
} else if (node instanceof ApplicationInstanceTreeNode) {
return false;
} else {
throw new IllegalArgumentException(
"The ApplicationTreeModel can only work with "
+ "ApplicationTypeTreeNodes and "
+ "ApplicationInstanceTreeNodes.");
}
}
@Override
public Iterator getChildren(final TreeNode node,
final PageState state) {
if (node instanceof RootTreeNode) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final org.libreccm.web.ApplicationManager appManager = cdiUtil
.findBean(org.libreccm.web.ApplicationManager.class);
return new AppTypesIterator(appManager.getApplicationTypes()
.values());
} else if (node instanceof ApplicationTypeTreeNode) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplicationRepository appRepo = cdiUtil.findBean(
ApplicationRepository.class);
return new AppIterator(appRepo.findByType(
((ApplicationTypeTreeNode) node).getApplicationType().name()));
} else {
throw new IllegalArgumentException(
"ApplicationTreeModel#getChildren can only process "
+ "the RootTreeNode and the instances of "
+ "ApplicationTypeTreeNode.");
}
}
private class RootTreeNode implements TreeNode {
public RootTreeNode() {
//Nothing
}
@Override
public Object getKey() {
return "-1";
}
@Override
public Object getElement() {
return "/";
}
}
private class AppTypesIterator
implements Iterator<ApplicationTypeTreeNode> {
private final Iterator<ApplicationType> appTypes;
public AppTypesIterator(final Collection<ApplicationType> appTypes) {
this.appTypes = appTypes.iterator();
}
@Override
public boolean hasNext() {
return appTypes.hasNext();
}
@Override
public ApplicationTypeTreeNode next() {
return new ApplicationTypeTreeNode(appTypes.next());
}
}
private class AppIterator implements Iterator<ApplicationInstanceTreeNode> {
private final Iterator<CcmApplication> applications;
public AppIterator(final Collection<CcmApplication> applications) {
this.applications = applications.iterator();
}
@Override
public boolean hasNext() {
return applications.hasNext();
}
@Override
public ApplicationInstanceTreeNode next() {
return new ApplicationInstanceTreeNode(applications.next());
}
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeModelBuilder;
import com.arsdigita.util.LockableImpl;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ApplicationTreeModelBuilder
extends LockableImpl implements TreeModelBuilder {
@Override
public TreeModel makeModel(final Tree tree,
final PageState state) {
tree.expand("-1", state);
return new ApplicationTreeModel();
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.tree.TreeNode;
import org.libreccm.web.ApplicationType;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ApplicationTypeTreeNode implements TreeNode {
private final ApplicationType applicationType;
public ApplicationTypeTreeNode(final ApplicationType applicationType) {
this.applicationType = applicationType;
}
@Override
public Object getKey() {
return applicationType.applicationClass().getName();
}
@Override
public Object getElement() {
return applicationType.name();
}
public ApplicationType getApplicationType() {
return applicationType;
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
@ -27,14 +27,9 @@ import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.Tree; import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.event.ChangeEvent; import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener; import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.LayoutPanel; import com.arsdigita.toolbox.ui.LayoutPanel;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer; import com.arsdigita.ui.admin.applications.tree.LegacyApplicationTreeModelBuilder;
import com.arsdigita.ui.admin.applications.ApplicationInstancePane;
import com.arsdigita.ui.admin.applications.ApplicationManager;
import com.arsdigita.ui.admin.applications.BaseApplicationPane;
import com.arsdigita.ui.admin.applications.MultiInstanceApplicationPane;
import com.arsdigita.ui.admin.applications.SingletonApplicationPane;
import com.arsdigita.ui.admin.applications.tree.ApplicationTreeModelBuilder;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -45,14 +40,15 @@ import org.libreccm.web.ApplicationRepository;
import org.libreccm.web.ApplicationType; import org.libreccm.web.ApplicationType;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import static com.arsdigita.ui.admin.AdminUiConstants.*;
/** /**
* A tab for managing CcmApplication and application instances. * A tab for managing CcmApplication and application instances.
* *
* @author pb * @author pb
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class ApplicationsAdministrationTab extends LayoutPanel implements public class ApplicationsAdministrationTab extends LayoutPanel {
AdminConstants {
private final Tree applicationTree; private final Tree applicationTree;
private final Map<String, BaseApplicationPane> appPanes private final Map<String, BaseApplicationPane> appPanes
@ -71,7 +67,7 @@ public class ApplicationsAdministrationTab extends LayoutPanel implements
setClassAttr("sidebarNavPanel"); setClassAttr("sidebarNavPanel");
setAttribute("navbar-title", "Sitemap"); setAttribute("navbar-title", "Sitemap");
applicationTree = new Tree(new ApplicationTreeModelBuilder()); applicationTree = new Tree(new LegacyApplicationTreeModelBuilder());
applicationTree.addChangeListener(new TreeStateChangeListener()); applicationTree.addChangeListener(new TreeStateChangeListener());
setClassAttr("navbar"); setClassAttr("navbar");
@ -244,8 +240,8 @@ public class ApplicationsAdministrationTab extends LayoutPanel implements
public Placeholder() { public Placeholder() {
super(); super();
final Label label = new Label(GlobalizationUtil.globalize( final Label label = new Label(new GlobalizedMessage(
"ui.admin.applications.placeholder")); "ui.admin.applications.placeholder", ADMIN_BUNDLE));
add(label); add(label);
} }

View File

@ -16,25 +16,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Tree;
import com.arsdigita.toolbox.ui.LayoutPanel; import com.arsdigita.toolbox.ui.LayoutPanel;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Deprecated public class ApplicationsTab extends LayoutPanel {
public class CategoriesAdminTab extends LayoutPanel {
private final Tree applicationTree;
public CategoriesAdminTab() {
public ApplicationsTab() {
super(); super();
setLeft(new Label("Categories Admin Tab Left")); setClassAttr("sidebarNavPanel");
setBody(new Label("Categories Admin Tab Body")); applicationTree = new Tree(new ApplicationTreeModelBuilder());
setLeft(applicationTree);
} }
} }

View File

@ -19,14 +19,15 @@
package com.arsdigita.ui.admin.applications.tree; package com.arsdigita.ui.admin.applications.tree;
import com.arsdigita.bebop.tree.TreeNode; import com.arsdigita.bebop.tree.TreeNode;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab; import com.arsdigita.ui.admin.applications.ApplicationsAdministrationTab;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**
* Tree Node for the application tree representing an instance of a application. * Tree Node for the application tree representing an instance of a application.
* *
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id: ApplicationInstanceTreeNode.java 2282 2013-08-01 10:45:42Z jensp $ * @version $Id: LegacyApplicationInstanceTreeNode.java 2282 2013-08-01 10:45:42Z jensp $
* *
* @see ApplicationTreeModel * @see ApplicationTreeModel
* @see ApplicationTreeModelBuilder * @see ApplicationTreeModelBuilder
@ -34,7 +35,7 @@ import org.libreccm.web.CcmApplication;
* @see ApplicationsAdministrationTab * @see ApplicationsAdministrationTab
* @see TreeNode * @see TreeNode
*/ */
public class ApplicationInstanceTreeNode implements TreeNode { public class LegacyApplicationInstanceTreeNode implements TreeNode {
/** /**
* The application instance represented by this {@code TreeNode} * The application instance represented by this {@code TreeNode}
@ -49,7 +50,7 @@ public class ApplicationInstanceTreeNode implements TreeNode {
* *
* @param application The application instance to represent by this {@code TreeNode} * @param application The application instance to represent by this {@code TreeNode}
*/ */
public ApplicationInstanceTreeNode(final CcmApplication application) { public LegacyApplicationInstanceTreeNode(final CcmApplication application) {
//this.application = application; //this.application = application;
path = application.getPrimaryUrl(); path = application.getPrimaryUrl();
title = application.getTitle().getValue(); title = application.getTitle().getValue();

View File

@ -21,7 +21,7 @@ package com.arsdigita.ui.admin.applications.tree;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.tree.TreeModel; import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeNode; import com.arsdigita.bebop.tree.TreeNode;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab; import com.arsdigita.ui.admin.applications.ApplicationsAdministrationTab;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -40,11 +40,11 @@ import org.libreccm.web.CcmApplication;
* {@link CCmApplication} instances. * {@link CCmApplication} instances.
* *
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id: ApplicationTreeModel.java 2406 2013-10-31 19:52:22Z jensp $ * @version $Id: LegacyApplicationTreeModel.java 2406 2013-10-31 19:52:22Z jensp $
*/ */
public class ApplicationTreeModel implements TreeModel { public class LegacyApplicationTreeModel implements TreeModel {
public ApplicationTreeModel() { public LegacyApplicationTreeModel() {
//Nothing //Nothing
} }
@ -57,9 +57,9 @@ public class ApplicationTreeModel implements TreeModel {
public boolean hasChildren(final TreeNode node, final PageState state) { public boolean hasChildren(final TreeNode node, final PageState state) {
if (node instanceof RootTreeNode) { if (node instanceof RootTreeNode) {
return true; return true;
} else if (node instanceof ApplicationTypeTreeNode) { } else if (node instanceof LegacyApplicationTypeTreeNode) {
final ApplicationTypeTreeNode typeTreeNode final LegacyApplicationTypeTreeNode typeTreeNode
= (ApplicationTypeTreeNode) node; = (LegacyApplicationTypeTreeNode) node;
//if (typeTreeNode.getApplicationType().isSingleton()) { //if (typeTreeNode.getApplicationType().isSingleton()) {
if (typeTreeNode.isSingleton()) { if (typeTreeNode.isSingleton()) {
@ -70,7 +70,7 @@ public class ApplicationTreeModel implements TreeModel {
return !retrieveApplicationInstances(typeTreeNode.getObjecType()) return !retrieveApplicationInstances(typeTreeNode.getObjecType())
.isEmpty(); .isEmpty();
} }
} else if (node instanceof ApplicationInstanceTreeNode) { } else if (node instanceof LegacyApplicationInstanceTreeNode) {
return false; return false;
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -89,9 +89,9 @@ public class ApplicationTreeModel implements TreeModel {
.getApplicationTypes().values(); .getApplicationTypes().values();
return new AppTypesIterator(appTypes); return new AppTypesIterator(appTypes);
} else if (node instanceof ApplicationTypeTreeNode) { } else if (node instanceof LegacyApplicationTypeTreeNode) {
final ApplicationTypeTreeNode typeTreeNode final LegacyApplicationTypeTreeNode typeTreeNode
= (ApplicationTypeTreeNode) node; = (LegacyApplicationTypeTreeNode) node;
final ApplicationRepository appRepo = CdiUtil.createCdiUtil() final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
.findBean(ApplicationRepository.class); .findBean(ApplicationRepository.class);
@ -100,7 +100,7 @@ public class ApplicationTreeModel implements TreeModel {
typeTreeNode.getObjecType()); typeTreeNode.getObjecType());
return new AppIterator(applications); return new AppIterator(applications);
} else if (node instanceof ApplicationInstanceTreeNode) { } else if (node instanceof LegacyApplicationInstanceTreeNode) {
return null; return null;
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -143,7 +143,7 @@ public class ApplicationTreeModel implements TreeModel {
} }
private class AppTypesIterator implements Iterator<ApplicationTypeTreeNode> { private class AppTypesIterator implements Iterator<LegacyApplicationTypeTreeNode> {
private final Iterator<ApplicationType> appTypes; private final Iterator<ApplicationType> appTypes;
@ -157,8 +157,8 @@ public class ApplicationTreeModel implements TreeModel {
} }
@Override @Override
public ApplicationTypeTreeNode next() { public LegacyApplicationTypeTreeNode next() {
return new ApplicationTypeTreeNode(appTypes.next()); return new LegacyApplicationTypeTreeNode(appTypes.next());
} }
@Override @Override
@ -168,7 +168,7 @@ public class ApplicationTreeModel implements TreeModel {
} }
private class AppIterator implements Iterator<ApplicationInstanceTreeNode> { private class AppIterator implements Iterator<LegacyApplicationInstanceTreeNode> {
private final Iterator<CcmApplication> applications; private final Iterator<CcmApplication> applications;
@ -182,8 +182,8 @@ public class ApplicationTreeModel implements TreeModel {
} }
@Override @Override
public ApplicationInstanceTreeNode next() { public LegacyApplicationInstanceTreeNode next() {
return new ApplicationInstanceTreeNode(applications.next()); return new LegacyApplicationInstanceTreeNode(applications.next());
} }
@Override @Override

View File

@ -22,7 +22,7 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Tree; import com.arsdigita.bebop.Tree;
import com.arsdigita.bebop.tree.TreeModel; import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeModelBuilder; import com.arsdigita.bebop.tree.TreeModelBuilder;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab; import com.arsdigita.ui.admin.applications.ApplicationsAdministrationTab;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
/** /**
@ -30,15 +30,15 @@ import com.arsdigita.util.LockableImpl;
* applications tree used in {@link ApplicationsAdministrationTab}. * applications tree used in {@link ApplicationsAdministrationTab}.
* *
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id: ApplicationTreeModelBuilder.java 2294 2013-08-05 18:39:46Z * @version $Id: LegacyApplicationTreeModelBuilder.java 2294 2013-08-05 18:39:46Z
* jensp $ jensp $
*/ */
public class ApplicationTreeModelBuilder extends LockableImpl public class LegacyApplicationTreeModelBuilder extends LockableImpl
implements TreeModelBuilder { implements TreeModelBuilder {
@Override @Override
public TreeModel makeModel(final Tree tree, final PageState state) { public TreeModel makeModel(final Tree tree, final PageState state) {
tree.expand("-1", state); tree.expand("-1", state);
return new ApplicationTreeModel(); return new LegacyApplicationTreeModel();
} }
} }

View File

@ -26,9 +26,9 @@ import org.libreccm.web.ApplicationType;
* Tree Node implementation for the Application Tree in the Application admin tab. * Tree Node implementation for the Application Tree in the Application admin tab.
* *
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id: ApplicationTypeTreeNode.java 2282 2013-08-01 10:45:42Z jensp $ * @version $Id: LegacyApplicationTypeTreeNode.java 2282 2013-08-01 10:45:42Z jensp $
*/ */
public class ApplicationTypeTreeNode implements TreeNode { public class LegacyApplicationTypeTreeNode implements TreeNode {
private final String name; private final String name;
private final String objectType; private final String objectType;
@ -38,7 +38,7 @@ public class ApplicationTypeTreeNode implements TreeNode {
// isSingleton // isSingleton
// getObjectType // getObjectType
public ApplicationTypeTreeNode(final ApplicationType applicationType) { public LegacyApplicationTypeTreeNode(final ApplicationType applicationType) {
//this.applicationType = applicationType; //this.applicationType = applicationType;
name = applicationType.name(); name = applicationType.name();
objectType = applicationType.name(); objectType = applicationType.name();

View File

@ -40,7 +40,7 @@ public class LoginApplicationSetup extends AbstractCcmApplicationSetup {
public void setup() { public void setup() {
final CcmApplication login = new CcmApplication(); final CcmApplication login = new CcmApplication();
login.setUuid(UUID.randomUUID().toString()); login.setUuid(UUID.randomUUID().toString());
login.setApplicationType(LOGIN_APP_NAME); login.setApplicationType(LoginConstants.LOGIN_APP_TYPE);
login.setPrimaryUrl(LoginConstants.LOGIN_PAGE_URL); login.setPrimaryUrl(LoginConstants.LOGIN_PAGE_URL);
getEntityManager().persist(login); getEntityManager().persist(login);

View File

@ -26,6 +26,8 @@ import com.arsdigita.globalization.GlobalizedMessage;
*/ */
public interface LoginConstants { public interface LoginConstants {
public static final String LOGIN_APP_TYPE = "com.arsdigita.ui.Login";
public static final String LOGIN_BUNDLE public static final String LOGIN_BUNDLE
= "com.arsdigita.ui.login.LoginResources"; = "com.arsdigita.ui.login.LoginResources";

View File

@ -18,12 +18,14 @@
*/ */
package org.libreccm.core; package org.libreccm.core;
import com.arsdigita.ui.admin.AdminApplicationCreator; import com.arsdigita.ui.admin.applications.AdminApplicationCreator;
import com.arsdigita.ui.admin.AdminServlet; import com.arsdigita.ui.admin.AdminServlet;
import com.arsdigita.ui.admin.AdminApplicationSetup; import com.arsdigita.ui.admin.AdminUiConstants;
import com.arsdigita.ui.admin.applications.AdminApplicationSetup;
import com.arsdigita.ui.login.LoginApplicationCreator; import com.arsdigita.ui.login.LoginApplicationCreator;
import com.arsdigita.ui.login.LoginServlet; import com.arsdigita.ui.login.LoginServlet;
import com.arsdigita.ui.login.LoginApplicationSetup; import com.arsdigita.ui.login.LoginApplicationSetup;
import com.arsdigita.ui.login.LoginConstants;
import org.libreccm.modules.CcmModule; import org.libreccm.modules.CcmModule;
import org.libreccm.modules.InitEvent; import org.libreccm.modules.InitEvent;
@ -40,12 +42,12 @@ import org.libreccm.web.ApplicationType;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Module(applicationTypes = { @Module(applicationTypes = {
@ApplicationType(name = LoginApplicationSetup.LOGIN_APP_NAME, @ApplicationType(name = LoginConstants.LOGIN_APP_TYPE,
description = "Login Application", description = "Login Application",
singleton = true, singleton = true,
creator = LoginApplicationCreator.class, creator = LoginApplicationCreator.class,
servlet = LoginServlet.class), servlet = LoginServlet.class),
@ApplicationType(name = AdminApplicationSetup.ADMIN_APP_NAME, @ApplicationType(name = AdminUiConstants.ADMIN_APP_TYPE,
description = "Site-wide admin application", description = "Site-wide admin application",
singleton = true, singleton = true,
creator = AdminApplicationCreator.class, creator = AdminApplicationCreator.class,