/**
   * Returns all allowed document types for a given space
   *
   * @param nSpaceId The space Id
   * @return Allowed documents types as a ReferenceList
   */
  public ReferenceList getAllowedDocumentTypes(int nSpaceId) {
    ReferenceList list = new ReferenceList();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECT_SPACE_DOCUMENT_TYPE);
    daoUtil.setInt(1, nSpaceId);
    daoUtil.executeQuery();

    while (daoUtil.next()) {
      list.addItem(daoUtil.getString(1), daoUtil.getString(2));
    }

    daoUtil.free();

    return list;
  }
  /**
   * Gets a list of icons available or space customization
   *
   * @return A list of icons
   */
  public ReferenceList getIconsList() {
    ReferenceList list = new ReferenceList();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECTALL_ICONS);
    daoUtil.executeQuery();

    while (daoUtil.next()) {
      int nIconId = daoUtil.getInt(1);
      String strIconUrl = daoUtil.getString(2);
      list.addItem(nIconId, strIconUrl);
    }

    daoUtil.free();

    return list;
  }
  /**
   * Load the list of documentSpaces
   *
   * @param locale The locale
   * @return The Collection of the DocumentSpaces
   */
  public ReferenceList getViewTypeList(Locale locale) {
    ReferenceList list = new ReferenceList();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECTALL_VIEWTYPE);
    daoUtil.executeQuery();

    while (daoUtil.next()) {
      String strCodeView = daoUtil.getString(1);
      String strViewNameKey = daoUtil.getString(2);
      list.addItem(strCodeView, I18nService.getLocalizedString(strViewNameKey, locale));
    }

    daoUtil.free();

    return list;
  }
  /**
   * Constructor
   *
   * @param group The group
   * @param locale The locale
   */
  public LocalizedDataGroup(ILocalizedDataGroup group, Locale locale) {
    _strName = I18nService.getLocalizedString(group.getNameKey(), locale);
    _strDescription = I18nService.getLocalizedString(group.getDescriptionKey(), locale);

    ReferenceList listProperties = DatastoreService.getDataByPrefix(group.getDatastoreKeysPrefix());

    for (int i = 0; i < listProperties.size(); i++) {
      ReferenceItem item = listProperties.get(i);
      LocalizedData property = new LocalizedData();
      property.setKey(item.getCode());
      property.setValue(item.getName());
      property.setLabel(I18nService.getLocalizedString(item.getCode(), locale));
      property.setHelp(I18nService.getLocalizedString(item.getCode() + SUFFIX_HELP, locale));
      _listLocalizedData.add(property);
    }
  }
  /**
   * Load the list of documentSpaces
   *
   * @return The Collection of the DocumentSpaces
   */
  public ReferenceList getDocumentSpaceList() {
    ReferenceList list = new ReferenceList();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECTALL);
    daoUtil.executeQuery();

    while (daoUtil.next()) {
      DocumentSpace space = new DocumentSpace();
      space.setId(daoUtil.getInt(1));
      space.setName(daoUtil.getString(3));

      list.addItem(space.getId(), space.getName());
    }

    daoUtil.free();

    return list;
  }
  /**
   * 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());
  }
  /**
   * 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());
  }