Poblemillas con openseemeese?<br>
<br>
Yo estube haciendo una tarea cron para eso... pero al final lo deje por imposible, lo del jsp rulaba mucho mejor<br><br><div><span class="gmail_quote">2005/5/16, Salvador Santander Gutiérrez <<a href="mailto:salvador.santander@juntadeandalucia.es">
salvador.santander@juntadeandalucia.es</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><font face="Arial" size="2"><span>Hello,
list.</span></font></div>
<div><font face="Arial" size="2"><span>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>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>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></span></font> </div>
<div><font face="Arial" size="2"><span>Anybody can
tell us how to get this? </span></font></div>
<div><font face="Arial" size="2"><span>Thanks very
much.</span></font></div>
<div><font face="Arial" size="2"><span></span></font> </div>
<div><font face="Arial" size="2"><span>The code of the
class:</span></font></div>
<div><font face="Arial" size="2"><span></span></font> </div>
<div><font face="Arial" size="2"><span>package
epsa.admin;</span></font></div>
<div> </div>
<div><font face="Arial" size="2"><span>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>/**<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>
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>
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></span></font> </div>
<div><font face="Arial" size="2"><span></span></font> </div>
<div><font face="Arial" size="2"><span></span></font> </div>
<div><font face="Arial" size="2"><span>package
epsa.admin;</span></font></div>
<div> </div>
<div><font face="Arial" size="2"><span>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><br>public class
EpsaAdminDatabaseImportThread extends A_CmsReportThread {</span></font></div>
<div> </div>
<div><font face="Arial" size="2"><span>
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>
/**<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>
/**<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>
/**<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> </span></font></div>
<br><br><br>_______________________________________________<br>This mail is send to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.opencms.org/mailman/listinfo/opencms-dev" target="_blank">
http://mail.opencms.org/mailman/listinfo/opencms-dev</a><br><br></blockquote></div><br><br><br>-- <br>Juan David Ayllón Burguillo