Example #1
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();
    }
  }
Example #2
0
  @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;
  }
Example #3
0
  @Override
  public ParametrosDTO[] getParametros() throws BusinessException {
    List<Parametros> list = null;
    ParametrosDTO[] parametros = null;

    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      ParametrosDAOImpl parametrosDAO = new ParametrosDAOImpl(bt);
      list = parametrosDAO.getParametros();

      parametros = new ParametrosDTO[list.size()];
      int i = 0;
      for (Iterator<Parametros> iterator = list.iterator(); iterator.hasNext(); i++) {
        parametros[i] = Convert.dao2dto((Parametros) iterator.next());
      }
    } catch (DaoException e) {
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      bt.rollbackTx();
      transactionFactory.endTx();
    }
    return parametros;
  }
Example #4
0
 @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();
   }
 }
Example #5
0
 @Override
 public void add(ParametrosDTO dto) throws BusinessException {
   Parametros dao = Convert.dto2dao(dto);
   TransactionFactory transactionFactory = new TransactionFactory();
   BusinessTransactionBo bt = transactionFactory.beginTx();
   try {
     ParametrosDAOImpl parametrosDAO = new ParametrosDAOImpl(bt);
     parametrosDAO.add(dao);
     bt.commitTx();
   } catch (DaoException e) {
     bt.rollbackTx();
     logger.error(e.getMessage());
     throw new BusinessException(e);
   } finally {
     transactionFactory.endTx();
   }
 }
Example #6
0
 @Override
 public String getValor(String id) throws BusinessException {
   Parametros dao;
   TransactionFactory transactionFactory = new TransactionFactory();
   BusinessTransactionBo bt = transactionFactory.beginTx();
   try {
     ParametrosDAOImpl parametrosDAO = new ParametrosDAOImpl(bt);
     dao = parametrosDAO.getByPrimaryKey(id);
   } catch (DaoException e) {
     logger.error(e.getMessage());
     throw new BusinessException(e);
   } finally {
     bt.rollbackTx();
     transactionFactory.endTx();
   }
   return dao == null ? "" : dao.getParValor();
 }
Example #7
0
  @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;
  }
Example #8
0
  @Override
  public ParametrosDTO getByPrimaryKey(String id) throws BusinessException {
    ParametrosDTO dto = null;

    TransactionFactory transactionFactory = new TransactionFactory();
    BusinessTransactionBo bt = transactionFactory.beginTx();
    try {
      ParametrosDAOImpl parametrosDAO = new ParametrosDAOImpl(bt);
      Parametros dao = parametrosDAO.getByPrimaryKey(id);
      if (dao != null) dto = Convert.dao2dto(dao);
      else dto = null;
    } catch (DaoException e) {
      logger.error(e.getMessage());
      throw new BusinessException(e);
    } finally {
      bt.rollbackTx();
      transactionFactory.endTx();
    }
    return dto;
  }
Example #9
0
  @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;
  }