[opencms-dev] Is there a way to (re-)publish the Online Project..?

Christian Steinert christian_steinert at web.de
Mon Feb 19 10:02:09 CET 2007


Chris Stephens schrieb:
> Hi folks,
>  
> We recently had an unusual problem where parts of the published
> webpages were blank in the browser. It transpired that those areas
> corresponded to included JSP elements and that the .java files output
> by Jasper (Tomcat's JSP engine) contained binary characters and hence
> couldn't be compiled into bytecode.
Could it be that your server filesystem gets corrupted? Maybe it's a
good idea to make backups and then run a thorough check...
>  
> Republishing the offending elements fixed the problem. Not sure what
> caused this! The elements had not been published for weeks/months.
did you check the file modification data?
> Part of the OpenCms caching mechanism perhaps..?
No, caching does not touch any files, caching only happens in memory.
And the JSPs in the filesystem should only be re-generated, if they have
changed
> Don't know.
>  
> But one component that was not visible escaped our attention - an
> included JavaScript element that tracked our visitor activity (using
> Omniture, in fact).
>  
> Because our website is a cluster of two servers (using OCEE from
> Alkacon) and because this error was only on one server (not sure if
> this reflects poorly on OCEE or not because I have no idea how the
> binary characters get into the picture) we didn't notice at first and
> thought we were getting reduced traffic. Took me a while to realise it
> was just not being recorded properly!
>  
> The point is: the fix for this problem (which I hope is rare) is to
> re-publish the files. But there is (AFAIK) no way to re-publish the
> Online Project. I can't just publish the Offline one because there are
> always some pages still being worked on.
>  
> Any clues?
You could write a script that touches all files which are not currently
locked so that you can re-publish them.
You can do this in a separate project, so that you can publish that
complete project without publishing anybody's ongoing work. (The same
set of files can be assigned to more than one project. Whenever a file
is changed, it is held by that project from which it was changed last.)

I had posted a JSP which touches *all* files in a folder tree without
modifying their change date. I will append it again.
But this script assumes that the files in question have been locked the
files in question before executing the script. If you want to lock the
files in the script,you would have to add code for that (see javadocs
for classes CmsObject and CmsResource)

If you want to be more careful, then you could call
res.getLock().isNullLock() for each resource first. If isNullLock() 
returns true, then the resource is not currently locked by anybody and
you can safely lock and touch this resource without interfering with
anybody else's work.

My code follows below.

hth
christian



______________________ touch_all_files_without_changing_date.jsp
__________________________________________
<%--
// touch all resources in /sites/default without modifying their change date
// (files must be locked before)
--%>
<%@ page session="true" %>
<%@ page import="org.opencms.file.*" %>
<%@ page import="org.opencms.main.*" %>
<%@ page import="org.opencms.jsp.*" %>
<%@ page import="java.util.*" %>
<html><head>
 <title>touching all resources</title>
 <style type="text/css">
  li{margin:0.5em}
  pre{color:#900000}
 </style>
</head>
<body>

<h1>touching all resources</h1>
<ol>
<%
        CmsJspActionElement cmsA   = new
CmsJspActionElement(pageContext, request, response);
        CmsObject           cms    = cmsA.getCmsObject();
    cms.getRequestContext().setSiteRoot("/sites/default");

    String[] languages = SiteContext.getLanguages(cms,true);

    String srcPath = "/";
    Iterator files;
    WpFileChange fs = WpFileChange.getInstance(cms);

    files =
cms.readResources(srcPath,CmsResourceFilter.DEFAULT,true).iterator();


    while(files.hasNext()) { //check all files in the source language
(English)
        %><li><%
        try{
            CmsResource res = (CmsResource)files.next();
            long changed = res.getDateLastModified();

            String dstFile = res.getRootPath();
            dstFile = cms.getRequestContext().removeSiteRoot( dstFile );
            %><%=dstFile%><%

            cms.touch( dstFile, changed,
CmsResource.TOUCH_DATE_UNCHANGED, CmsResource.TOUCH_DATE_UNCHANGED, false );
        } catch ( CmsException e ) {
            %><pre><%=e%></pre><%
        }
        %></li><%
    }
%>
</ol>
</body>
</html>


______________________ end: touch_all_files_without_changing_date.jsp


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20070219/7fb34855/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3269 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20070219/7fb34855/attachment.bin>


More information about the opencms-dev mailing list