Package org.apache.cocoon.portal

Examples of org.apache.cocoon.portal.PortalService


   
    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
     */
    public PortalUser getUser() {
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            final String layoutKey = service.getDefaultLayoutKey();
            final UserInfo info = this.provider.getUserInfo(service.getPortalName(), layoutKey);
            return info;
        } catch (Exception ce) {
            throw new CascadingRuntimeException("Exception during getUser().", ce);
        } finally {
            this.manager.release(service);
View Full Code Here


    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstanceDatas(java.lang.String)
     */
    public void saveUserCopletInstanceDatas(String layoutKey) {
        ProfileLS adapter = null;
        PortalService service = null;
        try {
            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            if (layoutKey == null) {
                layoutKey = service.getDefaultLayoutKey();
            }

            final RequestState state = this.getRequestState();
            final UserHandler handler = state.getHandler();

            final HashMap parameters = new HashMap();
            parameters.put("type", "user");
            parameters.put("config", state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
            parameters.put("handler", handler);
            parameters.put("profiletype", "copletinstancedata");

            final Map key = this.buildKey(service, parameters, layoutKey, false);

            final  CopletInstanceDataManager profileManager = ((CopletInstanceDataManager) service.getAttribute("CopletInstanceData:" +
                layoutKey));
            adapter.saveProfile(key, parameters, profileManager);
        } catch (Exception e) {
            // TODO
            throw new CascadingRuntimeException("Exception during save profile", e);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(java.lang.String)
     */
    public void saveUserLayout(String layoutKey) {
        ProfileLS adapter = null;
        PortalService service = null;
        try {
            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            if ( layoutKey == null ) {
                layoutKey = service.getDefaultLayoutKey();
            }

            final RequestState state = this.getRequestState();
            final UserHandler handler = state.getHandler();

            final HashMap parameters = new HashMap();
            parameters.put("type", "user");
            parameters.put("config", state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
            parameters.put("handler", handler);
            parameters.put("profiletype", "layout");

            final Map key = this.buildKey(service, parameters, layoutKey, false);
            final Layout layout = (Layout)service.getAttribute("Layout:" + layoutKey);
            adapter.saveProfile(key, parameters, layout);
           
        } catch (Exception e) {
            // TODO
            throw new CascadingRuntimeException("Exception during save profile", e);
View Full Code Here

   
    /**
     * @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) {
                layoutKey = service.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

       
    /* (non-Javadoc)
     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDatas()
     */
    public Collection getCopletDatas() {
        PortalService service = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);
            return this.getCopletDataManager(service).getCopletData().values();
        } catch (Exception e) {
            throw new CascadingRuntimeException("Error in getCopletDatas.", e);
View Full Code Here

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

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

            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

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.