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

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


        if (startup != null) {
            boolean start = Boolean.valueOf(startup).booleanValue();
            if (start)
            {
                LocalizedResource langUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
                runServer(langUtil, null, null);
                return;
            }
        }
    }
View Full Code Here


        String returnMessage;
        String traceSessionMessage;
        String traceDirMessage;
        String netParamMessage;

        LocalizedResource langUtil;
        String locale[] = new String[ 1 ];
       
        langUtil = getCurrentAppUI(request, locale);
        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");

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

        PrintWriter 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"));
        netParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_NetParam"));

        printBanner(langUtil, out);
        // set up a server we can use
        if (server == null) {
            try {
                server = new NetworkServerControl();
            }catch (Exception e) {
                printErrorForm(langUtil, e, returnMessage, out);
                return;
            }
        }
        server.setClientLocale( locale[ 0 ] );
        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, returnMessage, out);
            }
        }
        else if (form.equals(stopMessage))
        {
            if (serverStatus)   {
                shutdownServer(langUtil, returnMessage, out);
            }
            setDefaults();
                   
        }
        else if (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, returnMessage, out))
                    logStatus = true;
            }
            if (logButton !=  null && logButton.equals(logOffMessage))
            {
                if (logging(langUtil, false, returnMessage, out))
                    logStatus = false;
            }
            if (traceButton !=  null && traceButton.equals(traceOnMessage))
            {
                if (traceAll(langUtil, true, returnMessage, out))
                    traceStatus = true;
            }
            if (traceButton !=  null && traceButton.equals(traceOffMessage))
            {
                if (traceAll(langUtil, false, returnMessage, out))
                    traceStatus = false;
            }
            displayCurrentStatus(langUtil, returnMessage, out);
            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"), out);
            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");
                    Integer session;
                    try {
                        session = Integer.valueOf(sessionid);
                    } catch (NumberFormatException nfe) {
                        printErrorForm(langUtil,
                            langUtil.getTextMessage("SRV_InvalidVal",
                            sessionid, langUtil.getTextMessage("SRV_SessionID")),
                                       returnMessage, out);
                        return;
                    }
                    Properties p;
                    try {
                        p = server.getCurrentProperties();
                    } catch (Exception e) {
                        printErrorForm(langUtil, e, returnMessage, out);
                        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.intValue(),
                            returnMessage, out))
                    {
                        out.println( "<h4>" + langUtil.getTextMessage(
                                val ? "SRV_StatusTraceNoOn"
                                    : "SRV_StatusTraceNoOff",
                                session.toString()) + "</h4>");
                    }
                    else
                        return;
                       
                }
            }
            printAsContentHeader(langUtil.getTextMessage("SRV_TraceSessButton"), out);
            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, out);
            if (doAction != null)
            {
                if (doAction.equals(traceDirMessage))
                {
                    traceDirectory = getParam(request, "tracedirectory");
                    if (traceDirectory(langUtil, traceDirectory,
                                       returnMessage, out) )
                        set = true;
                    else
                        return;
                   
                }
            }
            if (set)
            {
                out.println("<h2>" + langUtil.getTextMessage("SRV_TraceDirDone",
                        escapeHTML(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='"+escapeHTML(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;
            int timeSlice;
            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, e, returnMessage, out);
                return;
            }
            if (doAction != null && doAction.equals(netParamMessage))
            {
                int newMaxThreads = getIntParameter(request, "newmaxthreads",
                    "SRV_NewMaxThreads", langUtil, returnMessage, out);
                int newTimeSlice = (newMaxThreads == INVALID) ? NOT_GIVEN :
                    getIntParameter(request, "newtimeslice", "SRV_NewTimeSlice", langUtil,
                        returnMessage, out);
                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,
                            returnMessage, out))
                        return;
                }
            }
           
            out.println(formHeader);
            printAsContentHeader(netParamMessage, out);
            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 locale                Name of locale (return arg)
     * @return the appUI which fits the browsers preferences
     */
    private LocalizedResource getCurrentAppUI(HttpServletRequest request, String[] locale )
    {
        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[ 0 ] = 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[ 0 ] = lang;
                return localUtil;
            }
        }
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

    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.