Examples of StringManager


Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = getStringManager(request);

        // Identify the request parameters that we need
        String command = request.getPathInfo();
        if (command == null)
            command = request.getServletPath();
        String config = request.getParameter("config");
        String path = request.getParameter("path");
        ContextName cn = null;
        if (path != null) {
            cn = new ContextName(path, request.getParameter("version"));
        }
        String type = request.getParameter("type");
        String war = request.getParameter("war");
        String tag = request.getParameter("tag");
        boolean update = false;
        if ((request.getParameter("update") != null)
            && (request.getParameter("update").equals("true"))) {
            update = true;
        }

        // Prepare our output writer to generate the response message
        response.setContentType("text/plain; charset=" + Constants.CHARSET);
        PrintWriter writer = response.getWriter();

        // Process the requested command (note - "/deploy" is not listed here)
        if (command == null) {
            writer.println(smClient.getString("managerServlet.noCommand"));
        } else if (command.equals("/deploy")) {
            if (war != null || config != null) {
                deploy(writer, config, cn, war, update, smClient);
            } else {
                deploy(writer, cn, tag, smClient);
            }
        } else if (command.equals("/list")) {
            list(writer, smClient);
        } else if (command.equals("/reload")) {
            reload(writer, cn, smClient);
        } else if (command.equals("/resources")) {
            resources(writer, type, smClient);
        } else if (command.equals("/save")) {
            save(writer, path, smClient);
        } else if (command.equals("/serverinfo")) {
            serverinfo(writer, smClient);
        } else if (command.equals("/sessions")) {
            expireSessions(writer, cn, request, smClient);
        } else if (command.equals("/expire")) {
            expireSessions(writer, cn, request, smClient);
        } else if (command.equals("/start")) {
            start(writer, cn, smClient);
        } else if (command.equals("/stop")) {
            stop(writer, cn, smClient);
        } else if (command.equals("/undeploy")) {
            undeploy(writer, cn, smClient);
        } else if (command.equals("/findleaks")) {
            findleaks(writer, smClient);
        } else {
            writer.println(smClient.getString("managerServlet.unknownCommand",
                    command));
        }

        // Finish up the response
        writer.flush();
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doPut(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = getStringManager(request);

        // Identify the request parameters that we need
        String command = request.getPathInfo();
        if (command == null)
            command = request.getServletPath();
        String path = request.getParameter("path");
        ContextName cn = null;
        if (path != null) {
            cn = new ContextName(path, request.getParameter("version"));
        }
        String tag = request.getParameter("tag");
        boolean update = false;
        if ((request.getParameter("update") != null)
            && (request.getParameter("update").equals("true"))) {
            update = true;
        }

        // Prepare our output writer to generate the response message
        response.setContentType("text/plain;charset="+Constants.CHARSET);
        PrintWriter writer = response.getWriter();

        // Process the requested command
        if (command == null) {
            writer.println(smClient.getString("managerServlet.noCommand"));
        } else if (command.equals("/deploy")) {
            deploy(writer, cn, tag, update, request, smClient);
        } else {
            writer.println(smClient.getString("managerServlet.unknownCommand",
                    command));
        }

        // Finish up the response
        writer.flush();
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    protected StringManager getStringManager(HttpServletRequest req) {
        Enumeration<Locale> requestedLocales = req.getLocales();
        while (requestedLocales.hasMoreElements()) {
            Locale locale = requestedLocales.nextElement();
            StringManager result = StringManager.getManager(Constants.Package,
                    locale);
            if (result.getLocale().equals(locale)) {
                return result;
            }
        }
        // Return the default
        return sm;
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = getStringManager(request);
       
        // Identify the request parameters that we need
        // By obtaining the command from the pathInfo, per-command security can
        // be configured in web.xml
        String command = request.getPathInfo();

        String path = request.getParameter("path");
        ContextName cn = null;
        if (path != null) {
            cn = new ContextName(path, request.getParameter("version"));
        }

        // Prepare our output writer to generate the response message
        response.setContentType("text/html; charset=" + Constants.CHARSET);

        String message = "";
        // Process the requested command
        if (command == null || command.equals("/")) {
            // No command == list
        } else if (command.equals("/list")) {
            // List always displayed - nothing to do here
        } else if (command.equals("/sessions")) {
            try {
                doSessions(cn, request, response, smClient);
                return;
            } catch (Exception e) {
                log("HTMLManagerServlet.sessions[" + cn + "]", e);
                message = smClient.getString("managerServlet.exception",
                        e.toString());
            }
        } else if (command.equals("/upload") || command.equals("/deploy") ||
                command.equals("/reload") || command.equals("/undeploy") ||
                command.equals("/expire") || command.equals("/start") ||
                command.equals("/stop")) {
            message =
                smClient.getString("managerServlet.postCommand", command);
        } else {
            message =
                smClient.getString("managerServlet.unknownCommand", command);
        }

        list(request, response, message, smClient);
    }
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = getStringManager(request);

        // Identify the request parameters that we need
        // By obtaining the command from the pathInfo, per-command security can
        // be configured in web.xml
        String command = request.getPathInfo();
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = getStringManager(request);

        // Identify the request parameters that we need
        String command = request.getPathInfo();
        if (command == null)
            command = request.getServletPath();
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    protected StringManager getStringManager(HttpServletRequest req) {
        Enumeration<Locale> requestedLocales = req.getLocales();
        while (requestedLocales.hasMoreElements()) {
            Locale locale = requestedLocales.nextElement();
            StringManager result = StringManager.getManager(Constants.Package,
                    locale);
            if (result.getLocale().equals(locale)) {
                return result;
            }
        }
        // Return the default
        return sm;
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException {

        StringManager smClient = StringManager.getManager(
                Constants.Package, request.getLocales());

        // Identify the request parameters that we need
        String command = request.getPathInfo();

        // Prepare our output writer to generate the response message
        response.setContentType("text/html; charset=" + Constants.CHARSET);

        String message = "";
        // Process the requested command
        if (command == null) {
            // No command == list
        } else if (command.equals("/list")) {
            // Nothing to do - always generate list
        } else if (command.equals("/add") || command.equals("/remove") ||
                command.equals("/start") || command.equals("/stop")) {
            message = smClient.getString(
                    "hostManagerServlet.postCommand", command);
        } else {
            message = smClient.getString(
                    "hostManagerServlet.unknownCommand", command);
        }

        list(request, response, message, smClient);
    }
View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

     */
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        StringManager smClient = StringManager.getManager(
                Constants.Package, request.getLocales());

        // Identify the request parameters that we need
        String command = request.getPathInfo();

View Full Code Here

Examples of org.apache.tomcat.util.res.StringManager

    {
  // this is how get locale is implemented. Ugly, but it's in
  // the next round of optimizations
  String acceptL=req.getMimeHeaders().getHeader( "Accept-Language");
  Locale locale=AcceptLanguage.getLocale(acceptL);;
  StringManager sm=StringManager.
      getManager("org.apache.tomcat.resources",locale);
  DateFormat dateFormat =
      new SimpleDateFormat(datePattern,locale );

  boolean inInclude=req.getChild()!=null;
  Request subReq=req;
  if( inInclude ) subReq = req.getChild();
  Context ctx=req.getContext();
  String pathInfo=subReq.servletPath().toString();
  if( pathInfo == null ) pathInfo="";
  String absPath=FileUtil.safePath( context.getAbsolutePath(),
            pathInfo);
  File file = new File( absPath );
  String requestURI=subReq.requestURI().toString();
  String base = ctx.getAbsolutePath();
  if (absPath.length() > base.length())
  {
    String relPath=absPath.substring( base.length() + 1);
    String relPathU=relPath.toUpperCase();
    if ( relPathU.startsWith("WEB-INF") ||
         relPathU.startsWith("META-INF")) {
        context.getContextManager().handleStatus( req, res, 404);
        return;
    }
  }

  OutputBuffer buf=res.getBuffer();
  if( sbNote==0 ) {
      //sbNote=req.getContextManager().
      //    getNoteId(ContextManager.REQUEST_NOTE,
      //          "RedirectHandler.buff");
      sbNote=req.getContextManager().
    getNoteId(ContextManager.REQUEST_NOTE,"uft8encoder");
  }

  // we can recycle it because
  // we don't call toString();
  //   StringBuffer buf=(StringBuffer)req.getNote( sbNote );
  //   if( buf==null ) {
  //       buf = new StringBuffer();
  //       req.setNote( sbNote, buf );
  //   }

  UEncoder utfEncoder=(UEncoder)req.getNote( sbNote );
  if( utfEncoder==null ) {
      utfEncoder=new UEncoder();
      utfEncoder.addSafeCharacter( '/' );
  }

  if (! inInclude) {
      res.setContentType("text/html");
      buf.write("<html>\r\n");
      buf.write("<head>\r\n");
      buf.write("<title>");
      buf.write(sm.getString("defaultservlet.directorylistingfor"));
      buf.write(requestURI);
      buf.write("</title>\r\n</head><body bgcolor=white>\r\n");
  }

  buf.write("<table width=90% cellspacing=0 ");
  buf.write("cellpadding=5 align=center>");
  buf.write("<tr><td colspan=3><font size=+2><strong>");
  buf.write(sm.getString("defaultservlet.directorylistingfor"));
  buf.write(requestURI);
  buf.write("</strong></td></tr>\r\n");

  if (! pathInfo.equals("/")) {
      buf.write("<tr><td colspan=3 bgcolor=#ffffff>");
      //buf.write("<a href=\"../\">Up one directory");
     
      String toPath = requestURI;

      if (toPath.endsWith("/")) {
    toPath = toPath.substring(0, toPath.length() - 1);
      }
     
      toPath = toPath.substring(0, toPath.lastIndexOf("/"));
     
      //if (toPath.length() == 0) {
      //toPath = "/";
      //}
      // Add trailing "/"
      toPath += "/";
     
      buf.write("<a href=\"");
      utfEncoder.urlEncode( buf, toPath);
      buf.write( "\"><tt>" );
      buf.write( sm.getString("defaultservlet.upto"));
      buf.write( toPath);
      buf.write("</tt></a></td></tr>\r\n");
  }

  // Pre-calculate the request URI for efficiency

  // Make another URI that definitely ends with a /
  String slashedRequestURI = null;

  if (requestURI.endsWith("/")) {
      slashedRequestURI = requestURI;
  } else {
      slashedRequestURI = requestURI + "/";
  }

  String[] fileNames = file.list();
  boolean dirsHead=true;
  boolean shaderow = false;

  for (int i = 0; i < fileNames.length; i++) {
      String fileName = fileNames[i];

            // Don't display special dirs at top level
      if( (pathInfo.length() == 0 || "/".equals(pathInfo)) &&
         "WEB-INF".equalsIgnoreCase(fileName) ||
         "META-INF".equalsIgnoreCase(fileName) )
        continue;

      File f = new File(file, fileName);

      if (f.isDirectory()) {
    if( dirsHead ) {
        dirsHead=false;
        buf.write("<tr><td colspan=3 bgcolor=#cccccc>");
        buf.write("<font size=+2><strong>");
        buf.write( sm.getString("defaultservlet.subdirectories"));
        buf.write( "</strong>\r\n");
        buf.write("</font></td></tr>\r\n");
    }

                String fileN = f.getName();

                buf.write("<tr");

                if (shaderow) buf.write(" bgcolor=#eeeeee");
    shaderow=!shaderow;
   
                buf.write("><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                buf.write("<tt><a href=\"");
    utfEncoder.urlEncode( buf, slashedRequestURI);
    utfEncoder.urlEncode( buf, fileN);
    buf.write("/\">");
    buf.write(fileN);
    buf.write("/</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    buf.write("</tt>\r\n");
                buf.write("</td><td><tt>&nbsp;&nbsp;</tt></td>");
                buf.write("<td align=right><tt>");
    buf.write(dateFormat.format(new Date(f.lastModified())));
                buf.write("</tt></td></tr>\r\n");
      }
  }

  shaderow = false;
  buf.write("<tr><td colspan=3 bgcolor=#ffffff>&nbsp;</td></tr>");
  boolean fileHead=true;
 
  for (int i = 0; i < fileNames.length; i++) {
      File f = new File(file, fileNames[i]);

      if (f.isFile()) {
    String fileN = f.getName();
   
    if( fileHead ) {
        fileHead=false;
        buf.write("<tr><td colspan=4 bgcolor=#cccccc>");
        buf.write("<font size=+2><strong>");
        buf.write(sm.getString("defaultservlet.files"));
        buf.write("</strong></font></td></tr>");
    }

    buf.write("<tr");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.