Package org.apache.cocoon.servlet.multipart

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


    }

    protected String getSourceExtension() {
        String extension = "";

        Part file = getPart(PARAMETER_FILE);
        String fileName = file.getFileName();
        int lastDotIndex = fileName.lastIndexOf(".");
        if (lastDotIndex > -1) {
            extension = fileName.substring(lastDotIndex + 1);
        } else {
            addErrorMessage(MESSAGE_UPLOAD_MISSING_EXTENSION);
View Full Code Here


        }
    }

    protected void doCheckExecutionConditions() throws Exception {
        super.doCheckExecutionConditions();
        Part file = getPart("file");
        if (file.isRejected()) {
            String[] params = { Integer.toString(file.getSize()) };
            addErrorMessage("upload-size-exceeded", params);
        }
    }
View Full Code Here

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

                sources.add(src);
                if (src.exists()) {
                    ds = new SourceDataSource(src, getType(), getName());
                }
            } else if (getObject() instanceof Part) {
                Part part = (Part) getObject();
                ds = new FilePartDataSource(part, getType(), getName());
            } else if (getObject() instanceof InputStream) {
                InputStream in = (InputStream) getObject();
                ds = new InputStreamDataSource(in, getType(), getName());
            } else if (getObject() instanceof byte[]) {
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)resolve(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)resolve(dest));
    }
View Full Code Here

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

        String title = getParameterAsString("title");
        String creator = getParameterAsString("creator");
        String rights = getParameterAsString("rights");
        Part file = getPart("file");

        Map metadata = new HashMap();
        metadata.put("title", title);
        metadata.put("creator", creator);
        metadata.put("rights", rights);
View Full Code Here

        }


        // 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;
            if (validateOversize()) {
                // Clear any validation error
                setValidationError(null);
            }
View Full Code Here

                                    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

        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

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.