Package org.apache.wsrp4j.consumer

Examples of org.apache.wsrp4j.consumer.Producer


        return portletKey;
    }

    protected Producer getProducer(String producerID) throws WSRPException {
        ProducerRegistry producerRegistry = getConsumerEnvironment().getProducerRegistry();
        Producer producer = producerRegistry.getProducer(producerID);
        if (producer == null) {
            // Create producer and register it
            RegistrationData regData = new RegistrationData();
            regData.setConsumerName("uPortal WSRP Consumer");
            regData.setConsumerAgent("uPortal WSRP Consumer");
View Full Code Here


     * @return Returns true if the producer could be added.
     */
    public boolean addProducer(ProducerDescription desc) {
        this.checkInitialized();
        try {
            final Producer producer = new ProducerImpl(desc.getId(),
                                        desc.getMarkupInterfaceUrl(),
                                        desc.getServiceDescriptionInterfaceUrl(),
                                        desc.getRegistrationInterfaceUrl(),
                                        desc.getPortletManagementInterfaceUrl(),
                                        desc.getRegistrationData());
            producer.setName(desc.getName());
            producer.setDescription(desc.getDescription());
            this.addProducer(producer);
            return true;
        } catch (WSRPException we) {
            this.logger.error("Unable to add wsrp producer: " + desc.getId()
                            + " - Continuing without configured producer.", we);
View Full Code Here

    public void removeAllProducers() {
        // we only remove all producers if we are initialized
        if ( this.initialized ) {
            Iterator iter = this.descriptions.values().iterator();
            while (iter.hasNext()) {
                final Producer producer = (Producer) iter.next();
                try {
                    producer.deregister();   
                } catch (WSRPException e) {
                    this.logger.error("deregister() producer: " + producer.getName());
                }
            }
        }
        this.descriptions.clear();
        super.removeAllProducers();
View Full Code Here

        if ( producerId == null ) {
            // if the producer can't be found, we simply return
            this.getLogger().error("Producer not configured in wsrp coplet " + copletData.getId());
            return;           
        }
        final Producer producer = consumerEnvironment.getProducerRegistry().getProducer(producerId);
        if ( producer == null ) {
            // if the producer can't be found, we simply return
            this.getLogger().error("Producer with id " + producerId + " not found.");
            return;
        }

        // get the wsrp user and store it as an attribute on the instance
        final String currentUserID = this.service.getComponentManager().getProfileManager().getUser().getUserName();      
        User user = this.consumerEnvironment.getUserRegistry().getUser(currentUserID);
        if ( user == null ) {
            // create a new user
            user = new UserImpl(currentUserID);
            user.setUserContext(this.userContextProvider.createUserContext(currentUserID));
            this.consumerEnvironment.getUserRegistry().addUser(user);
        }
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_USER, user);

        // get the portlet handle
        final String portletHandle = (String) copletData.getAttribute("portlet-handle");
        if ( portletHandle == null ) {
            // if the portlet handle can't be found, we simply return
            this.getLogger().error("Portlet handle not configured in wsrp coplet " + copletData.getId());
            return;           
        }

        // get the wsrp portlet
        final PortletKey portletKey = new PortletKeyImpl(portletHandle, producerId);
        WSRPPortlet wsrpportlet = this.consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
        if ( wsrpportlet == null ) {
            wsrpportlet = new WSRPPortletImpl(portletKey);
            final PortletContext portletContext = new PortletContext(null, portletKey.getPortletHandle(), null);
            wsrpportlet.setPortletContext(portletContext);
            try {
                consumerEnvironment.getPortletRegistry().addPortlet(wsrpportlet);
            } catch (WSRPException we) {
                this.getLogger().error("Exception adding wsrp portlet.", we);
                return;
            }
        }
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY, portletKey);
        final Session session = ObjectModelHelper.getRequest(this.service.getObjectModel()).getSession();
        final String portletInstanceKey = this.getPortletInstanceKey(portletKey, coplet, session.getId());
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY, portletInstanceKey);

        // create consumer parameters
        final Map addParams = new HashMap();
        addParams.put(Constants.PORTLET_INSTANCE_KEY, portletInstanceKey);
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_CONSUMER_MAP, addParams);

        // get the window-state and -mode
        SimplePortletWindowSession windowSession;
        wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);

        try {
            // this call includes the getServiceDescription()-Invocation
            // additionally register() initCookie() and so on will be handled
            // (within ProducerImpl and PortletDriverImpl)
            windowSession = getSimplePortletWindowSession(wsrpportlet,
                                                          portletInstanceKey,
                                                          user);
            final PortletDescription desc = producer.getPortletDescription(portletHandle);
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_TITLE,
                                         desc.getTitle());
            final MarkupType markupType = desc.getMarkupTypes(0);
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_MODES, markupType.getModes());
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_WINDOWSTATES, markupType.getWindowStates());
View Full Code Here

            final String content = markupContext.getMarkupString();

            final Boolean usePipeline;
            final boolean usesGet;
            // If the portlet uses the method get we always have to rewrite form elements
            final Producer producer = this.consumerEnvironment.getProducerRegistry().getProducer(portletKey.getProducerId());
            final PortletDescription desc = producer.getPortletDescription(portletKey.getPortletHandle());
            if ( desc.getUsesMethodGet() != null && desc.getUsesMethodGet().booleanValue() ) {
                usePipeline = Boolean.TRUE;
                usesGet = true;
            } else {
                usePipeline = (Boolean)this.getConfiguration(coplet, "use-pipeline", Boolean.FALSE);
View Full Code Here

      super.logout(coplet);

        PortletKey portletKey = (PortletKey)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY);
        User user = (User)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_USER);
        final String portletInstanceKey = (String)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
        Producer producer = consumerEnvironment.getProducerRegistry().getProducer(portletKey.getProducerId());
       
        // releaseSession()
        try {
            UserSession userSession = consumerEnvironment.getSessionHandler().getUserSession(portletKey.getProducerId(), user.getUserID());
            PortletDescription portletDescription = producer.getPortletDescription(portletKey.getPortletHandle());
            GroupSession groupSession = userSession.getGroupSession(portletDescription.getGroupID());
            PortletSession portletSession = groupSession.getPortletSession(portletInstanceKey);
            SessionContext sessionContext = portletSession.getSessionContext();
            WSRPPortlet wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
            PortletDriver portletDriver = consumerEnvironment.getPortletDriverRegistry().getPortletDriver(wsrpportlet);
View Full Code Here

        if (userSession != null) {
            // get the group session
            String groupID = null;
            try {
                Producer producer = consumerEnvironment.getProducerRegistry().getProducer(portlet.getPortletKey().getProducerId());
                // *********************************
                // getServiceDescription()
                // *********************************
                PortletDescription portletDescription = producer.getPortletDescription(portlet.getPortletKey().getPortletHandle());

                if (portletDescription != null) {
                    groupID = portletDescription.getGroupID();
                }
            } catch (WSRPException e) {
View Full Code Here

     * @return Returns true if the producer could be added.
     */
    public boolean addProducer(ProducerDescription desc) {
        this.checkInitialized();
        try {
            final Producer producer = new ProducerImpl(desc.getId(),
                                        desc.getMarkupInterfaceUrl(),
                                        desc.getServiceDescriptionInterfaceUrl(),
                                        desc.getRegistrationInterfaceUrl(),
                                        desc.getPortletManagementInterfaceUrl(),
                                        desc.getRegistrationData());
            producer.setName(desc.getName());
            producer.setDescription(desc.getDescription());
            this.addProducer(producer);
            return true;
        } catch (WSRPException we) {
            this.logger.error("Unable to add wsrp producer: " + desc.getId()
                            + " - Continuing without configured producer.", we);
View Full Code Here

    public void dispose() {
       
        consumerEnvironment.getPortletRegistry().removeAllPortlets();
       
        Iterator producers = consumerEnvironment.getProducerRegistry().getAllProducers();
        Producer producer;
        while (producers.hasNext()) {
            producer = (Producer) producers.next();
            try {
                producer.deregister();   
            } catch (WSRPException e) {
                this.getLogger().error("deregister() producer: " + producer.getName());
            }
        }
        consumerEnvironment.getProducerRegistry().removeAllProducers();
       
        consumerEnvironment.getUserRegistry().removeAllUsers();
View Full Code Here

        if ( producerId == null ) {
            // if the producer can't be found, we simply return
            this.getLogger().error("Producer not configured in wsrp coplet " + copletData.getId());
            return;           
        }
        final Producer producer = consumerEnvironment.getProducerRegistry().getProducer(producerId);
        if ( producer == null ) {
            // if the producer can't be found, we simply return
            this.getLogger().error("Producer with id " + producerId + " not found.");
            return;
        }

        // get the wsrp user and store it as an attribute on the instance
        final String currentUserID = this.service.getComponentManager().getProfileManager().getUser().getUserName();      
        User user = this.consumerEnvironment.getUserRegistry().getUser(currentUserID);
        if ( user == null ) {
            // create a new user
            user = new UserImpl(currentUserID);
            user.setUserContext(this.userContextProvider.createUserContext(currentUserID));
            this.consumerEnvironment.getUserRegistry().addUser(user);
        }
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_USER, user);

        // get the portlet handle
        final String portletHandle = (String) copletData.getAttribute("portlet-handle");
        if ( portletHandle == null ) {
            // if the portlet handle can't be found, we simply return
            this.getLogger().error("Portlet handle not configured in wsrp coplet " + copletData.getId());
            return;           
        }

        // get the wsrp portlet
        final PortletKey portletKey = new PortletKeyImpl(portletHandle, producerId);
        WSRPPortlet wsrpportlet = this.consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
        if ( wsrpportlet == null ) {
            wsrpportlet = new WSRPPortletImpl(portletKey);
            final PortletContext portletContext = new PortletContext(null, portletKey.getPortletHandle(), null);
            wsrpportlet.setPortletContext(portletContext);
            try {
                consumerEnvironment.getPortletRegistry().addPortlet(wsrpportlet);
            } catch (WSRPException we) {
                this.getLogger().error("Exception adding wsrp portlet.", we);
                return;
            }
        }
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY, portletKey);
        final Session session = ObjectModelHelper.getRequest(this.service.getObjectModel()).getSession();
        final String portletInstanceKey = this.getPortletInstanceKey(portletKey, coplet, session.getId());
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY, portletInstanceKey);

        // create consumer parameters
        final Map addParams = new HashMap();
        addParams.put(Constants.PORTLET_INSTANCE_KEY, portletInstanceKey);
        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_CONSUMER_MAP, addParams);

        // get the window-state and -mode
        SimplePortletWindowSession windowSession;
        wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);

        try {
            // this call includes the getServiceDescription()-Invocation
            // additionally register() initCookie() and so on will be handled
            // (within ProducerImpl and PortletDriverImpl)
            windowSession = getSimplePortletWindowSession(wsrpportlet,
                                                          portletInstanceKey,
                                                          user);
            final PortletDescription desc = producer.getPortletDescription(portletHandle);
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_TITLE,
                                         desc.getTitle());
            final MarkupType markupType = desc.getMarkupTypes(0);
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_MODES, markupType.getModes());
            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_WINDOWSTATES, markupType.getWindowStates());
View Full Code Here

TOP

Related Classes of org.apache.wsrp4j.consumer.Producer

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.