diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml index 5053cd534a..fdc46bdd75 100644 --- a/config/alfresco/action-services-context.xml +++ b/config/alfresco/action-services-context.xml @@ -355,7 +355,7 @@ - + @@ -363,10 +363,16 @@ - ${spaces.store} + ${spaces.store} - /${spaces.company_home.childname} + /${spaces.company_home.childname} + + + + + + diff --git a/config/alfresco/messages/action-config.properties b/config/alfresco/messages/action-config.properties index 536d7e0608..5e796af107 100644 --- a/config/alfresco/messages/action-config.properties +++ b/config/alfresco/messages/action-config.properties @@ -74,10 +74,13 @@ export.generic.package.description=Alfresco Repository export. export.package.error=Failed to find temporary file for export script.title=Execute a script -script.description=Execute a JavaScript file to perform tasks such as creating new files or folders +script.description=Execute a JavaScript file to perform tasks such as creating new files or folders. + +counter.title=Increment Counter +counter.counter=Increment the counter property for the item. execute-all-rules.title=Execute all rules -execute-all-rules.description=Execute all rules on the child items +execute-all-rules.description=Execute all rules on the child items. start-workflow.title=Start Workflow start-workflow.description=This will start a workflow for the matched items. diff --git a/config/alfresco/model/contentModel.xml b/config/alfresco/model/contentModel.xml index 0f38776be5..da5560951d 100644 --- a/config/alfresco/model/contentModel.xml +++ b/config/alfresco/model/contentModel.xml @@ -526,6 +526,9 @@ d:int + + d:int + diff --git a/source/java/org/alfresco/model/ContentModel.java b/source/java/org/alfresco/model/ContentModel.java index 6c3e4c6731..71f4d1c031 100644 --- a/source/java/org/alfresco/model/ContentModel.java +++ b/source/java/org/alfresco/model/ContentModel.java @@ -77,6 +77,7 @@ public interface ContentModel static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema"); static final QName PROP_SYS_VERSION_EDITION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionEdition"); + // // Content Model Definitions // @@ -184,6 +185,12 @@ public interface ContentModel public static final QName PROP_ADDRESSEES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressees"); public static final QName PROP_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subjectline"); + // countable aspect + public static final QName ASPECT_COUNTABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "countable"); + public static final QName PROP_HITS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "hits"); + public static final QName PROP_COUNTER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "counter"); + + // // Application Model Definitions // diff --git a/source/java/org/alfresco/repo/action/executer/CounterIncrementActionExecuter.java b/source/java/org/alfresco/repo/action/executer/CounterIncrementActionExecuter.java new file mode 100644 index 0000000000..f779787433 --- /dev/null +++ b/source/java/org/alfresco/repo/action/executer/CounterIncrementActionExecuter.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.repo.action.executer; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Simple action to increment an integer value. The runtime NodeService is used so any user + * can increment the counter value on a node. + * + * @author Kevin Roast + */ +public class CounterIncrementActionExecuter extends ActionExecuterAbstractBase +{ + /** Runtime NodeService with no permissions protection */ + private NodeService nodeService; + + + /** + * @param nodeService The Runtime NodeService to set. + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) + */ + protected void executeImpl(Action action, NodeRef actionedUponNodeRef) + { + // add the cm:countable aspect as required + if (this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_COUNTABLE) == false) + { + // set the value to 1 by default + Map props = new HashMap(1); + props.put(ContentModel.PROP_COUNTER, 1); + this.nodeService.addAspect(actionedUponNodeRef, ContentModel.ASPECT_COUNTABLE, props); + } + else + { + // increment the value and handle possibility that no value has been set yet + int resultValue = 1; + Integer value = (Integer)this.nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_COUNTER); + if (value != null) + { + resultValue = value.intValue() + 1; + } + this.nodeService.setProperty(actionedUponNodeRef, ContentModel.PROP_COUNTER, resultValue); + } + } + + /** + * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) + */ + protected void addParameterDefinitions(List paramList) + { + // none required + } +} diff --git a/source/java/org/alfresco/repo/action/executer/ScriptActionExecutor.java b/source/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java similarity index 94% rename from source/java/org/alfresco/repo/action/executer/ScriptActionExecutor.java rename to source/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java index 1815acecd3..2a49156dee 100644 --- a/source/java/org/alfresco/repo/action/executer/ScriptActionExecutor.java +++ b/source/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java @@ -32,9 +32,13 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.PersonService; /** + * Action to execute a JavaScript. The script has access to the default model. + * The actionedUponNodeRef is added to the default model as the 'document' and the owning + * NodeRef is added as the 'space'. + * * @author Kevin Roast */ -public class ScriptActionExecutor extends ActionExecuterAbstractBase +public class ScriptActionExecuter extends ActionExecuterAbstractBase { public static final String NAME = "script"; public static final String PARAM_SCRIPTREF = "script-ref";