]> source.dussan.org Git - archiva.git/commitdiff
add rest service to validate cron expression
authorOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 17:13:37 +0000 (17:13 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 17:13:37 +0000 (17:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235828 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java

index 0a20f1847bbd0b7e10fd452b005a6e81ba377336..cd0291a7045ea0b6493876cf20f932668648c1d6 100644 (file)
@@ -78,12 +78,10 @@ public class DefaultManagedRepositoryAdmin
     implements ManagedRepositoryAdmin
 {
 
-
     private Logger log = LoggerFactory.getLogger( getClass() );
 
     public static final String STAGE_REPO_ID_END = "-stage";
 
-
     @Inject
     @Named( value = "archivaTaskScheduler#repository" )
     private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
index f2869be8610cfb85f60c703d4c5deee143b610ce..675a31ef8d3a0ff4fa1b5c71b5286147c8a8993f 100644 (file)
@@ -66,4 +66,13 @@ public interface CommonServices
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
     @RedbackAuthorization( noRestriction = true )
     ArchivaRuntimeInfo archivaRuntimeInfo();
+
+
+    @Path( "validateCronExpression" )
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    @RedbackAuthorization( noRestriction = true )
+    Boolean validateCronExpression( @QueryParam( "cronExpression" ) String cronExpression )
+        throws ArchivaRestServiceException;
+
 }
index c16440643f40ff0be2a3e5d47b257dfc4d78a880..bab18fa61f48b1be2d2d7901a9813a97a7b1a63a 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.CommonServices;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.codehaus.redback.components.scheduler.CronExpressionValidator;
 import org.codehaus.redback.rest.api.services.RedbackServiceException;
 import org.codehaus.redback.rest.api.services.UtilServices;
 import org.slf4j.Logger;
@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -52,6 +54,9 @@ public class DefaultCommonServices
     @Inject
     private UtilServices utilServices;
 
+    @Inject
+    protected CronExpressionValidator cronExpressionValidator;
+
     public String getI18nResources( String locale )
         throws ArchivaRestServiceException
     {
@@ -174,4 +179,10 @@ public class DefaultCommonServices
     {
         return new ArchivaRuntimeInfo();
     }
+
+    public Boolean validateCronExpression( @QueryParam( "cronExpression" ) String cronExpression )
+        throws ArchivaRestServiceException
+    {
+        return cronExpressionValidator.validate( cronExpression );
+    }
 }