Package org.apache.cocoon.portal.coplet

Examples of org.apache.cocoon.portal.coplet.CopletData


    public void resetValue(Object object) {
        ((CopletDataManager) object).getCopletData().clear();
    }

    public void setValue(Object object, Object value) {
        CopletData data = (CopletData) value;
        ((CopletDataManager) object).getCopletData().put(data.getId(), data);
    }
View Full Code Here


               
                ContentItem ci = (ContentItem)event.getItem();
                CopletLayout layout = (CopletLayout) event.getLayout();
                CopletInstanceData cid = null;
                if ( ci.isContent() ) {
                    CopletData copletData = service.getComponentManager().getProfileManager().getCopletData(event.getCopletDataId());
                    cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
                    cid.setAttribute("item-content", ci.getContent());               
                } else {
                    if ( ci.getURL() != null ) {
                        SourceResolver resolver = null;
                        Source source = null;
                        String url = null;
                        try {
                            resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
                            url = ci.getURL();
                            source = resolver.resolveURI(url);
                            CopletData copletData = service.getComponentManager().getProfileManager().getCopletData(event.getCopletDataId());
                            cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
                            cid.setAttribute("item-content", IOUtils.toByteArray(source.getInputStream()));
                        } catch (IOException se) {
                            this.getLogger().warn("Unable to get content for " + url, se);
                        } catch (ServiceException se) {
                            this.getLogger().warn("Unable to get source resolver.", se);
                        } finally {
                            if ( source != null ) {
                                resolver.release(source);
                            }
                            this.manager.release(resolver);
                        }
                       
                    } else {
                        final CopletInstanceData original = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId());
                        final CopletData copletData = original.getCopletData();
                        cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
                        Map attributes = (Map) ci.getAttribute("coplet-attributes");
                        Iterator i = attributes.entrySet().iterator();
                        while ( i.hasNext() ) {
                            Map.Entry entry = (Map.Entry)i.next();
View Full Code Here

     * Get a configuration value
     * First the coplet data is queried and if it doesn't provide an
     * attribute with the given name, the coplet base data is used.
     */
    protected Object getConfiguration(CopletInstanceData coplet, String key) {
        CopletData copletData = coplet.getCopletData();
        Object data = copletData.getAttribute( key );
        if ( data == null) {
            data = copletData.getCopletBaseData().getCopletConfig().get( key );
        }
        return data;
    }
View Full Code Here

        ProfileManager profileManager = null;
        try {
            profileManager =
                (ProfileManager) this.manager.lookup(ProfileManager.ROLE);

            CopletData copletData = coplet.getCopletData();

            LayoutFactory lfac =
                (LayoutFactory) this.manager.lookup(LayoutFactory.ROLE);

            CopletLayout copletLayout =
View Full Code Here

     * @see org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter#login(org.apache.cocoon.portal.coplet.CopletInstanceData)
     */
    public void login(CopletInstanceData coplet) {
        super.login(coplet);

        final CopletData copletData = coplet.getCopletData();

        // get the producer
        final String producerId = (String) copletData.getAttribute("producer-id");
        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);
View Full Code Here

    /**
     * @see Receiver
     */
    public void inform(CopletDataEvent e, PortalService service) {
        CopletData data = (CopletData)e.getTarget();
        List instances = null;

        ProfileManager profileManager = service.getComponentManager().getProfileManager();
        instances = profileManager.getCopletInstanceData(data);

View Full Code Here

* @version CVS $Id: CopletDataReferenceFieldHandler.java 123407 2004-12-27 13:51:59Z cziegeler $
*/
public class CopletDataReferenceFieldHandler extends ReferenceFieldHandler {

    public Object getValue(Object object) {
        CopletData copletData = ((CopletInstanceData) object).getCopletData();
        if (copletData != null) {
            return copletData.getId();
        }
        return null;
    }
View Full Code Here

        }
        return null;
    }

    public Object newInstance(Object parent) {
        return new CopletData();
    }
View Full Code Here

    public void resetValue(Object object) {
        ((CopletInstanceData) object).setCopletData(null);
    }

    public void setValue(Object object, Object value) {
        CopletData copletData = (CopletData) getObjectMap().get(value);
        if (copletData == null) {
            throw new ProfileException(
                "Referenced Coplet Data " + value + " does not exist.");
        }
        ((CopletInstanceData) object).setCopletData(copletData);
View Full Code Here

        return result;
    }

    public Object newInstance(Object parent) {
        return new CopletData();
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.portal.coplet.CopletData

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.