Package kr.or.ioi2002.RMIClientBean

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


        return true;
    }

    public boolean submit(Contest contest, String userId, Task task,
            String language, String sourceFileName, byte[] sourceFileData) {
        User user = getUser(contest, userId);
        if (user == null)
            return false;

        TempFile tmp = null;
        try {
            tmp = TempFile.createFromByteArray(sourceFileData);
        } catch (java.io.IOException e) {
            Syslog.log("ContestManager: submit: " + e.toString());
            return false;
        }

        if (contest == null || !contest.isRunning())
            return false;

        if (!user.submitStart())
            return false;

        mediator.submit(contest.getId(),
                userId,
                task,
View Full Code Here


        LogSubmit.log(userId + ",START");
        return true;
    }

    public File getSourceCode(Contest contest, String userid, String task) {
        User user = getUser(contest, userid);
        if (user == null)
            return null;

        return user.getSourceCode(task);
    }
View Full Code Here

        return user.getSourceCode(task);
    }
   
  public String getSourceCodeLanguage(Contest contest, String userid, String task) {
    User user = getUser(contest, userid);
        if (user == null)
            return null;
       
    return user.getSourceCodeLanguage(task);
  }
View Full Code Here

        Vector<UserAccount> userAccounts = mediator.getAllUsers();
        for (Contest contest : allContests) {
            Map<String, User> userMap = new HashMap<String, User>();
            for (UserAccount account : userAccounts) {
                if (account.getContestIds().contains(contest.getId())) {
                    userMap.put(account.getLogin(), new User(contest.getId(), account.getLogin(),
                            workingDirectory));
                }
            }
            activeUsers.put(contest.getId(), userMap);
        }
View Full Code Here

    public void registerUserForContest(String contestId, String username) {
        Map<String, User> contestants = activeUsers.get(contestId);
        if (contestants == null)
            return;

        contestants.put(username, new User(contestId, username, workingDirectory));
    }
View Full Code Here

        request.setAttribute("userLogin", userLogin);
        request.setAttribute("contest", contest);
        request.setAttribute("time", Util.DATETIME_FORMAT.format(new java.util.Date()));

        User user = contestManager.getUser(contest.getId(), userLogin);
        Hashtable<String, String> hash = user.getStatus();
        generateTable(request, hash, contest.getTasks());

        request.setAttribute("announcement", generateAnnouncement(contest.getAnnouncement()));
        request.setAttribute("languages", Contest.Language.values());

        setOutputTabs(request, contest, user);

        request.setAttribute("isContestRunning", contest.isRunning() ? true : null);

        request.setAttribute("testState", user.getTestState());

        request.getRequestDispatcher("main.jsp").forward(request, response);
    }
View Full Code Here

        Contest contest = contestManager.getContest(request);
        if (contest == null) {
            response.sendRedirect("");
            return;
        }
        User user = contestManager.getUser(contest.getId(), userLogin);
        if (!contest.isRunning()) {
            user.getGeneralState().setOutputNow("Backup failed: Contest not running");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            return;
        }
View Full Code Here

        Contest contest = contestManager.getContest(request);
        if (contest == null) {
            response.sendRedirect("");
            return;
        }
        User user = contestManager.getUser(contest.getId(), userLogin);
        if (!contest.isRunning()) {
            user.getGeneralState().setOutputNow("Submission failed: Contest not running");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            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,
                    srcFile,
                    absoluteSrcFile,
                    isAlwaysAccept);

            if (!bResult) {
                user.getGeneralState().setOutputNow("Submission failed: Already processing");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            } else {
                request.getSession().setAttribute("tab", task.getName());
                response.sendRedirect("main");
            }
        } catch (java.io.IOException ex) {
            user.getGeneralState().setOutputNow("Submission failed: File upload failed (possibly file too big)");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            return;
        }
    }
View Full Code Here

        Contest contest = contestManager.getContest(request);
        if (contest == null) {
            response.sendRedirect("");
            return;
        }
        User user = contestManager.getUser(contest.getId(), userLogin);
        if (!contest.isRunning()) {
            user.getGeneralState().setOutputNow("Print failed: Contest not running");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            return;
        }
       
        // do not allow printing in open contests
        if (contest.isOpenContest()) {
            user.getGeneralState().setOutputNow("Print failed: No printing in open contests");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            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");
                return;
            }

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

            boolean bResult = printManager.print(fileSrcFile, userLogin);
            if (!bResult) {
                user.getGeneralState().setOutputNow("Print failed");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            } else {
                user.getGeneralState().setOutputNow("Print successful");
                request.getSession().setAttribute("tab", "General");
                response.sendRedirect("main");
                return;
            }
        } catch (java.io.IOException ex) {
            user.getGeneralState().setOutputNow("Print failed: File upload failed (possibly file(s) too big)");
            request.getSession().setAttribute("tab", "General");
            response.sendRedirect("main");
            return;
        }
    }
View Full Code Here

        if (JobType.FEEDBACK.equals(currentJob.getType()))
            return SUBMIT_PROCESS_TIMEOUT;
        if (JobType.TEST.equals(currentJob.getType()))
            return TEST_PROCESS_TIMEOUT;

        throw new AgentException("Invalid job type - not supported by this agent.");
    }
View Full Code Here

TOP

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

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.