Skip to content

Commit

Permalink
[MNT-23264] script execution error (#2900)
Browse files Browse the repository at this point in the history
* [MNT-23264] fix script execution error

* [MNT-23264]

* [MNT-23264] fix formatting issue

* [MNT-23264] fix formatting issue
  • Loading branch information
code4uuuu authored Sep 9, 2024
1 parent 02486a4 commit 58bad96
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
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.
Expand All @@ -56,8 +58,10 @@
*/
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;
Expand Down Expand Up @@ -152,6 +156,11 @@ protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// 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);

Expand Down

0 comments on commit 58bad96

Please sign in to comment.