public Connection getConexionTango() throws DataStoreException {

    if (_connTango == null) {
      _p = Props.getProps("partesMO", null);
      _driverTango = _p.getProperty("driverTango", "sun.jdbc.odbc.JdbcOdbcDriver");
      _urlTango = _p.getProperty("urlTango", "jdbc:odbc:tango");
      _userTango = _p.getProperty("userTango", "tango");
      _passWordTango = _p.getProperty("passWordTango", "tango");

      try {
        // Se carga el driver JDBC-ODBC
        Class.forName(_driverTango);
      } catch (ClassNotFoundException e) {
        MessageLog.writeErrorMessage(e, null);
        throw new DataStoreException("Imposible cargar el driver para Tango: " + e.getMessage());
      }

      try {
        // Se establece la conexión con la base de datos
        _connTango = DriverManager.getConnection(_urlTango, _userTango, _passWordTango);
      } catch (Exception e) {
        MessageLog.writeErrorMessage(e, null);
        throw new DataStoreException(
            "imposible establecer conexión con la base tango: " + e.getMessage());
      }
    }

    return _connTango;
  }
  /**
   * This method will load the font start and end tags from the page properties object.See the
   * Constants at the top of the class for valid values to pass to this method.
   */
  public void setDescriptionFont(String font) {
    _font = font;
    Props props = getPage().getPageProperties();

    if (_font != null) {
      _fontStartTag = props.getProperty(_font + Props.TAG_START);
      _fontEndTag = props.getProperty(_font + Props.TAG_END);
    } else {
      _fontStartTag = props.getProperty(HtmlText.FONT_DEFAULT + Props.TAG_START);
      _fontEndTag = props.getProperty(HtmlText.FONT_DEFAULT + Props.TAG_END);
    }
  }
Beispiel #3
0
  /**
   * This method sets the property theme for the component.
   *
   * @param theme The theme to use.
   */
  public void setTheme(String theme) {

    Props pr = getPage().getPageProperties();

    _headingBackgroundColor = pr.getThemeProperty(theme, Props.CAL_HEADING_BACKGROUND_COLOR);
    _headingForegroundColor = pr.getThemeProperty(theme, Props.CAL_HEADING_FOREGROUND_COLOR);
    _weekBackgroundColor = pr.getThemeProperty(theme, Props.CAL_WEEK_BACKGROUND_COLOR);
    _weekForegroundColor = pr.getThemeProperty(theme, Props.CAL_WEEK_FOREGROUND_COLOR);
    _dayBackgroundColor = pr.getThemeProperty(theme, Props.CAL_DAY_BACKGROUND_COLOR);
    _dayForegroundDeemphisis = pr.getThemeProperty(theme, Props.CAL_DAY_FOREGROUND_DEEMPHISIS);
    _dayForegroundNormal = pr.getThemeProperty(theme, Props.CAL_DAY_FOREGROUND_NORMAL);
    _dayForegroundCurrent = pr.getThemeProperty(theme, Props.CAL_DAY_FOREGROUND_CURRENT);
    _fontFace = pr.getThemeProperty(theme, Props.CAL_FONT_FACE);

    String ft = pr.getThemeProperty(theme, Props.CAL_FONT_LARGE);
    if (ft != null) {
      if (ft.endsWith("pt")) {
        _fontSizeUnit = FONT_SIZE_IN_POINTS;
        _largeFontSize = Integer.parseInt(ft.substring(0, ft.length() - 2));
      } else if (ft.endsWith("px")) {
        _fontSizeUnit = FONT_SIZE_IN_PIXELS;
        _largeFontSize = Integer.parseInt(ft.substring(0, ft.length() - 2));
      } else {
        _largeFontSize = Integer.parseInt(ft);
      }
    }

    ft = pr.getThemeProperty(theme, Props.CAL_FONT_SMALL);
    if (ft != null) {
      if (ft.endsWith("pt")) {
        _fontSizeUnit = FONT_SIZE_IN_POINTS;
        _smallFontSize = Integer.parseInt(ft.substring(0, ft.length() - 2));
      } else if (ft.endsWith("px")) {
        _fontSizeUnit = FONT_SIZE_IN_PIXELS;
        _smallFontSize = Integer.parseInt(ft.substring(0, ft.length() - 2));
      } else {
        _smallFontSize = Integer.parseInt(ft);
      }
    }

    _theme = theme;
  }
Beispiel #4
0
  /**
   * This method sets the property theme for the component.
   *
   * @param theme The theme to use.
   */
  public void setTheme(String theme) {
    Props props = getPage().getPageProperties();

    String font = props.getThemeProperty(theme, Props.SUBMIT_IMAGE_FONT_FACE);
    int fontStyle = props.getThemeIntProperty(theme, Props.SUBMIT_IMAGE_FONT_STYLE);
    int size = props.getThemeIntProperty(theme, Props.SUBMIT_IMAGE_FONT_SIZE);
    setFont(font, fontStyle, size);

    Color c = props.getThemeColorProperty(theme, Props.SUBMIT_IMAGE_TEXT_COLOR);

    if (c != null) {
      _textColor = c;
    }

    c = props.getThemeColorProperty(theme, Props.SUBMIT_IMAGE_BACKGROUND_COLOR);

    if (c != null) {
      _backgroundColor = c;
    }

    if (_height == -1) {
      _height = props.getThemeIntProperty(theme, Props.SUBMIT_IMAGE_DEFAULT_HEIGHT);
    }

    c = props.getThemeColorProperty(theme, Props.SUBMIT_IMAGE_TOPLEFT_BORDER_COLOR);

    if (c != null) {
      _topLeftBorder = c;
    }

    c = props.getThemeColorProperty(theme, Props.SUBMIT_IMAGE_BOTTOMRIGHT_BORDER_COLOR);

    if (c != null) {
      _bottomRightBorder = c;
    }

    c = props.getThemeColorProperty(theme, Props.SUBMIT_IMAGE_TRANSPARENT_COLOR);

    if (c != null) {
      _transparentColor = c;
    }

    String style = props.getThemeProperty(theme, Props.SUBMIT_IMAGE_STYLE);

    if (style != null) {
      if (style.toUpperCase().equals(STYLE_OVAL)) {
        _displayStyle = STYLE_OVAL;
      } else {
        _displayStyle = STYLE_RECTANGLE;
      }
    }

    _theme = theme;
  }
Beispiel #5
0
  public void service(ServletRequest request, ServletResponse response)
      throws ServletException, IOException {
    setUpApplicationContext(getServletConfig().getServletContext(), (HttpServletRequest) request);
    JspController cont = null;
    boolean sessionKeepAlive = true;
    try {
      long time = System.currentTimeMillis();
      request.setAttribute(SALMON_SERVLET_KEY, this);
      sessionKeepAlive = request.getParameter("sessionKeepAlive") != null;

      if (!_replaceFactoryInit) {
        Props p = Props.getSystemProps();
        _replaceFactoryInit = true;
        _replaceFactory = p.getBooleanProperty(Props.SYS_REPLACE_JSP_FACTORY, true);
        _cacheControllers = p.getBooleanProperty(Props.SYS_CACHE_CONTROLLERS, false);
        MessageLog.writeInfoMessage(
            "***JspServlet initialized with properties: "
                + Props.SYS_REPLACE_JSP_FACTORY
                + "="
                + _replaceFactory
                + ", "
                + Props.SYS_CACHE_CONTROLLERS
                + "="
                + _cacheControllers
                + ". To reset, change the System.properties file and restart the server.***",
            this);
      }

      //			if (_replaceFactory) {
      //				JspFactory fact = JspFactory.getDefaultFactory();
      //				if (fact == null ||
      // !fact.getClass().getName().equals("com.salmonllc.jsp.engine.JspFactoryImpl"))
      //					JspFactory.setDefaultFactory(new com.salmonllc.jsp.engine.JspFactoryImpl(fact));
      //			}

      HttpServletRequest req = (HttpServletRequest) request;
      HttpServletResponse res = (HttpServletResponse) response;

      if (sessionKeepAlive)
        com.salmonllc.util.MessageLog.writeInfoMessage(
            "JspServlet.service() keepAlive - URI=" + req.getRequestURI(),
            Props.LOG_LEVEL_10,
            this);
      else {
        notifyListeners((HttpServletRequest) request, (HttpServletResponse) response, true);
        com.salmonllc.util.MessageLog.writeInfoMessage(
            "JspServlet.service() start - URI=" + req.getRequestURI(), Props.LOG_LEVEL_10, this);
      }

      String sessID = req.getParameter(PageTag.getSessionIdentifier());
      HttpSession sess = PageTag.getSession(sessID);
      boolean sessValid = true;
      if (sess == null) {
        sessID = req.getRequestedSessionId();
        sessValid = req.isRequestedSessionIdValid();
        if (!sessValid && sessionKeepAlive) return;
        sess = req.getSession(true);
      }

      boolean onSession = false;
      boolean sessExp = false;
      if (sessID != null && !sessValid) sess.setAttribute("AppServer_SessExp", new Boolean(true));

      boolean createPage = (req.getHeader(SALMON_CREATE_PAGE_HEADER) != null);
      if (_replaceFactory) {
        Object sessToken = sess.getAttribute("AppServer_SessionToken");
        if (sessToken == null) {
          sess.setAttribute("AppServer_SessionToken", new String("tok"));
          sessToken = sess.getAttribute("AppServer_SessionToken");
        }
        synchronized (sessToken) {
          String sessName = "$jsp$" + com.salmonllc.jsp.tags.PageTag.generateSessionName(req);
          loadCachedController(sessName, sess);
          onSession = sess.getAttribute(sessName) != null;

          if (!onSession) _jspService(req, new HttpServletResponseDummy(res, null));

          cont = (JspController) sess.getAttribute(sessName);
          generateExpireResponseHeaders(res, cont.getAddExpireHeaders());

          cacheController(sessName, cont);
          cont.setSessionExpired(sessExp);
          cont.setDoPostRedirected(false);
          _jspService(req, res);
        }
      } else {
        String sessName = "$jsp$" + com.salmonllc.jsp.tags.PageTag.generateSessionName(req);
        String token = sessName + "$pageToken$";
        try {
          if (!createPage) {

            if (sess.getAttribute(token) != null) {

              /*
               * srufle : Jun 25, 2004 4 : 26 : 38 PM
               * This was put in to solve a thread deadlocking issue is was encountering
               *
               * Possible enhancements include
               * - making vars get their values from system parameters
               */
              int index = 0;
              int indexLimit = 1024;
              int sleepCount = 0;
              int sleepCountLimit = 4096;
              int sleepTime = 10;
              while (sess.getAttribute(token) != null) {
                index++;
                Thread.yield();

                if (index >= (indexLimit)) {
                  Thread.sleep(sleepTime);
                  index = 0;
                  sleepCount++;
                  if (sleepCount >= sleepCountLimit) {
                    throw (new ServletException("Thread Locked:Throwing to unlock"));
                  }
                }
              }
            }
            sess.setAttribute(token, token);
          }

          loadCachedController(sessName, sess);
          onSession = sess.getAttribute(sessName) != null;
          if (!onSession && !createPage) {
            createPage(req, res, sess, getPageURL(req, res), sess.getId());
            cont = (JspController) sess.getAttribute(sessName);

            cacheController(sessName, cont);
          } else cont = (JspController) sess.getAttribute(sessName);

          if (cont != null) {
            generateExpireResponseHeaders(res, cont.getAddExpireHeaders());
            cont.setSessionExpired(sessExp);
            cont.setDoPostRedirected(false);
            synchronized (cont) {
              _jspService(req, res);
            }
          } else {
            String contextToken = req.getHeader(SALMON_CONTEXT_TOKEN);
            _jspService(req, res);
            if (contextToken != null) {
              TagContext t = (TagContext) req.getAttribute(TagContext.TAG_CONTEXT_REQ_KEY);
              if (t != null) sess.setAttribute(contextToken, t);
            }
          }
        } catch (Exception e) {
          if (cont == null || cont.getPortletException() == null) {

            if (e instanceof SocketException) {
              // ignore java.net.SocketException
              MessageLog.writeInfoMessage("SocketException would have been thrown", this);
            } else {
              MessageLog.writeErrorMessage("service", e, this);
              throw (new ServletException(e.getMessage()));
            }
          }

        } finally {
          if (!createPage) sess.removeAttribute(token);
        }
      }

      if (!sessionKeepAlive) {
        time = (System.currentTimeMillis() - time);

        if (!createPage) addPageHit(time);

        if (Props.getSystemProps().getBooleanProperty(Props.SYS_RECORD_PAGE_TIMERS))
          recordTimerActivity(req.getRequestURI(), time, this, false);
        com.salmonllc.util.MessageLog.writeInfoMessage(
            "JspServlet.service() end - URI="
                + req.getRequestURI()
                + " Time="
                + time
                + " Init="
                + (!onSession),
            Props.LOG_LEVEL_10,
            this);
      }
    } catch (java.net.SocketException e) {
      // ignore java.net.SocketException
      MessageLog.writeInfoMessage("SocketException would have been thrown", this);
    } catch (ServletException e) {
      if (cont == null || cont.getPortletException() == null) {
        com.salmonllc.util.MessageLog.writeErrorMessage("JspServlet.service()", e, this);
        throw (e);
      }
    } catch (IOException e) {
      com.salmonllc.util.MessageLog.writeErrorMessage("JspServlet.service()", e, this);
      throw (e);
    } catch (Exception e) {
      com.salmonllc.util.MessageLog.writeErrorMessage("JspServlet.service()", e, this);
      throw (new ServletException(e));
    } finally {
      try {
        if (!sessionKeepAlive)
          notifyListeners((HttpServletRequest) request, (HttpServletResponse) response, false);
      } catch (Exception e) {
        com.salmonllc.util.MessageLog.writeErrorMessage("JspServlet.service()", e, this);
        throw (new ServletException(e));
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.salmonllc.html.HtmlComponent#setTheme(java.lang.String)
   */
  public void setTheme(String theme) {
    Props p = getPage().getPageProperties();
    _popupAttributes = p.getThemeProperty(theme, Props.LOOKUP_COMPONENT_POPUPATTRIBUTES);

    _lookUpPageURL = p.getThemeProperty(theme, Props.LOOKUP_COMPONENT_URL);
    _usePopup = p.getThemeBooleanProperty(theme, Props.LOOKUP_COMPONENT_USEPOPUP, false);
    _useModal = p.getThemeBooleanProperty(theme, Props.LOOKUP_COMPONENT_POPUPMODAL, false);
    _popupWidth = p.getThemeIntProperty(theme, Props.LOOKUP_COMPONENT_POPUPWIDTH, 300);
    _popupHeight = p.getThemeIntProperty(theme, Props.LOOKUP_COMPONENT_POPUPHEIGHT, 300);
    _popupTop = p.getThemeIntProperty(theme, Props.LOOKUP_COMPONENT_POPUPTOP, 0);
    _popupLeft = p.getThemeIntProperty(theme, Props.LOOKUP_COMPONENT_POPUPLEFT, 0);
    _popupPosition =
        p.getThemeProperty(
            theme, Props.LOOKUP_COMPONENT_POPUPPOSITION, Constants.POPUP_POSITION_CUSTOM);
    _useDiv = p.getThemeBooleanProperty(theme, Props.LOOKUP_COMPONENT_POPUPDIV, false);
    _divBorderStyle = p.getThemeProperty(theme, Props.LOOKUP_COMPONENT_POPUPDIVBORDERSTYLE);
    setEditDescription(p.getThemeBooleanProperty(theme, Props.LOOKUP_COMPONENT_EDITDESCRIPTION));
    super.setTheme(theme);
  }
  public void completaCategorias() throws DataStoreException {
    Props p;
    String driverTango = null;
    String urlTango = null;
    String userTango = null;
    String passWordTango = null;
    Connection connTango;
    Statement st = null;
    ResultSet r = null;
    String SQL = null;
    String cod_categoria = null;
    String desc_categoria = null;

    p = Props.getProps("partesMO", null);
    driverTango = p.getProperty("driverTango", "sun.jdbc.odbc.JdbcOdbcDriver");
    urlTango = p.getProperty("urlTango", "jdbc:odbc:tango");
    userTango = p.getProperty("userTango", "tango");
    passWordTango = p.getProperty("passWordTango", "tango");

    // realiza una búsqueda custom de los legajos
    try {
      // Se carga el driver
      Class.forName(driverTango);
    } catch (ClassNotFoundException e) {
      MessageLog.writeErrorMessage(e, null);
      throw new DataStoreException("Imposible cargar el driver para Tango: " + e.getMessage());
    }

    try {
      // Se establece la conexión con la base de datos
      connTango = DriverManager.getConnection(urlTango, userTango, passWordTango);
    } catch (Exception e) {
      MessageLog.writeErrorMessage(e, null);
      throw new DataStoreException(
          "imposible establecer conexión con la base tango: " + e.getMessage());
    }

    try {
      SQL = "select COD_CATEGORIA,DESC_CATEGORIA from CATEGORIA order by COD_CATEGORIA";
      st = connTango.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
      r = st.executeQuery(SQL);

      MessageLog.writeErrorMessage(SQL, 1, null, null);

      _categoriaTE2.resetOptions();
      _categoriaTE2.addOption("", "");

      while (r.next()) {
        cod_categoria = r.getString("COD_CATEGORIA");
        desc_categoria = r.getString("DESC_CATEGORIA");

        _categoriaTE2.addOption(cod_categoria, desc_categoria);
      }

    } catch (SQLException e) {
      MessageLog.writeErrorMessage(e, null);
      // adem�s de escribir en el log mando mensaje a la p�gina
      throw new DataStoreException("Error determinando categorías en tango: " + e.getMessage());

    } finally {
      if (r != null) {
        try {
          r.close();
        } catch (Exception ex) {
        }
      }

      if (st != null)
        try {
          st.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
    }
  }