-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Json RPC methods - Add REST endpoint
- Loading branch information
1 parent
7535b03
commit 663c079
Showing
4 changed files
with
134 additions
and
4 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
12 changes: 12 additions & 0 deletions
12
...va/blockchains/iaas/uni/stuttgart/de/management/tccsci/DistributedTransactionManager.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
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
64 changes: 64 additions & 0 deletions
64
...ckchains/iaas/uni/stuttgart/de/restapi/Controllers/DistributedTransactionsController.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,64 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Institute for the Architecture of Application System - | ||
* University of Stuttgart | ||
* | ||
* Author: Ghareeb Falazi | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms the Apache Software License 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package blockchains.iaas.uni.stuttgart.de.restapi.Controllers; | ||
|
||
import blockchains.iaas.uni.stuttgart.de.management.model.DistributedTransaction; | ||
import blockchains.iaas.uni.stuttgart.de.management.tccsci.DistributedTransactionRepository; | ||
import blockchains.iaas.uni.stuttgart.de.restapi.model.response.LinkCollectionResponse; | ||
import blockchains.iaas.uni.stuttgart.de.restapi.util.UriUtil; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.UriInfo; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Path("distributed-transactions") | ||
public class DistributedTransactionsController { | ||
|
||
@Context | ||
protected UriInfo uriInfo; | ||
@GET | ||
public Response get() { | ||
List<DistributedTransaction> all = DistributedTransactionRepository.getInstance().getAll(); | ||
final LinkCollectionResponse response = new LinkCollectionResponse(); | ||
|
||
for (final DistributedTransaction dtx : all) { | ||
response.add(UriUtil.generateSubResourceLink(uriInfo, dtx.getId().toString(), false, "self")); | ||
} | ||
|
||
return Response.ok(response).build(); | ||
} | ||
|
||
@GET | ||
@Path("/{dtxId}") | ||
public Response getSubscriptionDetails(@PathParam("dtxId") final String dtxId) { | ||
UUID uuid = UUID.fromString(dtxId); | ||
DistributedTransaction dtx = DistributedTransactionRepository.getInstance().getById(uuid); | ||
if (dtx != null) { | ||
return Response | ||
.status(Response.Status.OK) | ||
.entity(dtx) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} else { | ||
return Response.status(Response.Status.NOT_FOUND).build(); | ||
} | ||
} | ||
|
||
} |