[opencms-dev] Validating links even for published pages

Christian Steinert christian_steinert at web.de
Fri Feb 2 01:42:11 CET 2007


Arash, Jonathan,

thank you for your answers. I think I really stick to touching files
without changing their date.
I am definitely looking forward to the content relationship engine, even
though this will have to mean, that existent URLs will have to be replaced

regards
christian



P.S. if anybody else needs a script that touches all files on the
website, here is my code (all files in /sites/default have to be locked
before running the script, otherwise you will probably get lots of error
messages).

______________________ 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 --------------
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/20070202/353b7555/attachment.bin>


More information about the opencms-dev mailing list