CCM NG: First part of migration of WorkflowAdminPane, as well as some smaller things in other classes.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4251 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
639118217f
commit
02b61b7ddc
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.OptionGroup;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrated from the {@code DataQueryPrintListener} in the old system. Renamed
|
||||||
|
* and refactored to operate on a list.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @param <T> Type of the objects in the list.
|
||||||
|
*/
|
||||||
|
public abstract class ListOptionPrintListener<T> implements PrintListener {
|
||||||
|
|
||||||
|
public ListOptionPrintListener() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<T> getDataQuery(final PageState state);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final OptionGroup target = (OptionGroup) event.getTarget();
|
||||||
|
final List<T> dataQuery = getDataQuery(state);
|
||||||
|
|
||||||
|
dataQuery.forEach(item -> target.addOption(
|
||||||
|
new Option(getKey(item),
|
||||||
|
getValue(item))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getKey(final T object);
|
||||||
|
|
||||||
|
public String getValue(final T object) {
|
||||||
|
return getKey(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,289 @@
|
||||||
|
/*
|
||||||
|
* 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.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
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.RequestLocal;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.CheckboxGroup;
|
||||||
|
import com.arsdigita.bebop.form.Hidden;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.OptionGroup;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.form.Widget;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
import org.libreccm.security.User;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for adding multiple users to a role.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
|
||||||
|
* @author <a href="mailto:umathur@arsdigita.com">Uday Mathur</a>
|
||||||
|
*/
|
||||||
|
public abstract class UserAddForm extends SimpleContainer
|
||||||
|
implements FormProcessListener {
|
||||||
|
|
||||||
|
private final static String SEARCH_QUERY = "searchQuery";
|
||||||
|
private final static String USERS = "users";
|
||||||
|
private final static String SUBMIT = "addSubmit";
|
||||||
|
private final static String CANCEL = "addCancel";
|
||||||
|
|
||||||
|
private final static String DQ_USER_ID = "userId";
|
||||||
|
private final static String DQ_NAME = "name";
|
||||||
|
|
||||||
|
private Widget m_search;
|
||||||
|
private RequestLocal m_query;
|
||||||
|
private String m_label;
|
||||||
|
private String m_submitText;
|
||||||
|
|
||||||
|
private CMSContainer m_noMatches;
|
||||||
|
private CMSContainer m_matches;
|
||||||
|
|
||||||
|
private Form m_form;
|
||||||
|
private Hidden m_searchQuery;
|
||||||
|
private CheckboxGroup m_users;
|
||||||
|
private Submit m_submit;
|
||||||
|
private Submit m_cancel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param search The widget on the search form that contains the value of
|
||||||
|
* the search string.
|
||||||
|
*/
|
||||||
|
public UserAddForm(final Widget search) {
|
||||||
|
this(search, "AddUsers");
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAddForm(final Widget search, final String name) {
|
||||||
|
this(search, name,
|
||||||
|
"Check the box next to the name of the person(s) to assign.",
|
||||||
|
"Add Members");
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAddForm(final Widget search,
|
||||||
|
final String name,
|
||||||
|
final String text,
|
||||||
|
final String submitText) {
|
||||||
|
m_label = text;
|
||||||
|
m_submitText = submitText;
|
||||||
|
m_search = search;
|
||||||
|
|
||||||
|
m_query = new RequestLocal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object initialValue(final PageState state) {
|
||||||
|
return makeQuery(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
m_form = makeForm(name);
|
||||||
|
|
||||||
|
Label title = new Label(new GlobalizedMessage("cms.ui.matches",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
title.setFontWeight(Label.BOLD);
|
||||||
|
|
||||||
|
Label label = new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.there_was_no_one_matching_the_search_criteria",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
label.setFontWeight("em");
|
||||||
|
|
||||||
|
m_noMatches = new CMSContainer();
|
||||||
|
m_noMatches.add(title);
|
||||||
|
m_noMatches.add(label);
|
||||||
|
add(m_noMatches);
|
||||||
|
|
||||||
|
m_matches = new CMSContainer();
|
||||||
|
m_matches.add(title);
|
||||||
|
m_matches.add(m_form);
|
||||||
|
add(m_matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the form used to add users.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*
|
||||||
|
* @return The form
|
||||||
|
*/
|
||||||
|
protected Form makeForm(final String name) {
|
||||||
|
final CMSForm form = new CMSForm(name) {
|
||||||
|
|
||||||
|
public final boolean isCancelled(final PageState state) {
|
||||||
|
return m_cancel.isSelected(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// This hidden field will store the search query. A hidden widget is
|
||||||
|
// used instead of a request local variable because the search query
|
||||||
|
// should only be updated when the search form is submitted.
|
||||||
|
m_searchQuery = new Hidden(SEARCH_QUERY);
|
||||||
|
form.add(m_searchQuery, ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
|
Label l = new Label(m_label);
|
||||||
|
form.add(l, ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
|
// Add the list of users that can be added.
|
||||||
|
m_users = new CheckboxGroup(USERS);
|
||||||
|
m_users.addValidationListener(new NotNullValidationListener());
|
||||||
|
try {
|
||||||
|
m_users.addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepare(PrintEvent event) {
|
||||||
|
CheckboxGroup target = (CheckboxGroup) event.getTarget();
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
// Ensures that the init listener gets fired before the
|
||||||
|
// print listeners.
|
||||||
|
FormData data = m_form.getFormData(state);
|
||||||
|
addUsers(state, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
form.add(m_users, ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
|
// Submit and Cancel buttons.
|
||||||
|
SimpleContainer s = new SimpleContainer();
|
||||||
|
m_submit = new Submit(SUBMIT, m_submitText);
|
||||||
|
s.add(m_submit);
|
||||||
|
m_cancel = new Submit(CANCEL, "Cancel");
|
||||||
|
s.add(m_cancel);
|
||||||
|
form.add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
|
||||||
|
|
||||||
|
form.addProcessListener(this);
|
||||||
|
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the form for adding users.
|
||||||
|
*
|
||||||
|
* @return The "add user" form
|
||||||
|
*/
|
||||||
|
public Form getForm() {
|
||||||
|
return m_form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the widget that contains the search string.
|
||||||
|
*
|
||||||
|
* @return The widget that contains the search string
|
||||||
|
*/
|
||||||
|
protected Widget getSearchWidget() {
|
||||||
|
return m_searchQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the form is cancelled, false otherwise.
|
||||||
|
*
|
||||||
|
* @param state The page state
|
||||||
|
*
|
||||||
|
* @return true if the form is cancelled, false otherwise.
|
||||||
|
*
|
||||||
|
* @pre ( state != null )
|
||||||
|
*/
|
||||||
|
public boolean isCancelled(final PageState state) {
|
||||||
|
return m_cancel.isSelected(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds users to the option group.
|
||||||
|
*
|
||||||
|
* @param state The page state
|
||||||
|
* @param target The option group
|
||||||
|
*
|
||||||
|
* @pre ( state != null && target != null )
|
||||||
|
*/
|
||||||
|
protected void addUsers(final PageState state, final OptionGroup target) {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final List<User> users = (java.util.List<User>) m_query.get(state);
|
||||||
|
|
||||||
|
users.forEach(user -> target.addOption(
|
||||||
|
new Option(Long.toString(user.getPartyId()),
|
||||||
|
user.getName())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a {@link com.arsdigita.persistence.DataQuery} that encapsulates
|
||||||
|
* search results.
|
||||||
|
*
|
||||||
|
* @param state The page state
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract List<User> makeQuery(final PageState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process listener for the "Add users" form.
|
||||||
|
*
|
||||||
|
* @param event The form event
|
||||||
|
*
|
||||||
|
* @throws com.arsdigita.bebop.FormProcessException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public abstract void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the appropriate frame.
|
||||||
|
*
|
||||||
|
* @param state The page state
|
||||||
|
* @param parent The parent DOM element
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void generateXML(final PageState state,
|
||||||
|
final Element parent) {
|
||||||
|
|
||||||
|
m_searchQuery.setValue(state, m_search.getValue(state));
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final List<User> searchResults = (List<User>) m_query.get(state);
|
||||||
|
|
||||||
|
if (searchResults.size() > 0) {
|
||||||
|
m_matches.generateXML(state, parent);
|
||||||
|
} else {
|
||||||
|
m_noMatches.generateXML(state, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* 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.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to search for users to be added to a staff group.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
|
||||||
|
*/
|
||||||
|
public class UserSearchForm extends CMSForm {
|
||||||
|
|
||||||
|
private final static String SEARCH_LABEL = "Search";
|
||||||
|
|
||||||
|
private TextField m_search;
|
||||||
|
|
||||||
|
public UserSearchForm(String name) {
|
||||||
|
this(name,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.search_to_add_new_members",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserSearchForm(String name, Label heading) {
|
||||||
|
super(name, new ColumnPanel(3));
|
||||||
|
heading.setFontWeight(Label.BOLD);
|
||||||
|
add(heading, ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
|
add(new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.enter_first_name_last_name_andor_email_address",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
|
||||||
|
m_search = new TextField(new StringParameter("query"));
|
||||||
|
m_search.setSize(20);
|
||||||
|
add(m_search, ColumnPanel.RIGHT);
|
||||||
|
|
||||||
|
Submit submit = new Submit("submit");
|
||||||
|
submit.setButtonLabel(SEARCH_LABEL);
|
||||||
|
add(submit, ColumnPanel.LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextField getSearchWidget() {
|
||||||
|
return m_search;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.toolbox.ui.ProxyComponent;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author Justin Ross
|
||||||
|
*/
|
||||||
|
public class VisibilityComponent extends ProxyComponent {
|
||||||
|
|
||||||
|
private final String m_action;
|
||||||
|
|
||||||
|
public VisibilityComponent(final Component child, final String action) {
|
||||||
|
super(child);
|
||||||
|
|
||||||
|
m_action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(final PageState state) {
|
||||||
|
return super.isVisible(state) && hasPermission(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(final PageState state) {
|
||||||
|
Assert.exists(m_action, String.class);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
return permissionChecker.isPermitted(m_action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -316,8 +316,7 @@ public class FolderBrowser extends Table {
|
||||||
final List<Predicate> filters = new ArrayList<>();
|
final List<Predicate> filters = new ArrayList<>();
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig.
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
getDefaultLanguage());
|
|
||||||
if (state.getValue(m_aToZfilter) != null) {
|
if (state.getValue(m_aToZfilter) != null) {
|
||||||
filters.add(criteriaBuilder.like(criteriaBuilder.lower(
|
filters.add(criteriaBuilder.like(criteriaBuilder.lower(
|
||||||
root.get("Categorization.categorizedObject.displayName")),
|
root.get("Categorization.categorizedObject.displayName")),
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,7 @@ class AddPhaseForm extends CMSForm {
|
||||||
ConfigurationManager.class);
|
ConfigurationManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
// Check if the object already exists for double click protection.
|
// Check if the object already exists for double click protection.
|
||||||
final PhaseDefinition phaseDef = new PhaseDefinition();
|
final PhaseDefinition phaseDef = new PhaseDefinition();
|
||||||
|
|
@ -331,8 +330,7 @@ class AddPhaseForm extends CMSForm {
|
||||||
ConfigurationManager.class);
|
ConfigurationManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
for (final PhaseDefinition phaseDef : phaseDefs) {
|
for (final PhaseDefinition phaseDef : phaseDefs) {
|
||||||
if (phaseDef.getLabel().getValue(defaultLocale).equalsIgnoreCase(
|
if (phaseDef.getLabel().getValue(defaultLocale).equalsIgnoreCase(
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,7 @@ class BaseLifecycleForm extends BaseForm {
|
||||||
ConfigurationManager.class);
|
ConfigurationManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
final String label = (String) m_name.getValue(state);
|
final String label = (String) m_name.getValue(state);
|
||||||
|
|
||||||
final java.util.List<LifecycleDefinition> definitions = CMS
|
final java.util.List<LifecycleDefinition> definitions = CMS
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ class EditPhaseForm extends CMSForm {
|
||||||
PhaseDefinititionRepository.class);
|
PhaseDefinititionRepository.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig.getDefaultLanguage());
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
final PhaseDefinition phaseDefinition = m_phase.getPhase(state);
|
final PhaseDefinition phaseDefinition = m_phase.getPhase(state);
|
||||||
phaseDefinition.getLabel().addValue(defaultLocale, label);
|
phaseDefinition.getLabel().addValue(defaultLocale, label);
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,7 @@ class LifecycleAddForm extends BaseLifecycleForm {
|
||||||
ContentSectionManager.class);
|
ContentSectionManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
final LifecycleDefinition definition = new LifecycleDefinition();
|
final LifecycleDefinition definition = new LifecycleDefinition();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,10 @@ class LifecycleEditForm extends BaseLifecycleForm {
|
||||||
|
|
||||||
private class ProcessListener implements FormProcessListener {
|
private class ProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
public final void process(final FormSectionEvent e)
|
@Override
|
||||||
|
public final void process(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
final PageState state = e.getPageState();
|
final PageState state = event.getPageState();
|
||||||
final LifecycleDefinition definition = m_definition
|
final LifecycleDefinition definition = m_definition
|
||||||
.getLifecycleDefinition(state);
|
.getLifecycleDefinition(state);
|
||||||
|
|
||||||
|
|
@ -88,8 +89,7 @@ class LifecycleEditForm extends BaseLifecycleForm {
|
||||||
.findBean(LifecycleDefinitionRepository.class);
|
.findBean(LifecycleDefinitionRepository.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
definition.getLabel().addValue(defaultLocale,
|
definition.getLabel().addValue(defaultLocale,
|
||||||
(String) m_name.getValue(state));
|
(String) m_name.getValue(state));
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,7 @@ class LifecycleItemPane extends BaseItemPane {
|
||||||
ConfigurationManager.class);
|
ConfigurationManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
final java.util.List props = super.properties(state);
|
final java.util.List props = super.properties(state);
|
||||||
final LifecycleDefinition cycle = m_cycle
|
final LifecycleDefinition cycle = m_cycle
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the CCM Public
|
||||||
|
* License (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the
|
||||||
|
* License at http://www.redhat.com/licenses/ccmpl.html.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
||||||
|
* or implied. See the License for the specific language
|
||||||
|
* governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.table.AbstractTableModelBuilder;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
|
||||||
|
import org.librecms.workflow.CmsTask;
|
||||||
|
import org.librecms.workflow.CmsTaskType;
|
||||||
|
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
|
||||||
|
|
||||||
|
private final WorkflowRequestLocal m_workflow;
|
||||||
|
|
||||||
|
public AssignedTaskTableModelBuilder(final WorkflowRequestLocal workflow) {
|
||||||
|
m_workflow = workflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(final Table table, final PageState state) {
|
||||||
|
return new Model(m_workflow.getWorkflow(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Model implements TableModel {
|
||||||
|
|
||||||
|
private final Iterator m_iter;
|
||||||
|
private CmsTask m_task;
|
||||||
|
|
||||||
|
Model(final Workflow workflow) {
|
||||||
|
Assert.exists(workflow, Workflow.class);
|
||||||
|
|
||||||
|
if (workflow.getProcessState() == Workflow.STARTED) {
|
||||||
|
|
||||||
|
final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
|
||||||
|
|
||||||
|
Assert.exists(engine, Engine.class);
|
||||||
|
|
||||||
|
m_iter = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID()).iterator();
|
||||||
|
} else {
|
||||||
|
m_iter = Collections.emptyList().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getColumnCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean nextRow() {
|
||||||
|
if (m_iter.hasNext()) {
|
||||||
|
m_task = (CmsTask) m_iter.next();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Object getKeyAt(final int column) {
|
||||||
|
return m_task.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Object getElementAt(final int column) {
|
||||||
|
switch (column) {
|
||||||
|
case 0:
|
||||||
|
return m_task.getLabel();
|
||||||
|
case 1:
|
||||||
|
// SF patch [ 1587168 ] Show locking user
|
||||||
|
return m_task.isLocked() ? m_task.getLockedUser() : null;
|
||||||
|
case 2:
|
||||||
|
return m_task.getTaskType().getID().equals(CmsTaskType.DEPLOY)
|
||||||
|
? (Object) new Label("") : // null should work as well
|
||||||
|
(Object) lz("cms.ui.workflow.task.finish");
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static GlobalizedMessage gz(final String key) {
|
||||||
|
return GlobalizationUtil.globalize(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static String lz(final String key) {
|
||||||
|
return (String) gz(key).localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.cms.ui.BaseForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*
|
||||||
|
* @author Uday Mathur
|
||||||
|
* @author Michael Pih
|
||||||
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
|
*/
|
||||||
|
class BaseWorkflowForm extends BaseForm {
|
||||||
|
|
||||||
|
final Name m_title;
|
||||||
|
final Description m_description;
|
||||||
|
|
||||||
|
BaseWorkflowForm(final String key, final GlobalizedMessage message) {
|
||||||
|
super(key, message);
|
||||||
|
|
||||||
|
m_title = new Name("name", 200, true);
|
||||||
|
addField(gz("cms.ui.name"), m_title);
|
||||||
|
|
||||||
|
m_description = new Description("desc", 4000, true);
|
||||||
|
addField(gz("cms.ui.description"), m_description);
|
||||||
|
|
||||||
|
addAction(new Finish());
|
||||||
|
addAction(new Cancel());
|
||||||
|
|
||||||
|
addSecurityListener(CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW);
|
||||||
|
addValidationListener(new ValidationListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ValidationListener implements FormValidationListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void validate(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final String name = (String) m_title.getValue(event.getPageState());
|
||||||
|
|
||||||
|
// XXX do a dupe check here ala commented out code below
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
protected void addValidationListener(Form f) {
|
||||||
|
f.addValidationListener(new DataQueryExistsListener(ERROR_MSG) {
|
||||||
|
private final String QUERY_NAME =
|
||||||
|
"com.arsdigita.workflow.simple.getProcessDefinitions";
|
||||||
|
|
||||||
|
|
||||||
|
public void validate(FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
String name = (String) m_title.getValue(event.getPageState());
|
||||||
|
if ( name != null ) {
|
||||||
|
super.validate(event);
|
||||||
|
} else {
|
||||||
|
// Do nothing. The NotNullValidation listener should kick in.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataQuery getDataQuery(FormSectionEvent e) {
|
||||||
|
PageState s = e.getPageState();
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataQuery query = session.retrieveQuery(QUERY_NAME);
|
||||||
|
Filter listenerFilter = query.addFilter("lower(processDefinitionLabel) = lower(:label)");
|
||||||
|
listenerFilter.set("label", ((String) m_title.getValue(s)).trim());
|
||||||
|
Filter itemFilter = query.addNotEqualsFilter
|
||||||
|
("processDefinitionId", m_id.getValue(s));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,253 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
|
||||||
|
import com.arsdigita.cms.ui.BaseDeleteForm;
|
||||||
|
import com.arsdigita.cms.ui.BaseItemPane;
|
||||||
|
import com.arsdigita.cms.ui.VisibilityComponent;
|
||||||
|
import org.librecms.workflow.CmsTask;
|
||||||
|
import org.libreccm.security.User;
|
||||||
|
import com.arsdigita.toolbox.ui.ActionGroup;
|
||||||
|
import com.arsdigita.toolbox.ui.PropertyList;
|
||||||
|
import com.arsdigita.toolbox.ui.Section;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
abstract class BaseWorkflowItemPane extends BaseItemPane {
|
||||||
|
|
||||||
|
final WorkflowRequestLocal m_workflow;
|
||||||
|
final TaskRequestLocal m_task;
|
||||||
|
|
||||||
|
ActionGroup m_actionGroup;
|
||||||
|
final TaskTable m_tasks;
|
||||||
|
|
||||||
|
final SimpleContainer m_detailPane;
|
||||||
|
final TaskItemPane m_taskPane;
|
||||||
|
final SummarySection m_summarySection;
|
||||||
|
|
||||||
|
public BaseWorkflowItemPane(final WorkflowRequestLocal workflow,
|
||||||
|
final ActionLink editLink,
|
||||||
|
final ActionLink deleteLink) {
|
||||||
|
m_workflow = workflow;
|
||||||
|
|
||||||
|
m_tasks = new TaskTable();
|
||||||
|
m_task = new TaskSelectionRequestLocal();
|
||||||
|
|
||||||
|
m_detailPane = new SimpleContainer();
|
||||||
|
|
||||||
|
// Tasks
|
||||||
|
|
||||||
|
final FinishLink taskFinishLink = new FinishLink();
|
||||||
|
|
||||||
|
final ActionLink taskAddLink = new ActionLink
|
||||||
|
(new Label(gz("cms.ui.workflow.task.add")));
|
||||||
|
final TaskAddForm taskAddForm = new TaskAddForm
|
||||||
|
(m_workflow, m_tasks.getRowSelectionModel());
|
||||||
|
|
||||||
|
final ActionLink taskEditLink = new ActionLink
|
||||||
|
(new Label(gz("cms.ui.workflow.task.edit")));
|
||||||
|
final TaskEditForm taskEditForm = new TaskEditForm(m_workflow, m_task);
|
||||||
|
|
||||||
|
final ActionLink taskDeleteLink = new ActionLink
|
||||||
|
(new Label(gz("cms.ui.workflow.task.delete")));
|
||||||
|
final TaskDeleteForm taskDeleteForm = new TaskDeleteForm();
|
||||||
|
|
||||||
|
final ActionLink backLink = new ActionLink
|
||||||
|
(new Label(gz("cms.ui.workflow.task.return")));
|
||||||
|
backLink.addActionListener(new ResetListener());
|
||||||
|
|
||||||
|
m_taskPane = new TaskItemPane(m_workflow, m_task,
|
||||||
|
taskFinishLink, taskEditLink,
|
||||||
|
taskDeleteLink, backLink);
|
||||||
|
|
||||||
|
m_summarySection = new SummarySection(editLink, deleteLink);
|
||||||
|
m_detailPane.add(m_summarySection);
|
||||||
|
m_detailPane.add(new TaskSection(taskAddLink));
|
||||||
|
|
||||||
|
add(m_detailPane);
|
||||||
|
setDefault(m_detailPane);
|
||||||
|
add(m_taskPane);
|
||||||
|
add(taskAddForm);
|
||||||
|
add(taskEditForm);
|
||||||
|
add(taskDeleteForm);
|
||||||
|
|
||||||
|
connect(m_tasks, 0, m_taskPane);
|
||||||
|
|
||||||
|
connect(taskAddLink, taskAddForm);
|
||||||
|
connect(taskAddForm, m_taskPane);
|
||||||
|
|
||||||
|
connect(taskEditLink, taskEditForm);
|
||||||
|
connect(taskEditForm);
|
||||||
|
|
||||||
|
connect(taskDeleteLink, taskDeleteForm);
|
||||||
|
connect(taskDeleteForm, m_detailPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class AdminVisible extends VisibilityComponent {
|
||||||
|
public AdminVisible(final Component child) {
|
||||||
|
super(child, SecurityManager.WORKFLOW_ADMIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FinishLink extends ActionLink {
|
||||||
|
FinishLink() {
|
||||||
|
super(new Label(gz("cms.ui.workflow.task.finish")));
|
||||||
|
|
||||||
|
addActionListener(new Listener());
|
||||||
|
addActionListener(new ResetListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isVisible(final PageState state) {
|
||||||
|
CmsTask task = m_task.getTask(state);
|
||||||
|
User lockingUser = task.getLockedUser();
|
||||||
|
boolean visible = task.isEnabled() &&
|
||||||
|
(lockingUser == null ||
|
||||||
|
lockingUser.equals(Web.getWebContext().getUser()));
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Listener implements ActionListener {
|
||||||
|
public final void actionPerformed(final ActionEvent e) {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_task.getTask(state).finish
|
||||||
|
(Web.getWebContext().getUser());
|
||||||
|
} catch (TaskException te) {
|
||||||
|
throw new UncheckedWrapperException(te);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset(final PageState state) {
|
||||||
|
super.reset(state);
|
||||||
|
|
||||||
|
m_tasks.getRowSelectionModel().clearSelection(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TaskDeleteForm extends BaseDeleteForm {
|
||||||
|
TaskDeleteForm() {
|
||||||
|
super(new Label(gz("cms.ui.workflow.task.delete_prompt")));
|
||||||
|
|
||||||
|
addSecurityListener(SecurityManager.WORKFLOW_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void process(final FormSectionEvent e)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
|
m_task.getTask(state).delete();
|
||||||
|
|
||||||
|
m_tasks.getRowSelectionModel().clearSelection(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TaskSelectionRequestLocal extends TaskRequestLocal {
|
||||||
|
protected final Object initialValue(final PageState state) {
|
||||||
|
final String id = m_tasks.getRowSelectionModel().getSelectedKey
|
||||||
|
(state).toString();
|
||||||
|
|
||||||
|
return new CmsTask(new BigDecimal(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SummarySection extends Section {
|
||||||
|
SummarySection(final ActionLink editLink,
|
||||||
|
final ActionLink deleteLink) {
|
||||||
|
setHeading(new Label(gz("cms.ui.workflow.details")));
|
||||||
|
|
||||||
|
m_actionGroup = new ActionGroup();
|
||||||
|
setBody(m_actionGroup);
|
||||||
|
|
||||||
|
m_actionGroup.setSubject(new Properties());
|
||||||
|
m_actionGroup.addAction(new AdminVisible(editLink),
|
||||||
|
ActionGroup.EDIT);
|
||||||
|
m_actionGroup.addAction(new AdminVisible(deleteLink),
|
||||||
|
ActionGroup.DELETE);
|
||||||
|
// m_actionGroup.addAction(new AdminVisible(new StartLink()));
|
||||||
|
// m_actionGroup.addAction(new AdminVisible(new StopLink()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Properties extends PropertyList {
|
||||||
|
protected final java.util.List properties(final PageState state) {
|
||||||
|
final java.util.List props = super.properties(state);
|
||||||
|
final Workflow flow = (Workflow) m_workflow.get(state);
|
||||||
|
|
||||||
|
props.add(new Property(gz("cms.ui.name"),
|
||||||
|
flow.getLabel()));
|
||||||
|
props.add(new Property(gz("cms.ui.description"),
|
||||||
|
flow.getDescription()));
|
||||||
|
props.add(new Property(gz("cms.ui.workflow.current_state"),
|
||||||
|
flow.getStateString()));
|
||||||
|
props.add(new Property(gz("cms.ui.workflow.num_tasks"),
|
||||||
|
String.valueOf(flow.getTaskCount())));
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class TaskSection extends Section {
|
||||||
|
TaskSection(final ActionLink taskAddLink) {
|
||||||
|
setHeading(new Label(gz("cms.ui.workflow.tasks")));
|
||||||
|
|
||||||
|
final ActionGroup group = new ActionGroup();
|
||||||
|
setBody(group);
|
||||||
|
|
||||||
|
group.setSubject(m_tasks);
|
||||||
|
group.addAction(new AdminVisible(taskAddLink), ActionGroup.ADD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX Fix this.
|
||||||
|
private static final String[] s_columns = new String[] {
|
||||||
|
lz("cms.ui.name"),
|
||||||
|
lz("cms.ui.description"),
|
||||||
|
lz("cms.ui.workflow.task.dependencies"),
|
||||||
|
lz("cms.ui.workflow.task.state")
|
||||||
|
};
|
||||||
|
|
||||||
|
private class TaskTable extends Table {
|
||||||
|
public TaskTable() {
|
||||||
|
super(new TaskTableModelBuilder(m_workflow), s_columns);
|
||||||
|
|
||||||
|
setEmptyView(new Label(gz("cms.ui.workflow.task.none")));
|
||||||
|
|
||||||
|
getColumn(0).setCellRenderer
|
||||||
|
(new DefaultTableCellRenderer(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,206 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.GridPanel;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.CheckboxGroup;
|
||||||
|
import com.arsdigita.bebop.form.OptionGroup;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
|
||||||
|
import org.librecms.contentsection.ContentSection;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ui.CMSForm;
|
||||||
|
import com.arsdigita.cms.ui.ListOptionPrintListener;
|
||||||
|
|
||||||
|
import org.librecms.workflow.CmsTask;
|
||||||
|
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
import org.libreccm.workflow.TaskAssignment;
|
||||||
|
import org.libreccm.workflow.WorkflowManager;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
|
class TaskAddRole extends CMSForm {
|
||||||
|
|
||||||
|
private final TaskRequestLocal m_task;
|
||||||
|
private final OptionGroup m_roles;
|
||||||
|
private final Submit m_add;
|
||||||
|
private final Submit m_cancel;
|
||||||
|
|
||||||
|
TaskAddRole(final TaskRequestLocal task) {
|
||||||
|
super("GroupAssignForm");
|
||||||
|
|
||||||
|
m_task = task;
|
||||||
|
|
||||||
|
add(new Label(gz("cms.ui.workflow.task.roles")), ColumnPanel.TOP);
|
||||||
|
|
||||||
|
m_roles = new CheckboxGroup("roles");
|
||||||
|
add(m_roles);
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_roles.addPrintListener(new RoleOptionPrintListener());
|
||||||
|
} catch (TooManyListenersException ex) {
|
||||||
|
throw new UncheckedWrapperException("TooManyListeners: " + ex
|
||||||
|
.getMessage(), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
final SimpleContainer submits = new SimpleContainer();
|
||||||
|
add(submits, GridPanel.FULL_WIDTH | GridPanel.CENTER);
|
||||||
|
|
||||||
|
m_add = new Submit("add", gz("cms.ui.finish"));
|
||||||
|
submits.add(m_add);
|
||||||
|
|
||||||
|
m_cancel = new Submit("cancel", gz("cms.ui.cancel"));
|
||||||
|
submits.add(m_cancel);
|
||||||
|
|
||||||
|
addInitListener(new InitListener());
|
||||||
|
addSubmissionListener(new SubmissionListener());
|
||||||
|
addProcessListener(new ProcessListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InitListener implements FormInitListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void init(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
final List<TaskAssignment> assignments = task.getAssignments();
|
||||||
|
final List<Role> roles = new ArrayList<>();
|
||||||
|
|
||||||
|
assignments.forEach(assignment -> roles.add(assignment.getRole()));
|
||||||
|
|
||||||
|
m_roles.setValue(state, roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
if (m_add.isSelected(state)) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil.findBean(
|
||||||
|
WorkflowManager.class);
|
||||||
|
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||||
|
RoleRepository.class);
|
||||||
|
|
||||||
|
task.getAssignments().forEach(assignment -> workflowManager
|
||||||
|
.retractTask(task, assignment.getRole()));
|
||||||
|
|
||||||
|
final String[] roleIds = (String[]) m_roles.getValue(state);
|
||||||
|
|
||||||
|
if (roleIds != null) {
|
||||||
|
for (final String roleId : roleIds) {
|
||||||
|
final Role role = roleRepository.findById(Long
|
||||||
|
.parseLong(roleId));
|
||||||
|
workflowManager.assignTask(task, role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SubmissionListener implements FormSubmissionListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void submitted(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||||
|
PermissionChecker.class);
|
||||||
|
|
||||||
|
if (!permissionChecker.isPermitted(
|
||||||
|
CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW)) {
|
||||||
|
throw new FormProcessException(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.ui.workflow.insufficient_privileges",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RoleOptionPrintListener extends ListOptionPrintListener<Role> {
|
||||||
|
|
||||||
|
public static final String QUERY_NAME
|
||||||
|
= "com.arsdigita.cms.getStaffRoles";
|
||||||
|
|
||||||
|
public RoleOptionPrintListener() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Role> getDataQuery(final PageState state) {
|
||||||
|
final ContentSection section = CMS.getContext().getContentSection();
|
||||||
|
|
||||||
|
return section.getRoles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey(final Role role) {
|
||||||
|
return Long.toString(role.getRoleId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue(final Role role) {
|
||||||
|
return role.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GlobalizedMessage gz(final String key) {
|
||||||
|
return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String lz(final String key) {
|
||||||
|
return (String) gz(key).localize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,171 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.cms.ui.UserAddForm;
|
||||||
|
import com.arsdigita.cms.ui.UserSearchForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.security.User;
|
||||||
|
import org.libreccm.workflow.UserTask;
|
||||||
|
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.UserRepository;
|
||||||
|
import org.libreccm.workflow.WorkflowManager;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains forms to search and add users as Task Assignees.
|
||||||
|
*
|
||||||
|
* @author Uday Mathur
|
||||||
|
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
class TaskAddUser extends SimpleContainer {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(TaskAddUser.class);
|
||||||
|
|
||||||
|
private final TaskRequestLocal m_task;
|
||||||
|
|
||||||
|
private SearchForm m_search;
|
||||||
|
private AddForm m_add;
|
||||||
|
|
||||||
|
public TaskAddUser(final TaskRequestLocal task) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
m_task = task;
|
||||||
|
|
||||||
|
m_search = new SearchForm();
|
||||||
|
add(m_search);
|
||||||
|
|
||||||
|
m_add = new AddForm();
|
||||||
|
add(m_add);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserSearchForm getSearchForm() {
|
||||||
|
return m_search;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserAddForm getAddForm() {
|
||||||
|
return m_add;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void generateXML(final PageState state,
|
||||||
|
final Element parent) {
|
||||||
|
if (isVisible(state)) {
|
||||||
|
final FormData one = m_search.getFormData(state);
|
||||||
|
final FormData two = m_add.getForm().getFormData(state);
|
||||||
|
|
||||||
|
if (one != null && (one.isSubmission() || two.isSubmission())) {
|
||||||
|
m_search.generateXML(state, parent);
|
||||||
|
m_add.generateXML(state, parent);
|
||||||
|
} else {
|
||||||
|
m_search.generateXML(state, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SearchForm extends UserSearchForm {
|
||||||
|
|
||||||
|
private final Submit m_cancel;
|
||||||
|
|
||||||
|
public SearchForm() {
|
||||||
|
super("user-search");
|
||||||
|
|
||||||
|
m_cancel = new Submit("cancel", gz("cms.ui.cancel"));
|
||||||
|
|
||||||
|
add(m_cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AddForm extends UserAddForm {
|
||||||
|
|
||||||
|
public AddForm() {
|
||||||
|
super(m_search.getSearchWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final List<User> makeQuery(final PageState state) {
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final UserRepository userRepo = cdiUtil.findBean(
|
||||||
|
UserRepository.class);
|
||||||
|
|
||||||
|
final String search = (String) getSearchWidget().getValue(state);
|
||||||
|
|
||||||
|
return userRepo.filtered(search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final String[] users = (String[]) data.get("users");
|
||||||
|
|
||||||
|
if (users == null) {
|
||||||
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
|
"cms.ui.workflow.no_users_were_selected",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
} else {
|
||||||
|
// Add each checked user to the task.
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil.findBean(
|
||||||
|
WorkflowManager.class);
|
||||||
|
final UserRepository userRepo = cdiUtil.findBean(UserRepository.class);
|
||||||
|
|
||||||
|
final UserTask task = m_task.getTask(state);
|
||||||
|
User user;
|
||||||
|
|
||||||
|
for (int i = 0; i < users.length; i++) {
|
||||||
|
user = userRepo.findById(Long.parseLong(users[i]));
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GlobalizedMessage gz(final String key) {
|
||||||
|
return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String lz(final String key) {
|
||||||
|
return (String) gz(key).localize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,476 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the CCM Public
|
||||||
|
* License (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the
|
||||||
|
* License at http://www.redhat.com/licenses/ccmpl.html.
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
||||||
|
* or implied. See the License for the specific language
|
||||||
|
* governing rights and limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.TableActionAdapter;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.cms.ui.BaseItemPane;
|
||||||
|
import com.arsdigita.cms.ui.VisibilityComponent;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.librecms.workflow.CmsTask;
|
||||||
|
import org.libreccm.core.EmailAddress;
|
||||||
|
import org.libreccm.security.Group;
|
||||||
|
import org.libreccm.security.User;
|
||||||
|
|
||||||
|
import com.arsdigita.toolbox.ui.ActionGroup;
|
||||||
|
import com.arsdigita.toolbox.ui.PropertyList;
|
||||||
|
import com.arsdigita.toolbox.ui.Section;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
|
|
||||||
|
import com.sun.javafx.scene.control.skin.VirtualFlow;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.GroupRepository;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
import org.libreccm.security.Shiro;
|
||||||
|
import org.libreccm.workflow.Task;
|
||||||
|
import org.libreccm.workflow.UserTask;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
import org.libreccm.workflow.WorkflowManager;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
|
*/
|
||||||
|
final class TaskItemPane extends BaseItemPane {
|
||||||
|
|
||||||
|
private final WorkflowRequestLocal m_workflow;
|
||||||
|
private final TaskRequestLocal m_task;
|
||||||
|
|
||||||
|
private final SimpleContainer m_detailPane;
|
||||||
|
|
||||||
|
TaskItemPane(final WorkflowRequestLocal workflow,
|
||||||
|
final TaskRequestLocal task,
|
||||||
|
final ActionLink finishLink,
|
||||||
|
final ActionLink editLink,
|
||||||
|
final ActionLink deleteLink,
|
||||||
|
final ActionLink backLink) {
|
||||||
|
m_workflow = workflow;
|
||||||
|
m_task = task;
|
||||||
|
|
||||||
|
m_detailPane = new SimpleContainer();
|
||||||
|
m_detailPane.add(new Navigation(backLink));
|
||||||
|
m_detailPane.add(new SummarySection(finishLink, editLink, deleteLink));
|
||||||
|
|
||||||
|
// Users
|
||||||
|
final ActionLink userAddLink = new ActionLink(new Label(gz(
|
||||||
|
"cms.ui.workflow.task.user.add")));
|
||||||
|
|
||||||
|
final TaskAddUser userAddPane = new TaskAddUser(m_task);
|
||||||
|
|
||||||
|
final Form search = userAddPane.getSearchForm();
|
||||||
|
final Form add = userAddPane.getAddForm().getForm();
|
||||||
|
|
||||||
|
// Roles
|
||||||
|
final ActionLink roleAddLink = new ActionLink(new Label(gz(
|
||||||
|
"cms.ui.workflow.task.role.add")));
|
||||||
|
|
||||||
|
final TaskAddRole roleAddForm = new TaskAddRole(m_task);
|
||||||
|
|
||||||
|
m_detailPane.add(new RoleSection(roleAddLink));
|
||||||
|
|
||||||
|
add(m_detailPane);
|
||||||
|
setDefault(m_detailPane);
|
||||||
|
add(userAddPane);
|
||||||
|
add(roleAddForm);
|
||||||
|
|
||||||
|
userAddLink.addActionListener(new NavigationListener(userAddPane));
|
||||||
|
search.addSubmissionListener(new CancelListener(search));
|
||||||
|
add.addSubmissionListener(new CancelListener(add));
|
||||||
|
add.addProcessListener(new FormNavigationListener(m_detailPane));
|
||||||
|
|
||||||
|
connect(roleAddLink, roleAddForm);
|
||||||
|
resume(roleAddForm, m_detailPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasAdmin(final PageState state) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||||
|
PermissionChecker.class);
|
||||||
|
|
||||||
|
return permissionChecker.isPermitted(
|
||||||
|
CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AdminVisible extends VisibilityComponent {
|
||||||
|
|
||||||
|
public AdminVisible(final Component child) {
|
||||||
|
super(child, CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AssigneeVisible extends AdminVisible {
|
||||||
|
|
||||||
|
private final Component m_child;
|
||||||
|
private final Assigned m_assigned;
|
||||||
|
|
||||||
|
public AssigneeVisible(final Component child) {
|
||||||
|
super(child);
|
||||||
|
|
||||||
|
m_child = child;
|
||||||
|
m_assigned = new Assigned();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isVisible(final PageState state) {
|
||||||
|
if (m_child.isVisible(state)) {
|
||||||
|
return m_assigned.isAssigned(state) || hasPermission(state);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Assigned extends RequestLocal {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final Object initialValue(final PageState state) {
|
||||||
|
if (assigned(state)) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
} else {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean assigned(final PageState state) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil.findBean(
|
||||||
|
WorkflowManager.class);
|
||||||
|
final Shiro shiro = cdiUtil.findBean(Shiro.class);
|
||||||
|
|
||||||
|
final User user = shiro.getUser();
|
||||||
|
|
||||||
|
final List<UserTask> tasks = workflowManager.lockedBy(user);
|
||||||
|
|
||||||
|
return tasks.contains(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean isAssigned(final PageState state) {
|
||||||
|
return ((Boolean) get(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class VisibilityListener implements ActionListener {
|
||||||
|
|
||||||
|
private final TableColumn m_column;
|
||||||
|
|
||||||
|
VisibilityListener(final TableColumn column) {
|
||||||
|
m_column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void actionPerformed(final ActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (state.isVisibleOnPage(TaskItemPane.this) && !hasAdmin(state)) {
|
||||||
|
m_column.setVisible(state, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Navigation extends ActionGroup {
|
||||||
|
|
||||||
|
Navigation(final ActionLink backLink) {
|
||||||
|
addAction(backLink, ActionGroup.RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SummarySection extends Section {
|
||||||
|
|
||||||
|
SummarySection(final ActionLink finishLink,
|
||||||
|
final ActionLink editLink,
|
||||||
|
final ActionLink deleteLink) {
|
||||||
|
setHeading(new Label(gz("cms.ui.workflow.task.details")));
|
||||||
|
|
||||||
|
final ActionGroup group = new ActionGroup();
|
||||||
|
setBody(group);
|
||||||
|
|
||||||
|
group.setSubject(new Properties());
|
||||||
|
group.addAction(new AssigneeVisible(new LockLink()));
|
||||||
|
group.addAction(new AssigneeVisible(new UnlockLink()));
|
||||||
|
group.addAction(new AssigneeVisible(finishLink));
|
||||||
|
group.addAction(new AdminVisible(editLink), ActionGroup.EDIT);
|
||||||
|
group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LockLink extends ActionLink {
|
||||||
|
|
||||||
|
LockLink() {
|
||||||
|
super(new Label(gz("cms.ui.workflow.task.lock")));
|
||||||
|
|
||||||
|
addActionListener(new Listener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isVisible(final PageState state) {
|
||||||
|
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
return task.isActive() && !task.isLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Listener implements ActionListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void actionPerformed(final ActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (hasAdmin(state)) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil
|
||||||
|
.findBean(WorkflowManager.class);
|
||||||
|
workflowManager.lockTask(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnlockLink extends ActionLink {
|
||||||
|
|
||||||
|
UnlockLink() {
|
||||||
|
super(new Label(gz("cms.ui.workflow.task.unlock")));
|
||||||
|
|
||||||
|
addActionListener(new Listener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isVisible(final PageState state) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
return task.isActive() && task.isLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Listener implements ActionListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void actionPerformed(final ActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (hasAdmin(state)) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil
|
||||||
|
.findBean(WorkflowManager.class);
|
||||||
|
workflowManager.unlockTask(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Properties extends PropertyList {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final List<Property> properties(final PageState state) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final List<Property> props = super.properties(state);
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
|
||||||
|
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
|
props.add(new Property(gz("cms.ui.name"),
|
||||||
|
task.getLabel().getValue(defaultLocale)));
|
||||||
|
props.add(new Property(gz("cms.ui.description"),
|
||||||
|
task.getDescription().getValue(
|
||||||
|
defaultLocale)));
|
||||||
|
props.add(new Property(gz("cms.ui.workflow.task.dependencies"),
|
||||||
|
deps(task)));
|
||||||
|
props.add(new Property(gz("cms.ui.workflow.task.state"),
|
||||||
|
task.getTaskState()));
|
||||||
|
props.add(new Property(gz("cms.ui.workflow.task.locked"),
|
||||||
|
task.isLocked()
|
||||||
|
? lz("cms.ui.yes") : lz("cms.ui.no")));
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String deps(final CmsTask task) {
|
||||||
|
final List<Task> deps = task.getDependsOn();
|
||||||
|
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
final StringJoiner joiner = new StringJoiner(", ");
|
||||||
|
|
||||||
|
deps.forEach(dep -> joiner.add(dep.getLabel().getValue(
|
||||||
|
defaultLocale)));
|
||||||
|
|
||||||
|
return joiner.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RoleSection extends Section {
|
||||||
|
|
||||||
|
public RoleSection(final ActionLink roleAddLink) {
|
||||||
|
setHeading(new Label(gz("cms.ui.workflow.task.roles")));
|
||||||
|
|
||||||
|
final ActionGroup group = new ActionGroup();
|
||||||
|
setBody(group);
|
||||||
|
|
||||||
|
group.setSubject(new RoleTable());
|
||||||
|
group.addAction(new AdminVisible(roleAddLink), ActionGroup.ADD);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RoleTable extends Table {
|
||||||
|
|
||||||
|
public RoleTable() {
|
||||||
|
super(new RoleTableModelBuilder(m_task),
|
||||||
|
new String[]{
|
||||||
|
lz("cms.ui.name"), // XXX globz
|
||||||
|
lz("cms.ui.workflow.task.role.delete")
|
||||||
|
});
|
||||||
|
|
||||||
|
setEmptyView(new Label(gz("cms.ui.workflow.task.role.none")));
|
||||||
|
|
||||||
|
getColumn(1).setCellRenderer(new DefaultTableCellRenderer(true));
|
||||||
|
|
||||||
|
addTableActionListener(new TableActionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final int column = event.getColumn();
|
||||||
|
|
||||||
|
if (column == 1) {
|
||||||
|
if (hasAdmin(state)) {
|
||||||
|
final CmsTask task = m_task.getTask(state);
|
||||||
|
final Long roleId = Long.parseLong((String) event
|
||||||
|
.getRowKey());
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowManager workflowManager = cdiUtil
|
||||||
|
.findBean(WorkflowManager.class);
|
||||||
|
final RoleRepository roleRepo = cdiUtil.findBean(
|
||||||
|
RoleRepository.class);
|
||||||
|
|
||||||
|
final Role role = roleRepo.findById(roleId);
|
||||||
|
workflowManager.retractTask(task, role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void register(final Page page) {
|
||||||
|
super.register(page);
|
||||||
|
|
||||||
|
page.addActionListener(new VisibilityListener(getColumn(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RoleTableModelBuilder extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final TaskRequestLocal m_task;
|
||||||
|
|
||||||
|
public RoleTableModelBuilder(final TaskRequestLocal task) {
|
||||||
|
m_task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final TableModel makeModel(final Table table,
|
||||||
|
final PageState state) {
|
||||||
|
return new Model(m_task.getTask(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Model implements TableModel {
|
||||||
|
|
||||||
|
private final List<Role> roles = new ArrayList<>();
|
||||||
|
private Role role;
|
||||||
|
private int index = -1;
|
||||||
|
|
||||||
|
private Model(final CmsTask task) {
|
||||||
|
task.getAssignments().forEach(assignment -> roles.add(
|
||||||
|
assignment.getRole()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getColumnCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean nextRow() {
|
||||||
|
index++;
|
||||||
|
return index < roles.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Object getKeyAt(final int column) {
|
||||||
|
return Long.toString(role.getRoleId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Object getElementAt(final int column) {
|
||||||
|
switch (column) {
|
||||||
|
case 0:
|
||||||
|
return role.getName();
|
||||||
|
case 1:
|
||||||
|
return lz("cms.ui.workflow.task.role.delete");
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import org.librecms.workflow.CmsTask;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
public abstract class TaskRequestLocal extends RequestLocal {
|
||||||
|
|
||||||
|
public final CmsTask getTask(final PageState state) {
|
||||||
|
final CmsTask task = (CmsTask) get(state);
|
||||||
|
|
||||||
|
Assert.exists(task, "CmsTask task");
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.librecms.contentsection.ContentSection;
|
||||||
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.workflow.WorkflowTemplateRepository;
|
||||||
|
import org.librecms.contentsection.ContentSectionManager;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author Uday Mathur
|
||||||
|
* @author Michael Pih
|
||||||
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
|
*/
|
||||||
|
class WorkflowAddForm extends BaseWorkflowForm {
|
||||||
|
|
||||||
|
private final SingleSelectionModel<Long> m_model;
|
||||||
|
|
||||||
|
WorkflowAddForm(final SingleSelectionModel<Long> model) {
|
||||||
|
super("workflow", gz("cms.ui.workflow.add"));
|
||||||
|
|
||||||
|
m_model = model;
|
||||||
|
|
||||||
|
addProcessListener(new ProcessListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final String label = (String) m_title.getValue(state);
|
||||||
|
final String description = (String) m_description.getValue(state);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowTemplateRepository workflowTemplateRepository = cdiUtil.findBean(
|
||||||
|
WorkflowTemplateRepository.class);
|
||||||
|
final ContentSectionManager sectionManager = cdiUtil.findBean(
|
||||||
|
ContentSectionManager.class);
|
||||||
|
final ConfigurationManager confManager = cdiUtil.findBean(ConfigurationManager.class);
|
||||||
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
|
KernelConfig.class);
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
|
final WorkflowTemplate workflow = new WorkflowTemplate();
|
||||||
|
workflow.getName().addValue(defaultLocale, label);
|
||||||
|
workflow.getDescription().addValue(defaultLocale, description);
|
||||||
|
|
||||||
|
workflowTemplateRepository.save(workflow);
|
||||||
|
|
||||||
|
final ContentSection section =
|
||||||
|
CMS.getContext().getContentSection();
|
||||||
|
sectionManager.addWorkflowTemplateToContentSection(workflow, section);
|
||||||
|
|
||||||
|
m_model.setSelectedKey(state, workflow.getWorkflowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,24 +22,21 @@ import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.cms.SecurityManager;
|
|
||||||
import com.arsdigita.cms.ui.BaseAdminPane;
|
import com.arsdigita.cms.ui.BaseAdminPane;
|
||||||
import com.arsdigita.cms.ui.BaseDeleteForm;
|
import com.arsdigita.cms.ui.BaseDeleteForm;
|
||||||
import com.arsdigita.cms.ui.VisibilityComponent;
|
import com.arsdigita.cms.ui.VisibilityComponent;
|
||||||
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
* @version $Id: WorkflowAdminPane.java 287 2005-02-22 00:29:02Z sskracic $
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
*/
|
*/
|
||||||
public final class WorkflowAdminPane extends BaseAdminPane {
|
public final class WorkflowAdminPane extends BaseAdminPane {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
|
||||||
(WorkflowAdminPane.class);
|
|
||||||
|
|
||||||
private final WorkflowRequestLocal m_workflow;
|
private final WorkflowRequestLocal m_workflow;
|
||||||
|
|
||||||
public WorkflowAdminPane() {
|
public WorkflowAdminPane() {
|
||||||
|
|
@ -57,33 +54,39 @@ public final class WorkflowAdminPane extends BaseAdminPane {
|
||||||
getEditLink(),
|
getEditLink(),
|
||||||
getDeleteLink()));
|
getDeleteLink()));
|
||||||
|
|
||||||
addAction(new VisibilityComponent(getAddLink(),
|
addAction(new VisibilityComponent(
|
||||||
SecurityManager.WORKFLOW_ADMIN));
|
getAddLink(), CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DeleteForm extends BaseDeleteForm {
|
private class DeleteForm extends BaseDeleteForm {
|
||||||
|
|
||||||
DeleteForm() {
|
DeleteForm() {
|
||||||
super(gz("cms.ui.workflow.delete_prompt"));
|
super(gz("cms.ui.workflow.delete_prompt"));
|
||||||
|
|
||||||
addSecurityListener(SecurityManager.WORKFLOW_ADMIN);
|
addSecurityListener(CmsConstants.PRIVILEGE_ADMINISTER_WORKFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void process(final FormSectionEvent e)
|
public final void process(final FormSectionEvent e)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
final PageState state = e.getPageState();
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
m_workflow.getWorkflow(state).delete();
|
m_workflow.getWorkflow(state).delete();
|
||||||
|
|
||||||
getSelectionModel().clearSelection(state);
|
getSelectionModel().clearSelection(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SelectionRequestLocal extends WorkflowRequestLocal {
|
private class SelectionRequestLocal extends WorkflowRequestLocal {
|
||||||
|
|
||||||
protected final Object initialValue(final PageState state) {
|
protected final Object initialValue(final PageState state) {
|
||||||
final String id = getSelectionModel().getSelectedKey
|
final String id = getSelectionModel().getSelectedKey(state)
|
||||||
(state).toString();
|
.toString();
|
||||||
|
|
||||||
return new WorkflowTemplate(new BigDecimal(id));
|
return new WorkflowTemplate(new BigDecimal(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
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 com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
import org.libreccm.workflow.WorkflowRepository;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author Uday Mathur
|
||||||
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
|
*/
|
||||||
|
class WorkflowEditForm extends BaseWorkflowForm {
|
||||||
|
|
||||||
|
private final WorkflowRequestLocal m_workflow;
|
||||||
|
|
||||||
|
WorkflowEditForm(final WorkflowRequestLocal workflow) {
|
||||||
|
super("workflow", gz("cms.ui.workflow.edit"));
|
||||||
|
|
||||||
|
m_workflow = workflow;
|
||||||
|
|
||||||
|
addInitListener(new InitListener());
|
||||||
|
addProcessListener(new ProcessListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final Workflow workflow = m_workflow.getWorkflow(state);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final WorkflowRepository workflowRepo = cdiUtil.findBean(
|
||||||
|
WorkflowRepository.class);
|
||||||
|
final ConfigurationManager confManager = cdiUtil.findBean(
|
||||||
|
ConfigurationManager.class);
|
||||||
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
|
KernelConfig.class);
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
|
workflow.getName().addValue(defaultLocale,
|
||||||
|
(String) m_title.getValue(state));
|
||||||
|
workflow.getDescription().addValue(
|
||||||
|
defaultLocale,
|
||||||
|
(String) m_description.getValue(state));
|
||||||
|
|
||||||
|
workflowRepo.save(workflow);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InitListener implements FormInitListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void init(final FormSectionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final Workflow workflow = m_workflow.getWorkflow(state);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final ConfigurationManager confManager = cdiUtil.findBean(
|
||||||
|
ConfigurationManager.class);
|
||||||
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
|
KernelConfig.class);
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
|
m_title.setValue(state, workflow.getName().getValue(defaultLocale));
|
||||||
|
m_description.setValue(state, workflow.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
|
||||||
|
class WorkflowItemPane extends BaseWorkflowItemPane {
|
||||||
|
|
||||||
|
public WorkflowItemPane(final WorkflowRequestLocal workflow,
|
||||||
|
final ActionLink editLink,
|
||||||
|
final ActionLink deleteLink) {
|
||||||
|
super(workflow, editLink, deleteLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.List;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.list.AbstractListModelBuilder;
|
||||||
|
import com.arsdigita.bebop.list.ListModel;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.librecms.contentsection.ContentSection;
|
||||||
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
|
import org.libreccm.workflow.Task;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a list of workflow templates registered to the current content
|
||||||
|
* section.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @author Michael Pih
|
||||||
|
* @author <a href="mailto:jross@redhat.com">Justin Ross</a>
|
||||||
|
*/
|
||||||
|
class WorkflowListModelBuilder extends AbstractListModelBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ListModel makeModel(final List list, final PageState state) {
|
||||||
|
return new Model();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Model implements ListModel {
|
||||||
|
|
||||||
|
private final java.util.List<WorkflowTemplate> templates;
|
||||||
|
private int index = -1;
|
||||||
|
|
||||||
|
public Model() {
|
||||||
|
final ContentSection section = CMS.getContext().getContentSection();
|
||||||
|
|
||||||
|
templates = section.getWorkflowTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean next() {
|
||||||
|
index++;
|
||||||
|
return index < templates.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElement() {
|
||||||
|
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
return templates.get(index).getName().getValue(defaultLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return Long.toString(templates.get(index).getWorkflowId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-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.cms.ui.workflow;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
|
||||||
|
public abstract class WorkflowRequestLocal extends RequestLocal {
|
||||||
|
|
||||||
|
public final Workflow getWorkflow(final PageState state) {
|
||||||
|
return (Workflow) get(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -199,7 +199,7 @@ public class ContentItemManager {
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
|
|
||||||
item.setDisplayName(name);
|
item.setDisplayName(name);
|
||||||
item.getName().addValue(new Locale(kernelConfig.getDefaultLanguage()),
|
item.getName().addValue(kernelConfig.getDefaultLocale(),
|
||||||
name);
|
name);
|
||||||
item.setLifecycle(lifecycle);
|
item.setLifecycle(lifecycle);
|
||||||
item.setWorkflow(workflow);
|
item.setWorkflow(workflow);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.libreccm.security.PermissionManager;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
import org.libreccm.security.Role;
|
import org.libreccm.security.Role;
|
||||||
import org.libreccm.security.RoleRepository;
|
import org.libreccm.security.RoleRepository;
|
||||||
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -41,6 +42,7 @@ import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.librecms.lifecycle.LifecycleDefinition;
|
import org.librecms.lifecycle.LifecycleDefinition;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
@ -87,13 +89,12 @@ public class ContentSectionManager {
|
||||||
public ContentSection createContentSection(final String name) {
|
public ContentSection createContentSection(final String name) {
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The name of a ContentSection can't be blank.");
|
"The name of a ContentSection can't be blank.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defautLocale
|
final Locale defautLocale = kernelConfig.getDefaultLocale();
|
||||||
= new Locale(kernelConfig.getDefaultLanguage());
|
|
||||||
|
|
||||||
final ContentSection section = new ContentSection();
|
final ContentSection section = new ContentSection();
|
||||||
section.setLabel(name);
|
section.setLabel(name);
|
||||||
|
|
@ -233,12 +234,12 @@ public class ContentSectionManager {
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeRoleFromContentSection(
|
public void removeRoleFromContentSection(
|
||||||
final ContentSection contentSection,
|
final ContentSection contentSection,
|
||||||
final Role role) {
|
final Role role) {
|
||||||
|
|
||||||
if (contentSection == null) {
|
if (contentSection == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Can't remove role from ContentSection null");
|
"Can't remove role from ContentSection null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
|
|
@ -249,8 +250,8 @@ public class ContentSectionManager {
|
||||||
sectionRepo.save(contentSection);
|
sectionRepo.save(contentSection);
|
||||||
|
|
||||||
final TypedQuery<Permission> query = entityManager
|
final TypedQuery<Permission> query = entityManager
|
||||||
.createNamedQuery("ContentSection.findPermissions",
|
.createNamedQuery("ContentSection.findPermissions",
|
||||||
Permission.class);
|
Permission.class);
|
||||||
query.setParameter("section", contentSection);
|
query.setParameter("section", contentSection);
|
||||||
query.setParameter("rootDocumentsFolder",
|
query.setParameter("rootDocumentsFolder",
|
||||||
contentSection.getRootDocumentsFolder());
|
contentSection.getRootDocumentsFolder());
|
||||||
|
|
@ -280,8 +281,8 @@ public class ContentSectionManager {
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addLifecycleDefinitionToContentSection(
|
public void addLifecycleDefinitionToContentSection(
|
||||||
final LifecycleDefinition definition,
|
final LifecycleDefinition definition,
|
||||||
final ContentSection section) {
|
final ContentSection section) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -289,8 +290,8 @@ public class ContentSectionManager {
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeLifecycleDefinitionFromContentSection(
|
public void removeLifecycleDefinitionFromContentSection(
|
||||||
final LifecycleDefinition definition,
|
final LifecycleDefinition definition,
|
||||||
final ContentSection contentSection) {
|
final ContentSection contentSection) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,8 +299,8 @@ public class ContentSectionManager {
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addWorkflowTemplateToContentSection(
|
public void addWorkflowTemplateToContentSection(
|
||||||
final LifecycleDefinition definition,
|
final WorkflowTemplate definition,
|
||||||
final ContentSection section) {
|
final ContentSection section) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,15 +309,16 @@ public class ContentSectionManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
|
||||||
public void removeWorkflowTemplateFromContentSection(
|
public void removeWorkflowTemplateFromContentSection(
|
||||||
final LifecycleDefinition definition,
|
final LifecycleDefinition definition,
|
||||||
final ContentSection contentSection) {
|
final ContentSection contentSection) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemResolver getItemResolver(final ContentSection section) {
|
public ItemResolver getItemResolver(final ContentSection section) {
|
||||||
try {
|
try {
|
||||||
final Class<ItemResolver> itemResolverClazz = (Class<ItemResolver>) Class.
|
final Class<ItemResolver> itemResolverClazz
|
||||||
forName(section.getItemResolverClass());
|
= (Class<ItemResolver>) Class.
|
||||||
|
forName(section.getItemResolverClass());
|
||||||
return itemResolverClazz.newInstance();
|
return itemResolverClazz.newInstance();
|
||||||
} catch (ClassNotFoundException |
|
} catch (ClassNotFoundException |
|
||||||
IllegalAccessException |
|
IllegalAccessException |
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.libreccm.configuration.Configuration;
|
||||||
import org.libreccm.configuration.ConfigurationManager;
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
import org.libreccm.configuration.Setting;
|
import org.libreccm.configuration.Setting;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -199,6 +200,10 @@ public final class KernelConfig {
|
||||||
this.defaultLanguage = defaultLanguage;
|
this.defaultLanguage = defaultLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Locale getDefaultLocale() {
|
||||||
|
return new Locale(getDefaultLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
public String getSystemEmailAddress() {
|
public String getSystemEmailAddress() {
|
||||||
return systemEmailAddress;
|
return systemEmailAddress;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import java.util.Locale;
|
||||||
public class ApplicationInstanceTreeNode implements TreeNode {
|
public class ApplicationInstanceTreeNode implements TreeNode {
|
||||||
|
|
||||||
protected static final String INSTANCE_NODE_KEY_PREFIX = "appinstance_";
|
protected static final String INSTANCE_NODE_KEY_PREFIX = "appinstance_";
|
||||||
|
|
||||||
private final CcmApplication application;
|
private final CcmApplication application;
|
||||||
|
|
||||||
public ApplicationInstanceTreeNode(final CcmApplication application) {
|
public ApplicationInstanceTreeNode(final CcmApplication application) {
|
||||||
|
|
@ -45,7 +45,7 @@ public class ApplicationInstanceTreeNode implements TreeNode {
|
||||||
@Override
|
@Override
|
||||||
public Object getKey() {
|
public Object getKey() {
|
||||||
return String.format("%s%d",
|
return String.format("%s%d",
|
||||||
INSTANCE_NODE_KEY_PREFIX,
|
INSTANCE_NODE_KEY_PREFIX,
|
||||||
application.getObjectId());
|
application.getObjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,8 +57,7 @@ public class ApplicationInstanceTreeNode implements TreeNode {
|
||||||
.findBean(ConfigurationManager.class);
|
.findBean(ConfigurationManager.class);
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
if (application.getTitle().hasValue(globalizationHelper
|
if (application.getTitle().hasValue(globalizationHelper
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class GlobalizationHelper {
|
||||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||||
KernelConfig.class);
|
KernelConfig.class);
|
||||||
|
|
||||||
Locale preferred = new Locale(kernelConfig.getDefaultLanguage());
|
Locale preferred = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
final Locale selectedLocale = getSelectedLocale();
|
final Locale selectedLocale = getSelectedLocale();
|
||||||
if (selectedLocale == null || !kernelConfig.hasLanguage(selectedLocale
|
if (selectedLocale == null || !kernelConfig.hasLanguage(selectedLocale
|
||||||
|
|
|
||||||
|
|
@ -401,8 +401,7 @@ public class ChallengeManager {
|
||||||
} else {
|
} else {
|
||||||
final KernelConfig kernelConfig = configurationManager
|
final KernelConfig kernelConfig = configurationManager
|
||||||
.findConfiguration(KernelConfig.class);
|
.findConfiguration(KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale =kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
return localizedString.getValue(defaultLocale);
|
return localizedString.getValue(defaultLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -444,8 +443,7 @@ public class ChallengeManager {
|
||||||
} else {
|
} else {
|
||||||
final KernelConfig kernelConfig = configurationManager
|
final KernelConfig kernelConfig = configurationManager
|
||||||
.findConfiguration(KernelConfig.class);
|
.findConfiguration(KernelConfig.class);
|
||||||
final Locale defaultLocale = new Locale(kernelConfig
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
.getDefaultLanguage());
|
|
||||||
return localizedString.getValue(defaultLocale);
|
return localizedString.getValue(defaultLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue