Package org.apache.cocoon.portal

Examples of org.apache.cocoon.portal.PortalService


    /**
     * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(String, String)
     */
    public Layout getPortalLayout(String layoutKey, String layoutID) {
        PortalService service = null;
        ProfileLS adapter = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);

            if (layoutKey == null) {
                Layout l = getEntryLayout();
                if (null != l) {
                    return l;
                }
                layoutKey = getDefaultLayoutKey();
            }

            String serviceKey = LAYOUTKEY_PREFIX + layoutKey;
            Object[] objects = (Object[]) service.getAttribute(serviceKey);

            // check if the layout is already cached and still valid
            int valid = SourceValidity.INVALID;
            SourceValidity sourceValidity = null;
            if (objects != null) {
                sourceValidity = (SourceValidity) objects[1];
                valid = sourceValidity.isValid();
                Layout layout = null;
                if (valid == SourceValidity.VALID)
                    layout = (Layout) ((Map) objects[0]).get(layoutID);
                if (layout != null)
                    return layout;
            }

            CopletInstanceDataManager copletInstanceDataManager = getCopletInstanceDataManager(service);

            Map parameters = new HashMap();
            parameters.put("profiletype", "layout");
            parameters.put("objectmap", copletInstanceDataManager.getCopletInstanceData());

            Map map = new LinkedMap();
            map.put("base", this.profilesPath);
            map.put("portalname", service.getPortalName());
            map.put("profile", "layout");
            map.put("groupKey", layoutKey);

            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
            SourceValidity newValidity = adapter.getValidity(map, parameters);
            if (valid == SourceValidity.UNKNOWN) {
                if (sourceValidity.isValid(newValidity) == SourceValidity.VALID) {
                    return (Layout) ((Map) objects[0]).get(layoutID);
                }
            }

            // get Layout specified in the map
            Layout layout = (Layout) adapter.loadProfile(map, parameters);
            Map layouts = new HashMap();

            layouts.put(null, layout); //save root with null as key
            cacheLayouts(layouts, layout);

            LayoutFactory factory = service.getComponentManager().getLayoutFactory();
            factory.prepareLayout(layout);

            // store the new values in the service
            if (newValidity != null) {
                objects = new Object[] { layouts, newValidity };
                service.setAttribute(serviceKey, objects);
            }

            return (Layout) layouts.get(layoutID);
        } catch (Exception ce) {
            throw new CascadingRuntimeException("Unable to get layout.", ce);
View Full Code Here


    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
     */
    public CopletInstanceData getCopletInstanceData(String copletID) {
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            return getCopletInstanceDataManager(service).getCopletInstanceData(copletID);
        } catch (Exception e) {
            throw new CascadingRuntimeException("Error in getCopletInstanceData", e);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletData(java.lang.String)
     */
    public CopletData getCopletData(String copletDataId) {
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);

            Iterator i = getCopletInstanceDataManager(service).getCopletInstanceData().values().iterator();
            boolean found = false;
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(org.apache.cocoon.portal.coplet.CopletData)
     */
    public List getCopletInstanceData(CopletData data) {
        List coplets = new ArrayList();
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            Iterator iter = getCopletInstanceDataManager(service).getCopletInstanceData().values().iterator();
            while (iter.hasNext()){
                CopletInstanceData current = (CopletInstanceData) iter.next();
View Full Code Here

    /**
     * Change the default layout key for most functions
     */
    public void setDefaultLayoutKey(String layoutKey) {
        PortalService service = null;
        try {
            service = (PortalService)this.manager.lookup(PortalService.ROLE);
            if ( layoutKey == null ) {
                service.removeAttribute("default-layout-key");
            } else {
                service.setAttribute("default-layout-key", layoutKey);
            }
        } catch (ServiceException ce) {
            // this should never happen
            throw new CascadingRuntimeException("Unable to lookup portal service.", ce);
        } finally {
View Full Code Here

   
    /**
     * Get the default layout key
     */
    public String getDefaultLayoutKey() {
        PortalService service = null;
        try {
            service = (PortalService)this.manager.lookup(PortalService.ROLE);
            String defaultLayoutKey = (String)service.getAttribute("default-layout-key");
            if ( defaultLayoutKey == null ) {
                return this.defaultLayoutKey;
            }
            return defaultLayoutKey;
        } catch (ServiceException ce) {
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#setEntryLayout(org.apache.cocoon.portal.layout.Layout)
     */
    public void setEntryLayout(Layout object) {
        String layoutKey = this.getDefaultLayoutKey();
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            if ( object == null ) {
                service.removeTemporaryAttribute("DEFAULT_LAYOUT:" + layoutKey);
            } else {
                service.setTemporaryAttribute("DEFAULT_LAYOUT:" + layoutKey, object);
            }
        } catch (ServiceException e) {
            throw new CascadingRuntimeException("Unable to lookup service manager.", e);
        } finally {
            this.manager.release(service);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getEntryLayout()
     */
    public Layout getEntryLayout() {
        String layoutKey = this.getDefaultLayoutKey();
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            return (Layout)service.getTemporaryAttribute("DEFAULT_LAYOUT:" + layoutKey);
        } catch (ServiceException e) {
            throw new CascadingRuntimeException("Unable to lookup service manager.", e);
        } finally {
            this.manager.release(service);
        }
View Full Code Here

    public static CopletInstanceData getInstanceData(ServiceManager manager,
                                                     String copletID,
                                                     String portalName)
    throws ProcessingException {
        // set portal name
        PortalService portalService = null;
        try {
            portalService = (PortalService) manager.lookup(PortalService.ROLE);
            portalService.setPortalName(portalName);
               
            ProfileManager profileManager = portalService.getComponentManager().getProfileManager();
            CopletInstanceData data = profileManager.getCopletInstanceData(copletID);
            return data;
        } catch (ServiceException e) {
            throw new ProcessingException("Error getting portal service.", e);
        } finally {
View Full Code Here

    public static CopletInstanceData getInstanceData(ServiceManager manager,
                                                     Map objectModel,
                                                     Parameters parameters)
    throws ProcessingException {

        PortalService portalService = null;
        try {
            portalService = (PortalService) manager.lookup(PortalService.ROLE);

            // determine coplet id
            String copletId = null;
            Map context = (Map) objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
            if (context != null) {
                copletId = (String) context.get(Constants.COPLET_ID_KEY);
                if (copletId == null) {
                    throw new ProcessingException("copletId must be passed as parameter or in the object model within the parent context.");
                }
            } else {
                try {
                    copletId = parameters.getParameter(COPLET_ID_PARAM);

                    portalService.setPortalName(parameters.getParameter(PORTAL_NAME_PARAM));
                } catch (ParameterException e) {
                    throw new ProcessingException("copletId and portalName must be passed as parameter or in the object model within the parent context.");
                }
            }
            return portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId);
        } catch (ServiceException e) {
            throw new ProcessingException("Error getting portal service.", e);
        } finally {
            manager.release(portalService);
        }
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.