diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.desc.xml
new file mode 100644
index 0000000000..0f864cf617
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.desc.xml
@@ -0,0 +1,8 @@
+
+ Get Action Definition
+ Get an action definition given its name
+ /api/rules/actiondefs/{actionDefinitionName}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.json.ftl
new file mode 100644
index 0000000000..0835b86e12
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/actiondef.get.json.ftl
@@ -0,0 +1,4 @@
+<#import "actiondef.lib.ftl" as actionDefLib/>
+
+<@actionDefLib.actionDefJSON actiondef=actiondef/>
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.desc.xml
new file mode 100644
index 0000000000..00a0b4da3f
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.desc.xml
@@ -0,0 +1,8 @@
+
+ Get Condition Definition
+ Get a condition definition given its name
+ /api/rules/conditiondefs/{conditionDefinitionName}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.json.ftl
new file mode 100644
index 0000000000..bac65e023c
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/conditiondef.get.json.ftl
@@ -0,0 +1,4 @@
+<#import "conditiondef.lib.ftl" as conditionDefLib/>
+
+<@conditionDefLib.conditionDefJSON conditiondef=conditiondef/>
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.desc.xml
new file mode 100644
index 0000000000..2235ed4802
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.desc.xml
@@ -0,0 +1,10 @@
+
+ Delete Rule
+ Delete the rule identified by the specified rule node id.
+ /api/rules/{store_type}/{store_id}/{rule_id}
+ /api/node/{store_type}/{store_id}/{id}/rules/{rule_id}
+ /api/path/{store_type}/{store_id}/{id}/rules/{rule_id}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.json.ftl
new file mode 100644
index 0000000000..f81dc51f8d
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.delete.json.ftl
@@ -0,0 +1,3 @@
+{
+ "success": true
+}
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.desc.xml
new file mode 100644
index 0000000000..ee5fa3baab
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.desc.xml
@@ -0,0 +1,10 @@
+
+ Delete Rules
+ Delete the collection of rules which have been applied to the given rule owning node node.
+ /api/node/{store_type}/{store_id}/{id}/rules
+ /api/path/{store_type}/{store_id}/{id}/rules
+ /api/rules/appliedtonode/{store_type}/{store_id}/{id}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.json.ftl
new file mode 100644
index 0000000000..f81dc51f8d
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rules.delete.json.ftl
@@ -0,0 +1,3 @@
+{
+ "success": true
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java
new file mode 100644
index 0000000000..0fc39035db
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.web.scripts.rule;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.service.cmr.action.ActionDefinition;
+import org.alfresco.service.cmr.action.ActionService;
+import org.alfresco.web.scripts.DeclarativeWebScript;
+import org.alfresco.web.scripts.Status;
+import org.alfresco.web.scripts.WebScriptException;
+import org.alfresco.web.scripts.WebScriptRequest;
+
+/**
+ * Web Script to GET an action definition given its name
+ *
+ * @author glen johnson at alfresco dot com
+ */
+public class ActionDefGet extends DeclarativeWebScript
+{
+ // model property keys
+ private static final String MODEL_PROP_KEY_ACTION_DEF = "actiondef";
+
+ // private constants
+ private static final String REQ_PARAM_ACTION_DEF_NAME = "actionDefinitionName";
+
+ // properties for services
+ private ActionService actionService;
+
+ /**
+ * Set the actionService property.
+ *
+ * @param actionService The action service instance to set
+ */
+ public void setActionService(ActionService actionService)
+ {
+ this.actionService = actionService;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(
+ * org.alfresco.web.scripts.WebScriptRequest,
+ * org.alfresco.web.scripts.WebScriptResponse)
+ */
+ @Override
+ protected Map executeImpl(WebScriptRequest req,
+ Status status)
+ {
+ // initialise model to pass on for template to render
+ Map model = new HashMap();
+
+ // get URL parameter
+ String actionDefName = req.getParameter(REQ_PARAM_ACTION_DEF_NAME);
+ if ((actionDefName == null) || (actionDefName.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'actionDefinitionName' URL parameter has not been provided in URL");
+ }
+
+ // get an action definition with the given action definition name
+ ActionDefinition actionDef = this.actionService.getActionDefinition(actionDefName);
+
+ // add objects to model for the template to render
+ model.put(MODEL_PROP_KEY_ACTION_DEF, actionDef);
+
+ return model;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java
new file mode 100644
index 0000000000..a9206ecbf1
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.web.scripts.rule;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.service.cmr.action.ActionConditionDefinition;
+import org.alfresco.service.cmr.action.ActionService;
+import org.alfresco.web.scripts.DeclarativeWebScript;
+import org.alfresco.web.scripts.Status;
+import org.alfresco.web.scripts.WebScriptException;
+import org.alfresco.web.scripts.WebScriptRequest;
+
+/**
+ * Web Script to GET a condition definition given its name
+ *
+ * @author glen johnson at alfresco dot com
+ */
+public class ConditionDefGet extends DeclarativeWebScript
+{
+ // model property keys
+ private static final String MODEL_PROP_KEY_CONDITION_DEF = "conditiondef";
+
+ // private constants
+ private static final String REQ_PARAM_CONDITION_DEF_NAME = "conditionDefinitionName";
+
+ // properties for services
+ private ActionService actionService;
+
+ /**
+ * Set the actionService property.
+ *
+ * @param actionService The action service instance to set
+ */
+ public void setActionService(ActionService actionService)
+ {
+ this.actionService = actionService;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(
+ * org.alfresco.web.scripts.WebScriptRequest,
+ * org.alfresco.web.scripts.WebScriptResponse)
+ */
+ @Override
+ protected Map executeImpl(WebScriptRequest req,
+ Status status)
+ {
+ // initialise model to pass on for template to render
+ Map model = new HashMap();
+
+ // get URL parameter
+ String conditionDefName = req.getParameter(REQ_PARAM_CONDITION_DEF_NAME);
+ if ((conditionDefName == null) || (conditionDefName.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'conditionDefinitionName' URL parameter has not been provided in URL");
+ }
+
+ // get a condition definition with the given condition definition name
+ ActionConditionDefinition conditionDef = this.actionService.getActionConditionDefinition(conditionDefName);
+
+ // add objects to model for the template to render
+ model.put(MODEL_PROP_KEY_CONDITION_DEF, conditionDef);
+
+ return model;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java b/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java
new file mode 100644
index 0000000000..36fa5b8eb4
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.web.scripts.rule;
+
+import java.util.Map;
+
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.rule.Rule;
+import org.alfresco.service.cmr.rule.RuleService;
+import org.alfresco.web.scripts.DeclarativeWebScript;
+import org.alfresco.web.scripts.Status;
+import org.alfresco.web.scripts.WebScriptException;
+import org.alfresco.web.scripts.WebScriptRequest;
+
+/**
+ * Web Script to DELETE the rule identified by the given rule node id.
+ *
+ * @author glen johnson at alfresco dot com
+ */
+public class RuleDelete extends DeclarativeWebScript
+{
+ // private constants
+ private static final String REQ_TEMPL_VAR_STORE_TYPE = "store_type";
+ private static final String REQ_TEMPL_VAR_STORE_ID = "store_id";
+ private static final String REQ_TEMPL_VAR_RULE_NODE_ID = "rule_id";
+ private static final String REQ_TEMPL_VAR_RULE_OWNING_NODE_ID = "id";
+
+ // properties for services
+ private RuleService ruleService;
+
+ // dependencies
+ private RulesHelper rulesHelper;
+
+ /**
+ * Set the ruleService property.
+ *
+ * @param ruleService The rule service instance to set
+ */
+ public void setRuleService(RuleService ruleService)
+ {
+ this.ruleService = ruleService;
+ }
+
+ /**
+ * Set the rules helper property
+ *
+ * @param rulesHelper the rulesHelper to set
+ */
+ public void setRulesHelper(RulesHelper rulesHelper)
+ {
+ this.rulesHelper = rulesHelper;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(
+ * org.alfresco.web.scripts.WebScriptRequest,
+ * org.alfresco.web.scripts.WebScriptResponse)
+ */
+ @Override
+ protected Map executeImpl(WebScriptRequest req,
+ Status status)
+ {
+ String storeType = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_STORE_TYPE);
+ // Handle if 'store_type' URL template token not provided
+ if ((storeType == null) || (storeType.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'store_type' URL template token has not been provided in URL");
+ }
+
+ String storeId = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_STORE_ID);
+ // Handle if 'storeId' URL template token not provided
+ if ((storeId == null) || (storeId.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'storeId' URL template token has not been provided in URL");
+ }
+
+ String ruleNodeId = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_RULE_NODE_ID);
+ // Handle if 'ruleNodeId' URL template token not provided
+ if ((ruleNodeId == null) || (ruleNodeId.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'rule_id' URL template token has not been provided in URL");
+ }
+
+ String owningNodeId = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_RULE_OWNING_NODE_ID);
+ // Handle if 'owningNodeId' URL template token not provided
+ if ((owningNodeId == null) || (owningNodeId.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'id' URL template token has not been provided in URL");
+ }
+
+ // create the rule's identifying node reference from the given
+ // URL template tokens
+ NodeRef ruleNodeRef = this.rulesHelper.getNodeRefFromWebScriptUrl(req, storeType, storeId, ruleNodeId);
+
+ // create the rule owning node reference from the given
+ // URL template tokens
+ NodeRef ruleOwningNodeRef = this.rulesHelper.getNodeRefFromWebScriptUrl(req, storeType, storeId, owningNodeId);
+
+ // get the rule using it's unique identifying node reference
+ Rule rule = this.ruleService.getRule(ruleNodeRef);
+
+ // delete rule
+ this.ruleService.removeRule(ruleOwningNodeRef, rule);
+
+ return null;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java b/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java
new file mode 100644
index 0000000000..7cf3e6d4dc
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.web.scripts.rule;
+
+import java.util.Map;
+
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.rule.RuleService;
+import org.alfresco.web.scripts.DeclarativeWebScript;
+import org.alfresco.web.scripts.Status;
+import org.alfresco.web.scripts.WebScriptException;
+import org.alfresco.web.scripts.WebScriptRequest;
+
+/**
+ * Web Script to DELETE the rule collection associated with the given rule owning node.
+ *
+ * @author glen johnson at alfresco dot com
+ */
+public class RulesDelete extends DeclarativeWebScript
+{
+ // private constants
+ private static final String REQ_TEMPL_VAR_STORE_TYPE = "store_type";
+ private static final String REQ_TEMPL_VAR_STORE_ID = "store_id";
+ private static final String REQ_TEMPL_VAR_NODE_ID = "id";
+
+ // properties for services
+ private RuleService ruleService;
+
+ // properties for dependencies
+ private RulesHelper rulesHelper;
+
+ /**
+ * Set the ruleService property.
+ *
+ * @param ruleService The rule service instance to set
+ */
+ public void setRuleService(RuleService ruleService)
+ {
+ this.ruleService = ruleService;
+ }
+
+ /**
+ * @param rulesHelper the rulesHelper to set
+ */
+ public void setRulesHelper(RulesHelper rulesHelper)
+ {
+ this.rulesHelper = rulesHelper;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(
+ * org.alfresco.web.scripts.WebScriptRequest,
+ * org.alfresco.web.scripts.WebScriptResponse)
+ */
+ @Override
+ protected Map executeImpl(WebScriptRequest req,
+ Status status)
+ {
+ String storeType = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_STORE_TYPE);
+ // Handle if 'store_type' URL template token not provided
+ if ((storeType == null) || (storeType.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'store_type' URL template token has not been provided in URL");
+ }
+
+ String storeId = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_STORE_ID);
+ // Handle if 'storeId' URL template token not provided
+ if ((storeId == null) || (storeId.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'storeId' URL template token has not been provided in URL");
+ }
+
+ String nodeId = req.getServiceMatch().getTemplateVars().get(REQ_TEMPL_VAR_NODE_ID);
+ // Handle if 'nodeId' URL template token not provided
+ if ((nodeId == null) || (nodeId.length() == 0))
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST,
+ "The 'nodeId' URL template token has not been provided in URL");
+ }
+
+ // create the rule owning node reference from the given
+ // URL template tokens
+ NodeRef ruleOwningNodeRef = this.rulesHelper.getNodeRefFromWebScriptUrl(req, storeType, storeId, nodeId);
+
+ // delete rule collection associated with the rule owning node
+ this.ruleService.removeAllRules(ruleOwningNodeRef);
+
+ return null;
+ }
+}