mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- Added reapply rules action to manage rules dialog.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2787 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -223,6 +223,8 @@ add_multiple_files=Add Multiple Files
|
|||||||
import_directory=Import Directory
|
import_directory=Import Directory
|
||||||
advanced_space_wizard=Advanced Space Wizard
|
advanced_space_wizard=Advanced Space Wizard
|
||||||
create_rule=Create Rule
|
create_rule=Create Rule
|
||||||
|
reapply_rules=Reapply Rules
|
||||||
|
reapply_rules_success=The rules have been successfully reapplied.
|
||||||
manage_rules=Manage Content Rules
|
manage_rules=Manage Content Rules
|
||||||
manage_users=Manage System Users
|
manage_users=Manage System Users
|
||||||
manage_groups=Manage User Groups
|
manage_groups=Manage User Groups
|
||||||
|
@@ -459,6 +459,13 @@
|
|||||||
</params>
|
</params>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
<!-- ReApply Rules -->
|
||||||
|
<action id="reapply-rules">
|
||||||
|
<label-id>reapply_rules</label-id>
|
||||||
|
<image>/images/icons/export.gif</image>
|
||||||
|
<action-listener>#{RulesBean.reapplyRules}</action-listener>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
|
||||||
<!-- the 'action-group' elements define unique blocks of actions that reference the actions
|
<!-- the 'action-group' elements define unique blocks of actions that reference the actions
|
||||||
as defined above and can override or supply display elements for the group of actions -->
|
as defined above and can override or supply display elements for the group of actions -->
|
||||||
@@ -594,6 +601,11 @@
|
|||||||
<action idref="manage_content_users" />
|
<action idref="manage_content_users" />
|
||||||
</action-group>
|
</action-group>
|
||||||
|
|
||||||
|
<!-- Actions Menu for Manage Rules screen -->
|
||||||
|
<action-group id="rules_actions_menu">
|
||||||
|
<action idref="reapply-rules" />
|
||||||
|
</action-group>
|
||||||
|
|
||||||
</actions>
|
</actions>
|
||||||
</config>
|
</config>
|
||||||
|
|
||||||
|
@@ -16,14 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.rules;
|
package org.alfresco.web.bean.rules;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import org.alfresco.repo.action.executer.ExecuteAllRulesActionExecuter;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.rule.Rule;
|
import org.alfresco.service.cmr.rule.Rule;
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
@@ -32,6 +38,7 @@ import org.alfresco.web.app.context.IContextListener;
|
|||||||
import org.alfresco.web.app.context.UIContextService;
|
import org.alfresco.web.app.context.UIContextService;
|
||||||
import org.alfresco.web.bean.BrowseBean;
|
import org.alfresco.web.bean.BrowseBean;
|
||||||
import org.alfresco.web.bean.repository.Node;
|
import org.alfresco.web.bean.repository.Node;
|
||||||
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||||
import org.alfresco.web.ui.common.component.UIModeList;
|
import org.alfresco.web.ui.common.component.UIModeList;
|
||||||
@@ -47,6 +54,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
public class RulesBean implements IContextListener
|
public class RulesBean implements IContextListener
|
||||||
{
|
{
|
||||||
private static final String MSG_ERROR_DELETE_RULE = "error_delete_rule";
|
private static final String MSG_ERROR_DELETE_RULE = "error_delete_rule";
|
||||||
|
private static final String MSG_REAPPLY_RULES_SUCCESS = "reapply_rules_success";
|
||||||
private static final String LOCAL = "local";
|
private static final String LOCAL = "local";
|
||||||
private static final String INHERITED = "inherited";
|
private static final String INHERITED = "inherited";
|
||||||
|
|
||||||
@@ -58,6 +66,7 @@ public class RulesBean implements IContextListener
|
|||||||
private List<WrappedRule> rules;
|
private List<WrappedRule> rules;
|
||||||
private Rule currentRule;
|
private Rule currentRule;
|
||||||
private UIRichList richList;
|
private UIRichList richList;
|
||||||
|
private ActionService actionService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +146,53 @@ public class RulesBean implements IContextListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reapply the currently defines rules to the
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
public void reapplyRules(ActionEvent event)
|
||||||
|
{
|
||||||
|
FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
|
||||||
|
UserTransaction tx = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tx = Repository.getUserTransaction(fc);
|
||||||
|
tx.begin();
|
||||||
|
|
||||||
|
// Create the the apply rules action
|
||||||
|
Action action = this.actionService.createAction(ExecuteAllRulesActionExecuter.NAME);
|
||||||
|
|
||||||
|
// Set the include inherited parameter to match the current filter value
|
||||||
|
boolean executeInherited = true;
|
||||||
|
if (LOCAL.equals(this.getViewMode()) == true)
|
||||||
|
{
|
||||||
|
executeInherited = false;
|
||||||
|
}
|
||||||
|
action.setParameterValue(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, executeInherited);
|
||||||
|
|
||||||
|
// Execute the action
|
||||||
|
this.actionService.executeAction(action, this.getSpace().getNodeRef());
|
||||||
|
|
||||||
|
// TODO how do I get the message here ...
|
||||||
|
String msg = Application.getMessage(fc, MSG_REAPPLY_RULES_SUCCESS);
|
||||||
|
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
||||||
|
String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
|
||||||
|
fc.addMessage(formId + ":rulesList", facesMsg);
|
||||||
|
|
||||||
|
// commit the transaction
|
||||||
|
tx.commit();
|
||||||
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
// rollback the transaction
|
||||||
|
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||||
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
|
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current rule
|
* Returns the current rule
|
||||||
*
|
*
|
||||||
@@ -241,6 +297,16 @@ public class RulesBean implements IContextListener
|
|||||||
this.ruleService = ruleService;
|
this.ruleService = ruleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the action service to use
|
||||||
|
*
|
||||||
|
* @param actionService the action service
|
||||||
|
*/
|
||||||
|
public void setActionService(ActionService actionService)
|
||||||
|
{
|
||||||
|
this.actionService = actionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// IContextListener implementation
|
// IContextListener implementation
|
||||||
|
@@ -887,6 +887,10 @@
|
|||||||
<property-name>ruleService</property-name>
|
<property-name>ruleService</property-name>
|
||||||
<value>#{RuleService}</value>
|
<value>#{RuleService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>actionService</property-name>
|
||||||
|
<value>#{ActionService}</value>
|
||||||
|
</managed-property>
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
|
@@ -76,6 +76,12 @@
|
|||||||
<%-- Current object actions --%>
|
<%-- Current object actions --%>
|
||||||
<a:actionLink value="#{msg.create_rule}" image="/images/icons/new_rule.gif" padding="4" action="wizard:createRule" />
|
<a:actionLink value="#{msg.create_rule}" image="/images/icons/new_rule.gif" padding="4" action="wizard:createRule" />
|
||||||
</td>
|
</td>
|
||||||
|
<td style="padding-left:4px" width=80>
|
||||||
|
<%-- More actions menu --%>
|
||||||
|
<a:menu id="actionsMenu" itemSpacing="4" label="#{msg.more_actions}" image="/images/icons/menu.gif" menuStyleClass="moreActionsMenu" style="white-space:nowrap">
|
||||||
|
<r:actions id="acts_rules" value="rules_actions_menu" context="#{RulesBean.space}" />
|
||||||
|
</a:menu>
|
||||||
|
</td>
|
||||||
<td class="separator" width=1></td>
|
<td class="separator" width=1></td>
|
||||||
<td width="125" style="padding-left:2px">
|
<td width="125" style="padding-left:2px">
|
||||||
<%-- Filters --%>
|
<%-- Filters --%>
|
||||||
@@ -205,7 +211,7 @@
|
|||||||
|
|
||||||
<a:dataPager styleClass="pager" />
|
<a:dataPager styleClass="pager" />
|
||||||
</a:richList>
|
</a:richList>
|
||||||
|
<h:message for="rulesList" styleClass="statusMessage" />
|
||||||
</a:panel>
|
</a:panel>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user