Examples of FileUpload


Examples of org.apache.commons.fileupload.FileUpload

        if (ServletFileUpload.isMultipartContent(new ServletRequestContext(request))) {
            //Used to communicate to clients of multipart data if the request processing worked correctly
            UploadStatus uploadStatus;
           
            final String encoding = this.determineEncoding(request);
            final FileUpload fileUpload = this.prepareFileUpload(encoding);
            try {
                final List<FileItem> fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
                final MultipartParsingResult parsingResult = parseFileItems(fileItems, encoding);
               
                final Map<String, MultipartDataSource[]> multipartDataSources = this.getMultipartDataSources(parsingResult);
View Full Code Here

Examples of org.apache.tomcat.util.http.fileupload.FileUpload

   * @throws FileUploadException
   */
  @SuppressWarnings("unchecked")
  public List<FileItem> getFileItems() throws FileUploadException {
    FileItemFactory factory = new DefaultFileItemFactory();
    FileUpload upload = new FileUpload(factory);
    return upload.parseRequest(request);
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

                     *
                     */
                    @Override
                    public void onSubmit()
                    {
                        final FileUpload upload = fileUpload;
                        final String userName = getPortletRequest()
                                .getUserPrincipal().getName();
                        String pathSeparator = System
                                .getProperty("file.separator");
                        boolean copyIds = getCopyIdsOnImport();
                        boolean success = false;
                        if (upload != null)
                        {
                            try
                            {
                                PageManager pageManager = getServiceLocator()
                                        .getPageManager();
                                String fileName = upload.getClientFileName();
                                String fileType = fileExt(upload.getClientFileName());
                                cleanUserFolder(userName);
                                String usrFolder = getTempFolder(userName);
                                String destPath = node.getNodePath();
                                upload.writeTo(new File(usrFolder
                                        + pathSeparator
                                        + upload.getClientFileName()));
                                // File writed in temp folder
                                if (fileType != null && !fileType.equals("")
                                        && fileName != null
                                        && !fileName.equals("")
                                        && destPath != null
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

            this.clearMessages();

            File tempDir = new File(System.getProperty("java.io.tmpdir"));
            File userTempDir = new File(tempDir, getPortletRequest().getUserPrincipal().getName());

            final FileUpload upload = ((FileUploadField) this.get("importFile")).getFileUpload();

            if (upload == null)
            {
                this.errorMessage = createMessage("import.message.nofile", null);
                return;
            }

            synchronized (this)
            {
                try
                {
                    if (!userTempDir.isDirectory())
                    {
                        userTempDir.mkdirs();
                    }

                    final File importFile = new File(userTempDir, upload.getClientFileName());
                    this.fileName = importFile.getCanonicalPath();

                    if (importFile.exists())
                    {
                        importFile.delete();
                    }

                    upload.writeTo(importFile);
                }
                catch (IOException ioe)
                {
                    this.errorMessage = createMessage("import.message.exception", new Object[]
                    { upload.getClientFileName(), ioe.getMessage()});
                }

                try
                {
                    getJetspeedSerializer().importData(this.fileName, this.settings);

                    this.infoMessage = createMessage("import.message.success", new Object[]
                    { this.fileName});
                }
                catch (SerializerException se)
                {
                    this.errorMessage = createMessage("import.message.exception", new Object[]
                    { upload.getClientFileName(), se.getMessage()});
                }
            }
        }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

            @Override
            public void onSubmit()
            {
                AbstractAdminWebApplication app = ((AbstractAdminWebApplication)getApplication());
                FeedbackPanel feedback = (FeedbackPanel) UploadPortletApp.this.get("feedback");
                final FileUpload upload = fileUpload;
                if (upload != null)
                {
                    InputStream warStream = null;
                    File tempFile = null;
                    try
                    {
                        warStream = upload.getInputStream();           
                        tempFile = File.createTempFile(upload.getClientFileName(), "");                       
                        String tmpDir = System.getProperty("java.io.tmpdir");
                        tempFile = new File(tmpDir, upload.getClientFileName());
                        if (tempFile.exists())
                            tempFile.delete();
                        FileOutputStream fos = new FileOutputStream(tempFile);
                        drain(warStream, fos);
                        fos.close();
                       
                        UploadPortletApp.this.dm.deploy(tempFile);
                        feedback.info("Deployed 1 portlet application to server: " + upload.getClientFileName());
                        app.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
                                app.getUserPrincipalName(), app.getIPAddress(), AuditActivity.REGISTRY_DEPLOY, ApplicationsListHome.PORTLET_REGISTRY_MANAGER);                                                   
                    }
                    catch (Exception e)
                    {
                        String msg = "Failed to upload document: " + upload.getClientFileName();
                        log.error(msg, e);
                        feedback.error(msg);
                    }
                    finally
                    {
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

            add(new Label("clientFileName", clientFileName));
        }

        public void onSubmit()
        {
            FileUpload upload = uploadField.getFileUpload();
            if (upload == null) {
                clientFileName.setObject("Invalid file");
            }
            else {
                clientFileName.setObject(upload.getClientFileName() + " (" + upload.getSize() + " bytes, type " + upload.getContentType() + ")");
            }

            newFileUrl = manageInputSream(upload);
            // File is now uploaded, and the IFrame will be reloaded, during
            // reload we need to run the callback
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("setFile failed, no upload content detected.", fileUpload.getBytes().length > 0);
    assertEquals("pom.xml", fileUpload.getClientFileName());
    assertEquals("text/xml", fileUpload.getContentType());
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue(
      "uploaded content does not have the right size, expected 428, got " +
        fileUpload.getBytes().length, fileUpload.getBytes().length == 428);
    assertEquals("bg.jpg", fileUpload.getClientFileName());
    assertEquals("image/jpeg", fileUpload.getContentType());
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("setFile failed, no upload content detected.", fileUpload.getBytes().length > 0);
    assertEquals("pom.xml", fileUpload.getClientFileName());
    assertEquals("text/xml", fileUpload.getContentType());
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.upload.FileUpload

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue(
      "uploaded content does not have the right size, expected 428, got " +
        fileUpload.getBytes().length, fileUpload.getBytes().length == 428);
    assertEquals("bg.jpg", fileUpload.getClientFileName());
    assertEquals("image/jpeg", fileUpload.getContentType());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.