Package org.apache.cocoon.sunshine.connector

Examples of org.apache.cocoon.sunshine.connector.Resource


                } catch (javax.xml.transform.TransformerException local) {
                    throw new ProcessingException("Transformer exception: " + local, local);
                }
            }
            if (user == null || node == null) {
                final Resource newUserResource = this.handler.getNewUserResource();
                final SourceParameters newUsersPars = newUserResource.getResourceParameters();
                if (parameters == null) parameters = new SourceParameters();
                parameters.add(newUsersPars);

                if (this.applicationName != null)
                    parameters.setSingleParameterValue("application", this.applicationName);
                parameters.setSingleParameterValue("type", "user");
                parameters.setSingleParameterValue("role", role);
                parameters.setSingleParameterValue("ID", ID);

                this.getResourceConnector().loadXML(newUserResource.getResourceType(), null,
                                                    newUserResource.getResourceIdentifier(), parameters);
                result = true;
            }
        }

        if (this.getLogger().isDebugEnabled() == true) {
View Full Code Here


        // calling method is syned
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN deleteRole role="+name+", parameters="+parameters);
        }
        if (this.handler != null && this.handler.getDeleteRoleResource() != null) {
            final Resource deleteRoleResource = this.handler.getDeleteRoleResource();
            final SourceParameters handlerPars = deleteRoleResource.getResourceParameters();
            if (parameters == null) parameters = new SourceParameters();
            parameters.add(handlerPars);

            if (this.applicationName != null)
                parameters.setSingleParameterValue("application", this.applicationName);
            parameters.setSingleParameterValue("type", "role");
            parameters.setSingleParameterValue("role", name);

            this.getResourceConnector().loadXML(deleteRoleResource.getResourceType(), null,
                                                deleteRoleResource.getResourceIdentifier(), parameters);
        }

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END deleteRole");
        }
View Full Code Here

        // calling method is syned
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN deleteUser role="+role+", ID="+name+", parameters="+parameters);
        }
        if (this.handler != null && this.handler.getDeleteUserResource() != null) {
            final Resource deleteUserResource = this.handler.getDeleteUserResource();
            final SourceParameters handlerPars = deleteUserResource.getResourceParameters();
            if (parameters == null) parameters = new SourceParameters();
            parameters.add(handlerPars);

            if (this.applicationName != null)
                parameters.setSingleParameterValue("application", this.applicationName);
            parameters.setSingleParameterValue("type", "user");
            parameters.setSingleParameterValue("role", role);
            parameters.setSingleParameterValue("ID", name);

            this.getResourceConnector().loadXML(deleteUserResource.getResourceType(), null,
                                                deleteUserResource.getResourceIdentifier(), parameters);
        }

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END deleteUser");
        }
View Full Code Here

        // calling method is syned
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN changeUser role="+role+", ID="+name+", parameters="+parameters);
        }
        if (this.handler != null && this.handler.getChangeUserResource() != null) {
            final Resource changeUserResource = this.handler.getChangeUserResource();
            final SourceParameters handlerPars = changeUserResource.getResourceParameters();
            if (parameters == null) parameters = new SourceParameters();
            parameters.add(handlerPars);

            if (this.applicationName != null)
                parameters.setSingleParameterValue("application", this.applicationName);
            parameters.setSingleParameterValue("type", "user");
            parameters.setSingleParameterValue("role", role);
            parameters.setSingleParameterValue("ID", name);

            this.getResourceConnector().loadXML(changeUserResource.getResourceType(), null,
                                                changeUserResource.getResourceIdentifier(), parameters);
        }

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END changeUser");
        }
View Full Code Here

        Object o = this.getSunShineComponent().getSession(true);
        synchronized(o) {

            if (appHandler.getIsLoaded(context) == false) {

                final Resource loadResource     = appHandler.getLoadResource();
                final String   loadResourceName = loadResource.getResourceIdentifier();
                final int      loadResourceType = loadResource.getResourceType();
                SourceParameters parameters = loadResource.getResourceParameters();
                if (parameters != null) parameters = (SourceParameters)parameters.clone();
                parameters = this.createParameters(parameters,
                                                   appHandler.getHandler().getName(),
                                                   path,
                                                   appHandler.getName());
View Full Code Here

        try {
            // Determine the resource to load
            // If the sunLet is customizable and has no customization info
            // the customization resource is loaded, otherwise the resource
            Resource resource = null;
            boolean showCustomizePage = p.getParameterAsBoolean(Constants.PARAMETER_CUSTOMIZE, false);
            if (showCustomizePage == true) {
                final String value = XMLUtil.getValueOf(sunletConf, "customization/@uri", null);
                if (value == null) {
                    this.logger.error("The sunLet '"+this.sunletID+"' is customizable but has no customization info.");
                }
                resource = new Resource(this.resolver, value);
            }
            if (resource == null) {
                resource = new Resource(this.resolver, XMLUtil.getValueOf(sunletConf, "resource/@uri"));
            }
            boolean handlesSizable = XMLUtil.getValueAsBooleanOf(sunletConf, "configuration/handlesSizable", false);

            if (handlesSizable == false && p.getParameter("size", "max").equals("max") == false) {
                // do nothing here
                loadedSunlet[0] = new byte[0];
            } else {

                compiler = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                compiler.startDocument();

                XMLConsumer nextConsumer = compiler;
                NodeList transformations = XMLUtil.selectNodeList(sunletConf,
                                                        "transformation/stylesheet");
                Transformer xslT = null;
                ArrayList transformers = new ArrayList();
                ComponentSelector selector = null;
                Request request = ObjectModelHelper.getRequest(this.objectModel);

                try {
                    if (transformations != null && transformations.getLength() > 0) {
                        selector = (ComponentSelector) this.manager.lookup(Transformer.ROLE + "Selector");
                        nextConsumer = new IncludeXMLConsumer(nextConsumer);
                        for(int k = transformations.getLength()-1; k >=0; k--) {
                            xslT = (Transformer)selector.select("xslt");
                            transformers.add(xslT);
                            xslT.setup(resolver,
                                       objectModel,
                                       XMLUtil.getValueOfNode(transformations.item(k)),
                                       new Parameters());
                            xslT.setConsumer(nextConsumer);
                            nextConsumer = xslT;
                        }
                        nextConsumer.startDocument();
                    }
                    switch (resource.getResourceType()) {
                        case ResourceConnector.RESOURCE_TYPE_CLASS: {
                             Sunlet theSunlet;
                             try {
                                 Class loaderClass = Class.forName(resource.getResourceIdentifier());
                                 theSunlet = (Sunlet)loaderClass.newInstance();
                             } catch (ClassNotFoundException cnfException) {
                                 throw new ProcessingException("getSunlet: Class not found: " + resource.getResourceIdentifier(), cnfException);
                             } catch (IllegalAccessException iaException) {
                                 throw new ProcessingException("getSunlet: Illegal Access: " + resource.getResourceIdentifier(), iaException);
                             } catch (InstantiationException iException) {
                                 throw new ProcessingException("getSunlet: Instantion exception: " + resource.getResourceIdentifier(), iException);
                             }
                             theSunlet.init(objectModel, p);
                             theSunlet.execute(nextConsumer, nextConsumer, objectModel, p);
                             break;
                        }
                        default: {
                            boolean includeFragment = true;
                            boolean handlesParameters = XMLUtil.getValueAsBooleanOf(sunletConf, "configuration/handlesParameters", true);
                            String size = p.getParameter("size", "max");
                            if (resource.getResourceType() == ResourceConnector.RESOURCE_TYPE_FILE) {
                                // files have no possibility to evaluate minimized, so if they are not maximized
                                // they will be neglected
                                includeFragment = size.equals("max");

                            } else {
                                includeFragment = size.equals("max");
                                if (includeFragment == false) {
                                    if (this.logger.isWarnEnabled() == true) {
                                        this.logger.warn("Minimized sunlet '"+sunletID+"' not handled correctly.");
                                    }
                                }
                            }
                            if ( includeFragment == true) {
                                String res;

                                if (resource.getResourceType() == ResourceConnector.RESOURCE_TYPE_URI) {
                                     if (this.response != null) {
                                         res = this.response.encodeURL(resource.getResourceIdentifier());
                                     } else {
                                         res = resource.getResourceIdentifier();
                                     }
                                } else {
                                     res = resource.getResourceIdentifier();
                                }
                                if (this.logger.isDebugEnabled() == true) {
                                    this.logger.debug("sunSpot Loading sunlet " + sunletID);
                                }
                                // add the parameters to the request attributes
                                Map info = new HashMap(3);
                                SessionContextImpl.sunLetInfo.set(info);
                                info.put(Constants.SUNLETINFO_PARAMETERS, p);
                                info.put(Constants.SUNLETINFO_PORTALURI, request.getRequestURI());
                                info.put(Constants.SUNLETINFO_STATUSPROFILE, loadedSunlet[7]);
                                this.resourceConnector.streamXML(resource.getResourceType(), null,
                                           res, (handlesParameters == true ? p : null),
                                             new IncludeXMLConsumer(nextConsumer), null);
                                if (this.logger.isDebugEnabled() == true) {
                                    this.logger.debug("sunSpot: Loaded sunlet " + sunletID);
                                }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.sunshine.connector.Resource

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.