Package org.apache.cocoon.servlet.multipart

Examples of org.apache.cocoon.servlet.multipart.Part


                                    a.getType(src.getMimeType()),
                                    a.getName(name.substring(name.lastIndexOf('/') + 1)));
                        }
                    } else {
                        if (a.getObject() instanceof Part) {
                            Part part = (Part) a.getObject();
                            ds =
                                new FilePartDataSource(
                                    part,
                                    a.getType(part.getMimeType()),
                                    a.getName(part.getUploadName()));
                        } else {
                            // TODO: other classes?
                            throw new AddressException(
                                "Not yet supported: " + a.getObject());
                        }
View Full Code Here


    public void readFromRequest(FormContext formContext) {
        Object obj = formContext.getRequest().get(getFullyQualifiedId());
       
        // If the request object is a Part, keep it
        if (obj instanceof Part) {
            Part requestPart = (Part)obj;
            if (this.part != null) {
                // Replace the current part
                this.part.dispose();
            }
       
            // Keep the request part
            requestPart.setDisposeWithRequest(false);
            this.part = requestPart;
            this.validationError = null;
           
        // If it's not a part and not null, clear any existing value
        // We also check if we're the submit widget, as a result of clicking the "..." button
View Full Code Here

        while (params.hasMoreElements()) {
            String name = (String) params.nextElement();
            if (name.indexOf("..") > -1) throw new Exception("We are under attack!!");
//System.out.println("[param] " + name);
            if (name.startsWith("save:")) {
                Part part = (Part) request.get(name);
                String code = name.substring(5);
                File file = new File(dir, code);
                save(part,file);
            } else if (name.startsWith("delete:")) {
                String value = request.getParameter(name);
View Full Code Here

  public static void fomSave(FOM_Cocoon cocoon, String dirName) throws Exception {
    save(cocoon.getRequest(), dirName);
  }
   
    public static void save(Request request, String param, String file) throws Exception {
        Part part = (Part) request.get(param);
        save(part,new File(file));
    }
View Full Code Here

        while (params.hasMoreElements()) {
            String name = (String) params.nextElement();
            if (name.indexOf("..") > -1) throw new Exception("We are under attack!!");
//System.out.println("[param] " + name);
            if (name.startsWith("save:")) {
                Part part = (Part) request.get(name);
                String code = name.substring(5);
                if (!(collection instanceof ModifiableSource)) {
                  throw new RuntimeException("Cannot modify the given source");
               
                result = (ModifiableTraversableSource)env.resolveURI(collection.getURI() + "/" + code);
View Full Code Here

            }
        }
    }
   
    public static void save(Request request, String param, String dest) throws Exception {
        Part part = (Part) request.get(param);
        save(part, (ModifiableTraversableSource)env.resolveURI(dest));
    }
View Full Code Here

        }
    }

    protected void doCheckExecutionConditions() throws Exception {
        super.doCheckExecutionConditions();
        Part file = getPart("file");
        if (file == null) {
            addErrorMessage("missing-file");
        } else {
            if (file.isRejected()) {
                String[] params = { Integer.toString(file.getSize()) };
                addErrorMessage("upload-size-exceeded", params);
            } else {
                String mimeType = file.getMimeType();
                if (!OpenDocumentWrapper.ODT_MIME_TYPE.equals(mimeType)) {
                    String[] params = { mimeType, OpenDocumentWrapper.ODT_MIME_TYPE };
                    addErrorMessage("wrong-mime-type", params);
                }
            }
View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        super.doExecute();
        OpenDocumentWrapper odt = new OpenDocumentWrapper(getSourceDocument(), getLogger());
        Part file = getPart("file");
        odt.write(file);
    }
View Full Code Here

     */
    protected void doCheckExecutionConditions() throws Exception {

        super.doCheckExecutionConditions();

        Part file = getPart(PARAMETER_FILE);
        if (hasErrors() && file != null) {
            resetUploadField();
        } else {
            if (file == null) {
                addErrorMessage(MESSAGE_UPLOAD_CHOOSE_FILE);
            } else if (file.isRejected()) {
                String[] params = { Integer.toString(file.getSize()) };
                addErrorMessage(MESSAGE_UPLOAD_SIZE_EXCEEDED, params);
            }
        }
    }
View Full Code Here

            RepositoryException, MetaDataException {

        if (getLogger().isDebugEnabled())
            getLogger().debug("Assets::addAsset() called");

        Part file = getPart(PARAMETER_FILE);
        Document document = getNewDocument();
        ResourceWrapper wrapper = new ResourceWrapper(document, this.manager, getLogger());
        wrapper.write(file);
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.servlet.multipart.Part

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.