Hi all,
how can I check thought code if the page that I'm currently displaying
is the current version of a page or a previous version?
My problem is that I have a page accessible only under certain
conditions, checked in the page itself, otherwise there is a redirection
to another page. Conditions work great until someone tries to see any
previous version of this page, because you can't interact with versioned
content and so the conditions trigger the redirect.
I came up with two solutions but I'm not satisfied by either of them,
even if they seem to work. The first is to check if the page is in the
version workspace, but I'm not totally sure that the current version is
only in website and not also in the versioning workspace
if (pageOrParagraph != null) {
return
(!StringUtils.equalsIgnoreCase(pageOrParagraph.getWorkspace().getName(),
ContentRepository.VERSION_STORE));
}
The other option is to see if the content is versionable in some way,
but even this left me with the doubt that the current page may be also a
ContentVersion instance:
return (!((pageOrParagraph != null) && ((pageOrParagraph instanceof
ContentVersion) || ((pageOrParagraph instanceof ContentWrapper) &&
(((ContentWrapper) pageOrParagraph).getWrappedContent() instanceof
ContentVersion)))));
Any better ideas? Did I miss some method that would've done the right
check? I'm using Magnolia 4.0.1.
Regards, Danilo.
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------