Package kr.or.ioi2002.RMIClientBean

Examples of kr.or.ioi2002.RMIClientBean.HttpPostFileParser$UpFile


    private static final long serialVersionUID = -4753159772794540849L;

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpPostFileParser ur = new HttpPostFileParser();
        ur.init(request);

        LinkedList<String[]> llist = new LinkedList<String[]>();

        if (ur.nFile > 0) {
            File fileSrcFile = ur.upFile[0].GetTmpFile();
View Full Code Here


            response.sendRedirect("main");
            return;
        }

        try {
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile <= 1) {
                user.getTestState().setOutputNow("Test failed: Select two files");
                response.sendRedirect("main");
                return;
            }
            String srcFile = null;
            byte[] abSrcFile = null;

            srcFile = postFileParser.upFile[0].pc_file_name;
            if (srcFile != null)
                srcFile = FilenameUtils.getName(srcFile);

            String task = contestManager.getTaskFromFilename(contest, srcFile, postFileParser
                    .getParameter("task"));
            String language = contestManager.getLanguageFromFilename(contest,
                    srcFile,
                    postFileParser.getParameter("language"));

            if (task == null) {
                user
                        .getTestState()
                        .setOutputNow("Invalid task name!\nThe task you are trying to submit is not part of the contest you are registered in.");
View Full Code Here

            return;
        }

        try {
            // request parsing
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile == 0) {
                response.sendRedirect("main?error=12");
                return;
            }

            String srcFile = postFileParser.upFile[0].pc_file_name;
            if (srcFile != null)
                srcFile = FilenameUtils.getName(srcFile);
           
            String taskName = contestManager.getTaskFromFilename(contest, srcFile, postFileParser.getParameter("task"));
            String language = contestManager.getLanguageFromFilename(contest, srcFile, postFileParser.getParameter("language"));
           
            Task task = contest.getTaskByName(taskName);

            // TODO: export these as error messages or sth
            if (task == null || taskName == null) {
View Full Code Here

    }

    private void doBackup(Contest contest) throws IOException, ServletException {
        try {

            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // no more than the maximum test should be allowed
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile < 1) {
                response.sendRedirect("main?error=22");
                return;
            }
View Full Code Here

            return;
        }

        try {
            // request parsing
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxFileSize = printManager.getMaxFileSize() * 1024;
            postFileParser.init(request, maxFileSize);

            if (postFileParser.nFile == 0) {
                response.sendRedirect("main?error=12");
                return;
            }
View Full Code Here

            response.sendRedirect("main?error=23");
            return;
        }

        try {
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile <= 1) {
                response.sendRedirect("main?error=22");
                return;
            }
            String srcFile = null;
            byte[] abSrcFile = null;

            srcFile = postFileParser.upFile[0].pc_file_name;
            if (srcFile != null)
                srcFile = FilenameUtils.getName(srcFile);
           
            String task = contestManager.getTaskFromFilename(contest, srcFile, postFileParser.getParameter("task"));
            String language = contestManager.getLanguageFromFilename(contest, srcFile, postFileParser.getParameter("language"));
           
            // TODO: export these as error messages or sth
            if (task == null) {
              User user = contestManager.getUser(contest.getId(), userLogin);
              user.setStrLastTaskTest("Invalid task name!\nThe task you are trying to submit is not part of the contest you are registered in.");
View Full Code Here

    private void doBackup(HttpServletRequest request, HttpServletResponse response,
            Contest contest, User user, Properties propertyBackup, File propertyFile,
            File backupDirectory) throws IOException, ServletException {
        try {

            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // no more than the maximum test should be allowed
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile < 1) {
                user.getGeneralState().setOutputNow("Please select file.");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
View Full Code Here

            return;
        }

        try {
            // request parsing
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxUploadSize = contest.getMaxUploadSize() * 1024;
            postFileParser.init(request, maxUploadSize);

            if (postFileParser.nFile == 0) {
                user.getGeneralState().setOutputNow("Submission failed: No file selected");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            }

            String srcFile = postFileParser.upFile[0].pc_file_name;
            if (srcFile != null)
                srcFile = FilenameUtils.getName(srcFile);

            String taskName = contestManager.getTaskFromFilename(contest, srcFile, postFileParser
                    .getParameter("task"));
            String language = contestManager.getLanguageFromFilename(contest,
                    srcFile,
                    postFileParser.getParameter("language"));

            Task task = contest.getTaskByName(taskName);

            if (task == null || taskName == null) {
                user
                        .getGeneralState()
                        .setOutputNow("Invalid task name!\nThe task you are trying to submit is not part of the contest you are registered in.");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            }
            if (postFileParser.upFile[0].size > contest.getTaskByName(taskName).getMaxSubmitSize()) {
                user.getGeneralState().setOutputNow("Submission failed: File too big");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            }
            if (contest.getTaskByName(taskName).getType() == Task.PROBLEM_TYPE_OUTPUT) {
                String index = null;
                int indexNumber = 0;
                if (srcFile != null && srcFile.split("\\.").length >= 2) {
                    index = srcFile.split("\\.")[1];
                    if ("txt".equals(index) || "out".equals(index)) {
                        indexNumber = 1;
                    } else {
                        try {
                            indexNumber = Integer.parseInt(index);
                            if (indexNumber <= 0
                                    || indexNumber > contest.getTaskByName(taskName)
                                            .getNumberOfTests()) {
                                index = null;
                            }
                        } catch (NumberFormatException e) {
                            index = null;
                        }
                    }
                }
                if (index == null) {
                    user
                            .getGeneralState()
                            .setOutputNow("Invalid file name!\nFormat is [taskname].[case_number].txt (e.g. output.10.txt).");
                    request.getSession().setAttribute("tab", "General");
                    response.sendRedirect("main");
                    return;
                }
                // TODO: remove HACK
                language = String.format("%0" + Task.TESTCASE_PADDING_LENGTH + "d", indexNumber);
            }
            if (language == null) {
                user.getGeneralState().setOutputNow("Invalid language!");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            }

            java.io.File fileSrcFile = postFileParser.upFile[0].GetTmpFile();

            byte[] absoluteSrcFile = new byte[postFileParser.upFile[0].size];
            java.io.BufferedInputStream bis = new java.io.BufferedInputStream(
                    new java.io.FileInputStream(fileSrcFile));
            int index = 0;
            int iRead;
            while ((iRead = bis.read(absoluteSrcFile, index, postFileParser.upFile[0].size - index)) > 0) {
                index += iRead;
            }
            bis.close();

            // for debug only
            postFileParser.upFile[0].save("./ioidebugsubmit", userLogin
                    + "_"
                    + String.valueOf(postFileParser.upFile[0].hashCode()));

            boolean isAlwaysAccept = Boolean.valueOf(postFileParser.getParameter("always_accept"));

            boolean bResult = contestManager.submit(contest,
                    userLogin,
                    task,
                    language,
View Full Code Here

            return;
        }

        try {
            // request parsing
            HttpPostFileParser postFileParser = new HttpPostFileParser();
            // convert from KBytes to bytes
            int maxFileSize = printManager.getMaxFileSize() * 1024;
            postFileParser.init(request, maxFileSize);

            if (postFileParser.nFile == 0) {
                user.getGeneralState().setOutputNow("Print failed: No file selected");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
View Full Code Here

     * job to null.
     *
     * @return the just finished job
     */
    private Job resetCurrentJob() {
        Job finishedJob = currentJob;
        currentJob = null;
        return finishedJob;
    }
View Full Code Here

TOP

Related Classes of kr.or.ioi2002.RMIClientBean.HttpPostFileParser$UpFile

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.