Esempio n. 1
0
  /**
   * Saves the catalog Item information into database and the icon file into disk.
   *
   * @param catalogItemImpl
   * @throws CantPublishWalletInCatalogException
   */
  public void publishWallet(CatalogItemImpl catalogItemImpl)
      throws CantPublishWalletInCatalogException {
    try {
      DeveloperIdentity developer = catalogItemImpl.getDetailedCatalogItemImpl().getDeveloper();
      Language language =
          (Language) catalogItemImpl.getDetailedCatalogItemImpl().getDefaultLanguage();
      TranslatorIdentity translator =
          catalogItemImpl.getDetailedCatalogItemImpl().getDefaultLanguage().getTranslator();
      Skin skin = (Skin) catalogItemImpl.getDetailedCatalogItemImpl().getDefaultSkin();

      DesignerIdentity designer = skin.getDesigner();
      // I publish all the wallet info
      this.publishItemInDB(catalogItemImpl, developer, language, translator, skin, designer);

      // I save the icon file of the wallet and the skins.
      saveCatalogItemIconFile(catalogItemImpl);
      saveSkinImageFiles(skin);

    } catch (Exception exception) {
      exception.printStackTrace();
      throw new CantPublishWalletInCatalogException(
          CantPublishWalletInCatalogException.DEFAULT_MESSAGE,
          exception,
          "Publish Wallet",
          "Wallet Store");
    }
  }
Esempio n. 2
0
  /**
   * Get the detailed catalog item from db and icon imagess.
   *
   * @param walletId
   * @return
   * @throws CantGetCatalogItemException
   */
  public DetailedCatalogItemImpl getDetailedCatalogItem(UUID walletId)
      throws CantGetCatalogItemException {
    try {
      DetailedCatalogItemImpl detailedCatalogItemImpl;
      detailedCatalogItemImpl = getDetailedCatalogItemFromDatabase(walletId);

      Skin defaultSkin = (Skin) detailedCatalogItemImpl.getDefaultSkin();
      try {
        defaultSkin.setPresentationImage(
            getSkinContent(defaultSkin.getSkinId().toString(), defaultSkin.getSkinName()));
        defaultSkin.setPreviewImageList(
            getPreviewImagesFromDisk(
                defaultSkin.getSkinId().toString(), defaultSkin.getSkinName()));
      } catch (FileNotFoundException | CantCreateFileException | CantLoadFileException e) {
        defaultSkin.setPresentationImage(null);
      }
      detailedCatalogItemImpl.setDefaultSkin(defaultSkin);

      return detailedCatalogItemImpl;
    } catch (Exception exception) {
      throw new CantGetCatalogItemException(
          CantGetCatalogItemException.DEFAULT_MESSAGE, exception, null, null);
    }
  }