Package com.adito.vfs

Examples of com.adito.vfs.UploadDetails


                    throws Exception {
      if (log.isDebugEnabled())
        log.debug("Execute file upload.");
        UploadForm uploadForm = (UploadForm) form;
        int uploadId = uploadForm.getUploadId();
        UploadDetails upload = CoreUtil.getUpload(request.getSession(), uploadId);
        if (upload == null) {
            throw new Exception("No file upload details configured for upload id " + uploadId + ".");
        }
        int sessionTimeoutBlockId = LogonControllerFactory.getInstance().addSessionTimeoutBlock(request.getSession(),
            "Upload request.");
        try {
            UploadHandler handler = UploadHandlerFactory.getInstance().getUploader(upload.getType());
            if (handler == null) {
                throw new Exception("No handler for upload type " + upload.getType());
            }
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, new Integer(uploadId));
           
            boolean isFileExist = handler.checkFileToUpload(request, response, upload, uploadForm.getUploadFile());
            if (isFileExist) {
                request.getSession().setAttribute("uploadForm", uploadForm);
                return new ActionForward("/confirmFileUpload.do?arg0=" + uploadForm.getUploadFile().getFileName());
            } else {
                return confirmUpload(mapping, form, request, response);
            }

        } catch (Exception e) {
            String stacktraceAsString = VfsUtils.maskSensitiveArguments(CoreUtil.toString(e));
            log.error("Failed to upload:" + stacktraceAsString);
           
            String exceptionMessage = VfsUtils.maskSensitiveArguments(e.getMessage());
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileNotUploaded", exceptionMessage));
            saveErrors(request, msgs);
            if (null != upload.getUploadedForward())
                return upload.getUploadedForward();
            else
                throw e;
        } finally {
            LogonControllerFactory.getInstance().removeSessionTimeoutBlock(request.getSession(), sessionTimeoutBlockId);
        }
View Full Code Here


    public ActionForward confirmUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled())
            log.debug("Execute file upload.");
        UploadForm uploadForm = (UploadForm) form;
        int uploadId = uploadForm.getUploadId();
        UploadDetails upload = CoreUtil.getUpload(request.getSession(), uploadId);
        if (upload == null) {
            throw new Exception("No file upload details configured for upload id " + uploadId + ".");
        }
        int sessionTimeoutBlockId = LogonControllerFactory.getInstance().addSessionTimeoutBlock(request.getSession(),
            "Upload request.");
       
        try {
            UploadHandler handler = UploadHandlerFactory.getInstance().getUploader(upload.getType());
            if (handler == null) {
                throw new Exception("No handler for upload type " + upload.getType());
            }
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, new Integer(uploadId));

            ActionForward fwd = handler.performUpload(request, response, upload, uploadForm.getUploadFile());
            ActionMessages msgs = new ActionMessages();
            if(upload.getResourcePath()==null) {
                msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileUploadedNoPath", uploadForm.getUploadFile()
                        .getFileName()));
            } else {
                msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileUploaded", uploadForm.getUploadFile()
                            .getFileName(), upload.getResourcePath()));
            }
            saveMessages(request, msgs);
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, uploadId);
            uploadForm.setUploadId(uploadId);
            return fwd;
        }
        catch (CoreException ce) {
            log.error("Failed to upload.", ce);
            ActionMessages errs = getErrors(request);
            errs.add(Globals.ERROR_KEY, ce.getBundleActionMessage());
            saveErrors(request, errs);
            if (null != upload.getUploadedForward())
                return new RedirectWithMessages(upload.getUploadedForward(), request);
            else
                throw ce;
        }       
        catch (Exception e) {
            log.error("Failed to upload.", e);
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileNotUploaded", e.getMessage()));
            saveErrors(request, msgs);
            if (null != upload.getUploadedForward())
                return upload.getUploadedForward();
            else
                throw e;
        } finally {
            LogonControllerFactory.getInstance().removeSessionTimeoutBlock(request.getSession(), sessionTimeoutBlockId);
        }
View Full Code Here

                    throws Exception {
        Integer i = (Integer) request.getAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS);
        if (i == null) {
            throw new Exception("No upload id.");
        }
        UploadDetails upload = CoreUtil.getUpload(request.getSession(), i.intValue());
        if (upload == null) {
            throw new Exception("No file upload details configured for upload id " + i + ".");
        }
        ((ShowUploadForm) form).initialise(i.intValue(), upload);
        CoreUtil.addRequiredFieldMessage(this, request);
View Full Code Here

     * @return forward
     * @throws Exception on any error
     */
    public ActionForward uploadDone(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        UploadDetails upload = CoreUtil.removeUpload(request.getSession(), ((ShowUploadForm) form).getUploadId());
        return upload.getDoneForward();
    }
View Full Code Here

     * @return forward
     * @throws Exception on any error
     */
    public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        UploadDetails upload = CoreUtil.removeUpload(request.getSession(), ((ShowUploadForm) form).getUploadId());
        return upload.getCancelForward();
    }
View Full Code Here

     * @return removed upload details
     */
    public static UploadDetails removeUpload(HttpSession session, int uploadId) {
        UploadManager mgr = (UploadManager) session.getAttribute(Constants.UPLOAD_MANAGER);
        if (mgr != null) {
            UploadDetails details = mgr.removeUpload(uploadId);
            if (mgr.isEmpty()) {
                session.removeAttribute(Constants.UPLOAD_MANAGER);
            }
            return details;
        }
View Full Code Here

      return fwd;
    }
    ActionForward returnTo = new ActionForward("/fileSystem.do?" + LaunchSession.LAUNCH_ID + "=" + fileSystemForm.getLaunchSession().getId()
      + "&actionTarget=list&path="
      + DAVUtilities.encodePath(fileSystemForm.getPath()), true);
    UploadDetails details = new UploadDetails(NetworkPlacePlugin.MESSAGE_RESOURCES_KEY,
            NetworkPlaceUploadHandler.TYPE_VFS,
            fileSystemForm.getPath(),
            mapping.findForward("upload"),
            returnTo,
            null);
    details.setExtraAttribute1(fileSystemForm.getPath());
    details.setExtraAttribute2(fileSystemForm.getLaunchSession().getId());
    request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, new Integer(CoreUtil.addUpload(request.getSession(), details)));
    return mapping.findForward("upload");
  }
View Full Code Here

    public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermissions(PolicyConstants.EXTENSIONS_RESOURCE_TYPE,
            new Permission[] { PolicyConstants.PERM_CHANGE },
            request);
        UploadDetails details = new UploadDetails("extensions",
                        ExtensionUploadHandler.TYPE_EXTENSION,
                        null,
                        mapping.findForward("list"),
                        null, // Keep this as NULL. We do not want to show Exit button here!
                        mapping.findForward("list"));
View Full Code Here

           
            String confirm = request.getParameter("confirm");
            ActionForm uploadForm = (UploadForm)request.getSession().getAttribute("uploadForm");
            form = (UploadForm)uploadForm;
            int uploadId = ((UploadForm)uploadForm).getUploadId();
            UploadDetails upload = CoreUtil.getUpload(request.getSession(), uploadId);
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, uploadId);
            UploadAction action = new UploadAction();
            request.getSession().removeAttribute("uploadForm");
            if("yes".equals(confirm)) {
                return action.confirmUpload(mapping, uploadForm, request, response);
            } else {
                return new ActionForward(upload.getUploadedForward().getPath());
            }
        } catch (Exception e) {
            log.error("Confirm Upload error: " + e);
            throw e;
        }
View Full Code Here

TOP

Related Classes of com.adito.vfs.UploadDetails

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.