示例#1
0
  public static MimeFilesDTO dao2dto(MimeFiles dao) {
    MimeFilesDTO dto = new MimeFilesDTO(dao.getMimFilExtension(), dao.getMimFilMime());
    dto.setMimFilPk(dao.getMimFilPk());
    dto.setMimFilIcon(dao.getMimFilIcon());

    return dto;
  }
示例#2
0
  public static MimeFiles dto2dao(MimeFilesDTO dto) {
    MimeFiles dao = new MimeFiles(dto.getMimFilExtension(), dto.getMimFilMime());
    dao.setMimFilPk(dto.getMimFilPk());
    dao.setMimFilIcon(dto.getMimFilIcon());

    return dao;
  }
示例#3
0
  @Override
  public void add(String path, byte[] file, MimeFilesDTO dto) throws BusinessException {
    MimeFiles dao = Convert.dto2dao(dto);
    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      MimeFilesDAOImpl mimeFilesDAO = new MimeFilesDAOImpl(bt);
      Long pk = mimeFilesDAO.add(dao);
      dto.setMimFilPk(pk);

      if (file != null) {
        FileUtils.carga(path, file);
      }
      bt.commitTx();
    } catch (DaoException e) {
      bt.rollbackTx();
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } catch (IOException e) {
      bt.rollbackTx();
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      transactionFactory.endTx();
    }
  }