Пример #1
0
  @Override
  public void processSend(PageRequestContext requestContext) {
    PluginDAO pluginDAO = DAOFactory.getInstance().getPluginDAO();
    PluginRepositoryDAO pluginRepositoryDAO = DAOFactory.getInstance().getPluginRepositoryDAO();

    Long pluginsRowCount = requestContext.getLong("pluginsTable.rowCount");
    for (int i = 0; i < pluginsRowCount; i++) {
      String colPrefix = "pluginsTable." + i;

      Long id = requestContext.getLong(colPrefix + ".id");
      Boolean enabled = "1".equals(requestContext.getString(colPrefix + ".enabled"));
      Boolean remove = "1".equals(requestContext.getString(colPrefix + ".remove"));
      String groupId = requestContext.getString(colPrefix + ".groupId");
      String artifactId = requestContext.getString(colPrefix + ".artifactId");
      String version = requestContext.getString(colPrefix + ".version");

      if (id == null) {
        pluginDAO.create(artifactId, groupId, version, enabled);
      } else {
        Plugin plugin = pluginDAO.findById(id);
        if (remove == true) {
          pluginDAO.delete(plugin);
        } else {
          pluginDAO.updateEnabled(plugin, enabled);
          pluginDAO.updateArtifactId(plugin, artifactId);
          pluginDAO.updateGroupId(plugin, groupId);
          pluginDAO.updateVersion(plugin, version);
        }
      }
    }

    Long repositoriesRowCount = requestContext.getLong("repositoriesTable.rowCount");
    for (int i = 0; i < repositoriesRowCount; i++) {
      String colPrefix = "repositoriesTable." + i;

      Long id = requestContext.getLong(colPrefix + ".id");
      String url = requestContext.getString(colPrefix + ".url");
      Boolean remove = "1".equals(requestContext.getString(colPrefix + ".remove"));

      if (id == null) {
        pluginRepositoryDAO.create(url);
      } else {
        PluginRepository repository = pluginRepositoryDAO.findById(id);
        if (remove == true) {
          pluginRepositoryDAO.delete(repository);
        } else {
          pluginRepositoryDAO.updateUrl(repository, url);
        }
      }
    }

    processForm(requestContext);

    //    List<PluginRepository> pluginRepositories = pluginRepositoryDAO.listAll();
    //    List<Plugin> plugins = pluginDAO.listAll();
    //
    //    requestContext.getRequest().setAttribute("repositories", pluginRepositories);
    //    requestContext.getRequest().setAttribute("plugins", plugins);
    //
    //    requestContext.setIncludeJSP("/templates/system/plugins.jsp");
  }
Пример #2
0
  @Override
  public void processForm(PageRequestContext requestContext) {
    PluginRepositoryDAO pluginRepositoryDAO = DAOFactory.getInstance().getPluginRepositoryDAO();
    PluginDAO pluginDAO = DAOFactory.getInstance().getPluginDAO();

    PluginManager pluginManager = PluginManager.getInstance();

    List<PluginRepository> pluginRepositories = pluginRepositoryDAO.listAll();
    List<Plugin> plugins = pluginDAO.listAll();
    List<PluginBean> pluginBeans = new ArrayList<PluginsViewController.PluginBean>(plugins.size());
    for (Plugin plugin : plugins) {
      String status = "";
      boolean loaded =
          pluginManager.isLoaded(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
      boolean deletable = false;

      if (loaded) {
        if (plugin.getEnabled())
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusLoaded");
        else
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusUnloadOnRestart");
      } else {
        if (plugin.getEnabled())
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusLoadOnRestart");
        else
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusNotLoaded");
        deletable = true;
      }

      PluginBean pluginBean =
          new PluginBean(
              plugin.getId(),
              plugin.getGroupId(),
              plugin.getArtifactId(),
              plugin.getVersion(),
              plugin.getEnabled(),
              deletable,
              status);
      pluginBeans.add(pluginBean);
    }

    requestContext.getRequest().setAttribute("repositories", pluginRepositories);
    requestContext.getRequest().setAttribute("plugins", pluginBeans);
    /**
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusNotLoaded");
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusUnloadOnRestart");
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusLoaded");
     */
    requestContext.setIncludeJSP("/templates/system/plugins.jsp");
  }