Esempio n. 1
0
  protected static String getString(
      HttpServletRequest request, String propertyName, String propertyValueDefault) {
    String res = null;

    {
      try {
        Principal userPrincipal = request.getUserPrincipal();
        if (userPrincipal != null) {
          PreferenceAccessorFactory f = DefaultPreferenceAccessorFactory.getInstance();
          PreferenceAccessor a = f.getUserPreferenceAccessor();

          res = a.getPreferenceProperty(userPrincipal, propertyName);

          if (res == null || res.length() == 0) {
            if (propertyValueDefault != null) {
              res = propertyValueDefault;
            }
          }
        }
      } catch (Throwable ex) {
        ex.printStackTrace(); // TODO: Log!
      }
    }

    return res;
  }
Esempio n. 2
0
  private static Integer getMenuPropertyValue(HttpServletRequest request) {
    Integer res = null;

    {
      try {
        Principal userPrincipal = request.getUserPrincipal();
        if (userPrincipal != null) {
          PreferenceAccessorFactory f = DefaultPreferenceAccessorFactory.getInstance();
          PreferenceAccessor a = f.getUserPreferenceAccessor();

          String name = a.getPreferenceProperty(userPrincipal, MENU_PROPERTY_NAME);
          if (name != null) {
            res = Integer.parseInt(name);
          }
        }
      } catch (Throwable ex) {
        ex.printStackTrace(); // TODO: Log!
      }
    }

    return res;
  }