This is an automated email from the ASF dual-hosted git repository.

bhliva pushed a commit to branch feature-DLAB-582
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 06f1da6f14fecc7a1572d2cb9a79d46b57ecc5a5
Author: bhliva <bohdan_hl...@epam.com>
AuthorDate: Fri Apr 5 12:28:19 2019 +0300

    DLAB-582 added API for getting DLab version
---
 .../com/epam/dlab/dto/InfrastructureMetaInfoDTO.java}   | 16 +++++++++-------
 services/self-service/pom.xml                           |  6 ++++++
 .../resources/InfrastructureInfoResource.java           |  9 +++++++++
 .../backendapi/service/InfrastructureInfoService.java   |  3 +++
 .../service/impl/InfrastructureInfoServiceBase.java     | 11 +++++++++++
 .../resources/InfrastructureInfoResourceTest.java       | 17 +++++++++++++++++
 6 files changed, 55 insertions(+), 7 deletions(-)

diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
 
b/services/dlab-model/src/main/java/com/epam/dlab/dto/InfrastructureMetaInfoDTO.java
similarity index 69%
copy from 
services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
copy to 
services/dlab-model/src/main/java/com/epam/dlab/dto/InfrastructureMetaInfoDTO.java
index a3e08d2..c873fab 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
+++ 
b/services/dlab-model/src/main/java/com/epam/dlab/dto/InfrastructureMetaInfoDTO.java
@@ -17,13 +17,15 @@
  * under the License.
  */
 
-package com.epam.dlab.backendapi.service;
+package com.epam.dlab.dto;
 
-import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO;
-import com.epam.dlab.backendapi.resources.dto.InfrastructureInfo;
+import lombok.Builder;
+import lombok.Data;
 
-public interface InfrastructureInfoService {
-       InfrastructureInfo getUserResources(String user);
-
-       HealthStatusPageDTO getHeathStatus(String user, boolean fullReport, 
boolean isAdmin);
+@Data
+@Builder
+public class InfrastructureMetaInfoDTO {
+       private final String branch;
+       private final String version;
+       private final String commit;
 }
diff --git a/services/self-service/pom.xml b/services/self-service/pom.xml
index 9ff451b..a71c9c4 100644
--- a/services/self-service/pom.xml
+++ b/services/self-service/pom.xml
@@ -134,6 +134,12 @@
             <artifactId>oshi-core</artifactId>
             <version>${com.github.oshi.core.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.jcabi</groupId>
+            <artifactId>jcabi-manifests</artifactId>
+            <version>1.1</version>
+        </dependency>
+
 
         <dependency>
             <groupId>com.smoketurner</groupId>
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResource.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResource.java
index dfedb8e..6b44c33 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResource.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResource.java
@@ -88,4 +88,13 @@ public class InfrastructureInfoResource {
                return 
infrastructureInfoService.getUserResources(userInfo.getName());
 
        }
+
+       @GET
+       @Path("/meta")
+       @ApiOperation("Return metainfo regarding application version etc")
+       public Response getVersion(@ApiParam(hidden = true) @Auth UserInfo 
userInfo) {
+               return 
Response.ok(infrastructureInfoService.getInfrastructureMetaInfo())
+                               .build();
+
+       }
 }
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
index a3e08d2..b54edb9 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/InfrastructureInfoService.java
@@ -21,9 +21,12 @@ package com.epam.dlab.backendapi.service;
 
 import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO;
 import com.epam.dlab.backendapi.resources.dto.InfrastructureInfo;
+import com.epam.dlab.dto.InfrastructureMetaInfoDTO;
 
 public interface InfrastructureInfoService {
        InfrastructureInfo getUserResources(String user);
 
        HealthStatusPageDTO getHeathStatus(String user, boolean fullReport, 
boolean isAdmin);
+
+       InfrastructureMetaInfoDTO getInfrastructureMetaInfo();
 }
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceBase.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceBase.java
index 0f0584c..6981531 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceBase.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceBase.java
@@ -27,9 +27,11 @@ import com.epam.dlab.backendapi.dao.KeyDAO;
 import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO;
 import com.epam.dlab.backendapi.resources.dto.InfrastructureInfo;
 import com.epam.dlab.backendapi.service.InfrastructureInfoService;
+import com.epam.dlab.dto.InfrastructureMetaInfoDTO;
 import com.epam.dlab.dto.base.edge.EdgeInfo;
 import com.epam.dlab.exceptions.DlabException;
 import com.google.inject.Inject;
+import com.jcabi.manifests.Manifests;
 import lombok.extern.slf4j.Slf4j;
 import org.bson.Document;
 
@@ -83,5 +85,14 @@ public abstract class InfrastructureInfoServiceBase<T> 
implements Infrastructure
                }
        }
 
+       @Override
+       public InfrastructureMetaInfoDTO getInfrastructureMetaInfo() {
+               return InfrastructureMetaInfoDTO.builder()
+                               .branch(Manifests.read("GIT-Branch"))
+                               .commit(Manifests.read("GIT-Commit"))
+                               
.version(Manifests.read("Implementation-Version"))
+                               .build();
+       }
+
        protected abstract Map<String, String> getSharedInfo(T sharedInfo);
 }
diff --git 
a/services/self-service/src/test/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResourceTest.java
 
b/services/self-service/src/test/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResourceTest.java
index 631b79f..30c69ff 100644
--- 
a/services/self-service/src/test/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResourceTest.java
+++ 
b/services/self-service/src/test/java/com/epam/dlab/backendapi/resources/InfrastructureInfoResourceTest.java
@@ -22,6 +22,7 @@ package com.epam.dlab.backendapi.resources;
 import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO;
 import com.epam.dlab.backendapi.resources.dto.InfrastructureInfo;
 import com.epam.dlab.backendapi.service.InfrastructureInfoService;
+import com.epam.dlab.dto.InfrastructureMetaInfoDTO;
 import com.epam.dlab.exceptions.DlabException;
 import io.dropwizard.auth.AuthenticationException;
 import io.dropwizard.testing.junit.ResourceTestRule;
@@ -209,6 +210,22 @@ public class InfrastructureInfoResourceTest extends 
TestBase {
                verifyNoMoreInteractions(infrastructureInfoService);
        }
 
+       @Test
+       public void getInfrastructureMeta() {
+
+               
when(infrastructureInfoService.getInfrastructureMetaInfo()).thenReturn(
+                               InfrastructureMetaInfoDTO.builder()
+                                               .version("1.0").build());
+               final Response response = resources.getJerseyTest()
+                               .target("/infrastructure/meta")
+                               .request()
+                               .header("Authorization", "Bearer " + TOKEN)
+                               .get();
+
+               final InfrastructureMetaInfoDTO infrastructureMetaInfoDTO = 
response.readEntity(InfrastructureMetaInfoDTO.class);
+               assertEquals("1.0", infrastructureMetaInfoDTO.getVersion());
+       }
+
        private HealthStatusPageDTO getHealthStatusPageDTO() {
                HealthStatusPageDTO hspdto = new HealthStatusPageDTO();
                hspdto.setStatus("someStatus");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to