Merge branch 'features1.4/clean' into develop-1.4
This commit is contained in:
commit
ca3fbda8da
|
@ -6,7 +6,6 @@ import blockchain.configuration.Config;
|
|||
import blockchain.user.UserContext;
|
||||
import blockchain.utility.Util;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.ChaincodeID;
|
||||
import org.hyperledger.fabric.sdk.ChaincodeResponse;
|
||||
import org.hyperledger.fabric.sdk.ProposalResponse;
|
||||
|
@ -15,7 +14,6 @@ import java.util.Collection;
|
|||
|
||||
|
||||
public class QueryWrapper {
|
||||
private static Logger logger = Logger.getLogger(QueryWrapper.class);
|
||||
|
||||
public String sendQuery(String functionName,String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
|
@ -42,11 +40,8 @@ public class QueryWrapper {
|
|||
|
||||
for (ProposalResponse proposalResponse : queryProposals) {
|
||||
if (!proposalResponse.isVerified() || proposalResponse.getStatus() != ChaincodeResponse.Status.SUCCESS) {
|
||||
logger.error("Failed query proposal from peer " + proposalResponse.getPeer().getName() + " status : " + proposalResponse.getStatus() +
|
||||
". Message : " + proposalResponse.getMessage() + ". Was verified : " + proposalResponse.isVerified());
|
||||
} else {
|
||||
response = new String(proposalResponse.getChaincodeActionResponsePayload());
|
||||
logger.info("Query payload : " + response + " from peer : " + proposalResponse.getPeer().getName());
|
||||
}
|
||||
}
|
||||
return response;
|
||||
|
|
|
@ -6,68 +6,52 @@ import blockchain.configuration.Config;
|
|||
import blockchain.user.UserContext;
|
||||
import blockchain.utility.Util;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TransactionWrapper {
|
||||
private static Logger logger = Logger.getLogger(TransactionWrapper.class);
|
||||
|
||||
public BlockEvent.TransactionEvent sendTransaction(String functionName, String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
UserContext user = Util.readUserContext(Config.ORG1,"admin");
|
||||
|
||||
//try{
|
||||
Collection<ProposalResponse> successful = new LinkedList<>();
|
||||
FabricClientWrapper fabricClientWrapper;
|
||||
|
||||
Collection<ProposalResponse> successful = new LinkedList<>();
|
||||
//Collection<ProposalResponse> failed = new LinkedList<>();
|
||||
FabricClientWrapper fabricClientWrapper;
|
||||
if(user != null){
|
||||
fabricClientWrapper = new FabricClientWrapper(user);
|
||||
} else {
|
||||
throw new Exception("No UserContext");
|
||||
}
|
||||
|
||||
if(user != null){
|
||||
fabricClientWrapper = new FabricClientWrapper(user);
|
||||
ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME);
|
||||
|
||||
//INIT CHANNEL FOR QUERY
|
||||
Channel channel = channelClientWrapper.getChannel();
|
||||
Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL);
|
||||
channel.addOrderer(orderer);
|
||||
Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL);
|
||||
channel.addPeer(peer);
|
||||
channel.initialize();
|
||||
//
|
||||
|
||||
//Prepare transaction
|
||||
TransactionProposalRequest tpr = fabricClientWrapper.getClient().newTransactionProposalRequest();
|
||||
ChaincodeID cid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_NAME).build();
|
||||
tpr.setChaincodeID(cid);
|
||||
tpr.setFcn(functionName);
|
||||
tpr.setArgs(args);
|
||||
tpr.setProposalWaitTime(120000);
|
||||
|
||||
Collection<ProposalResponse> invokePropResp = channel.sendTransactionProposal(tpr); //Send proposal transaction
|
||||
for(ProposalResponse response : invokePropResp){
|
||||
if (response.getStatus() == ChaincodeResponse.Status.SUCCESS) {
|
||||
successful.add(response);
|
||||
} else {
|
||||
throw new Exception("No UserContext");
|
||||
throw new Exception("Error during insert into Blockchain");
|
||||
}
|
||||
|
||||
ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME);
|
||||
|
||||
//INIT CHANNEL FOR QUERY
|
||||
Channel channel = channelClientWrapper.getChannel();
|
||||
Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL);
|
||||
channel.addOrderer(orderer);
|
||||
Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL);
|
||||
channel.addPeer(peer);
|
||||
channel.initialize();
|
||||
//
|
||||
|
||||
//Prepare transaction
|
||||
TransactionProposalRequest tpr = fabricClientWrapper.getClient().newTransactionProposalRequest();
|
||||
ChaincodeID cid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_NAME).build();
|
||||
tpr.setChaincodeID(cid);
|
||||
tpr.setFcn(functionName);
|
||||
tpr.setArgs(args);
|
||||
tpr.setProposalWaitTime(120000);
|
||||
|
||||
Collection<ProposalResponse> invokePropResp = channel.sendTransactionProposal(tpr); //Send proposal transaction
|
||||
for(ProposalResponse response : invokePropResp){
|
||||
if (response.getStatus() == ChaincodeResponse.Status.SUCCESS) {
|
||||
logger.info("Successful transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
||||
successful.add(response);
|
||||
} else {
|
||||
logger.info("Failed transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
||||
throw new Exception("Error during insert into Blockchain");
|
||||
//failed.add(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return channelClientWrapper.sendTransaction(successful); //Send successful transaction to orderer
|
||||
/*
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
return channelClientWrapper.sendTransaction(successful); //Send successful transaction to orderer
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package database;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
@DatabaseTable(tableName = "T_TEST")
|
||||
public class DatabaseTest {
|
||||
private static final String NAME_FIELD_NAME = "name";
|
||||
private static final String ID_FIELD_NAME = "id";
|
||||
|
||||
@DatabaseField(columnName = ID_FIELD_NAME, id = true)
|
||||
private int id;
|
||||
@DatabaseField(columnName = NAME_FIELD_NAME, canBeNull = false)
|
||||
private String name;
|
||||
|
||||
public DatabaseTest(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DatabaseTest() { }
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.hyperledger.fabric.sdk.BlockEvent;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockchainQueryImplementation {
|
||||
|
||||
/*
|
||||
public Double getWalletSold(String walletHash){
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
Double sold = 0.0;
|
||||
|
||||
String result = queryWrapper.sendQuery("readWallet", new String[]{walletHash});
|
||||
if(result != null) {
|
||||
JsonReader reader = Json.createReader(new StringReader(result));
|
||||
JsonObject walletInfo = reader.readObject();
|
||||
sold = walletInfo.getJsonNumber("sold").doubleValue();
|
||||
}
|
||||
return sold;
|
||||
}
|
||||
|
||||
|
||||
public String getUserAssociation(String userHash){
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String result = queryWrapper.sendQuery("readUser", new String[]{userHash});
|
||||
String association = null;
|
||||
if(result != null){
|
||||
JsonReader reader = Json.createReader(new StringReader(result));
|
||||
JsonObject userInfo = reader.readObject();
|
||||
association = userInfo.getString("userAssociation");
|
||||
}
|
||||
return association;
|
||||
}
|
||||
|
||||
|
||||
public List<HashMap> getUserWallets(String userHash){
|
||||
List<HashMap> wallets = new ArrayList<>();
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String response = queryWrapper.sendQuery("queryWalletsByOwner",new String[]{userHash});
|
||||
|
||||
if(response != null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonArray walletInfo = reader.readArray();
|
||||
|
||||
for(Object obj : walletInfo){
|
||||
HashMap<String,String> wallet = new HashMap<String, String>();
|
||||
JsonObject o = (JsonObject) obj;
|
||||
o = o.get("Record").asJsonObject();
|
||||
wallet.put("walletHash",o.getString("id"));
|
||||
wallet.put("walletType",o.getString("walletType"));
|
||||
wallet.put("sold",o.getJsonNumber("sold").toString());
|
||||
wallets.add(wallet);
|
||||
}
|
||||
}
|
||||
return wallets;
|
||||
}
|
||||
|
||||
|
||||
public String sendTransaction(String sourceWallet, String destinationWallet, Double amount){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
BlockEvent.TransactionEvent transactionEvent = transactionWrapper.sendTransaction("transaction",new String[]{sourceWallet,destinationWallet,amount.toString()});
|
||||
return transactionEvent.getTransactionID();
|
||||
}
|
||||
|
||||
|
||||
public void registerUser(String[] userInfo){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("registerUser",userInfo);
|
||||
}
|
||||
|
||||
|
||||
public void deleteWallet(String walletHash){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("deleteWallet",new String[]{walletHash});
|
||||
}
|
||||
|
||||
public void setPermission(String userHash){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("setUserPermission",new String[]{userHash});
|
||||
}
|
||||
|
||||
public void transferWallet(String walletHash, String userHash){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("transferWallet", new String[]{walletHash,userHash});
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.transaction.Transaction;
|
||||
import database.transaction.TransactionDao;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
public class DatabaseTransactionImplementation {
|
||||
|
||||
/*
|
||||
public void saveTransaction(Transaction transaction) throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
long now = Instant.now().toEpochMilli();
|
||||
transaction.setTransactionDate(now);
|
||||
transactionDao.addTransaction(transaction);
|
||||
}
|
||||
|
||||
public Transaction getUserTransaction(String userHash, String transactionHash)throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
Transaction tx = transactionDao.getTransaction(userHash,transactionHash);
|
||||
if(tx != null){
|
||||
return tx;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Transaction> getAllUserTransactions(String userHash)throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getUserTransactions(userHash);
|
||||
}
|
||||
|
||||
public List<Transaction> getLastTenTransactions(String userHash)throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getTenLastUserTransactions(userHash);
|
||||
}
|
||||
|
||||
public List<Transaction> getSentTransaction(String userHash)throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getUserSentTransaction(userHash);
|
||||
}
|
||||
|
||||
public List<Transaction> getReceivedTransaction(String userHash)throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getUserReceivedTransaction(userHash);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DatabaseUserImplementation {
|
||||
|
||||
/*
|
||||
public Map<String,String> saveUser(User user) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
Map<String,String> response = new HashMap<String, String>();
|
||||
|
||||
User dbUser = userDao.getUser(user.getEmail());
|
||||
if(dbUser != null){
|
||||
response.put("response","false");
|
||||
return response;
|
||||
}else {
|
||||
user.setPassword(hashPassword(user.getPassword()));
|
||||
long now = Instant.now().toEpochMilli();
|
||||
user.setCreation_date(now);
|
||||
user.setModification_date(now);
|
||||
user.setVerified(true);
|
||||
user.setApproved(true);
|
||||
|
||||
//TEMPORARY USER HASH IS
|
||||
//name+email+password
|
||||
user.setUser_hash(hashPassword(user.getName()+user.getEmail()+user.getPassword()));
|
||||
userDao.addUser(user);
|
||||
response.put("userHash",user.getUser_hash());
|
||||
response.put("response","true");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public User getUser(String email, String password) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
User user1 = userDao.getUser(email);
|
||||
if(user1 != null){
|
||||
String hash = user1.getPassword();
|
||||
if(BCrypt.checkpw(password, hash)){
|
||||
return user1;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String,String> userLogger(User user) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
Map<String,String> response = new HashMap<String, String>();
|
||||
|
||||
User user1 = userDao.getUser(user.getEmail());
|
||||
if(user1 != null){
|
||||
String hash = user1.getPassword();
|
||||
|
||||
if(!BCrypt.checkpw(user.getPassword(), hash)){
|
||||
response.put("response","Not Allowed");
|
||||
}else{
|
||||
response.put("response","Ok");
|
||||
response.put("userHash",user1.getUser_hash());
|
||||
}
|
||||
} else {
|
||||
response.put("response","Not Exist");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String hashPassword(String plainTextPassword){
|
||||
return BCrypt.hashpw(plainTextPassword,BCrypt.gensalt());
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -10,7 +10,6 @@ import database.user.User;
|
|||
import database.user.UserDao;
|
||||
import org.hyperledger.fabric.sdk.BlockEvent;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
|
@ -82,14 +81,12 @@ public class TransactionImplementation {
|
|||
return returnResponse;
|
||||
}
|
||||
|
||||
|
||||
//GET
|
||||
public Transaction getTransaction(String wallet_hash, String transaction_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getTransaction(wallet_hash,transaction_hash);
|
||||
}
|
||||
|
||||
|
||||
//SENT
|
||||
public List<Transaction> getSentTransaction(String wallet_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
|
@ -107,7 +104,6 @@ public class TransactionImplementation {
|
|||
return transactionList;
|
||||
}
|
||||
|
||||
|
||||
//RECEIVED
|
||||
public List<Transaction> getReceivedTransaction(String wallet_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
|
@ -125,9 +121,6 @@ public class TransactionImplementation {
|
|||
return transactionList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Transaction> getLatestTransactions(String user_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
|
@ -154,8 +147,6 @@ public class TransactionImplementation {
|
|||
return returnList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Transaction> getAllTransactions(String user_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
|
@ -178,5 +169,4 @@ public class TransactionImplementation {
|
|||
}
|
||||
|
||||
//TODO SELECT BETWEEN
|
||||
|
||||
}
|
||||
|
|
|
@ -3,16 +3,12 @@ package restImplementation;
|
|||
import blockchain.query.TransactionWrapper;
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserImplementation {
|
||||
private static Logger logger = Logger.getLogger(UserImplementation.class);
|
||||
|
||||
public Map<String,String> registerUser(User user) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
|
@ -52,7 +48,6 @@ public class UserImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void approveUser(User user) throws Exception{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
UserDao userDao = new UserDao();
|
||||
|
@ -60,7 +55,6 @@ public class UserImplementation {
|
|||
userDao.approveUser(user.getEmail());
|
||||
}
|
||||
|
||||
|
||||
public void deleteUser(User user) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("deleteUser",new String[]{user.getUser_hash()});
|
||||
|
@ -68,7 +62,6 @@ public class UserImplementation {
|
|||
userDao.deleteUser(user.getEmail());
|
||||
}
|
||||
|
||||
|
||||
public User getUser(String email, String password) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
User user1 = userDao.getUserWithEmail(email);
|
||||
|
@ -89,15 +82,11 @@ public class UserImplementation {
|
|||
return userDao.getUserIdWithHashAndEmail(user_hash,user_email);
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> userLogger(User user) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
UserDao userDao = new UserDao();
|
||||
Map<String,String> response = new HashMap<>();
|
||||
|
||||
User userResponse = userDao.getUserWithEmail(user.getEmail());
|
||||
logger.info(userResponse.getEmail());
|
||||
|
||||
if(userResponse != null){
|
||||
String hash = userResponse.getPassword();
|
||||
|
@ -114,9 +103,7 @@ public class UserImplementation {
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
private String hashPassword(String plainTextPassword){
|
||||
return BCrypt.hashpw(plainTextPassword,BCrypt.gensalt());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ import database.Wallet.WalletDao;
|
|||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import restService.UserResource;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
@ -22,7 +18,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class WalletImplementation {
|
||||
private static Logger logger = Logger.getLogger(WalletImplementation.class);
|
||||
|
||||
public Map<String,String> createWallet(Wallet wallet) throws Exception {
|
||||
Map<String,String> response = new HashMap<>();
|
||||
|
@ -41,7 +36,6 @@ public class WalletImplementation {
|
|||
wallet.setCreation_date(now);
|
||||
wallet.setModification_date(now);
|
||||
|
||||
|
||||
walletDao.addWallet(wallet); // add wallet to replica DB
|
||||
|
||||
response.put("walletHash",wallet.getWallet_hash());
|
||||
|
@ -85,8 +79,6 @@ public class WalletImplementation {
|
|||
|
||||
//setBalance
|
||||
public void setBalanceToWallet(String associationHash, String associationPwd, String walletHash, double amount) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
UserDao userDao = new UserDao();
|
||||
User association = userDao.getUserWithHash(associationHash);
|
||||
|
@ -97,23 +89,17 @@ public class WalletImplementation {
|
|||
double newBalance = 0.0;
|
||||
transactionWrapper.sendTransaction("setBalanceOnWallet",new String[]{walletHash,String.valueOf(amount)});
|
||||
Wallet wallet = getWallet(walletHash);
|
||||
logger.info("wallet : "+wallet);
|
||||
if(wallet!=null){
|
||||
logger.info("wallet!=null");
|
||||
newBalance=wallet.getBalance();
|
||||
logger.info("newBalance : "+newBalance);
|
||||
logger.info("walletHash : "+walletHash);
|
||||
WalletDao walletDao = new WalletDao();
|
||||
walletDao.updateWalletBalance(walletHash,newBalance);
|
||||
} else {
|
||||
throw new Exception("ERROR QUERY WALLET");
|
||||
}
|
||||
|
||||
}else {
|
||||
System.out.println("WRONG PDW");
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
|
||||
}else {
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
|
@ -141,7 +127,6 @@ public class WalletImplementation {
|
|||
walletDao.transferWallet(walletHash,newUserHash);
|
||||
}
|
||||
|
||||
|
||||
//delete
|
||||
public void deleteWallet(String walletHash, String userHash) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
|
@ -164,10 +149,7 @@ public class WalletImplementation {
|
|||
return walletList;
|
||||
}
|
||||
|
||||
|
||||
private String generateWalletHash(String walletBuilderString){
|
||||
return BCrypt.hashpw(walletBuilderString,BCrypt.gensalt());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
package restService;
|
||||
|
||||
import database.user.User;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.BlockchainQueryImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/query")
|
||||
public class BlockchainQueryResource {
|
||||
|
||||
/*
|
||||
@RequestMapping(value = "/balance", method = RequestMethod.GET ,params = {"walletHash"},produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> getUserBalance(@RequestParam(value = "walletHash") String walletHash){
|
||||
try{
|
||||
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
||||
Double result = blockchainQueryImplementation.getWalletSold(walletHash);
|
||||
StringResponse response = new StringResponse("Ok",result);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
StringResponse response = new StringResponse("Error");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/registerUser", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> registerUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
||||
String[] userInfos = new String[]{user.getUser_hash(),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
||||
blockchainQueryImplementation.registerUser(userInfos);
|
||||
StringResponse response = new StringResponse("OK");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
StringResponse response = new StringResponse("Error: "+e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package restService;
|
||||
|
||||
import database.transaction.Transaction;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.DatabaseTransactionImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/transaction")
|
||||
public class DatabaseTransactionResource {
|
||||
/*
|
||||
@PostMapping("/save")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity<String> saveTransaction(@Valid @RequestBody Transaction transaction){
|
||||
try{
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
databaseTransactionImplementation.saveTransaction(transaction);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
}catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get", method = RequestMethod.GET, params = {"userHash","transactionHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<Transaction> getTransaction(@RequestParam(value = "userHash") String userHash, @RequestParam(value = "transactionHash") String transactionHash){
|
||||
try{
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
Transaction tx = databaseTransactionImplementation.getUserTransaction(userHash,transactionHash);
|
||||
if(tx != null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(tx);
|
||||
}else {
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getLatest", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<List<Transaction>> getLatestTransactions(@RequestParam(value = "userHash") String userHash){
|
||||
try{
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
List<Transaction> transactionList = databaseTransactionImplementation.getLastTenTransactions(userHash);
|
||||
if(!transactionList.isEmpty()){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(transactionList);
|
||||
}else {
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getAll", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<List<Transaction>> getAllTransactions(@RequestParam(value = "userHash") String userHash){
|
||||
try{
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
List<Transaction> transactionList = databaseTransactionImplementation.getAllUserTransactions(userHash);
|
||||
if(!transactionList.isEmpty()){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(transactionList);
|
||||
}else {
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/sent", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<List<Transaction>> getSentTransactions(@RequestParam(value = "userHash") String userHash){
|
||||
try {
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
List<Transaction> transactionList = databaseTransactionImplementation.getSentTransaction(userHash);
|
||||
if(!transactionList.isEmpty()){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(transactionList);
|
||||
}else {
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/received", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<List<Transaction>> getReceivedTransactions(@RequestParam(value = "userHash") String userHash){
|
||||
try {
|
||||
DatabaseTransactionImplementation databaseTransactionImplementation = new DatabaseTransactionImplementation();
|
||||
List<Transaction> transactionList = databaseTransactionImplementation.getReceivedTransaction(userHash);
|
||||
if(!transactionList.isEmpty()){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(transactionList);
|
||||
}else {
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package restService;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import database.user.User;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.BlockchainQueryImplementation;
|
||||
import restImplementation.DatabaseUserImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/api/rest/user")
|
||||
public class DatabaseUserResource {
|
||||
|
||||
/*
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity<StringResponse> saveUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
Map<String,String> response = databaseUserImplementation.saveUser(user);
|
||||
if(Boolean.parseBoolean(response.get("response"))){
|
||||
StringResponse responseS = new StringResponse("Ok",response.get("userHash"));
|
||||
|
||||
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
||||
String[] userInfos = new String[]{response.get("userHash"),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
||||
blockchainQueryImplementation.registerUser(userInfos);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
||||
}else {
|
||||
StringResponse responseS = new StringResponse("User already exist");
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(responseS);
|
||||
}
|
||||
}catch (Exception e){
|
||||
StringResponse responseS = new StringResponse(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(responseS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> login(@Valid @RequestBody User user){
|
||||
try{
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
Map<String,String> response = databaseUserImplementation.userLogger(user);
|
||||
switch (response.get("response")){
|
||||
case "Not Exist" : {
|
||||
StringResponse responseS = new StringResponse("User Not Found");
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseS);
|
||||
}
|
||||
case "Not Allowed" :{
|
||||
StringResponse responseS = new StringResponse("Wrong Password!");
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(responseS);
|
||||
}
|
||||
case "" :{
|
||||
StringResponse responseS = new StringResponse("Error");
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(responseS);
|
||||
}
|
||||
case "Ok":{
|
||||
StringResponse responseS = new StringResponse("Ok",response.get("userHash"));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
||||
}
|
||||
default:{
|
||||
StringResponse responseS = new StringResponse("Error");
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(responseS);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
StringResponse responseS = new StringResponse(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(responseS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/get", produces = "application/json")
|
||||
@ResponseBody
|
||||
public ResponseEntity<User> getUser(@RequestBody User user){
|
||||
try{
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
User response = databaseUserImplementation.getUser(user.getEmail(), user.getPassword());
|
||||
if(response != null){
|
||||
User userResponse = new User();
|
||||
userResponse.setUser_hash(response.getUser_hash());
|
||||
userResponse.setUserId(response.getUserId());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(userResponse);
|
||||
}else{
|
||||
return new ResponseEntity("Error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity updateUser(@RequestBody User user){
|
||||
return new ResponseEntity(null, HttpStatus.OK);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -10,7 +10,6 @@ import java.util.Map;
|
|||
@RestController
|
||||
@RequestMapping(value = "/api/rest/session")
|
||||
public class SessionResource {
|
||||
|
||||
@RequestMapping(value = "/start", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity startSession(@RequestBody Map<String,String> requestParam){
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.TransactionImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -14,7 +13,6 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping(value = "/api/rest/transaction")
|
||||
public class TransactionResource {
|
||||
|
||||
//DO TRANSACTION
|
||||
@RequestMapping(value = "/send", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
|
@ -111,8 +109,6 @@ public class TransactionResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/get/latest", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getLatestTransaction(@RequestParam(value = "user_hash") String user_hash){
|
||||
|
@ -126,7 +122,6 @@ public class TransactionResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getAll", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getAllTransaction(@RequestParam(value = "user_hash") String user_hash){
|
||||
|
@ -139,5 +134,4 @@ public class TransactionResource {
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package restService;
|
||||
|
||||
import database.user.User;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -14,9 +12,6 @@ import java.util.Map;
|
|||
@RestController
|
||||
@RequestMapping(value = "/api/rest/user")
|
||||
public class UserResource {
|
||||
private static Logger logger = Logger.getLogger(UserResource.class);
|
||||
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity<StringResponse> registerUser(@Valid @RequestBody User user){
|
||||
|
@ -43,7 +38,6 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/approve", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> approveUser(@Valid @RequestBody User user){
|
||||
|
@ -58,17 +52,12 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> login(@Valid @RequestBody User user){
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
logger.info(user.getEmail());
|
||||
logger.info(user.getPassword());
|
||||
Map<String,String> response = userImplementation.userLogger(user);
|
||||
logger.info(response.get("response"));
|
||||
switch (response.get("response")){
|
||||
case "Not Exist" : {
|
||||
StringResponse responseS = new StringResponse("Not Found");
|
||||
|
@ -97,7 +86,6 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/get", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<User> getUser(@Valid @RequestBody User user){
|
||||
|
@ -117,8 +105,6 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> removeUser(@Valid @RequestBody User user){
|
||||
|
@ -133,7 +119,6 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity updateUser(@RequestBody User user){
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.WalletImplementation;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
@ -14,7 +13,6 @@ import java.util.Map;
|
|||
@RestController
|
||||
@RequestMapping(value = "/api/rest/wallet")
|
||||
public class WalletResource {
|
||||
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity createWallet(@Valid @RequestBody Wallet wallet){
|
||||
|
@ -40,7 +38,6 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getUserWallets", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallets(@RequestParam(value = "userHash") String userHash){
|
||||
|
@ -54,7 +51,6 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getWallet", method = RequestMethod.GET, params = {"walletHash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallet(@RequestParam(value = "walletHash") String walletHash){
|
||||
|
@ -72,8 +68,6 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/setBalance", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity setBalance(@RequestBody BalanceWallet BalanceWallet){
|
||||
|
@ -87,8 +81,6 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/transfer", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity transferWallet(@RequestBody Wallet wallet){
|
||||
|
@ -102,7 +94,6 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public ResponseEntity deleteWallet(@RequestBody Map<String,String> requestParam){
|
||||
String userHash = requestParam.get("userHash");
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
@RestController
|
||||
public class WelcomeResource {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index(){return "Welcome from Monnethic !";}
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package database;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.dao.DaoManager;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//Testing class for postgresql connection
|
||||
@Ignore
|
||||
public class DatabaseHelperTest {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
|
||||
//Test connection by getting existing data in T_TEST
|
||||
@Test
|
||||
public void TestConnection(){
|
||||
Dao<DatabaseTest, Integer> testDao;
|
||||
try{
|
||||
testDao = DaoManager.createDao(dbh.setupDatabaseConnection(),DatabaseTest.class);
|
||||
DatabaseTest dbt = testDao.queryForId(1);
|
||||
System.out.println(dbt.getName());
|
||||
assert dbt != null;
|
||||
assert "thomas".equals(dbt.getName());
|
||||
}catch (Exception e){
|
||||
System.out.println("\n"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package database;
|
||||
|
||||
import database.user.User;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import restImplementation.DatabaseUserImplementation;
|
||||
|
||||
@Ignore
|
||||
public class DatabaseUserImplementationTest {
|
||||
/*
|
||||
@Test
|
||||
public void TestUser(){
|
||||
try {
|
||||
//String email = "null";
|
||||
String email = "thomas.marshal@gmail.com";
|
||||
String password = "null";
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
User response = databaseUserImplementation.getUser(email, password);
|
||||
System.out.println(response);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class GetUserAssociationTest {
|
||||
private static Logger logger = Logger.getLogger(GetUserAssociationTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void GetUserAssociationTest() {
|
||||
BlockchainQueryImplementation queryImplementation = new BlockchainQueryImplementation();
|
||||
String association = queryImplementation.getUserAssociation("bitman");
|
||||
logger.info("association : "+association);
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class GetUserWalletsTest {
|
||||
private static Logger logger = Logger.getLogger(GetWalletSoldTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void GetUserWalletsTest() {
|
||||
BlockchainQueryImplementation queryImplementation = new BlockchainQueryImplementation();
|
||||
List<HashMap> wallets = queryImplementation.getUserWallets("bitman");
|
||||
for(HashMap w : wallets){
|
||||
logger.info("walletHash : "+w.get("walletHash")+". walletType : "+w.get("walletType")+". sold : "+w.get("sold"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class GetWalletSoldTest {
|
||||
private static Logger logger = Logger.getLogger(GetWalletSoldTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void GetWalletSold() {
|
||||
BlockchainQueryImplementation queryImplementation = new BlockchainQueryImplementation();
|
||||
Double sold = queryImplementation.getWalletSold("qerh654d5f5h46q4fdh6h65fh00");
|
||||
logger.info("result sold : "+sold);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ public class TransactionImplementationTest {
|
|||
private static Logger logger = Logger.getLogger(TransactionImplementationTest.class);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void doMultipleTransaction(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
|
@ -55,11 +55,11 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void doTransaction(){
|
||||
public void doTransactionA(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.","thomasPwd158$*",
|
||||
|
@ -73,9 +73,9 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void doTransaction(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
|
@ -91,10 +91,10 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllSentTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -113,9 +113,9 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getSent(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -130,10 +130,10 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllReceivedTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -152,10 +152,10 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getReceived(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -170,10 +170,10 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getLatestTransactions(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -189,9 +189,9 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
|
@ -206,6 +206,6 @@ public class TransactionImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.user.User;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Ignore
|
||||
public class UserLoggerTest {
|
||||
/*
|
||||
@Test
|
||||
public void testLoggerUser(){
|
||||
try{
|
||||
User user = new User();
|
||||
user.setPassword("newPassword");
|
||||
user.setEmail("thomas.marshal@gmail.com");
|
||||
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
Map<String, String> res = databaseUserImplementation.userLogger(user);
|
||||
System.out.println(res);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -12,7 +12,6 @@ import java.util.Map;
|
|||
public class WalletImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(WalletImplementationTest.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void CreateWalletTest() { // OK
|
||||
BasicConfigurator.configure();
|
||||
|
@ -34,9 +33,6 @@ public class WalletImplementationTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void TestDeleteWallet() { //OK
|
||||
BasicConfigurator.configure();
|
||||
|
@ -48,10 +44,6 @@ public class WalletImplementationTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void TestGetWallet(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
|
@ -67,26 +59,16 @@ public class WalletImplementationTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void TestSetBalance(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.setBalanceToWallet("$2a$10$WN6ARfShm9bgRZ8s9bzZqejvL.VzZrjXRmZLj6N3U6No9G/YLVqVi",50.0);
|
||||
//walletImplementation.setBalanceToWallet("$2a$10$WN6ARfShm9bgRZ8s9bzZqejvL.VzZrjXRmZLj6N3U6No9G/YLVqVi",50.0);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void TestTransferWalelt(){ //OK
|
||||
|
@ -99,10 +81,8 @@ public class WalletImplementationTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void TestGetUserWallet(){ //TODO wait for chaincode correction
|
||||
public void TestGetUserWallet(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
|
@ -111,8 +91,4 @@ public class WalletImplementationTest {
|
|||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue