Package org.apache.wicket.markup.html.form.upload

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


            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

            @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

            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

    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

    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

    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

    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

        super(id, model);
    }

   
    protected Blob getBlobOrClobFrom(final List<FileUpload> fileUploads) {
        final FileUpload fileUpload = fileUploads.get(0);
        final String contentType = fileUpload.getContentType();
        final String clientFileName = fileUpload.getClientFileName();
        final byte[] bytes = fileUpload.getBytes();
        final Blob blob = new Blob(clientFileName, contentType, bytes);
        return blob;
    }
View Full Code Here

    public IsisClobPanel(final String id, final ScalarModel model) {
        super(id, model);
    }

    protected Clob getBlobOrClobFrom(final List<FileUpload> fileUploads) {
        final FileUpload fileUpload = fileUploads.get(0);
        final String contentType = fileUpload.getContentType();
        final String clientFileName = fileUpload.getClientFileName();
        final String str = new String(fileUpload.getBytes(), CHARSET);
        final Clob blob = new Clob(clientFileName, contentType, str);
        return blob;
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.form.upload.FileUpload

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.