Package org.jstripe.tomcat.probe.model

Examples of org.jstripe.tomcat.probe.model.FollowedFile


    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

       System.out.println("FollowController:");

        FollowedFile ff = (FollowedFile) request.getSession(true).getAttribute("followed_file");

  if (ff == null)
  {
     System.out.println("FollowController: followed_file attr is null");
  }

        if (ff != null) {
     File f = new File(ff.getFileName());

     System.out.println("FollowController: file is: " + ff.getFileName());

            if (f.exists()) {

     System.out.println("FollowController: file exists");

                long currentLength = f.length();
                long readSize = 0;
                int listSize = ff.getLines().size();

    System.out.println("FollowController: current len:" + currentLength + " lastknownlen: " + ff.getLastKnowLength() + " listsize: " + listSize);

                if (currentLength < ff.getLastKnowLength()) {
                    //
                    // file length got reset
                    //
                    ff.setLastKnowLength(0);
                    ff.getLines().add(listSize, " ------------- THE FILE HAS BEEN TRUNCATED --------------");
                }

                BackwardsFileStream bfs = new BackwardsFileStream(f, currentLength);
                try {
                    LineReader br = new LineReader(bfs, true);
                    String s;
                    while (readSize < currentLength - ff.getLastKnowLength() && (s = br.readLine()) != null) {
                        if (ff.getLines().size() >= maxLines) {
                            if (listSize > 0) {
                                ff.getLines().remove(0);
                                listSize--;
                            } else {
                                break;
                            }
                        }
                        ff.getLines().add(listSize, s);
                        readSize += s.length();
                        if (ff.getLastKnowLength() == 0 && ff.getLines().size() >= initialLines) break;
                    }

                    if (readSize > currentLength - ff.getLastKnowLength() && listSize > 0) {
                        ff.getLines().remove(listSize-1);
                    }

                    ff.setLastKnowLength(currentLength);
                } finally {
                    bfs.close();
                }
            } else {
                ff.getLines().clear();
            }
            request.getSession(true).setAttribute(fileAttributeName, ff);
        }

        return new ModelAndView(getViewName());
View Full Code Here


        if (file.exists()) {
    
     System.out.println("SetupFollowController: filename: " + file.getAbsolutePath() + "file attrib name:" + fileAttributeName);

            FollowedFile ff = new FollowedFile();
            ff.setFileName(file.getAbsolutePath());
            ff.setLastKnowLength(0);
            ff.setLines(new ArrayList());
            ff.setSize(file.length());
            ff.setLastModified(new Timestamp(file.lastModified()));
            request.getSession(true).setAttribute(fileAttributeName, ff);
        }
        return new ModelAndView(getViewName());
    }
View Full Code Here

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

       System.out.println("UpdateFileInfoController");

        if (request.getSession() != null) {
            FollowedFile ff = (FollowedFile) request.getSession().getAttribute(fileAttributeName);
            if (ff != null) {
                File f = new File(ff.getFileName());
                if (f.exists()) {
                    ff.setLastModified(new Timestamp(f.lastModified()));
                    ff.setSize(f.length());
                    request.getSession().setAttribute(fileAttributeName, ff);
                } else {

       //logger.debug("File "+ff.getFileName() + " does not exist");
       System.out.println("UpdateFileInfoController File "+ff.getFileName() + " does not exist");
                }
            } else {
        
         //logger.debug(fileAttributeName + " attribute is not in session");
                System.out.println("UpdateFileInfoController " + fileAttributeName + " attribute is not in session");
View Full Code Here

public class ClearBufferController extends AbstractController {
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        HttpSession session = request.getSession();
        if (session != null) {
            FollowedFile ff = (FollowedFile) session.getAttribute("followed_file");
            if (ff != null) ff.getLines().clear();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.jstripe.tomcat.probe.model.FollowedFile

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.