Skip to content

Commit

Permalink
Merge pull request #10 from SBI-/master
Browse files Browse the repository at this point in the history
Implement base and clean up entry service
  • Loading branch information
SBI- committed Jul 4, 2018
2 parents 6daef76 + 25fc89c commit 064a3f7
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 68 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.6.0.qualifier"
version="1.6.1.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.6.0-SNAPSHOT</version>
<version>1.6.1-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.6.0.qualifier
Bundle-Version: 1.6.1.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.6.0-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
package org.jazzcommunity.GitConnectorService;

import com.ibm.team.jfs.app.http.util.HttpConstants.HttpMethod;
import com.ibm.team.repository.service.TeamRawService;
import com.siemens.bt.jazz.services.base.rest.RestAction;
import com.siemens.bt.jazz.services.base.rest.RestActionBuilder;
import com.siemens.bt.jazz.services.base.rest.parameters.RestRequest;
import com.siemens.bt.jazz.services.base.router.Router;
import com.siemens.bt.jazz.services.base.router.map.MapRouter;
import com.siemens.bt.jazz.services.base.BaseService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* Entry point for the Service, called by the Jazz class loader.
* <p>
* <p>This class must be implemented for enabling plug-ins to run inside Jazz. The implemented interface corresponds to
* the component in {@code plugin.xml}, and this service is therefore the provided service by the interface.</p>
*/
public class GitConnectorService extends TeamRawService implements IGitConnectorService {

private final Router router = new MapRouter();
public class GitConnectorService extends BaseService implements IGitConnectorService {

/**
* Constructs a new Service
Expand Down Expand Up @@ -56,54 +44,12 @@ public GitConnectorService() {
* We have decided to use the IBM rich hovers for now, but potential support will remain built into
* the service until the decision is final, depending on how IBM will proceed with their own git
* integration support.
*
* Note that these services use the legacy way of defining path parameters.
*/
// router.addService(HttpMethod.GET, ".*/gitlab/[a-zA-Z.]+/project/[0-9]+/commit/[^\\/]+/link.*",
// new RestFactory(CommitLinkService.class));
// router.addService(HttpMethod.GET, ".*/gitlab/[a-zA-Z.]+/project/[0-9]+/commit/[^\\/]+/preview.*",
// new RestFactory(CommitPreviewService.class));
}

@Override
public void perform_GET(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException {
performAction(uri, request, response);
}

@Override
public void perform_POST(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException {
performAction(uri, request, response);
}

protected void performAction(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
RestActionBuilder builder = prepareRequest(uri, request, response);
RestAction action = builder.create();
action.execute();
} catch (IOException e) {
// This will need extra logging, but we quench it for now to allow non-authorized requests
// without spamming the server log. Sorry :-*
//throw e;
} catch (Exception e) {
// catch everything and log. Makes sure that there is no checked exception from our service back
// to jazz, except for the expected IOException when the response isn't writable. We need to make
// sure that our plug-in conforms to the contract that no exceptions bubble out into the system.
super.getLog().error(e);
this.http500return(request, response, e);
}
}

protected final RestActionBuilder prepareRequest(
String uri,
HttpServletRequest request,
HttpServletResponse response) {

HttpMethod method = HttpMethod.fromString(request.getMethod());
@SuppressWarnings("unchecked")
RestRequest restRequest = new RestRequest(method, uri, request.getParameterMap());
return router.prepareAction(
this,
this.getLog(),
request,
response,
restRequest);
}
}
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.6.0-SNAPSHOT</version>
<version>1.6.1-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.6.0.qualifier
Bundle-Version: 1.6.1.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-3.0.0-SNAPSHOT.jar,
target/dependency/com.siemens.bt.jazz.services.PersonalTokenService-1.0.2-SNAPSHOT.jar,
target/dependency/org.jazzcommunity.GitConnectorService-1.6.0-SNAPSHOT.jar,
target/dependency/org.jazzcommunity.GitConnectorService-1.6.1-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.6.0-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>org.jazzcommunity.GitConnectorService</groupId>
<artifactId>org.jazzcommunity.GitConnectorService</artifactId>
<version>1.6.0-SNAPSHOT</version>
<version>1.6.1-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.6.0-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down

0 comments on commit 064a3f7

Please sign in to comment.