Esempio n. 1
0
 @Override
 public PluginDetails getPluginDetails(final Long pluginId) {
   EntityManager em = daoManager.getEntityManagerFromFactory();
   try {
     daoManager.startTransaction(em);
     PluginDetailsEntity entity = em.find(PluginDetailsEntity.class, pluginId);
     return entity;
   } catch (Exception e) {
     daoManager.closeEntityManager(em);
     return null;
   }
 }
Esempio n. 2
0
  @Override
  public List<PluginDetails> getInstalledPlugins() {
    List<PluginDetails> result = Lists.newArrayList();

    EntityManager em = daoManager.getEntityManagerFromFactory();
    Query query;
    try {
      query = em.createQuery("select h from PluginDetailsEntity h");
      result = (List<PluginDetails>) query.getResultList();
    } catch (Exception e) {
      LOG.error(e.toString(), e);
    } finally {
      daoManager.closeEntityManager(em);
    }
    return result;
  }
Esempio n. 3
0
  @Override
  public void deleteDetails(final Long pluginId) {
    EntityManager em = daoManager.getEntityManagerFromFactory();

    try {
      daoManager.startTransaction(em);
      PluginDetailsEntity entity = em.find(PluginDetailsEntity.class, pluginId);

      File karFile = new File(entity.getKar());

      if (karFile.delete()) {
        em.remove(entity);
        em.flush();
        daoManager.commitTransaction(em);
      }
    } catch (Exception ex) {
      daoManager.rollBackTransaction(em);
      LOG.error("ConfigDataService deleteOperation:" + ex.toString());
    } finally {
      daoManager.closeEntityManager(em);
    }
  }
Esempio n. 4
0
  @Override
  public void saveDetails(
      final String name, final String version, final String pathToKar /*, final Long userId,
    final Long roleId, final String token */) {
    PluginDetails pluginDetails = new PluginDetailsEntity();
    pluginDetails.setName(name);
    pluginDetails.setVersion(version);
    pluginDetails.setKar(pathToKar);

    EntityManager em = daoManager.getEntityManagerFactory().createEntityManager();

    try {
      daoManager.startTransaction(em);
      em.merge(pluginDetails);
      daoManager.commitTransaction(em);
    } catch (Exception e) {
      daoManager.rollBackTransaction(em);
      LOG.error("ConfigDataService saveProfile:" + e.toString());
    } finally {
      daoManager.closeEntityManager(em);
    }
  }