Clean API
This commit is contained in:
parent
3893e90630
commit
70a3b3328d
|
@ -1,21 +1,16 @@
|
||||||
package blockchain.configuration;
|
package blockchain.configuration;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
//TEST
|
|
||||||
public static final String u2 = "woEXRrZdwXiu";
|
|
||||||
|
|
||||||
//ORGANIZATION
|
//ORGANIZATION
|
||||||
public static final String ORG1_MSP = "Org1MSP";
|
public static final String ORG1_MSP = "Org1MSP";
|
||||||
|
|
||||||
public static final String ORG1 = "Org1";
|
public static final String ORG1 = "Org1";
|
||||||
|
|
||||||
//ADMIN
|
//ADMIN
|
||||||
public static final String ADMIN = "admin";
|
public static final String ADMIN = "admin";
|
||||||
|
|
||||||
public static final String ADMIN_PASSWORD = "adminpw";
|
public static final String ADMIN_PASSWORD = "adminpw";
|
||||||
|
|
||||||
//USER
|
//USER
|
||||||
//public static final String UserPWD = "ZIidLJHQbLcC";
|
|
||||||
public static final String UserPWD = "OelXVCdHnYPe";
|
public static final String UserPWD = "OelXVCdHnYPe";
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,23 +39,17 @@ public class Config {
|
||||||
|
|
||||||
public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:7051";
|
public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:7051";
|
||||||
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:7051";
|
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:7051";
|
||||||
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:8051";
|
|
||||||
//ublic static final String ORG1_PEER_0_URL = "grpc://vps592802.ovh.net:7051";
|
//ublic static final String ORG1_PEER_0_URL = "grpc://vps592802.ovh.net:7051";
|
||||||
|
|
||||||
|
|
||||||
//PEER 1
|
//PEER 1
|
||||||
public static final String ORG_PEER = "peer1.org1.example.com";
|
public static final String ORG_PEER = "peer1.org1.example.com";
|
||||||
|
|
||||||
public static final String ORG_PEER_URL = "grpc://vps592802.ovh.net:9051";
|
public static final String ORG_PEER_URL = "grpc://vps592802.ovh.net:9051";
|
||||||
|
|
||||||
//EVENTHUB
|
|
||||||
public static final String ORG_PEER_EVENT_URL = "grpc://vps592802.ovh.net:9053";
|
|
||||||
|
|
||||||
//ADMIN FILE TEST
|
//ADMIN FILE TEST
|
||||||
public static final String ADMIN_FILE_PATH = "msp/AdminFiles";
|
public static final String ADMIN_FILE_PATH = "msp/AdminFiles";
|
||||||
|
|
||||||
public static final String ADMIN_KEY_PATH = ADMIN_FILE_PATH+"/keystore";
|
public static final String ADMIN_KEY_PATH = ADMIN_FILE_PATH+"/keystore";
|
||||||
|
|
||||||
public static final String ADMIN_CERT_PATH = ADMIN_FILE_PATH+"/admincerts";
|
public static final String ADMIN_CERT_PATH = ADMIN_FILE_PATH+"/admincerts";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class WalletImplementation {
|
||||||
|
|
||||||
User user = userDao.getUserWithHash(wallet.getUser_hash());
|
User user = userDao.getUserWithHash(wallet.getUser_hash());
|
||||||
wallet.setWallet_hash(generateWalletHash(user.getName()+wallet.getType()+user.getFirstname()+ RandomStringUtils.randomAlphabetic(10)));
|
wallet.setWallet_hash(generateWalletHash(user.getName()+wallet.getType()+user.getFirstname()+ RandomStringUtils.randomAlphabetic(10)));
|
||||||
|
|
||||||
transactionWrapper.sendTransaction("initWallet",new String[]{wallet.getWallet_hash(),wallet.getType(),wallet.getUser_hash()}); //Create Wallet in Blockchain
|
transactionWrapper.sendTransaction("initWallet",new String[]{wallet.getWallet_hash(),wallet.getType(),wallet.getUser_hash()}); //Create Wallet in Blockchain
|
||||||
|
|
||||||
wallet.setBalance(0.0);
|
wallet.setBalance(0.0);
|
||||||
|
@ -35,17 +34,8 @@ public class WalletImplementation {
|
||||||
long now = Instant.now().toEpochMilli();
|
long now = Instant.now().toEpochMilli();
|
||||||
wallet.setCreation_date(now);
|
wallet.setCreation_date(now);
|
||||||
wallet.setModification_date(now);
|
wallet.setModification_date(now);
|
||||||
|
|
||||||
walletDao.addWallet(wallet); // add wallet to replica DB
|
walletDao.addWallet(wallet); // add wallet to replica DB
|
||||||
|
|
||||||
/*
|
|
||||||
response.put("wallet_hash",wallet.getWallet_hash());
|
|
||||||
response.put("wallet_type",wallet.getType());
|
|
||||||
response.put("wallet_balance",wallet.getBalance().toString());
|
|
||||||
response.put("owner_hash",wallet.getUser_hash());
|
|
||||||
response.put("response","true");
|
|
||||||
*/
|
|
||||||
|
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ public class SessionResource {
|
||||||
int session_id = sessionImplementation.startSession(user_hash,user_email);
|
int session_id = sessionImplementation.startSession(user_hash,user_email);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"session_id\":"+session_id+"}");
|
return ResponseEntity.status(HttpStatus.OK).body("{\"session_id\":"+session_id+"}");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ public class SessionResource {
|
||||||
sessionImplementation.endSession(session_id);
|
sessionImplementation.endSession(session_id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
package restService;
|
|
||||||
|
|
||||||
public class StringResponse {
|
|
||||||
private String response;
|
|
||||||
private String user_hash;
|
|
||||||
private Double userBalance;
|
|
||||||
|
|
||||||
public StringResponse(String response){
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringResponse(String response, Double userBalance){
|
|
||||||
this.response=response;
|
|
||||||
this.userBalance=userBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringResponse(String response, String userHash){
|
|
||||||
this.response=response;
|
|
||||||
this.user_hash=userHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getResponse() {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponse(String response) {
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserHash() {
|
|
||||||
return user_hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserHash(String userHash) {
|
|
||||||
this.user_hash = userHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getUserBalance(){return userBalance;}
|
|
||||||
|
|
||||||
public void setUserBalance(Double userBalance){this.userBalance=userBalance;}
|
|
||||||
}
|
|
|
@ -29,8 +29,8 @@ public class TransactionResource {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"response\":\""+mapResponse.get("message")+"\"}");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"response\":\""+mapResponse.get("message")+"\"}");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ public class TransactionResource {
|
||||||
return new ResponseEntity("{\"response\":\"error\"}", HttpStatus.NOT_FOUND);
|
return new ResponseEntity("{\"response\":\"error\"}", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ public class TransactionResource {
|
||||||
List<List<Transaction>> listTransaction = transactionImplementation.getAllSentTransaction(user_hash);
|
List<List<Transaction>> listTransaction = transactionImplementation.getAllSentTransaction(user_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//GET SENT FROM WALLET
|
//GET SENT FROM WALLET
|
||||||
|
@ -75,8 +75,8 @@ public class TransactionResource {
|
||||||
List<Transaction> listTransaction = transactionImplementation.getSentTransaction(wallet_hash);
|
List<Transaction> listTransaction = transactionImplementation.getSentTransaction(wallet_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ public class TransactionResource {
|
||||||
List<List<Transaction>> listTransaction = transactionImplementation.getAllReceivedTransaction(user_hash);
|
List<List<Transaction>> listTransaction = transactionImplementation.getAllReceivedTransaction(user_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//GET RECEIVED FROM WALLET
|
//GET RECEIVED FROM WALLET
|
||||||
|
@ -104,8 +104,8 @@ public class TransactionResource {
|
||||||
List<Transaction> listTransaction = transactionImplementation.getReceivedTransaction(wallet_hash);
|
List<Transaction> listTransaction = transactionImplementation.getReceivedTransaction(wallet_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ public class TransactionResource {
|
||||||
List<Transaction> listTransaction = transactionImplementation.getLatestTransactions(user_hash);
|
List<Transaction> listTransaction = transactionImplementation.getLatestTransactions(user_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ public class TransactionResource {
|
||||||
List<Transaction> listTransaction = transactionImplementation.getAllTransactions(user_hash);
|
List<Transaction> listTransaction = transactionImplementation.getAllTransactions(user_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,26 +30,26 @@ public class UserResource {
|
||||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+userHashResponse.get("user_hash")+"\"}";
|
String r = "{\"response\":\"ok\",\"user_hash\":\""+userHashResponse.get("user_hash")+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||||
}else {
|
}else {
|
||||||
StringResponse responseS = new StringResponse("User already exist");
|
String r = "{\"response\":\"User already exist\"}";
|
||||||
return ResponseEntity.status(HttpStatus.FOUND).body(responseS);
|
return ResponseEntity.status(HttpStatus.FOUND).body(r);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/approve", method = RequestMethod.POST, produces = "application/json")
|
@RequestMapping(value = "/approve", method = RequestMethod.POST, produces = "application/json")
|
||||||
@ResponseStatus(HttpStatus.OK)
|
@ResponseStatus(HttpStatus.OK)
|
||||||
public ResponseEntity<StringResponse> approveUser(@Valid @RequestBody User user){
|
public ResponseEntity approveUser(@Valid @RequestBody User user){
|
||||||
try{
|
try{
|
||||||
UserImplementation userImplementation = new UserImplementation();
|
UserImplementation userImplementation = new UserImplementation();
|
||||||
userImplementation.approveUser(user);
|
userImplementation.approveUser(user);
|
||||||
StringResponse response = new StringResponse("Ok",user.getUser_hash());
|
String r = "{\"response\":\"ok\",\"user_hash\":\""+user.getUser_hash()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse response = new StringResponse("Error: "+e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,30 +61,29 @@ public class UserResource {
|
||||||
Map<String,String> response = userImplementation.userLogger(user);
|
Map<String,String> response = userImplementation.userLogger(user);
|
||||||
switch (response.get("response")){
|
switch (response.get("response")){
|
||||||
case "Not Exist" : {
|
case "Not Exist" : {
|
||||||
StringResponse responseS = new StringResponse("Not Found");
|
String r = "{\"response\":\"Not Found\"}";
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseS);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(r);
|
||||||
}
|
}
|
||||||
case "Not Allowed" :{
|
case "Not Allowed" :{
|
||||||
StringResponse responseS = new StringResponse("Wrong authentication");
|
String r = "{\"response\":\"Wrong authentication\"}";
|
||||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(responseS);
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(r);
|
||||||
}
|
}
|
||||||
case "" :{
|
case "" :{
|
||||||
StringResponse responseS = new StringResponse("Error");
|
String r = "{\"response\":\"Error\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
case "true":{
|
case "true":{
|
||||||
//StringResponse responseS = new StringResponse("Ok",response.get("user_hash"));
|
|
||||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+response.get("user_hash")+"\"}";
|
String r = "{\"response\":\"ok\",\"user_hash\":\""+response.get("user_hash")+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||||
}
|
}
|
||||||
default:{
|
default:{
|
||||||
StringResponse responseS = new StringResponse("Error");
|
String r = "{\"response\":\"Error\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,15 +105,15 @@ public class UserResource {
|
||||||
|
|
||||||
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json")
|
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json")
|
||||||
@ResponseStatus(HttpStatus.OK)
|
@ResponseStatus(HttpStatus.OK)
|
||||||
public ResponseEntity<StringResponse> removeUser(@Valid @RequestBody User user){
|
public ResponseEntity removeUser(@Valid @RequestBody User user){
|
||||||
try{
|
try{
|
||||||
UserImplementation userImplementation = new UserImplementation();
|
UserImplementation userImplementation = new UserImplementation();
|
||||||
userImplementation.deleteUser(user);
|
userImplementation.deleteUser(user);
|
||||||
StringResponse responseS = new StringResponse("Ok");
|
String r = "{\"response\":\"ok\"}";
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,27 +19,10 @@ public class WalletResource {
|
||||||
try{
|
try{
|
||||||
WalletImplementation walletImplementation = new WalletImplementation();
|
WalletImplementation walletImplementation = new WalletImplementation();
|
||||||
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
||||||
|
|
||||||
/*
|
|
||||||
Wallet returnWallet = new Wallet();
|
|
||||||
returnWallet.setWallet_hash(walletResponse.get("wallet_hash"));
|
|
||||||
returnWallet.setUser_hash(wallet.getUser_hash());
|
|
||||||
returnWallet.setBalance(Double.parseDouble(walletResponse.get("wallet_balance")));
|
|
||||||
returnWallet.setType(walletResponse.get("wallet_type"));
|
|
||||||
*/
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
||||||
/*
|
|
||||||
if(Boolean.parseBoolean(walletResponse.get("response"))){
|
|
||||||
|
|
||||||
}else {
|
|
||||||
StringResponse responseS = new StringResponse("Wallet already exist");
|
|
||||||
return ResponseEntity.status(HttpStatus.FOUND).body(responseS);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +34,8 @@ public class WalletResource {
|
||||||
JsonArray wallets = walletImplementation.getAllUserWallets(user_hash);
|
JsonArray wallets = walletImplementation.getAllUserWallets(user_hash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(wallets);
|
return ResponseEntity.status(HttpStatus.OK).body(wallets);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +51,8 @@ public class WalletResource {
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"response\":null}");
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"response\":null}");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +64,8 @@ public class WalletResource {
|
||||||
walletImplementation.setBalanceToWallet(BalanceWallet.getAssociation_hash(), BalanceWallet.getAssocation_pwd(), BalanceWallet.getWallet_hash(),BalanceWallet.getAmount());
|
walletImplementation.setBalanceToWallet(BalanceWallet.getAssociation_hash(), BalanceWallet.getAssocation_pwd(), BalanceWallet.getWallet_hash(),BalanceWallet.getAmount());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +77,8 @@ public class WalletResource {
|
||||||
walletImplementation.transferWallet(wallet.getWallet_hash(),wallet.getUser_hash());
|
walletImplementation.transferWallet(wallet.getWallet_hash(),wallet.getUser_hash());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +91,8 @@ public class WalletResource {
|
||||||
walletImplementation.deleteWallet(walletHash,userHash);
|
walletImplementation.deleteWallet(walletHash,userHash);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
StringResponse responseS = new StringResponse(e.getMessage());
|
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.apache.log4j.BasicConfigurator;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import restService.StringResponse;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
|
Loading…
Reference in a new issue