コード例 #1
0
ファイル: MimeFilesBOImpl.java プロジェクト: GregoXYZ/portal
  @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();
    }
  }
コード例 #2
0
ファイル: MimeFilesBOImpl.java プロジェクト: GregoXYZ/portal
  @Override
  public MimeFilesDTO[] getMimeFiles() throws BusinessException {
    List<MimeFiles> list = null;
    MimeFilesDTO[] mimefiles = null;

    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      MimeFilesDAOImpl mimeFilesDAO = new MimeFilesDAOImpl(bt);
      list = mimeFilesDAO.getMimeFiles();

      mimefiles = new MimeFilesDTO[list.size()];
      int i = 0;
      for (Iterator<MimeFiles> iterator = list.iterator(); iterator.hasNext(); i++) {
        mimefiles[i] = Convert.dao2dto((MimeFiles) iterator.next());
        if (mimefiles[i].getMimFilIcon() == null)
          mimefiles[i].setMimFilIcon(IConstantes.DEFAUL_ICON_DIR + IConstantes.DEFAUL_ICON_FILE);
        else
          mimefiles[i].setMimFilIcon(
              IConstantes.DEFAUL_MIME_ICON_DIR + mimefiles[i].getMimFilIcon());
      }
    } catch (DaoException e) {
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      bt.rollbackTx();
      transactionFactory.endTx();
    }
    return mimefiles;
  }
コード例 #3
0
ファイル: MimeFilesBOImpl.java プロジェクト: GregoXYZ/portal
 @Override
 public void delete(MimeFilesDTO dto) throws BusinessException {
   MimeFiles dao = Convert.dto2dao(dto);
   TransactionFactory transactionFactory = new TransactionFactory();
   BusinessTransactionBo bt = transactionFactory.beginTx();
   try {
     MimeFilesDAOImpl mimeFilesDAO = new MimeFilesDAOImpl(bt);
     mimeFilesDAO.delete(dao);
     bt.commitTx();
   } catch (DaoException e) {
     bt.rollbackTx();
     logger.error(e.getMessage());
     throw new BusinessException(e);
   } finally {
     transactionFactory.endTx();
   }
 }
コード例 #4
0
ファイル: MimeFilesBOImpl.java プロジェクト: GregoXYZ/portal
  @Override
  public MimeFilesDTO getByPrimaryKey(Long id) throws BusinessException {
    MimeFilesDTO dto = null;

    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      MimeFilesDAOImpl mimeFilesDAO = new MimeFilesDAOImpl(bt);
      dto = Convert.dao2dto(mimeFilesDAO.getByPrimaryKey(id));
    } catch (DaoException e) {
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      bt.rollbackTx();
      transactionFactory.endTx();
    }
    return dto;
  }
コード例 #5
0
ファイル: MimeFilesBOImpl.java プロジェクト: GregoXYZ/portal
  @Override
  public MimeFilesDTO getByExtension(String uk) throws BusinessException {
    MimeFilesDTO dto = null;
    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      MimeFilesDAOImpl mimeFilesDAO = new MimeFilesDAOImpl(bt);
      MimeFiles mimefile = mimeFilesDAO.getByExtension(uk);

      if (mimefile != null) {
        dto = Convert.dao2dto(mimefile);
      }
    } catch (DaoException e) {
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      bt.rollbackTx();
      transactionFactory.endTx();
    }
    return dto;
  }