예제 #1
0
 public static boolean isDigitalAssetComplete(DigitalAssetMetadata digitalAssetMetadata) {
   try {
     DigitalAsset digitalAsset = digitalAssetMetadata.getDigitalAsset();
     areObjectsSettled(digitalAsset);
     CryptoAddress genesisAddress = digitalAsset.getGenesisAddress();
     if (Validate.isObjectNull(genesisAddress)) {
       return false;
     }
     String digitalAssetHash = digitalAssetMetadata.getDigitalAssetHash();
     if (Validate.isValidString(digitalAssetHash)) {
       return false;
     }
     return true;
   } catch (ObjectNotSetException e) {
     return false;
   }
 }
예제 #2
0
 /** This method will deliver the DigitalAssetMetadata to ActorAssetUser */
 private void deliverDigitalAssetToRemoteDevice(
     DigitalAssetMetadata digitalAssetMetadata, ActorAssetUser actorAssetUser)
     throws CantDeliverDigitalAssetException {
   try {
     // First, I going to persist in database the basic information about digitalAssetMetadata
     System.out.println("ASSET DISTRIBUTION begins for " + actorAssetUser.getActorPublicKey());
     persistDigitalAsset(digitalAssetMetadata, actorAssetUser);
     System.out.println("ASSET DISTRIBUTION begins for persisted");
     // Now, I'll check is Hash wasn't modified
     // checkDigitalAssetMetadata(digitalAssetMetadata);
     DigitalAsset digitalAsset = digitalAssetMetadata.getDigitalAsset();
     System.out.println(
         "ASSET DISTRIBUTION Digital Asset genesis address: " + digitalAsset.getGenesisAddress());
     String genesisTransaction = digitalAssetMetadata.getGenesisTransaction();
     System.out.println("ASSET DISTRIBUTION Genesis transaction:" + genesisTransaction);
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.CHECKING_AVAILABLE_BALANCE, genesisTransaction);
     if (!isAvailableBalanceInAssetVault(digitalAsset.getGenesisAmount(), genesisTransaction)) {
       System.out.println(
           "ASSET DISTRIBUTION The Available balance in asset vault is insufficient - genesisAmount:"
               + digitalAsset.getGenesisAmount());
       throw new CantDeliverDigitalAssetException(
           "The Available balance in asset vault is incorrect");
     }
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.AVAILABLE_BALANCE_CHECKED, genesisTransaction);
     DigitalAssetContract digitalAssetContract = digitalAsset.getContract();
     System.out.println("ASSET DISTRIBUTION Digital Asset contract: " + digitalAssetContract);
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.CHECKING_CONTRACT, genesisTransaction);
     if (!isValidContract(digitalAssetContract)) {
       System.out.println("ASSET DISTRIBUTION The contract is not valid");
       throw new CantDeliverDigitalAssetException(
           "The DigitalAsset Contract is not valid, the expiration date has passed");
     }
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.CONTRACT_CHECKED, genesisTransaction);
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.CHECKING_HASH, genesisTransaction);
     if (!isDigitalAssetHashValid(digitalAssetMetadata)) {
       System.out.println("ASSET DISTRIBUTION The DAM Hash is not valid");
       throw new CantDeliverDigitalAssetException("The DigitalAsset hash is not valid");
     }
     this.assetDistributionDao.updateDistributionStatusByGenesisTransaction(
         DistributionStatus.HASH_CHECKED, genesisTransaction);
     System.out.println(
         "ASSET DISTRIBUTION set debit in asset issuer wallet:" + genesisTransaction);
     digitalAssetDistributionVault.setDigitalAssetMetadataAssetIssuerWalletDebit(
         digitalAssetMetadata, this.cryptoTransaction, BalanceType.AVAILABLE);
     System.out.println("ASSET DISTRIBUTION Begins the deliver to an remote actor");
     deliverToRemoteActor(digitalAssetMetadata, actorAssetUser);
   } catch (CantPersistDigitalAssetException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Cannot persist digital asset into database");
   } catch (CantCreateDigitalAssetFileException exception) {
     throw new CantDeliverDigitalAssetException(
         exception,
         "Delivering digital assets",
         "Cannot persist digital asset into local storage");
   } catch (CantGetCryptoTransactionException exception) {
     throw new CantDeliverDigitalAssetException(
         exception,
         "Delivering digital assets",
         "Cannot get the genesisTransaction from Asset Vault");
   } catch (CantExecuteQueryException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Cannot execute a database operation");
   } catch (UnexpectedResultReturnedFromDatabaseException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Unexpected result in database");
   } catch (CantSendDigitalAssetMetadataException exception) {
     throw new CantDeliverDigitalAssetException(
         exception,
         "Delivering digital assets",
         "There is an error delivering the digital asset through the network layer");
   } catch (DAPException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Generic DAP Exception");
   } catch (CantGetTransactionsException exception) {
     throw new CantDeliverDigitalAssetException(
         exception,
         "Delivering digital assets",
         "Cannot get the genesis transaction from crypto network");
   } catch (CantLoadWalletException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Cannot load Asset issuer wallet");
   } catch (CantRegisterDebitException exception) {
     throw new CantDeliverDigitalAssetException(
         exception, "Delivering digital assets", "Cannot register a debit in Asset Issuer Wallet");
   }
 }