From 58bad96724be3c9bdde58f940e82c1353313ef07 Mon Sep 17 00:00:00 2001 From: Manish Kumar <110275771+code4uuuu@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:40:33 +0530 Subject: [PATCH] [MNT-23264] script execution error (#2900) * [MNT-23264] fix script execution error * [MNT-23264] * [MNT-23264] fix formatting issue * [MNT-23264] fix formatting issue --- .../repo/action/executer/ScriptActionExecuter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/repository/src/main/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java b/repository/src/main/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java index b8458fa60d..1a231d61de 100644 --- a/repository/src/main/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java +++ b/repository/src/main/java/org/alfresco/repo/action/executer/ScriptActionExecuter.java @@ -46,6 +46,8 @@ import org.alfresco.service.cmr.repository.ScriptLocation; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.UrlUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Action to execute a JavaScript. The script has access to the default model. @@ -56,8 +58,10 @@ import org.alfresco.util.UrlUtil; */ public class ScriptActionExecuter extends ActionExecuterAbstractBase { + private static final Logger LOGGER = LoggerFactory.getLogger(ScriptActionExecuter.class); public static final String NAME = "script"; public static final String PARAM_SCRIPTREF = "script-ref"; + private static final String SYSTEM_USER = "System"; private ServiceRegistry serviceRegistry; private SysAdminParams sysAdminParams; @@ -152,6 +156,11 @@ public class ScriptActionExecuter extends ActionExecuterAbstractBase { // get the references we need to build the default scripting data-model String userName = this.serviceRegistry.getAuthenticationService().getCurrentUserName(); + if (SYSTEM_USER.equals(userName)) + { + LOGGER.info("Skipping Script Execution for the System user."); + return; + } NodeRef personRef = this.personService.getPerson(userName); NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);