Package org.apache.cocoon.portal.profile

Examples of org.apache.cocoon.portal.profile.ProfileLS


    /**
     * @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);

View Full Code Here


            (CopletInstanceDataManager) this.copletInstanceDataManagers.get(portalName);
        if (copletInstanceDataManager != null) {
            return copletInstanceDataManager;
        }
       
        ProfileLS adapter = null;
        try {
            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);

            Map parameters = new HashMap();
            parameters.put("profiletype", "copletbasedata");
            parameters.put("objectmap", null);

            Map map = new LinkedMap();
            map.put("base", this.profilesPath);
            map.put("portalname", service.getPortalName());
            map.put("profile", "coplet");
            map.put("name", "basedata");
            CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager) adapter.loadProfile(map, parameters);

            //CopletData
            parameters.clear();
            parameters.put("profiletype", "copletdata");
            parameters.put("objectmap", copletBaseDataManager.getCopletBaseData());

            map.clear();
            map.put("base", this.profilesPath);
            map.put("portalname", service.getPortalName());
            map.put("profile", "coplet");
            map.put("name", "data");
            CopletDataManager copletDataManager = (CopletDataManager) adapter.loadProfile(map, parameters);

            //CopletInstanceData
            parameters.clear();
            parameters.put("profiletype", "copletinstancedata");
            parameters.put("objectmap", copletDataManager.getCopletData());

            map.clear();
            map.put("base", this.profilesPath);
            map.put("portalname", service.getPortalName());
            map.put("profile", "coplet");
            map.put("name", "instancedata");
            copletInstanceDataManager = (CopletInstanceDataManager) adapter.loadProfile(map, parameters);

            CopletFactory copletFactory = service.getComponentManager().getCopletFactory();
            Iterator iterator = copletDataManager.getCopletData().values().iterator();
            while (iterator.hasNext()) {
                CopletData cd = (CopletData) iterator.next();
View Full Code Here

        return layout;
    }
   
    public void saveUserProfiles() {
        final String layoutKey = this.getDefaultLayoutKey();
    ProfileLS adapter = null;
    PortalService service = null;
    try {
      adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
      service = (PortalService) this.manager.lookup(PortalService.ROLE);
           
            RequestState state = this.getRequestState();
            UserHandler handler = state.getHandler();

      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");

      Map key = this.buildKey(service, parameters, layoutKey, false);
 
      // save coplet instance data
            CopletInstanceDataManager profileManager = ((CopletInstanceDataManager)service.getAttribute("CopletInstanceData:" + layoutKey));
      adapter.saveProfile(key, parameters, profileManager);

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

                keyMap = this.buildKey(service, parameters, layoutKey, true);
        result = this.loadProfile(keyMap, parameters, factory);
      }
     
      // save profile as user profile
      ProfileLS adapter = null;
      try {
        adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
                parameters.put("type", "user");
                keyMap = this.buildKey(service, parameters, layoutKey, false);
       
View Full Code Here

                                 boolean forcedLoad,
                                 PortalService service)
  throws Exception {
        final Map key = this.buildKey(service, parameters, layoutKey, true);

        ProfileLS adapter = null;
    try {
      adapter = (ProfileLS)this.manager.lookup(ProfileLS.ROLE);

      Object result = this.checkValidity(key, parameters, forcedLoad, adapter);
           
      if (!(result instanceof SourceValidity))
        return new Object[]{result, Boolean.FALSE};
      SourceValidity newValidity = (SourceValidity)result;

      this.lock.releaseReadLock();
      this.lock.writeLock();
     
      // check validity again in case of another thread has already loaded
      result = this.checkValidity(key, parameters, forcedLoad, adapter);
           
      if (!(result instanceof SourceValidity))
        return new Object[]{result, Boolean.FALSE};
      newValidity = (SourceValidity)result;

      Object object = adapter.loadProfile(key, parameters);
      this.prepareObject(object, factory);
      if (newValidity != null) {
                this.attributes.put(key, new Object[] {object, newValidity});
      }
View Full Code Here

  /**
   * Loads a profile.
   */
    protected Object loadProfile(Object key, Map map, Object factory)
  throws Exception {
        ProfileLS adapter = null;
    try {
      adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);

      Object object = adapter.loadProfile(key, map);
      this.prepareObject(object, factory);

      return object;
    } finally {
      this.manager.release(adapter);
View Full Code Here

     * Load the profile
     */
    protected UserProfile loadProfile(final String layoutKey, final PortalService service)
    throws Exception {
        final UserInfo info = this.provider.getUserInfo(service.getPortalName(), layoutKey);
        ProfileLS loader = null;
        try {
            loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
            final UserProfile profile = new UserProfile();
            this.storeUserProfile(layoutKey, service, profile);
           
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);
        } finally {
            this.manager.release(adapter);
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);
        } finally {
View Full Code Here

                keyMap = this.buildKey(service, parameters, layoutKey, true);
        result = this.loadProfile(keyMap, parameters, factory);
      }
     
      // save profile as user profile
      ProfileLS adapter = null;
      try {
        adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
                parameters.put("type", "user");
                keyMap = this.buildKey(service, parameters, layoutKey, false);
       
View Full Code Here

TOP

Related Classes of org.apache.cocoon.portal.profile.ProfileLS

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.