From: Olivier Lamy Date: Wed, 25 Jan 2012 17:13:37 +0000 (+0000) Subject: add rest service to validate cron expression X-Git-Tag: archiva-1.4-M3~1468 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=627bdfa6b15b22490b5da7413c093d314d570bdc;p=archiva.git add rest service to validate cron expression git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235828 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index 0a20f1847..cd0291a70 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java index f2869be86..675a31ef8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java @@ -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; + } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java index c16440643..bab18fa61 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java @@ -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 ); + } }