From 3e410d223b25436d43e050570fb58a53c2acae34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ramos?= Date: Mon, 23 Oct 2023 16:03:24 +0100 Subject: [PATCH] [PDI-19868] - Schedule perspective for the Administrator Role is different between PUC and PDI --- .../scheduler2/ws/DefaultSchedulerService.java | 18 ++++++++++++++++-- .../scheduler2/ws/ISchedulerService.java | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/DefaultSchedulerService.java b/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/DefaultSchedulerService.java index bf5c5d6dfad..54507e4fd17 100644 --- a/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/DefaultSchedulerService.java +++ b/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/DefaultSchedulerService.java @@ -123,7 +123,16 @@ public Job[] getJobs() throws SchedulerException { /** {@inheritDoc} */ public void pause() throws SchedulerException { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$ - scheduler.pause(); + if(PentahoSystem.get( IAuthorizationPolicy.class ).isAllowed( ADMIN_PERM )) { + scheduler.pause(); + }else { + throw new SchedulerException( "Operation not allowed" ); + } + } + + @Override + public boolean canStopScheduler() { + return PentahoSystem.get( IAuthorizationPolicy.class ).isAllowed( ADMIN_PERM ); } /** {@inheritDoc} */ @@ -141,7 +150,12 @@ public void removeJob( String jobId ) throws SchedulerException { /** {@inheritDoc} */ public void start() throws SchedulerException { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$ - scheduler.start(); + if (PentahoSystem.get( IAuthorizationPolicy.class ).isAllowed( ADMIN_PERM )) { + scheduler.start(); + } else { + throw new SchedulerException( "Operation not allowed" ); + } + } /** {@inheritDoc} */ diff --git a/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/ISchedulerService.java b/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/ISchedulerService.java index 361b9ca41cb..2ea1c4ba160 100644 --- a/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/ISchedulerService.java +++ b/scheduler/src/main/java/org/pentaho/platform/scheduler2/ws/ISchedulerService.java @@ -104,4 +104,7 @@ public String updateJobComplexTriggerWithJobName( String jobName, String jobId, */ public int getSchedulerStatus() throws SchedulerException; + default public boolean canStopScheduler (){ + return true; + } }