Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Request


        uribuf.append(mountPoint);

        baseURI = uribuf.toString();
       
        Request request = ObjectModelHelper.getRequest(objectModel);
       
        host = request.getServerName();
        port = request.getServerPort();

        serviceSelector = null;
        acResolver = null;
        policyManager = null;

        identity = Identity.getIdentity(request.getSession(false));

        try {
            String publicationId = envelope.getPublication().getId();
            String area = envelope.getDocument().getArea();
View Full Code Here


    /**
     * @see org.apache.cocoon.generation.Generator#generate()
     */
    public void generate() throws SAXException {
        Request request = (Request) objectModel.get(ObjectModelHelper.REQUEST_OBJECT);

        log.debug("\n----------------------------------------------------------------"
                + "\n- Request: (" + request.getClass().getName() + ") at port "
                + request.getServerPort()
                + "\n----------------------------------------------------------------");

        String submitMethod = request.getMethod();

        SAXParser parser = null;

        try {
            // DEBUG
            if (submitMethod.equals("POST")) {
                // FIXME: Andreas
                if (request instanceof HttpRequest) {
                    InputStream is = intercept(((HttpRequest) request).getInputStream());
                }
            }

            URL url = createURL(request);

            // Forward "InputStream", Parameters, QueryString to Servlet
            HttpMethod httpMethod = null;

            if (submitMethod.equals("POST")) {
                httpMethod = new PostMethod();

                Enumeration params = request.getParameterNames();

                while (params.hasMoreElements()) {
                    String paramName = (String) params.nextElement();
                    String[] paramValues = request.getParameterValues(paramName);

                    for (int i = 0; i < paramValues.length; i++) {
                        ((PostMethod) httpMethod).setParameter(paramName, paramValues[i]);
                    }
                }
            } else if (submitMethod.equals("GET")) {
                httpMethod = new GetMethod();
                httpMethod.setQueryString(request.getQueryString());
            }

            // Copy/clone Cookies
            Cookie[] cookies = request.getCookies();
            org.apache.commons.httpclient.Cookie[] transferedCookies = null;

            if (cookies != null) {
                transferedCookies = new org.apache.commons.httpclient.Cookie[cookies.length];

                for (int i = 0; i < cookies.length; i++) {
                    boolean secure = false; // http: false, https: true
                    transferedCookies[i] = new org.apache.commons.httpclient.Cookie(url.getHost(),
                            cookies[i].getName(), cookies[i].getValue(), url.getFile(), null,
                            secure);
                }
            }

            // Initialize HttpClient
            HttpClient httpClient = new HttpClient();

            // Set cookies
            if ((transferedCookies != null) && (transferedCookies.length > 0)) {
                HttpState httpState = new HttpState();
                httpState.addCookies(transferedCookies);
                httpClient.setState(httpState);
            }

            // DEBUG cookies
            // Send request to servlet
            httpMethod.setRequestHeader("Content-type", "text/plain");
            httpMethod.setPath(url.getPath());

            // FIXME
            for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
                String name = (String) e.nextElement();
                httpMethod.addRequestHeader(name, request.getHeader(name));
                log.debug("Header Name=" + name + "value=" + request.getHeader(name));
            }

            HostConfiguration hostConfiguration = new HostConfiguration();
            hostConfiguration.setHost(url.getHost(), url.getPort(), url.getProtocol());

View Full Code Here

                getLogger().debug("    Area:           [" + area + "]");
            }

            urlPrefix = "/" + publicationId + "/" + area;

            Request request = ObjectModelHelper.getRequest(objectModel);

            serviceSelector =
                (ServiceSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");

            acResolver =
View Full Code Here

                getLogger().debug("Parameter href = " + href);
            } else {
                getLogger().debug("No Parameter");
            }

            Request request = ObjectModelHelper.getRequest(objectModel);

            String request_uri = request.getRequestURI();
            String sitemap_uri = request.getSitemapURI();
            getLogger().debug("REQUEST URI: " + request_uri);
            getLogger().debug("SITEMAP URI: " + sitemap_uri);

            context = request.getContextPath();

            String context_publication = context + "/" + publication;
            int port = request.getServerPort();
            String cocoon_base_request = "http://" + domain + ":" + port + context_publication;
            getLogger().debug("COCOON_BASE_REQUEST: " + cocoon_base_request);

            if (href != null) {
                return new org.apache.lenya.xml.XPSAssembler().assemble(doc, sitemapPath + href,
View Full Code Here

        Map objectModel,
        String src,
        Parameters parameters)
        throws Exception {
        // Get request object
        Request request = ObjectModelHelper.getRequest(objectModel);

        if (request == null) {
            getLogger().error(".act(): No request object");

            return null;
        }

        PageEnvelope envelope = null;
        Publication publication = null;

        try {
            envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            publication = envelope.getPublication();
            document = envelope.getDocument();
        } catch (Exception e) {
            getLogger().error("Resolving page envelope failed: ", e);
            throw e;
        }

        //get Parameters for RC
        String publicationPath = publication.getDirectory().getAbsolutePath();
        RCEnvironment rcEnvironment =
            RCEnvironment.getInstance(publication.getServletContext().getAbsolutePath());
        rcmlDirectory = rcEnvironment.getRCMLDirectory();
        rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
        backupDirectory = rcEnvironment.getBackupDirectory();
        backupDirectory = publicationPath + File.separator + backupDirectory;

        // Initialize Revision Controller
        rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
        getLogger().debug("revision controller" + rc);

        // /Initialize Revision Controller
        // Get session
        Session session = request.getSession(false);

        if (session == null) {
            getLogger().error(".act(): No session object");

            return null;
View Full Code Here

        super.act(redirector, resolver, objectModel, src, parameters);

        HashMap actionMap = new HashMap();

        // Get request object
        Request request = ObjectModelHelper.getRequest(objectModel);

        if (request == null) {
            getLogger().error("No request object");

            return null;
        }

        // Get parameters                                                                                                                      
        String rollbackTime = request.getParameter("rollbackTime");

        // Do the rollback to an earlier version
        long newtime = 0;

        try {
            newtime = getRc().rollback(getFilename(), getUsername(), true, Long.parseLong(rollbackTime));
        } catch (FileNotFoundException e) {
            getLogger().error("Unable to roll back!" + e);

            return null;
        } catch (Exception e) {
            getLogger().error("Unable to roll back!" + e);

            return null;
        }

        getLogger().debug("rollback complete, old (and now current) time was " + rollbackTime +
            " backup time is " + newtime);

        String location = request.getHeader("Referer");

        getLogger().debug("redirect to " + location);
        actionMap.put("location", location);

        return actionMap;
View Full Code Here

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Setting up transformer");
            getLogger().debug("    Processed version:       [" + getCurrentDocument() + "]");
        }

        Request request = ObjectModelHelper.getRequest(objectModel);

        this.serviceSelector = null;
        this.acResolver = null;
        this.policyManager = null;
View Full Code Here

    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
        Parameters parameters) throws Exception {
        Publication publication = PublicationFactory.getPublication(objectModel);

        // Get request object
        Request request = ObjectModelHelper.getRequest(objectModel);

        if (request == null) {
            getLogger().error("No request object");

            return null;
        }

        // Get parameters
        //String parentid = request.getParameter("parentid");
        String parentid = request.getParameter("properties.create.parent-id");
        log.debug("properties.create.parent-id = " + parentid);

        //String childid = request.getParameter("childid");
        String childid = request.getParameter("properties.create.child-id");
        log.debug("properties.create.child-id = " + childid);

        //String childname = request.getParameter("childname");
        String childname = request.getParameter("properties.create.child-name");
        log.debug("properties.create.child-name = " + childname);

        //String childtype = request.getParameter("childtype");
        String childtype = request.getParameter("properties.create.child-type");
        log.debug("properties.create.childtype = " + childtype);
       
        //String visibleInNav = request.getParameter("visible");
        String visible = request.getParameter("properties.create.visible");

        boolean visibleInNav = true;
        if (visible.equals("no")){
          visibleInNav = false;
        }
       
        short childType;
        if (childtype.equals("branch")) {
            childType = ParentChildCreatorInterface.BRANCH_NODE;
        } else if (childtype.equals("leaf")) {
            childType = ParentChildCreatorInterface.LEAF_NODE;
        } else {
            log.error("No such child type: " + childtype);
            return null;
        }



        //String doctype = request.getParameter("doctype");
        String doctype = request.getParameter("properties.create.doctype");
        log.debug("poperties.create.doctype = " + doctype);

        //String language = request.getParameter("language");
        String language = request.getParameter("properties.create.language");
        log.debug("poperties.create.language = " + language);
   



        if (!validate(parentid, childid, childname, childtype, doctype)) {
            getLogger().error("Exception: Validation of parameters failed");

            return null;
        }

        // Get session
        Session session = request.getSession(true);

        if (session == null) {
            getLogger().error("No session object");

            return null;
        }

        // Get creator
        ParentChildCreatorInterface creator = null;
        String absoluteDoctypesPath = publication.getDirectory() + File.separator + doctypesPath;
        Document doctypesDoc = new SAXReader().read("file:" + absoluteDoctypesPath +
                "doctypes.xconf");
        Attribute creator_src = (Attribute) doctypesDoc.selectSingleNode("/doctypes/doc[@type='" +
                doctype + "']/creator/@src");

        if (creator_src != null) {
            log.info("Creator found for \"" + doctype + "\": " + creator_src.getName() + " " + creator_src.getPath() + " " + creator_src.getValue());

            // now get the constructor that accepts the configuration
            Class creatorClass = Class.forName(creator_src.getValue());
            creator = (ParentChildCreatorInterface) creatorClass.newInstance();
        } else {
            log.warn("No creator found for \"" + doctype + "\". DefaultBranchCreator will be taken.");
            creator = new org.apache.lenya.cms.authoring.DefaultBranchCreator();
        }

        getLogger().debug(".act(): Creator : " + creator.getClass().getName());

        // Init creator
        // "Read" the configuration from the DOM node
        DefaultConfigurationBuilder defaultConfigBuilder = new DefaultConfigurationBuilder();
        Configuration[] docTypeConfigs = defaultConfigBuilder.buildFromFile(absoluteDoctypesPath +
                "doctypes.xconf").getChildren();

        Configuration doctypeConf = null;

        for (int i = 0; i < docTypeConfigs.length; i++) {
            String typeName = docTypeConfigs[i].getAttribute("type");

            if (typeName.equals(doctype)) {
                doctypeConf = docTypeConfigs[i].getChild("creator", false);
            }
        }

        creator.init(doctypeConf);

        // add a node to the tree
        SiteTree siteTree = publication.getTree(Publication.AUTHORING_AREA);
        Label[] labels = new Label[1];
        labels[0] = new Label(childname, language);
        siteTree.addNode(parentid, creator.generateTreeId(childid, childType), labels, visibleInNav);

        // Transaction should actually be finished here!
        // Create actual document
        // grab all the parameters from session, request params and
        // sitemap params
        HashMap allParameters = new HashMap();
        String[] names = parameters.getNames();

        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            String value = null;

            try {
                value = parameters.getParameter(name);
            } catch (ParameterException pe) {
                value = null;
            }

            allParameters.put(name, value);
        }

        Enumeration requestParameters = request.getParameterNames();

        while (requestParameters.hasMoreElements()) {
            String requestParameterName = (String) requestParameters.nextElement();

            if (allParameters.containsKey(requestParameterName)) {
                // we do not allow name clashes
                throw new ProcessingException("Name clash in request parameter " +
                    "and sitemap parameter: " + requestParameterName);
            }

            allParameters.put(requestParameterName, request.getParameter(requestParameterName));
        }

        Enumeration sessionAttributeNames = session.getAttributeNames();

        while (sessionAttributeNames.hasMoreElements()) {
View Full Code Here

        serviceSelector = null;
        acResolver = null;
        authorizer = null;

        Request request = ObjectModelHelper.getRequest(objectModel);

        try {
            roles = PolicyAuthorizer.getRoles(request);

            publication = PublicationFactory.getPublication(objectModel);
View Full Code Here

        ServiceSelector selector = null;
        AccessControllerResolver resolver = null;
        accessController = null;

        Request request = ObjectModelHelper.getRequest(objectModel);

        Map result = null;

        try {
            selector =
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Request

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.