Package org.apache.cocoon.portal

Examples of org.apache.cocoon.portal.PortalService


        if ( layout instanceof CompositeLayout ) {
            CompositeLayout composite = (CompositeLayout)layout;
            composite.setItemClassName(layoutDescription.getItemClassName());
        }
       
        PortalService service = null;
        try {
            service = (PortalService)this.manager.lookup(PortalService.ROLE);
            service.getComponentManager().getProfileManager().register(layout);
        } catch (ServiceException ce) {
            throw new ProcessingException("Unable to lookup profile manager.", ce);
        } finally {
            this.manager.release( service );
        }
View Full Code Here


            Item parent = layout.getParent();
            if ( parent != null && parent.getParent() != null) {
                parent.getParent().removeItem( parent );
            }
           
            PortalService service = null;
            EventManager eventManager = null;
            try {
                service = (PortalService)this.manager.lookup(PortalService.ROLE);               
                ProfileManager profileManager = service.getComponentManager().getProfileManager();
                if ( layout instanceof CopletLayout ) {
                    // full screen?
                    if ( layout.equals(service.getEntryLayout(null)) ) {
                        Event event = new FullScreenCopletEvent(((CopletLayout)layout).getCopletInstanceData(), null);
                        eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
                        eventManager.getPublisher().publish(event);
                        service.getComponentManager().getLinkService().addEventToLink(event);
                    }
                    CopletFactory factory = service.getComponentManager().getCopletFactory();
                    factory.remove( ((CopletLayout)layout).getCopletInstanceData());
                }
                profileManager.unregister(layout);
            } catch (ServiceException ce) {
                throw new ProcessingException("Unable to lookup portal service.", ce);
View Full Code Here

        if ( UPLOAD_ITEM_ELEMENT.equals(name) ) {
            this.uploadElements.add(attr.getValue("name"));
            this.startElement("", "input", "input", attr);
        } else if ( UPLOAD_FORM_ELEMENT.equals(name) ) {
            AttributesImpl ai = new AttributesImpl(attr);
            PortalService service = null;
            String parameters;
            try {
                service = (PortalService)this.manager.lookup(PortalService.ROLE);
                Event e = new UploadItemEvent(this.basketManager.getFolder(), this.uploadElements);
                parameters = service.getComponentManager().getLinkService().getLinkURI(e);
                int pos = parameters.indexOf('?');
                ai.addCDATAAttribute("action", parameters.substring(0, pos));
                parameters = parameters.substring(pos+1);
            } catch (ServiceException se) {
                throw new SAXException("Unable to lookup portal service.", se);
View Full Code Here

     */
    public void startTransformingElement(String uri, String name,
                                         String raw, Attributes attr)
    throws ProcessingException, IOException, SAXException {
        if ( ADD_ITEM_ELEMENT.equals(name) ) {
            PortalService service = null;
            try {
                service = (PortalService)this.manager.lookup(PortalService.ROLE);

                // do we want to add content or a link?
            boolean addContent = false;
                final String value = attr.getValue("content");
            if ( value != null ) {
                addContent = new Boolean(value).booleanValue();
            }
               
                // do we want to add a url or a coplet?
                final ContentItem ci;
                final String href = attr.getValue("href");           
                if ( href != null ) {
                    ci = new ContentItem(href, addContent);
                } else {
                    final String copletId = attr.getValue("coplet");
                    final CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(copletId);                   
                    ci = new ContentItem(cid, addContent);
            }

                // do we want to add the content to the basket or to the briefcase
                final ContentStore store;
                final String storeName = (attr.getValue("store") == null ? this.defaultStoreName : attr.getValue("store"));
                if ("basket".equalsIgnoreCase(storeName) )     {
                    store = this.basketManager.getBasket();
                } else {
                    store = this.basketManager.getBriefcase();
                }

                final Event e = new AddItemEvent(store, ci);
                final AttributesImpl ai = new AttributesImpl();
                String newLink = service.getComponentManager().getLinkService().getLinkURI(e);
                // check for bockmark
                final String bookmark = attr.getValue("bookmark");
                if ( bookmark != null && bookmark.length() > 0) {
                    int pos = newLink.indexOf('?') + 1;
                    final char separator;
View Full Code Here

  public void showPortal(ContentHandler contentHandler, Parameters parameters)
    throws SAXException {
//        final boolean useContentDeliverer = (parameters == null ? true :
//                                               parameters.getParameterAsBoolean("use-content-deliverer", true));
       
        PortalService service = null;
        try {
            service = (PortalService)this.manager.lookup(PortalService.ROLE);
            Layout portalLayout = service.getComponentManager().getProfileManager().getPortalLayout(null, null);

            Renderer portalLayoutRenderer = service.getComponentManager().getRenderer( portalLayout.getRendererName());      

            contentHandler.startDocument();
            portalLayoutRenderer.toSAX(portalLayout, service, contentHandler);
            contentHandler.endDocument();
        } catch (ServiceException ce) {
View Full Code Here

     * @param event  The event triggering the action
     * @param basket The basket
     */
    protected void processShowItemEvent(ShowItemEvent event, Basket basket) {
        if ( event.getItem() instanceof ContentItem ) {
            PortalService service = null;
            try {
                service = (PortalService) this.manager.lookup(PortalService.ROLE);
               
                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", IOUtil.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 {
                        CopletData copletData = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId()).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();
                            cid.setAttribute(entry.getKey().toString(), entry.getValue());
View Full Code Here

                        }
                        this.manager.release(resolver);
                    }
                } else if ( ci.getURL() == null ) {
                    // copy coplet attributes
                    PortalService service = null;
                    try {
                        service = (PortalService) this.manager.lookup(PortalService.ROLE);
                        CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId());
                        Map attributes = new HashMap();
                        Iterator i = cid.getAttributes().entrySet().iterator();
                        while ( i.hasNext() ) {
                            Map.Entry entry = (Map.Entry)i.next();
                            attributes.put(entry.getKey(), entry.getValue());
View Full Code Here

    throws ProcessingException, SAXException, IOException {
        super.setup(resolver, objectModel, src, par);
       
        // instantiate the portal service for this request
        // and set the portal-name
        PortalService service = null;
        try {
            service = (PortalService)this.manager.lookup(PortalService.ROLE);
            service.setPortalName(par.getParameter("portal-name"));
           
            // This is a fix: if we don't use the link service here, we get
            // in some rare cases a wrong uri!
            service.getComponentManager().getLinkService().getRefreshLinkURI();
           
        } catch (ParameterException pe) {
            throw new ProcessingException("Parameter portal-name is required.");
        } catch (ServiceException ce) {
            throw new ProcessingException("Unable to lookup portal service.", ce);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
     */
    public void logout() {
        final String layoutKey = this.getDefaultLayoutKey();
        PortalService service = null;
        ServiceSelector adapterSelector = null;
        try {
            adapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
            service = (PortalService)this.manager.lookup(PortalService.ROLE);

            CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)service.getAttribute("CopletInstanceData:"+layoutKey);
            if ( copletInstanceDataManager != null ) {
                Iterator iter = copletInstanceDataManager.getCopletInstanceData().values().iterator();
                while ( iter.hasNext() ) {
                    CopletInstanceData cid = (CopletInstanceData) iter.next();
                    CopletAdapter adapter = null;
                    try {
                        adapter = (CopletAdapter)adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
                        adapter.logout( cid );
                    } finally {
                        adapterSelector.release( adapter );
                    }
                }
            }
           
            service.removeAttribute("CopletData:"+layoutKey);
            service.removeAttribute("CopletInstanceData:"+layoutKey);
            service.removeAttribute("Layout:"+layoutKey);
        } catch (ServiceException e) {
            throw new CascadingRuntimeException("Unable to lookup portal service.", e);
        } finally {
            this.manager.release(service);
            this.manager.release(adapterSelector);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
     */
    public CopletInstanceData getCopletInstanceData(String copletID) {
        String layoutKey = this.getDefaultLayoutKey();
        PortalService service = null;
        String attribute = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);

      attribute = "CopletInstanceData:"+layoutKey;
      CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)service.getAttribute(attribute);

            return copletInstanceDataManager.getCopletInstanceData(copletID);
        } catch (ServiceException e) {
            throw new CascadingRuntimeException("Unable to lookup portal service.", e);
        } finally {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.portal.PortalService

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.