예제 #1
0
  /**
   * Return the xsl export management page ( list of export format )
   *
   * @param request The Http request
   * @return Html of the xsl export management page
   */
  public String getManageXslExport(HttpServletRequest request) {
    HashMap<String, Object> model = new HashMap<String, Object>();
    List<XslExport> listXslExport = XslExportHome.getList();
    _strCurrentPageIndex =
        Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex);
    _nItemsPerPage =
        Paginator.getItemsPerPage(
            request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage);

    model.put(
        MARK_PERMISSION_CREATE,
        RBACService.isAuthorized(
            XslExport.RESOURCE_TYPE,
            RBAC.WILDCARD_RESOURCES_ID,
            XslExportResourceIdService.PERMISSION_CREATE,
            getUser()));
    model.put(
        MARK_PERMISSION_MODIFY,
        RBACService.isAuthorized(
            XslExport.RESOURCE_TYPE,
            RBAC.WILDCARD_RESOURCES_ID,
            XslExportResourceIdService.PERMISSION_MODIFY,
            getUser()));
    model.put(
        MARK_PERMISSION_DELETE,
        RBACService.isAuthorized(
            XslExport.RESOURCE_TYPE,
            RBAC.WILDCARD_RESOURCES_ID,
            XslExportResourceIdService.PERMISSION_DELETE,
            getUser()));

    LocalizedPaginator<XslExport> paginator =
        new LocalizedPaginator<XslExport>(
            listXslExport,
            _nItemsPerPage,
            getJspManageXslExport(request),
            PARAMETER_PAGE_INDEX,
            _strCurrentPageIndex,
            getLocale());

    model.put(MARK_PAGINATOR, paginator);
    model.put(MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPage);
    model.put(MARK_XSL_EXPORT_LIST, paginator.getPageItems());
    setPageTitleProperty(PROPERTY_MANAGE_XSL_EXPORT_TITLE);

    HtmlTemplate templateList =
        AppTemplateService.getTemplate(TEMPLATE_MANAGE_XSL_EXPORT, getLocale(), model);

    return getAdminPage(templateList.getHtml());
  }
예제 #2
0
  /**
   * Perform the export format supression
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The URL to go after performing the action
   */
  public String doRemoveXslExport(HttpServletRequest request) throws AccessDeniedException {
    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_DELETE,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    // ArrayList<String> listErrors = new ArrayList<String>( );
    String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT);
    int nIdXslExport = Integer.parseInt(strIdXslExport);
    XslExport xslExport = XslExportHome.findByPrimaryKey(nIdXslExport);

    // if ( !XslExportRemovalListenerService.getService( ).checkForRemoval( strIdXslExport,
    // listErrors, getLocale( ) ) )
    // {
    // String strCause = AdminMessageService.getFormattedList( listErrors, getLocale( ) );
    // Object[] args =
    // { strCause };
    //
    // return AdminMessageService.getMessageUrl( request, MESSAGE_CAN_NOT_REMOVE_XSL_EXPORT, args,
    // AdminMessage.TYPE_STOP );
    // }
    XslExportHome.remove(nIdXslExport);

    if (xslExport.getFile() != null) {
      FileHome.remove(xslExport.getFile().getIdFile());
    }

    return getJspManageXslExport(request);
  }
  /**
   * Build the advanced parameters management
   *
   * @param user the current user
   * @return The model for the advanced parameters
   */
  public Map<String, Object> getManageAdvancedParameters(AdminUser user) {
    Map<String, Object> model = new HashMap<String, Object>();

    if (RBACService.isAuthorized(
        Directory.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS,
        user)) {
      ReferenceList listDirectoryParamDefaultValues =
          DirectoryParameterService.getService().findDefaultValueParameters();
      ReferenceList listEntryParamDefaultValues = EntryParameterService.getService().findAll();
      ReferenceList listExportEncodingParam =
          DirectoryParameterService.getService().findExportEncodingParameters();

      model.put(MARK_LIST_DIRECTORY_PARAM_DEFAULT_VALUES, listDirectoryParamDefaultValues);
      model.put(MARK_LIST_ENTRY_PARAM_DEFAULT_VALUES, listEntryParamDefaultValues);
      model.put(MARK_LIST_EXPORT_ENCODING_PARAM, listExportEncodingParam);
    }

    if (RBACService.isAuthorized(
        DirectoryXsl.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        DirectoryXslResourceIdService.PERMISSION_CREATE,
        user)) {
      model.put(MARK_PERMISSION_XSL, true);
    }

    if (RBACService.isAuthorized(
        Directory.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY,
        user)) {
      model.put(MARK_PERMISSION_INDEX_ALL_DIRECTORY, true);
    }

    return model;
  }
  /**
   * Build the advanced parameters management
   *
   * @param user the admin user
   * @return The model for the advanced parameters
   */
  public Map<String, Object> getManageAdvancedParameters(AdminUser user) {
    Map<String, Object> model = new HashMap<String, Object>();
    Plugin plugin = PluginService.getPlugin(DatabasePlugin.PLUGIN_NAME);

    if (RBACService.isAuthorized(
        DatabaseResourceIdService.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        DatabaseResourceIdService.PERMISSION_MANAGE,
        user)) {
      // Encryption Password
      String strAlgorithms = AppPropertiesService.getProperty(PROPERTY_ENCRYPTION_ALGORITHMS_LIST);

      if (StringUtils.isNotBlank(strAlgorithms)) {
        String[] listAlgorithms = strAlgorithms.split(COMMA);

        model.put(MARK_ENCRYPTION_ALGORITHMS_LIST, listAlgorithms);
        model.put(MARK_IS_PLUGIN_JCAPTCHA_ENABLE, isPluginJcaptchaEnable());

        if (isPluginJcaptchaEnable()) {
          model.put(
              MARK_ENABLE_JCAPTCHA,
              SecurityUtils.getBooleanSecurityParameter(
                  _userParamService, plugin, MARK_ENABLE_JCAPTCHA));
        }
      }

      model.put(
          PARAMETER_ACCOUNT_CREATION_VALIDATION_EMAIL,
          SecurityUtils.getBooleanSecurityParameter(
              _userParamService, plugin, PARAMETER_ACCOUNT_CREATION_VALIDATION_EMAIL));

      model.put(
          PARAMETER_AUTO_LOGIN_AFTER_VALIDATION_EMAIL,
          SecurityUtils.getBooleanSecurityParameter(
              _userParamService, plugin, PARAMETER_AUTO_LOGIN_AFTER_VALIDATION_EMAIL));

      model.put(
          MARK_BANNED_DOMAIN_NAMES,
          SecurityUtils.getLargeSecurityParameter(
              _userParamService, plugin, MARK_BANNED_DOMAIN_NAMES));

      model = SecurityUtils.checkSecurityParameters(_userParamService, model, plugin);
    }

    return model;
  }
예제 #5
0
  /**
   * Gets the confirmation page of delete xsl export
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return the confirmation page of delete xsl export
   */
  public String getConfirmRemoveXslExport(HttpServletRequest request) throws AccessDeniedException {
    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_DELETE,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT);

    UrlItem url = new UrlItem(JSP_DO_REMOVE_XSL_EXPORT);
    url.addParameter(PARAMETER_ID_XSL_EXPORT, strIdXslExport);

    return AdminMessageService.getMessageUrl(
        request, MESSAGE_CONFIRM_REMOVE_XSL_EXPORT, url.getUrl(), AdminMessage.TYPE_CONFIRMATION);
  }
예제 #6
0
  /**
   * Perform the xsl export modification
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The URL to go after performing the action
   */
  public String doModifyXslExport(HttpServletRequest request) throws AccessDeniedException {
    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_MODIFY,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    XslExport xslExport;
    String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT);
    int nIdXslExport = Integer.parseInt(strIdXslExport);
    xslExport = XslExportHome.findByPrimaryKey(nIdXslExport);

    String strError = getXslExportData(request, xslExport);

    if (strError != null) {
      return strError;
    }

    // if xslExport
    File fileStore = XslExportHome.findByPrimaryKey(nIdXslExport).getFile();

    if (xslExport.getFile() != null) {
      // the file has been modified
      File fileSource = xslExport.getFile();
      // init id file source and id physical file before update
      fileSource.setIdFile(fileStore.getIdFile());

      if (fileStore.getPhysicalFile() != null) {
        fileSource
            .getPhysicalFile()
            .setIdPhysicalFile(fileStore.getPhysicalFile().getIdPhysicalFile());
      }

      FileHome.update(fileSource);
    } else {
      xslExport.setFile(fileStore);
    }

    XslExportHome.update(xslExport);

    return getJspManageXslExport(request);
  }
예제 #7
0
  /**
   * Gets the export format modification page
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The export format creation page
   */
  public String getModifyXslExport(HttpServletRequest request) throws AccessDeniedException {
    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_MODIFY,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    XslExport xslExport;
    String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT);
    HashMap<String, Object> model = new HashMap<String, Object>();
    int nIdXslExport = Integer.parseInt(strIdXslExport);
    xslExport = XslExportHome.findByPrimaryKey(nIdXslExport);
    model.put(MARK_XSL_EXPORT, xslExport);

    Collection<Plugin> listPlugins = PluginService.getPluginList();
    ReferenceList refListPlugins = new ReferenceList();
    ReferenceItem refItem = new ReferenceItem();
    Plugin pluginCore = PluginService.getCore();
    refItem.setCode(pluginCore.getName());
    refItem.setName(pluginCore.getName());
    refListPlugins.add(refItem);

    for (Plugin plugin : listPlugins) {
      if (plugin != null) {
        refItem = new ReferenceItem();
        refItem.setCode(plugin.getName());
        refItem.setName(plugin.getName());
        refListPlugins.add(refItem);
      }
    }

    model.put(MARK_LIST_PLUGINS, refListPlugins);

    setPageTitleProperty(PROPERTY_MODIFY_XSL_EXPORT_TITLE);

    HtmlTemplate template =
        AppTemplateService.getTemplate(TEMPLATE_MODIFY_XSL_EXPORT, getLocale(), model);

    return getAdminPage(template.getHtml());
  }
예제 #8
0
  /**
   * Gets the xsl export creation page
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The xsl export creation page
   */
  public String getCreateXslExport(HttpServletRequest request) throws AccessDeniedException {
    HashMap<String, Object> model = new HashMap<String, Object>();

    Collection<Plugin> listPlugins = PluginService.getPluginList();
    ReferenceList refListPlugins = new ReferenceList();
    ReferenceItem refItem = new ReferenceItem();
    Plugin pluginCore = PluginService.getCore();
    refItem.setCode(pluginCore.getName());
    refItem.setName(pluginCore.getName());
    refListPlugins.add(refItem);

    for (Plugin plugin : listPlugins) {
      if (plugin != null) {
        refItem = new ReferenceItem();
        refItem.setCode(plugin.getName());
        refItem.setName(plugin.getName());
        refListPlugins.add(refItem);
      }
    }

    model.put(MARK_LIST_PLUGINS, refListPlugins);

    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_CREATE,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    setPageTitleProperty(PROPERTY_CREATE_XSL_EXPORT_TITLE);

    HtmlTemplate template =
        AppTemplateService.getTemplate(TEMPLATE_CREATE_XSL_EXPORT, getLocale(), model);

    return getAdminPage(template.getHtml());
  }
예제 #9
0
  /**
   * Perform the xsl export creation
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The URL to go after performing the action
   */
  public String doCreateXslExport(HttpServletRequest request) throws AccessDeniedException {
    XslExport xslExport = new XslExport();
    String strError = getXslExportData(request, xslExport);

    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_CREATE,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    if (strError != null) {
      return strError;
    }

    if (xslExport.getFile() != null) {
      xslExport.getFile().setIdFile(FileHome.create(xslExport.getFile()));
    }

    XslExportHome.create(xslExport);

    return getJspManageXslExport(request);
  }