platform module archetype updates

This commit is contained in:
2024-08-07 11:42:30 -04:00
parent e1cd5245ef
commit f8b92d5c35
5 changed files with 29 additions and 13 deletions

View File

@@ -30,6 +30,8 @@ import org.springframework.stereotype.Component;
/** /**
* This class is an example of how you can use the Alfresco Java Public API in Alfresco Actions. * This class is an example of how you can use the Alfresco Java Public API in Alfresco Actions.
*
* The bean must be declared in the XML and not through annotations.
*/ */
public class ExampleActionExecuter extends ActionExecuterAbstractBase { public class ExampleActionExecuter extends ActionExecuterAbstractBase {
@@ -45,9 +47,8 @@ public class ExampleActionExecuter extends ActionExecuterAbstractBase {
} }
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNoderef) { protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
if (this.logger.isTraceEnabled()) this.logger.trace("executeImpl({})", actionedUponNodeRef);
this.logger.trace("executeImpl('" + actionedUponNoderef + "')");
String value = (String)action.getParameterValue("example.param"); String value = (String)action.getParameterValue("example.param");
// TODO do some work // TODO do some work

View File

@@ -14,11 +14,19 @@
*/ */
package ${package}; package ${package};
import java.io.Serializable;
import java.util.Map;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.namespace.QName;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +37,8 @@ import org.springframework.stereotype.Component;
* This class is an example of how you can use the Alfresco Java Public API when Alfresco triggers an event. * This class is an example of how you can use the Alfresco Java Public API when Alfresco triggers an event.
*/ */
@Component @Component
public class ExampleEventListener extends AbstractLifecycleBean implements OnCreateNodePolicy { @BehaviourBean
public class ExampleEventListener extends AbstractLifecycleBean implements OnCreateNodePolicy, OnUpdatePropertiesPolicy {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -64,9 +73,17 @@ public class ExampleEventListener extends AbstractLifecycleBean implements OnCre
*/ */
@Override @Override
public void onCreateNode(ChildAssociationRef childAssocRef) { public void onCreateNode(ChildAssociationRef childAssocRef) {
this.logger.trace("onCreateNode('" + childAssocRef.getChildRef() + "')"); this.logger.trace("onCreateNode({})", childAssocRef.getChildRef());
// TODO do some work // TODO do some work
} }
@Behaviour(kind = BehaviorKind.CLASS, NotificationFrequency = NotificationFrequency.FIRST_EVENT)
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) {
this.logger.trace("onUpdateProperties({})", nodeRef);
// TODO do some work
}
} }

View File

@@ -46,7 +46,6 @@ public class ExampleGetWebScript extends AbstractWebScript {
*/ */
@Override @Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
if (this.logger.isTraceEnabled())
this.logger.trace("execute()"); this.logger.trace("execute()");
// TODO do some work // TODO do some work

View File

@@ -23,6 +23,8 @@ import org.springframework.stereotype.Component;
/** /**
* This class is an example of how you can use the Alfresco Java Public API to extend the JavaScript engine. * This class is an example of how you can use the Alfresco Java Public API to extend the JavaScript engine.
*
* The bean must be declared in the XML and not through annotations.
*/ */
public class ExampleJavaScriptRootObject extends BaseProcessorExtension { public class ExampleJavaScriptRootObject extends BaseProcessorExtension {
@@ -40,8 +42,7 @@ public class ExampleJavaScriptRootObject extends BaseProcessorExtension {
* The `example` root name comes from the `module-context.xml` file. * The `example` root name comes from the `module-context.xml` file.
*/ */
public String getMessage(String messageKey) { public String getMessage(String messageKey) {
if (this.logger.isTraceEnabled()) this.logger.trace("getMessage({})", messageKey);
this.logger.trace("getMessage('" + messageKey + "')");
return this.serviceRegistry.getDictionaryService().getMessage(messageKey); return this.serviceRegistry.getDictionaryService().getMessage(messageKey);
} }

View File

@@ -61,8 +61,7 @@ public class ExampleJob implements Job {
@Override @Override
public void execute(JobExecutionContext context) throws JobExecutionException { public void execute(JobExecutionContext context) throws JobExecutionException {
if (this.logger.isTraceEnabled()) this.logger.trace("execute({})", context.getFireInstanceId());
this.logger.trace("execute('" + context.getFireInstanceId() + "')");
// provide some authority within the Alfresco context // provide some authority within the Alfresco context
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() { AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@@ -81,8 +80,7 @@ public class ExampleJob implements Job {
} }
public void fire(JobExecutionContext context) throws JobExecutionException { public void fire(JobExecutionContext context) throws JobExecutionException {
if (this.logger.isTraceEnabled()) this.logger.trace("fire({})", context.getFireInstanceId());
this.logger.trace("fire('" + context.getFireInstanceId() + "')");
// TODO do some work // TODO do some work
} }