Skip to content

Commit

Permalink
Merge pull request #5 from SBI-/master
Browse files Browse the repository at this point in the history
Add service that exposes version
  • Loading branch information
SBI- committed Jun 28, 2018
2 parents 1ae34c4 + aa515cc commit 41b654b
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 12 deletions.
2 changes: 1 addition & 1 deletion feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.jazzcommunity.GitConnectorService.feature"
label="REST Service"
version="1.3.0.qualifier"
version="1.4.0.qualifier"
provider-name="PROVIDER">

<description url="http://www.example.com/description">
Expand Down
2 changes: 1 addition & 1 deletion feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService.parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.jazzcommunity.GitConnectorService
Bundle-SymbolicName: org.jazzcommunity.GitConnectorService;singleton:=true
Bundle-Version: 1.3.0.qualifier
Bundle-Version: 1.4.0.qualifier
Bundle-Vendor: VENDOR
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle:
Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService.parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
import com.siemens.bt.jazz.services.base.rest.RestActionBuilder;
import com.siemens.bt.jazz.services.base.rest.RestRequest;
import com.siemens.bt.jazz.services.base.router.factory.RestFactory;
import org.eclipse.core.runtime.Platform;
import org.jazzcommunity.GitConnectorService.builder.VersionService;
import org.jazzcommunity.GitConnectorService.builder.gitlab.IssueLinkService;
import org.jazzcommunity.GitConnectorService.builder.gitlab.IssuePreviewService;
import org.jazzcommunity.GitConnectorService.builder.gitlab.RequestLinkService;
import org.jazzcommunity.GitConnectorService.builder.gitlab.RequestPreviewService;
import org.jazzcommunity.GitConnectorService.router.CustomRouter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -41,13 +45,20 @@ public GitConnectorService() {
"gitlab/[a-zA-Z.]+/project/[0-9]+/issue/[0-9]+/preview.*",
new RestFactory(IssuePreviewService.class));

router.addService(HttpMethod.GET,
router.addService(
HttpMethod.GET,
"gitlab/[a-zA-Z.]+/project/[0-9]+/merge-request/[0-9]+/link.*",
new RestFactory(RequestLinkService.class));
router.addService(HttpMethod.GET,
router.addService(
HttpMethod.GET,
"gitlab/[a-zA-Z.]+/project/[0-9]+/merge-request/[0-9]+/preview.*",
new RestFactory(RequestPreviewService.class));

router.addService(
HttpMethod.GET,
"info/version",
new RestFactory(VersionService.class));

/**
* This code is purposely commented out and not deleted!
* We have decided to use the IBM rich hovers for now, but potential support will remain built into
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.jazzcommunity.GitConnectorService.builder;

import com.google.gson.*;
import com.ibm.team.repository.service.TeamRawService;
import com.siemens.bt.jazz.services.base.rest.AbstractRestService;
import com.siemens.bt.jazz.services.base.rest.RestRequest;
import org.apache.commons.logging.Log;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class VersionService extends AbstractRestService {
private static Gson gson = new GsonBuilder()
.setPrettyPrinting()
.create();

public VersionService(Log log, HttpServletRequest request, HttpServletResponse response, RestRequest restRequest, TeamRawService parentService) {
super(log, request, response, restRequest, parentService);
}

@Override
public void execute() throws Exception {
Version version = FrameworkUtil.getBundle(getClass()).getVersion();
response.getWriter().write(gson.toJson(new VersionAdapter(version)));
}

private static final class VersionAdapter {
private final int major;
private final int minor;
private final int micro;
private final String qualifier;
private final String version;

public VersionAdapter(Version version) {
major = version.getMajor();
minor = version.getMinor();
micro = version.getMicro();
qualifier = version.getQualifier();
this.version = version.toString();
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService.parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.jazzcommunity.GitConnectorService
Bundle-SymbolicName: org.jazzcommunity.GitConnectorService.test;singleton:=true
Bundle-Version: 1.3.0.qualifier
Bundle-Version: 1.4.0.qualifier
Bundle-Vendor: VENDOR
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: target/dependency/junit-4.12.jar,
target/dependency/hamcrest-core-1.3.jar,
target/dependency/gson-2.8.2.jar,
target/dependency/com.siemens.bt.jazz.services.base-2.0.1-SNAPSHOT.jar,
target/dependency/com.siemens.bt.jazz.services.PersonalTokenService-1.0.2-SNAPSHOT.jar,
target/dependency/org.jazzcommunity.GitConnectorService-1.3.0-SNAPSHOT.jar,
target/dependency/org.jazzcommunity.GitConnectorService-1.4.0-SNAPSHOT.jar,
target/dependency/asm-5.0.3.jar,
target/dependency/asm-analysis-5.0.3.jar,
target/dependency/asm-tree-5.0.3.jar,
Expand Down
4 changes: 2 additions & 2 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService.parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion update-site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService.parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down

0 comments on commit 41b654b

Please sign in to comment.