diff --git a/pom.xml b/pom.xml index 7436fce68..2703f6f93 100644 --- a/pom.xml +++ b/pom.xml @@ -92,6 +92,10 @@ + + org.codehaus.mojo + buildnumber-maven-plugin + org.apache.maven.plugins maven-eclipse-plugin diff --git a/src/main/java/li/strolch/rest/inspector/AgentRef.java b/src/main/java/li/strolch/rest/AgentRef.java similarity index 97% rename from src/main/java/li/strolch/rest/inspector/AgentRef.java rename to src/main/java/li/strolch/rest/AgentRef.java index fb6188a94..060cfde68 100644 --- a/src/main/java/li/strolch/rest/inspector/AgentRef.java +++ b/src/main/java/li/strolch/rest/AgentRef.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package li.strolch.rest.inspector; +package li.strolch.rest; import li.strolch.agent.api.ComponentContainer; import li.strolch.agent.api.StrolchAgent; diff --git a/src/main/java/li/strolch/rest/inspector/StrolchRestfulClasses.java b/src/main/java/li/strolch/rest/StrolchRestfulClasses.java similarity index 90% rename from src/main/java/li/strolch/rest/inspector/StrolchRestfulClasses.java rename to src/main/java/li/strolch/rest/StrolchRestfulClasses.java index 76f05bd75..cfb09f5b1 100644 --- a/src/main/java/li/strolch/rest/inspector/StrolchRestfulClasses.java +++ b/src/main/java/li/strolch/rest/StrolchRestfulClasses.java @@ -13,12 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package li.strolch.rest.inspector; +package li.strolch.rest; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import li.strolch.rest.endpoint.Inspector; +import li.strolch.rest.endpoint.VersionQuery; + /** * @author Robert von Burg */ @@ -30,6 +33,7 @@ public class StrolchRestfulClasses { static { Set> restfulClasses = new HashSet<>(); restfulClasses.add(Inspector.class); + restfulClasses.add(VersionQuery.class); Set> providerClasses = new HashSet<>(); providerClasses.add(StrolchRestfulExceptionMapper.class); diff --git a/src/main/java/li/strolch/rest/inspector/StrolchRestfulExceptionMapper.java b/src/main/java/li/strolch/rest/StrolchRestfulExceptionMapper.java similarity index 94% rename from src/main/java/li/strolch/rest/inspector/StrolchRestfulExceptionMapper.java rename to src/main/java/li/strolch/rest/StrolchRestfulExceptionMapper.java index 7b2b69c87..6d92c4dc4 100644 --- a/src/main/java/li/strolch/rest/inspector/StrolchRestfulExceptionMapper.java +++ b/src/main/java/li/strolch/rest/StrolchRestfulExceptionMapper.java @@ -1,4 +1,4 @@ -package li.strolch.rest.inspector; +package li.strolch.rest; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; diff --git a/src/main/java/li/strolch/rest/inspector/Inspector.java b/src/main/java/li/strolch/rest/endpoint/Inspector.java similarity index 99% rename from src/main/java/li/strolch/rest/inspector/Inspector.java rename to src/main/java/li/strolch/rest/endpoint/Inspector.java index 2cea98050..c915f876d 100644 --- a/src/main/java/li/strolch/rest/inspector/Inspector.java +++ b/src/main/java/li/strolch/rest/endpoint/Inspector.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package li.strolch.rest.inspector; +package li.strolch.rest.endpoint; import java.util.ArrayList; import java.util.List; @@ -35,6 +35,7 @@ import li.strolch.exception.StrolchException; import li.strolch.model.Order; import li.strolch.model.Resource; import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.rest.AgentRef; import li.strolch.rest.model.AgentOverview; import li.strolch.rest.model.ElementMapOverview; import li.strolch.rest.model.ElementMapType; diff --git a/src/main/java/li/strolch/rest/endpoint/VersionQuery.java b/src/main/java/li/strolch/rest/endpoint/VersionQuery.java new file mode 100644 index 000000000..d49b0cf4f --- /dev/null +++ b/src/main/java/li/strolch/rest/endpoint/VersionQuery.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed 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. + */ +package li.strolch.rest.endpoint; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import li.strolch.agent.api.VersionQueryResult; +import li.strolch.rest.AgentRef; + +/** + * @author Robert von Burg + */ +@Path("strolch/version") +public class VersionQuery { + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getVersions() { + VersionQueryResult versionQueryResult = AgentRef.getInstance().getAgent().getVersion(); + GenericEntity entity = new GenericEntity(versionQueryResult, + VersionQueryResult.class) { + }; + return Response.ok().entity(entity).build(); + } +} diff --git a/src/main/resources/componentVersion.properties b/src/main/resources/componentVersion.properties new file mode 100644 index 000000000..1f050160f --- /dev/null +++ b/src/main/resources/componentVersion.properties @@ -0,0 +1,6 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +artifactVersion=${project.version} +scmRevision=r${buildNumber} +scmBranch=${scmBranch} +buildTimestamp=${buildTimestamp} \ No newline at end of file diff --git a/src/test/java/li/strolch/rest/inspector/test/AbstractRestfulTest.java b/src/test/java/li/strolch/rest/inspector/test/AbstractRestfulTest.java index a6aba4a5c..153a6a260 100644 --- a/src/test/java/li/strolch/rest/inspector/test/AbstractRestfulTest.java +++ b/src/test/java/li/strolch/rest/inspector/test/AbstractRestfulTest.java @@ -20,9 +20,9 @@ import java.net.URI; import javax.ws.rs.core.MediaType; -import li.strolch.rest.inspector.AgentRef; -import li.strolch.rest.inspector.StrolchRestfulClasses; -import li.strolch.rest.inspector.StrolchRestfulExceptionMapper; +import li.strolch.rest.AgentRef; +import li.strolch.rest.StrolchRestfulClasses; +import li.strolch.rest.StrolchRestfulExceptionMapper; import li.strolch.testbase.runtime.RuntimeMock; import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider; diff --git a/src/test/java/li/strolch/rest/inspector/test/InspectorTest.java b/src/test/java/li/strolch/rest/inspector/test/RestfulServicesTest.java similarity index 82% rename from src/test/java/li/strolch/rest/inspector/test/InspectorTest.java rename to src/test/java/li/strolch/rest/inspector/test/RestfulServicesTest.java index 515bf7147..41ec023aa 100644 --- a/src/test/java/li/strolch/rest/inspector/test/InspectorTest.java +++ b/src/test/java/li/strolch/rest/inspector/test/RestfulServicesTest.java @@ -23,14 +23,15 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import li.strolch.agent.api.AgentVersion; +import li.strolch.agent.api.ComponentVersion; +import li.strolch.agent.api.VersionQueryResult; import li.strolch.rest.model.AgentOverview; import li.strolch.rest.model.ElementMapOverview; import li.strolch.rest.model.ElementMapType; import li.strolch.rest.model.ElementMapsOverview; -import li.strolch.rest.model.OrderDetail; import li.strolch.rest.model.RealmDetail; import li.strolch.rest.model.RealmOverview; -import li.strolch.rest.model.ResourceDetail; import li.strolch.rest.model.TypeOverview; import org.junit.Test; @@ -41,7 +42,7 @@ import com.sun.jersey.api.client.GenericType; /** * @author Robert von Burg */ -public class InspectorTest extends AbstractRestfulTest { +public class RestfulServicesTest extends AbstractRestfulTest { @Test public void shouldGetAgent() { @@ -162,4 +163,32 @@ public class InspectorTest extends AbstractRestfulTest { assertTrue(entity .contains("\"date\":\"2012-11-30T18:12:05.628+01:00\",\"state\":\"CREATED\",\"parameterBags\"")); } + + @Test + public void shouldQueryVersion() { + + // query + ClientResponse response = getClientResponse("/strolch/version"); + VersionQueryResult versionQueryResult = response.getEntity(new GenericType() { + }); + + if (versionQueryResult.hasErrors()) { + for (String error : versionQueryResult.getErrors()) { + logger.error(error); + } + } + + AgentVersion agentVersion = versionQueryResult.getAgentVersion(); + logger.info(agentVersion.toString()); + List componentVersions = versionQueryResult.getComponentVersions(); + assertEquals(4, componentVersions.size()); + for (ComponentVersion version : componentVersions) { + logger.info(version.toString()); + assertEquals("li.strolch", agentVersion.getGroupId()); + } + + assertEquals("StrolchPersistenceTest", agentVersion.getAgentName()); + assertEquals("li.strolch", agentVersion.getGroupId()); + assertEquals("li.strolch.agent", agentVersion.getArtifactId()); + } }