<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>Hello, 
list.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>We've developed a 
cron task for import certain resources from other opencms server. We've got this 
developing a java class and calling it from the Cron tasks in OpenCMS 
Administration View.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>All goes well, the 
task import the resources, publish them, but they're not exported to html pages 
(static export). When we login in opencms, we check that the new 
resources has been updated. </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>If we call the class 
of the cron task in a jsp page, the resources are exported, but not when 
the class is called from the cron scheduler of OpenCMS.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>Anybody can 
tell us how to get this? </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>Thanks very 
much.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>The code of the 
class:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>package 
epsa.admin;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>import 
java.util.*;<BR>import java.sql.*;<BR>import com.opencms.flex.jsp.*;<BR>import 
com.opencms.file.*;<BR>import com.opencms.workplace.*;<BR>import 
com.opencms.report.*;<BR>import com.opencms.core.*;<BR>import 
com.opencms.file.*;<BR>import epsa.admin.*;<BR>import 
java.io.*;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>/**<BR>* Clase que 
realiza la exportacion de contenidos de internet<BR>* @author Salvador Santander 
Gutiérrez<BR>* @company dominion<BR>*/<BR>public class CronInternetContentImport 
implements I_CmsCronJob {<BR>        
<BR>        
/**<BR>         * Nombre del fichero de 
exportacion<BR>         
*/<BR> String nombreFichero    = 
"/var/tomcat4/webapps/epsa/WEB-INF/export/internetContentExport.zip";<BR>        
String nombreFicheroLog = 
"/var/tomcat4/webapps/epsa/WEB-INF/export/internetContentImported.html";<BR>        
<BR>        private void writeFile( String 
fileName, String scriptSQL 
)<BR>            throws 
FileNotFoundException, IOException<BR>        
{<BR>            
FileOutputStream file = new FileOutputStream( fileName.trim() 
);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005>            
file.write( scriptSQL.getBytes() 
);<BR>            
file.flush();<BR>            
file.close(); <BR>        
}<BR>        <BR> /**<BR>  * Método 
que ejecuta el gestor de tareas de opencms y que 
<BR>         * lanzará la exportación de 
contenidos de internet<BR>  * @param CmsObject cms object.<BR>  * 
@param String Parametros<BR>  * @throws Exception Excepcion. <BR>  
*/<BR> public String launch (CmsObject cms, String params) 
<BR>  throws 
Exception<BR> {<BR>            
StringBuffer mensajeResultado;  // Mensaje que se escribirá en el 
log<BR>         
<BR>            
mensajeResultado    = new 
StringBuffer();<BR>            
<BR>            
try<BR>            
{<BR>                
mensajeResultado.append( " \n----- IMPORTACION DE CONTENIDOS DE INTERNET ------ 
\n" 
);<BR>                
<BR>                
// Comenzamos la 
importacion<BR>                
int projectOfflineId = 
4;<BR>                
int projectOnlineId = 1;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005>                
cms.getRequestContext().setCurrentProject( projectOfflineId 
);<BR>                
EpsaAdminDatabaseImportThread hiloImportacion = new 
EpsaAdminDatabaseImportThread( cms, nombreFichero 
);<BR>                
hiloImportacion.run();<BR>                
writeFile( nombreFicheroLog , hiloImportacion.getReportUpdate() 
);<BR>                
<BR>                
cms.lockResource("/eintranet/", 
true);<BR>                
cms.lockResource("/system/modules/", 
true);<BR>                
cms.lockResource("/system/galleries/", 
true);<BR>                
cms.touch("/eintranet/", new java.util.Date().getTime(), 
true);<BR>                
cms.touch("/system/modules/", new java.util.Date().getTime(), 
true);<BR>                
cms.touch("/system/galleries/", new java.util.Date().getTime(), 
true);<BR>                
cms.unlockResource("/eintranet/");<BR>                
cms.unlockResource("/system/modules/");<BR>                
cms.unlockResource("/system/galleries/");<BR>                
cms.publishResource("/eintranet/");<BR>                
cms.publishResource("/system/modules/");<BR>                
cms.publishResource("/system/galleries/");<BR>                
<BR>                
cms.unlockProject( projectOfflineId 
);<BR>                
cms.publishProject( projectOfflineId );    
<BR>                
<BR>                
cms.getRequestContext().setCurrentProject( projectOnlineId 
);<BR>                
<BR>                
Vector linksToExport = new 
Vector();<BR>                
linksToExport.add("/");<BR>                
cms.exportStaticResources(linksToExport);<BR>                
<BR>            
}<BR>            catch( 
Exception ex 
)<BR>            
{<BR>                
mensajeResultado.append( "\nERROR!!!:\n" 
);<BR>                
mensajeResultado.append( "Mensaje: " + ex.getMessage() + "\n" 
);<BR>                
mensajeResultado.append( "Localizacion: " + ex.getLocalizedMessage() + "\n" 
);<BR>                
mensajeResultado.append( "StackTrace: " + 
com.opencms.util.Utils.getStackTrace(ex) + 
"\n");<BR>                
<BR>                
OpenCms.log(OpenCms.C_OPENCMS_CRITICAL, mensajeResultado.toString() 
);<BR>                
<BR>            
}<BR>            
<BR>            
mensajeResultado.append( " \n----- FIN DE EXPORTACIÓN DE CONTENIDOS DE INTERNET 
------ \n" 
);<BR>            
<BR>            return 
mensajeResultado.toString();<BR> }<BR>}<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=389091709-16052005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>package 
epsa.admin;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>import 
com.opencms.boot.I_CmsLogChannels;<BR>import 
com.opencms.core.A_OpenCms;<BR>import com.opencms.core.CmsException;<BR>import 
com.opencms.core.I_CmsConstants;<BR>import com.opencms.file.CmsObject;<BR>import 
com.opencms.report.A_CmsReportThread;<BR>import 
com.opencms.report.CmsHtmlReport;<BR>import 
com.opencms.report.I_CmsReport;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005><BR>public class 
EpsaAdminDatabaseImportThread extends A_CmsReportThread {</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>    
private String m_existingFile;<BR>    private CmsObject 
m_cms;<BR>    private I_CmsReport m_report;</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>    
/**<BR>     * Imports the 
database.<p><BR>     */<BR>    public 
EpsaAdminDatabaseImportThread(<BR>        
CmsObject cms, <BR>        String 
existingFile<BR>    ) 
{<BR>        m_cms = 
cms;<BR>        
m_cms.getRequestContext().setUpdateSessionEnabled(false);<BR>        
m_existingFile = existingFile;<BR>        
m_report = new CmsHtmlReport("es");<BR>    }</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>    
/**<BR>     * @see 
java.lang.Runnable#run()<BR>     */<BR>    
public void run() {<BR>        try 
{<BR>            
m_report.println(m_report.key("report.import_db_begin"), 
I_CmsReport.C_FORMAT_HEADLINE);            
<BR>            
m_cms.importResources(m_existingFile, I_CmsConstants.C_ROOT, 
m_report);<BR>            
m_report.println(m_report.key("report.import_db_end"), 
I_CmsReport.C_FORMAT_HEADLINE);            
<BR>        
}<BR>        catch(CmsException e) 
{<BR>            
m_report.println(e);<BR>            
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging()) 
{<BR>                
A_OpenCms.log(A_OpenCms.C_OPENCMS_CRITICAL, 
e.getMessage());<BR>            
}<BR>        }<BR>    
}</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=389091709-16052005>    
/**<BR>     * Returns the part of the report that is 
ready.<p><BR>     */<BR>    public 
String getReportUpdate()<BR>    
{<BR>        return 
m_report.getReportUpdate();<BR>    }<BR>}<BR></SPAN></FONT><FONT 
face=Arial size=2><SPAN 
class=389091709-16052005> </SPAN></FONT></DIV></BODY></HTML>