⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesystemviewdispatchaction.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward confirmDeleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                           HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled())
            log.debug("Delete file.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        DAVResource res = getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        buildModel(res, fileSystemForm, request);
        return mapping.findForward("deleteFile");
    }

    /**
     * <p>
     * Cut the selected file into the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward cutFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Cut file.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        addToClipboard(request, fileSystemForm, true);
        return mapping.findForward("list");
    }

    /**
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param fileSystemForm The <code>FileSystemForm<code> for the action.
     * @param delOrig Delete the source files.
     */
    private void addToClipboard(HttpServletRequest request, FileSystemForm fileSystemForm, boolean delOrig) {
        String delPath = fileSystemForm.getPath() + "/" + fileSystemForm.getFileName();
        ActionMessages msgs = new ActionMessages();
        Clipboard cb = new Clipboard();
        DAVResourceClipboardContent fcc = new DAVResourceClipboardContent(delPath, delOrig);
        cb.addContent(fcc);
        request.getSession().setAttribute(Constants.CLIPBOARD, cb);
        msgs.add(Globals.MESSAGE_KEY, new ActionMessage("vfs.copy.to.clipboard", fileSystemForm.getFileName()));
        this.addMessages(request, msgs);
    }

    /**
     * <p>
     * Copy the selected file into the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward copyFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Copy file.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        addToClipboard(request, fileSystemForm, false);
        return mapping.findForward("list");
    }

    /**
     * <p>
     * Zip the selected file.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward zipFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Zip file.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        String[] uris = { fileSystemForm.getFileName() };
        return zipSelection(mapping, request, fileSystemForm, uris);
    }

    /**
     * <p>
     * Paste the selected files from the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if an exception is thrown.
     */
    public ActionForward pasteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Paste file.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        pasteFromClipBoard(request, response, fileSystemForm.getPath() + "/" + fileSystemForm.getFileName(), fileSystemForm);
        return mapping.findForward("list");
    }

    /**
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @param delPath The path to the resource to be deleted.
     * @throws Exception if an exception is thrown.
     */
    private void deleteSingleFile(HttpServletRequest request, HttpServletResponse response, String delPath,
                                  FileSystemForm fileSystemForm) throws Exception {
        DAVResource res = DAVServlet.getDAVResource(request, response, delPath);
        if (log.isDebugEnabled())
            log.debug("Deleting " + res.getRelativePath());
        String name = null;
        try {
            name = res.getDisplayName();
            boolean isFolder = res.isCollection();
            res.delete();
        } catch (Exception e) {
            throw e;
        }

    }

    /**
     * <p>
     * Cut the selected files into the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward cut(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Cut files.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        DAVResource res = getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        buildModel(res, fileSystemForm, request);
        Object[] uris = fileSystemForm.getSelectedFileNames();
        if (uris == null || uris.length < 1) {
            ActionMessages msgs = getErrors(request);
            msgs.add(Globals.ERROR_KEY, new ActionMessage("vfs.cut.select.error"));
            saveErrors(request, msgs);
            return mapping.getInputForward();
        }
        copyFilesToClipboard(form, request, response, true, fileSystemForm.getSelectedFileNames());
        return mapping.findForward("list");
    }

    /**
     * <p>
     * Copy the selected files into the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Copy files.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        DAVResource res = getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        buildModel(res, fileSystemForm, request);
        String[] uris = fileSystemForm.getSelectedFileNames();
        if (uris == null || uris.length < 1) {
            ActionMessages msgs = getErrors(request);
            msgs.add(Globals.ERROR_KEY, new ActionMessage("vfs.copy.select.error"));
            saveErrors(request, msgs);
            return mapping.getInputForward();
        }
        copyFilesToClipboard(form, request, response, false, uris);
        return mapping.findForward("list");
    }

    /**
     * <p>
     * Copy files into the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent}.
     * 
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @param deleteOnPaste weather the source resource is deleted on th epaste action.
     * @param uris uris to copy
     */
    private void copyFilesToClipboard(ActionForm form, HttpServletRequest request, HttpServletResponse response,
                                      boolean deleteOnPaste, String[] uris) {
        ActionMessages msgs = new ActionMessages();
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        String allFiles = "";
        Clipboard cb = new Clipboard();
        if (uris != null) {
            for (int i = 0; i < uris.length; i++) {
                String divider = allFiles.equals("") ? "" : ", ";
                allFiles = allFiles + divider + uris[i];
                DAVResourceClipboardContent fcc = new DAVResourceClipboardContent(fileSystemForm.getPath() + "/" + uris[i],
                                deleteOnPaste);
                cb.addContent(fcc);
            }
            msgs.add(Globals.MESSAGE_KEY, new ActionMessage("vfs.copy.to.clipboard", allFiles));
        }
        this.addMessages(request, msgs);
        request.getSession().setAttribute(Constants.CLIPBOARD, cb);
    }

    /**
     * <p>
     * Paste the contents of the
     * {@link com.sslexplorer.vfs.clipboard.DAVResourceClipboardContent} to the
     * specified location.
     * 
     * @param mapping The
     *        <code>ActionMapping<code> associated with this dispatch action.
     * @param form The <code>FileSystemForm<code> for the action.
     * @param request The <code>HttpServletRequest<code> for the action.
     * @param response The <code>HttpServletResponse<code> for the action.
     * @return <code>ActionForward<code> The result of the action.
     * @throws Exception if aan exception is thrown.
     */
    public ActionForward paste(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        if (log.isDebugEnabled())
            log.debug("Paste files.");
        FileSystemForm fileSystemForm = (FileSystemForm) form;
        DAVResource res = getResourceForPath(request, response, fileSystemForm);
        ActionForward fwd = checkAccess(mapping, fileSystemForm, request);
        if (fwd != null) {
            return fwd;
        }
        buildModel(res, fileSystemForm, request);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -