-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SBI-/master
Add service that exposes version
- Loading branch information
Showing
10 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugin/src/main/java/org/jazzcommunity/GitConnectorService/builder/VersionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters