From 7b50ea96e2a4f963e922abc2b662053dda1e741e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 27 Jan 2012 11:19:51 +0000 Subject: [PATCH] move this rest services used only by the js ui in a new rest ui service git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1236634 13f79535-47bb-0310-9956-ffa450edef68 --- .../rest/api/services/CommonServices.java | 7 ---- .../rest/services/DefaultCommonServices.java | 6 --- .../api/DefaultRuntimeInfoService.java | 36 ++++++++++++++++ .../ui/services/api/RuntimeInfoService.java | 41 +++++++++++++++++++ .../model/ApplicationRuntimeInfo.java} | 10 ++--- .../resources/META-INF/spring-context.xml | 33 ++++++++++++++- .../src/main/webapp/index.html | 6 +-- 7 files changed, 117 insertions(+), 22 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java create mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java rename archiva-modules/archiva-web/{archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRuntimeInfo.java => archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java} (88%) 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 675a31ef8..1c2ed2bf0 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 @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.rest.api.model.ArchivaRuntimeInfo; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; import javax.ws.rs.GET; @@ -61,12 +60,6 @@ public interface CommonServices String getAllI18nResources( @QueryParam( "locale" ) String locale ) throws ArchivaRestServiceException; - @Path( "archivaRuntimeInfo" ) - @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noRestriction = true ) - ArchivaRuntimeInfo archivaRuntimeInfo(); - @Path( "validateCronExpression" ) @GET 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 ba010aaf1..4a7940e0c 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 @@ -18,7 +18,6 @@ package org.apache.archiva.rest.services; * under the License. */ -import org.apache.archiva.rest.api.model.ArchivaRuntimeInfo; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.CommonServices; import org.apache.commons.io.IOUtils; @@ -31,7 +30,6 @@ 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; @@ -175,10 +173,6 @@ public class DefaultCommonServices } } - public ArchivaRuntimeInfo archivaRuntimeInfo() - { - return new ArchivaRuntimeInfo(); - } public Boolean validateCronExpression( String cronExpression ) throws ArchivaRestServiceException diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java new file mode 100644 index 000000000..c4562fb74 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java @@ -0,0 +1,36 @@ +package org.apache.archiva.webapp.ui.services.api; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.webapp.ui.services.model.ApplicationRuntimeInfo; +import org.springframework.stereotype.Service; + +/** + * @author Olivier Lamy + */ +@Service( "runtimeInfoService#rest" ) +public class DefaultRuntimeInfoService + implements RuntimeInfoService +{ + public ApplicationRuntimeInfo archivaRuntimeInfo() + { + ApplicationRuntimeInfo archivaRuntimeInfo = new ApplicationRuntimeInfo(); + return archivaRuntimeInfo; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java new file mode 100644 index 000000000..43e82dd59 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java @@ -0,0 +1,41 @@ +package org.apache.archiva.webapp.ui.services.api; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.webapp.ui.services.model.ApplicationRuntimeInfo; +import org.codehaus.plexus.redback.authorization.RedbackAuthorization; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * @author Olivier Lamy + * @since 1.4-M3 + */ +@Path( "/runtimeInfoService/" ) +public interface RuntimeInfoService +{ + @Path( "archivaRuntimeInfo" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( noRestriction = true ) + ApplicationRuntimeInfo archivaRuntimeInfo(); +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRuntimeInfo.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java similarity index 88% rename from archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRuntimeInfo.java rename to archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java index f27bfe1bc..3759d9a3e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRuntimeInfo.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java @@ -1,4 +1,4 @@ -package org.apache.archiva.rest.api.model; +package org.apache.archiva.webapp.ui.services.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -24,14 +24,14 @@ import javax.xml.bind.annotation.XmlRootElement; * @author Olivier Lamy * @since 1.4-M3 */ -@XmlRootElement( name = "archivaRuntimeInfo" ) -public class ArchivaRuntimeInfo +@XmlRootElement( name = "applicationRuntimeInfo" ) +public class ApplicationRuntimeInfo { private boolean devMode = false; private boolean javascriptLog = false; - public ArchivaRuntimeInfo() + public ApplicationRuntimeInfo() { this.devMode = Boolean.getBoolean( "archiva.devMode" ); @@ -62,7 +62,7 @@ public class ArchivaRuntimeInfo public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append( "ArchivaRuntimeInfo" ); + sb.append( "ApplicationRuntimeInfo" ); sb.append( "{devMode=" ).append( devMode ); sb.append( ", javascriptLog=" ).append( javascriptLog ); sb.append( '}' ); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml index 7bbafb370..4751faff4 100755 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml @@ -22,15 +22,25 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util - http://www.springframework.org/schema/util/spring-util-3.0.xsd" + http://www.springframework.org/schema/util/spring-util-3.0.xsd + http://cxf.apache.org/jaxrs + http://cxf.apache.org/schemas/jaxrs.xsd" default-lazy-init="true"> + + + + + @@ -44,5 +54,26 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index 857fa4e63..1d06f8be3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -48,11 +48,11 @@