public class ProducerContent extends Producer {
- private String contentTemplate = MirConfig.getProp("Producer.Content.Template");
+ private String contentTemplate=MirConfig.getProp("Producer.Content.Template");
public static void main(String argv[]){
/**
* from cron-script. In that case the config has to be initliased.
* Don't know if is ok that way //rk
*
+ * ok, i figured that out a few months ago.. -mh
+ *
*/
//Configuration.initConfig("config");
System.out.println(MirConfig.getProp("Producer.DocRoot"));
}
public void handle(PrintWriter htmlout, EntityUsers user, boolean force,
- boolean sync, String id) throws StorageObjectException, ModuleException
+ boolean sync, String id) throws StorageObjectException,
+ ModuleException
{
long startTime = System.currentTimeMillis();
EntityList batchEntityList;
EntityUsers userEntity=null;
+ int contentBatchsize =
+ Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
// production of the content-pages
/** @todo this should be moved to ModuleContent */
// if true: produces a single content item
if(id !=null){
whereClause += " AND id="+id;
+ // I think this avoids a select count(*)...
+ contentBatchsize=-1;
}
batchEntityList = contentModule.getContent(whereClause, orderBy, 0,
- -1, userEntity);
+ contentBatchsize, userEntity);
} else {
whereClause="is_produced='0' AND is_published='1'";
//if true produces a single contentitem
if(id !=null){
whereClause += " AND id="+id;
+ // I think this avoids a select count(*)...
+ contentBatchsize=-1;
}
batchEntityList = contentModule.getContent(whereClause, orderBy, 0,
- -1, userEntity);
+ contentBatchsize, userEntity);
}
- if (batchEntityList!=null) {
+ while (batchEntityList!=null) {
for(int i=0;i<batchEntityList.size();i++) {
currentContent = (EntityContent)batchEntityList.elementAt(i);
}
catch(Exception e)
{
- String errorText = "Producer.Content ERROR while producing content ID:"
+ String errorText = "Producer.Content <font color=red>ERROR</font> while producing content ID:"
+ currentContent.getId()+", skipping it :: "+e.toString();
logHTML(htmlout, errorText);
theLog.printError(errorText);
}
pageCount++;
}//for
+ // if next batch get it...
+ if (batchEntityList.hasNextBatch()){
+ batchEntityList = contentModule.getByWhereClause(whereClause,
+ null, batchEntityList.getNextBatch(),
+ contentBatchsize);
+ } else {
+ batchEntityList=null;
+ }
+
}