Re: Cache settings

astik <[email protected]>
Newsgroups gmane.comp.cms.infoglue.devel
Message-ID <[email protected]>
In fact that is a little more complex to do ...
Setting the infogluePrincipalRoles has to be done also when  
authenticating ...
I had to override ExtranetLoginAction

I did a utils method to handle the session attribute settings :
	public static void setRoleKeyIntoSession(final HttpSession  
httpSession) {
		InfoGluePrincipal infoGluePrincipal = (InfoGluePrincipal)  
httpSession.getAttribute("infogluePrincipal");
		// set the user role into a session attribute
		if (infoGluePrincipal != null) {
			String roleKey = "";
			List roleList = infoGluePrincipal.getRoles();
			Iterator<InfoGlueRole> itRole = roleList.iterator();
			while (itRole.hasNext()) {
				InfoGlueRole infoGlueRole = (InfoGlueRole) itRole.next();
				roleKey += "+" + infoGlueRole.getName();
			}
			httpSession.setAttribute("infogluePrincipalRoles", roleKey);
		}
	}

One thing to know ... you can override  
org.infoglue.deliver.applications.actions.ExtranetLoginAction  
directly, because it's a final class ....

__
Romain
http://blog.astik.info

Le 22 sept. 2009 à 14:21, astik a écrit :

> Hi all,
> It seems there is an error with page cache settings. By default, page
> cache key is defined in deliver.properties :
> pageKey=$siteNodeId_$languageId_$contentId_$queryString_
> $session.principal
>
> With that default parameter, whatever access right I set, the page is
> defined by the first user who visit it. When the first user get the
> page, the cache is set whater right the user have.
>
> Here are the attributes available in my session :
> {
> LanguageId=4,
> infoglueRemoteUser=administrator,
> infogluePrincipal=administrator,
> javax.servlet.jsp.jstl.fmt.request.charset=ISO-8859-1,
> cmsUserName=administrator
> }
>
> So, I guess page cache key should be : $siteNodeId_$languageId_
> $contentId_$queryString_$session.infogluePrincipal
>
> After this little change into the ServerNode properties or into page
> cache key, it works great, only allowed content are retrieve.
>
> If we want to go farest, I'd like to set the page key so that each
> role has a different cache, not each user. This way I could reduce a
> lot memory consumption.
> The page key is set this way for session attribute :
> pageKey = pageKey.replaceAll("\\$session." + sessionAttribute, "" +
> session.getAttribute(sessionAttribute));
>
> Is there a way to user session's infogluePrincipal attributes ?
> If not, I may need a new attribute into the user session ... I think I
> will override ViewPageAction.handleExtranetLogic to be something like
> this :
> 	@Override
> 	public boolean handleExtranetLogic(Database db, boolean gateway)
> throws SystemException, Exception {
> 		boolean isRedirected = super.handleExtranetLogic(db, gateway);
> 		setRoleKeyIntoSession();
> 		return isRedirected;
> 	}
>
> 	@Override
> 	public boolean handleExtranetLogic(Database db, Integer repositoryId,
> Integer protectedSiteNodeVersionId, boolean protectDeliver, boolean
> forceCmsUser) throws SystemException, Exception {
> 		boolean isRedirected = super.handleExtranetLogic(db, repositoryId,
> protectedSiteNodeVersionId, protectDeliver, forceCmsUser);
> 		setRoleKeyIntoSession();
> 		return isRedirected;
> 	}
>
> 	@SuppressWarnings("unchecked")
> 	private void setRoleKeyIntoSession() {
> 		// set the user role into a session attribute
> 		InfoGluePrincipal principal = getInfoGluePrincipal();
> 		if (principal != null) {
> 			String roleKey = "";
> 			List roleList = principal.getRoles();
> 			Iterator<InfoGlueRole> itRole = roleList.iterator();
> 			while (itRole.hasNext()) {
> 				InfoGlueRole infoGlueRole = (InfoGlueRole) itRole.next();
> 				roleKey += infoGlueRole.getName();
> 			}
> 			this.getHttpSession().setAttribute("infogluePrincipalRoles",
> roleKey);
> 		}
> 	}
> All I have to do is change the actions.xml to make it use my new
> ViewPageAction.
>
> My new page cache key will be : $siteNodeId_$languageId_$contentId_
> $queryString_$session.infogluePrincipalRole for page that depends on
> role (by default, set in serverNodeProperties) and $siteNodeId_
> $languageId_$contentId_$queryString_$session.infogluePrincipal for
> user specific page (set in sitenode cover).
>
> It would be really cool if this kind of settings could be available
> with IG without redefining ViewPageAction.
>
> By the way, the solution to make it work with group is the same.
>
> Any opinion on this feature ?
>
> Tcho


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.