Package org.apache.derby.iapi.tools.i18n

Examples of org.apache.derby.iapi.tools.i18n.LocalizedResource


  */
  public void init(ServletConfig config)
    throws ServletException
  {
   
    LocalizedResource langUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
       
    String port = config.getInitParameter("portNumber");
    if (port != null) {
      int p = Integer.valueOf(port).intValue();
      if (p > 0)
View Full Code Here


    String traceDirMessage;
    String contMessage;
    String setParamMessage;
    String setParamMessage2;
    String netParamMessage;
    LocalizedResource langUtil;
   
    langUtil = getCurrentAppUI(request);
    response.setContentType("text/html; charset=UTF-8");
   
    //prevent caching of the servlet since contents can change - beetle 4649
    response.setHeader("Cache-Control", "no-cache,no-store");

    formHeader = "<form enctype='multipart/form-data; charset=UTF-8' action='" +
      request.getRequestURI() +" '>";

    out = new PrintWriter(new
       OutputStreamWriter(response.getOutputStream(), "UTF8"),true);
   
    //inialize messages
    logOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOn"));
    logOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOff"));
    traceOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOn"));
    traceOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOff"));
    startMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Start"));
    stopMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Stop"));
    traceSessionMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceSessButton"));
    traceOnOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOnOff"));
    returnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Return"));
    traceDirMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceDir"));
    contMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Continue"));
    setParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam"));
    setParamMessage2 = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam2"));
    netParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_NetParam"));

    printBanner(langUtil);
    // set up a server we can use
    if (server == null) {
      try {
        server = new NetworkServerControl();
      }catch (Exception e) {
        printErrorForm(langUtil, request, e, returnMessage);
        return;
      }
    }
    server.setClientLocale(locale);
    String form = getForm(request);
    String doAction = getDoAction(request);
    // if doAction is set, use it to determine form
    if (doAction != null )
    {
      if (doAction.equals(traceOnOffMessage))
        form = traceSessionMessage;
      else
        form = doAction;
    }
    // if no form, determine form based on server status
    boolean serverStatus = getServerStatus();
    if (form == null)
    {
      if (serverStatus)
        form = startMessage;
      else
        form = stopMessage;
    }
    else if (form.equals(startMessage))
    {
      if (!serverStatus)  {
        runServer(langUtil, request, returnMessage);
      }
    }
    else if (form.equals(stopMessage))
    {
      if (serverStatus)   {
        shutdownServer(langUtil, request, returnMessage);
      }
      setDefaults();
         
    }
    else if (form.equals(returnMessage) || form.equals(returnMessage))
    {
      // check if server is still running and use that to determine which form
      if (serverStatus)
      {
        form = startMessage;
      }
      else
      {
        form = stopMessage;
      }
    }

    out.println( formHeader);
    // display forms

    form = escapeSingleQuotes(form);
    doAction = escapeSingleQuotes(doAction);
      if (form.equals(startMessage))
    {
      String logButton = getLogging(request);
      String traceButton = getTrace(request);
      if (logButton !=  null && logButton.equals(logOnMessage))
      {
        if (logging(langUtil, true, request, returnMessage))
          logStatus = true;
      }
      if (logButton !=  null && logButton.equals(logOffMessage))
      {
        if (logging(langUtil, false, request, returnMessage))
          logStatus = false;
      }
      if (traceButton !=  null && traceButton.equals(traceOnMessage))
      {
        if (traceAll(langUtil, true, request, returnMessage))
          traceStatus = true;
      }
      if (traceButton !=  null && traceButton.equals(traceOffMessage))
      {
        if (traceAll(langUtil, false, request, returnMessage))
          traceStatus = false;
      }
      displayCurrentStatus(request, langUtil, returnMessage);
      out.println( "<h4>"+langUtil.getTextMessage("SRV_StopButton")+"</h4>" );
      out.println( "<INPUT type=submit name=form value='"+ stopMessage + "'>" );

      out.println( "<h4>"+langUtil.getTextMessage("SRV_LogButton2")+"</h4>" );

      if (logStatus)
      {
        out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
      }
      else
      {
        out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
      }
      out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceButton2")+"</h4>" );
      if (traceStatus)
      {
        out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage+ "'>" );
      }
      else
      {
        out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
      }

      out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceSession")+"</h4>" );
      out.println( "<INPUT type=submit name=form value='"+ traceSessionMessage + "'>" );
      out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceDirButton")+"</h4>" );
      out.println( "<INPUT type=submit name=form value='"+ traceDirMessage + "'>" );
      out.println( "<h4>"+langUtil.getTextMessage("SRV_ThreadButton")+"</h4>" );
      out.println( "<INPUT type=submit name=form value='"+ netParamMessage+ "'>" );
    }
    else if (form.equals(stopMessage))
    {

      printAsContentHeader(langUtil.getTextMessage("SRV_NotStarted"));
      String logButton = getLogging(request);
      String traceButton =  getTrace(request);
      if (logButton !=  null && logButton.equals(logOnMessage))
        logStatus = true;
      if (logButton !=  null && logButton.equals(logOffMessage))
        logStatus = false;
      if (traceButton !=  null && traceButton.equals(traceOnMessage))
        traceStatus = true;
      if (traceButton !=  null && traceButton.equals(traceOffMessage))
        traceStatus = false;
      if (logStatus)
      {
        out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOffButton")+"</h4>" );
        out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
      }
      else
      {
        out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOnButton")+"</h4>" );
        out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
      }
      if (traceStatus)
      {
        out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOffButton")+"</h4>" );
        out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage + "'>" );
      }
      else
      {
        out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOnButton")+"</h4>" );
        out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
      }
      out.println( "<h4>"+langUtil.getTextMessage("SRV_StartButton")+"</h4>" );
      out.println( "<INPUT type=submit name=form value='"+startMessage+ "'>" );
    }
    else if (form.equals(traceSessionMessage))
    {
      if (doAction != null)
      {
        if (doAction.equals(traceOnOffMessage))
        {
          String sessionid = request.getParameter("sessionid");
          int session = 0;
          try {
             session = (new Integer(sessionid)).intValue();
          } catch (Exception e) {
            printErrorForm(langUtil, request,
              langUtil.getTextMessage("SRV_InvalidVal",
              sessionid, langUtil.getTextMessage("SRV_SessionID")),
              returnMessage);
            return;
          }
          Properties p = null;
          try {
            p = server.getCurrentProperties();
          } catch (Exception e) {
            printErrorForm(langUtil, request, e, returnMessage);
            return;
          }
          // if it's on, turn it off, if its off, turn it on
          boolean val;
          if (p.getProperty(Property.DRDA_PROP_TRACE+sessionid) != null)
            val = false;
          else
            val = true;
          if (traceSession(langUtil, val, session, request, returnMessage))
          {
            if (val)
              out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOn", sessionid)+"</h4>");
            else
              out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOff", sessionid)+"</h4>");
          }
          else
            return;
           
        }
      }
      printAsContentHeader(langUtil.getTextMessage("SRV_TraceSessButton"));
      out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
        "SRV_SessionID", "sessionId") + "</h4>");
      out.println( "<INPUT type=text name=sessionid size=10 maxlength=10 " +
        "id='sessionId' value=''>");
      out.println( "<h4> </h4>");
      out.println( "<INPUT type=submit name=doaction value='"+traceOnOffMessage+ "'>" );
      out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
    }
    else if (form.equals(traceDirMessage))
    {
      boolean set = false;
      String traceDirectory = null;
      printAsContentHeader(traceDirMessage);
      if (doAction != null)
      {
        if (doAction.equals(traceDirMessage))
        {
          traceDirectory = getParam(request, "tracedirectory");
          if (traceDirectory(langUtil, traceDirectory, request,
              returnMessage) )
            set = true;
          else
            return;
         
        }
      }
      if (set)
      {
        out.println( "<h2>"+langUtil.getTextMessage("SRV_TraceDirDone", traceDirectory)+"</h2>");
        out.println( "<INPUT type=submit name=form value='"+returnMessage+"'>" );
      }
      else
      {
        out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
          "SRV_TraceDir", "tracedir") + "</h4>");
        out.println( "<INPUT type=text name=tracedirectory size=60 maxlength=256 " +
          "id='tracedir' value='"+tracingDirectory+"'>");
        out.println( "<h4> </h4>");
        out.println( "<INPUT type=submit name=doaction value='"+traceDirMessage+ "'>" );
        out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
      }
    }
    else if (form.equals(netParamMessage))
    {
      int maxThreads = 0;
      int timeSlice = 0;
      String maxName = langUtil.getTextMessage("SRV_NewMaxThreads");
      String sliceName = langUtil.getTextMessage("SRV_NewTimeSlice");
      try {
        Properties p = server.getCurrentProperties();
        String val = p.getProperty(Property.DRDA_PROP_MAXTHREADS);
        maxThreads= (new Integer(val)).intValue();
        val = p.getProperty(Property.DRDA_PROP_TIMESLICE);
        timeSlice= (new Integer(val)).intValue();
      } catch (Exception e) {
        printErrorForm(langUtil, request, e, returnMessage);
        return;
      }
      if (doAction != null && doAction.equals(netParamMessage))
      {
        int newMaxThreads = getIntParameter(request, "newmaxthreads",
          "SRV_NewMaxThreads", langUtil, returnMessage);
        int newTimeSlice = (newMaxThreads == INVALID) ? NOT_GIVEN :
          getIntParameter(request, "newtimeslice", "SRV_NewTimeSlice", langUtil,
            returnMessage);
        if ((newMaxThreads == INVALID) || (newTimeSlice == INVALID))
          return;
        else if (!(newMaxThreads == NOT_GIVEN && newTimeSlice == NOT_GIVEN))
        {
          if (newMaxThreads != NOT_GIVEN)
            maxThreads = newMaxThreads;
          if (newTimeSlice != NOT_GIVEN)
            timeSlice = newTimeSlice;
          if (!setNetParam(langUtil, maxThreads, timeSlice, request,
              returnMessage))
            return;
        }
      }
     
      out.println(formHeader);
      printAsContentHeader(netParamMessage);
      out.println( "<h4>"+langUtil.getTextMessage("SRV_MaxThreads", new Integer(maxThreads).toString()) +"</h4>");
      out.println( "<h4>"+langUtil.getTextMessage("SRV_TimeSlice", new Integer(timeSlice).toString()) +"</h4>");
      out.println( "<h4> </h4>");
      out.println( "<h4> <label for='newmaxthreads'>"+maxName+"</label> </h4>");
      out.println( "<INPUT type=text name=newmaxthreads size=10 maxlength=10 " +
        "id='newmaxthreads' value=''>" );
      out.println( "<h4> <label for='newslice'>"+sliceName+"</label> </h4>");
View Full Code Here

   * @param request       HttpServetRequest for forms
   * @return the appUI which fits the browsers preferences
   */
  private LocalizedResource getCurrentAppUI(HttpServletRequest request)
  {
    LocalizedResource localUtil;
    String acceptLanguage = request.getHeader("Accept-Language");
    localUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
    // if no language specified use one set by derby.locale, derby.codeset
    locale = null;
    if (acceptLanguage == null)
    {
      return localUtil;
    }
    // Use a tokenizer ot separate acceptable languages
    StringTokenizer tokenizer = new StringTokenizer(acceptLanguage, ",");
    while (tokenizer.hasMoreTokens())
    {
      //Get the next acceptable language
      String lang = tokenizer.nextToken();
      lang = getLocStringFromLanguage(lang);
      int langindex = translationAvailable(lang);
      // have we found one
      if (langindex != -1)
      {
        localUtil.init(null, lang, SERVLET_PROP_MESSAGES);
        // locale will be passed to server, server routines will get set appropriately
        locale = lang;
        return localUtil;
      }
    }
View Full Code Here

    private void init() throws Exception
    {

        // adjust the application in accordance with derby.ui.locale and derby.ui.codeset
    langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);

    serverInstance = this;
   
    //set Server attributes to be used in EXCSAT
    ProductVersionHolder myPVH = getNetProductVersionHolder();
View Full Code Here

      int localeLen = reader.readByte();
      if (localeLen > 0)
      {
        currentSession = session;
        locale = reader.readCmdString(localeLen);
        session.langUtil = new LocalizedResource(codeset,locale,DRDA_PROP_MESSAGES);
      }
      String notLocalMessage = null;
      // for now codesetLen is always 0
      int codesetLen = reader.readByte();
      int command = reader.readByte();
View Full Code Here

   * @return system information for the Network Server
   */
  private String getNetSysInfo()
  {
    StringBuffer sysinfo = new StringBuffer();
    LocalizedResource localLangUtil = langUtil;
    if (currentSession != null && currentSession.langUtil != null)
    localLangUtil = currentSession.langUtil;
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBanner.I")+ "\n");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoVersion.I")+ " " + att_srvrlslv);
    sysinfo.append("  ");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBuild.I")+ " " + buildNumber);
    sysinfo.append("  ");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoDrdaPRDID.I")+ " " + prdId);
    if (SanityManager.DEBUG)
    {
      sysinfo.append("  ** SANE BUILD **");
    }
    sysinfo.append("\n");
 
View Full Code Here

   * @throws IOException if a problem occurs encoding string
   */
  private String getCLSSysInfo() throws IOException
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    LocalizedResource localLangUtil = langUtil;
    if (currentSession != null && currentSession.langUtil != null)
    localLangUtil = currentSession.langUtil;
    LocalizedOutput aw = localLangUtil.getNewOutput(bos);
    org.apache.derby.impl.tools.sysinfo.Main.getMainInfo(aw, false);
    return bos.toString();
  }
View Full Code Here

    private void init() throws Exception
    {

        // adjust the application in accordance with derby.ui.locale and derby.ui.codeset
    langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);

    serverInstance = this;
   
    //set Server attributes to be used in EXCSAT
    ProductVersionHolder myPVH = getNetProductVersionHolder();
View Full Code Here

      int localeLen = reader.readByte();
      if (localeLen > 0)
      {
        currentSession = session;
        locale = reader.readCmdString(localeLen);
        session.langUtil = new LocalizedResource(codeset,locale,DRDA_PROP_MESSAGES);
      }
      String notLocalMessage = null;
      // for now codesetLen is always 0
      int codesetLen = reader.readByte();
      int command = reader.readByte();
View Full Code Here

   * @return system information for the Network Server
   */
  private String getNetSysInfo()
  {
    StringBuffer sysinfo = new StringBuffer();
    LocalizedResource localLangUtil = langUtil;
    if (currentSession != null && currentSession.langUtil != null)
    localLangUtil = currentSession.langUtil;
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBanner.I")+ "\n");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoVersion.I")+ " " + att_srvrlslv);
    sysinfo.append("  ");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBuild.I")+ " " + buildNumber);
    sysinfo.append("  ");
    sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoDrdaPRDID.I")+ " " + prdId);
    if (SanityManager.DEBUG)
    {
      sysinfo.append("  ** SANE BUILD **");
    }
    sysinfo.append("\n");
 
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.tools.i18n.LocalizedResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.