Korrekturen und Formatierungen

git-svn-id: https://svn.libreccm.org/ccm/trunk@946 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-05-31 19:02:37 +00:00
parent 37ada8557f
commit 09eeec3a34
9 changed files with 189 additions and 197 deletions

View File

@ -32,6 +32,7 @@ import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection; import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
/** /**
* *
@ -39,6 +40,8 @@ import com.arsdigita.xml.Element;
*/ */
public class GenericOrganizationalUnitPanel extends CompoundContentItemPanel { public class GenericOrganizationalUnitPanel extends CompoundContentItemPanel {
private final static Logger logger = Logger.getLogger(GenericOrganizationalUnit.class);
public static final String SHOW_CONTACTS = "contacts"; public static final String SHOW_CONTACTS = "contacts";
public static final String SHOW_MEMBERS = "members"; public static final String SHOW_MEMBERS = "members";
private boolean displayContacts = true; private boolean displayContacts = true;
@ -72,6 +75,7 @@ public class GenericOrganizationalUnitPanel extends CompoundContentItemPanel {
protected void generateContactsXML(GenericOrganizationalUnit orga, protected void generateContactsXML(GenericOrganizationalUnit orga,
Element parent, PageState state) { Element parent, PageState state) {
long start = System.currentTimeMillis();
GenericOrganizationalUnitContactCollection contacts; GenericOrganizationalUnitContactCollection contacts;
contacts = orga.getContacts(); contacts = orga.getContacts();
@ -98,6 +102,7 @@ public class GenericOrganizationalUnitPanel extends CompoundContentItemPanel {
Integer.toString(contacts.getContactOrder()), Integer.toString(contacts.getContactOrder()),
true); true);
} }
System.out.printf("Generated Contacts XML in %d ms.\n", System.currentTimeMillis() - start);
} }
protected void generateMembersXML(GenericOrganizationalUnit orga, protected void generateMembersXML(GenericOrganizationalUnit orga,

View File

@ -38,7 +38,6 @@ import java.math.BigDecimal;
import java.util.HashSet; import java.util.HashSet;
import java.io.File; import java.io.File;
/** /**
* Class for queuing tasks for publishing and unpublishing to * Class for queuing tasks for publishing and unpublishing to
* the file system and for processing the queue. When processing * the file system and for processing the queue. When processing
@ -66,34 +65,27 @@ public class QueueManager implements Runnable {
// Creates a s_logging category with name = to the full name of class // Creates a s_logging category with name = to the full name of class
private static Logger s_log = Logger.getLogger(QueueManager.class); private static Logger s_log = Logger.getLogger(QueueManager.class);
// Should probably use these constants. Are hardcoded for now because // Should probably use these constants. Are hardcoded for now because
// matches DataQuery suffex. // matches DataQuery suffex.
// final static String BLOCK_SELECT_METHOD_QUEUED_ORDER = "QueuedOrder"; // final static String BLOCK_SELECT_METHOD_QUEUED_ORDER = "QueuedOrder";
// final static String BLOCK_SELECT_METHOD_GROUP_BY_PARENT = "GroupByParent"; // final static String BLOCK_SELECT_METHOD_GROUP_BY_PARENT = "GroupByParent";
// Parameters involved in processing the queue and their default values. // Parameters involved in processing the queue and their default values.
// Set to values other than default by calling methods from an initializer. // Set to values other than default by calling methods from an initializer.
private int m_startupDelay; private int m_startupDelay;
private int m_pollDelay; private int m_pollDelay;
static Integer s_retryDelay = new Integer(120); static Integer s_retryDelay = new Integer(120);
static Integer s_blockSize = new Integer(20); static Integer s_blockSize = new Integer(20);
static String s_blockSelectMethod = "QueuedOrder"; static String s_blockSelectMethod = "QueuedOrder";
static Integer s_maximumFailCount = new Integer(-1); static Integer s_maximumFailCount = new Integer(-1);
// Following true if should keep watching queue // Following true if should keep watching queue
static private boolean s_keepWatchingQueue = true; static private boolean s_keepWatchingQueue = true;
static private Thread s_queueThread = null; static private Thread s_queueThread = null;
// Class implementing methods run when publishing or unpublishing to file. // Class implementing methods run when publishing or unpublishing to file.
private static PublishToFileListener s_publishListener = null; private static PublishToFileListener s_publishListener = null;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Constructor related code. // Constructor related code.
// //
/** /**
* *
* @param startupDelay * @param startupDelay
@ -107,7 +99,6 @@ public class QueueManager implements Runnable {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialization related code. // Initialization related code.
// //
/** /**
* Set how many seconds the queue manager should wait before trying to * Set how many seconds the queue manager should wait before trying to
* process an entry which has previously failed. * process an entry which has previously failed.
@ -146,7 +137,6 @@ public class QueueManager implements Runnable {
s_maximumFailCount = maxFailCount; s_maximumFailCount = maxFailCount;
} }
/*** /***
* Set the listener that processes the publish and unpublish requests. * Set the listener that processes the publish and unpublish requests.
*/ */
@ -157,7 +147,6 @@ public class QueueManager implements Runnable {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Methods for queuing tasks // Methods for queuing tasks
// //
public static void requeueMissingFiles() { public static void requeueMissingFiles() {
DomainCollection files = PublishedFile.retrieveAll(); DomainCollection files = PublishedFile.retrieveAll();
@ -167,7 +156,7 @@ public class QueueManager implements Runnable {
HashSet done = new HashSet(); HashSet done = new HashSet();
while (files.next()) { while (files.next()) {
PublishedFile fileRecord = (PublishedFile)files.getDomainObject(); PublishedFile fileRecord = (PublishedFile) files.getDomainObject();
if (done.contains(fileRecord.getFileName())) { if (done.contains(fileRecord.getFileName())) {
continue; continue;
@ -182,26 +171,26 @@ public class QueueManager implements Runnable {
} else if (file.exists()) { } else if (file.exists()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug( "File " + file.getAbsolutePath() + s_log.debug("File " + file.getAbsolutePath()
" already exists"); + " already exists");
} }
} else { } else {
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("Published file " + file.getAbsolutePath() + s_log.info("Published file " + file.getAbsolutePath()
" for item " + fileRecord.getItemId() + + " for item " + fileRecord.getItemId()
" isn't on the filesystem. Scheduling for " + + " isn't on the filesystem. Scheduling for "
"republishing."); + "republishing.");
} }
ContentItem item = fileRecord.getItem(); ContentItem item = fileRecord.getItem();
if (item == null) { if (item == null) {
s_log.warn s_log.warn("No corresponding content item found for "
("No corresponding content item found for " + + "published file " + fileRecord.getFileName()
"published file " + fileRecord.getFileName() + " " + + " " + "(draft id " + fileRecord.getDraftId()
"(draft id " + fileRecord.getDraftId() + ", " + + ", " + "item id " + fileRecord.getItemId()
"item id " + fileRecord.getItemId() + ")"); + ")");
} else { } else {
ACSObject parent = item.getParent(); ACSObject parent = item.getParent();
BigDecimal parentID = null; BigDecimal parentID = null;
@ -215,7 +204,6 @@ public class QueueManager implements Runnable {
} }
} }
/*** /***
* Schedule an item for publishing. This should be called just after a new * Schedule an item for publishing. This should be called just after a new
* live version of an item becomes available. * live version of an item becomes available.
@ -225,8 +213,8 @@ public class QueueManager implements Runnable {
* @pre ! item instanceof ContainerItem * @pre ! item instanceof ContainerItem
***/ ***/
public static void queuePublish(ContentItem item) { public static void queuePublish(ContentItem item) {
Assert.isTrue( !(item instanceof ContentBundle), Assert.isTrue(!(item instanceof ContentBundle),
"Cannot queue content bundle " + item ); "Cannot queue content bundle " + item);
Assert.isTrue(item.isLiveVersion(), "Item is not live"); Assert.isTrue(item.isLiveVersion(), "Item is not live");
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("Queue publish task for " + item.getID()); s_log.info("Queue publish task for " + item.getID());
@ -234,17 +222,17 @@ public class QueueManager implements Runnable {
String task = QueueEntry.TASK_PUBLISH; String task = QueueEntry.TASK_PUBLISH;
QueueEntryCollection q = new QueueEntryCollection( QueueEntryCollection q = new QueueEntryCollection(
item.getID()); item.getID());
while (q.next()) { while (q.next()) {
if ( q.isPublishTask() ) { if (q.isPublishTask()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Deleting existing publish task " + q.getID()); s_log.debug("Deleting existing publish task " + q.getID());
} }
q.delete(); q.delete();
} else if ( q.isUnpublishTask() || q.isRepublishTask() ) { } else if (q.isUnpublishTask() || q.isRepublishTask()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Deleting existing (un|re)publish task " + s_log.debug("Deleting existing (un|re)publish task " + q.
q.getID()); getID());
} }
task = QueueEntry.TASK_REPUBLISH; task = QueueEntry.TASK_REPUBLISH;
q.delete(); q.delete();
@ -253,7 +241,6 @@ public class QueueManager implements Runnable {
queue(item, task); queue(item, task);
} }
/*** /***
* Schedule an item for unpublishing. This should be called just before * Schedule an item for unpublishing. This should be called just before
* the live version <code>item</code> is deleted. * the live version <code>item</code> is deleted.
@ -268,11 +255,11 @@ public class QueueManager implements Runnable {
} }
QueueEntryCollection q = new QueueEntryCollection( QueueEntryCollection q = new QueueEntryCollection(
item.getID()); item.getID());
while (q.next()) { while (q.next()) {
if ( q.isPublishTask() if (q.isPublishTask()
|| q.isRepublishTask() || q.isRepublishTask()
|| q.isUnpublishTask() ) { || q.isUnpublishTask()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Deleting existing (un|re|new)publish task " s_log.debug("Deleting existing (un|re|new)publish task "
+ q.getID()); + q.getID());
@ -283,7 +270,6 @@ public class QueueManager implements Runnable {
queue(item, QueueEntry.TASK_UNPUBLISH); queue(item, QueueEntry.TASK_UNPUBLISH);
} }
/*** /***
* Schedule an item for republishing. This should be called whenever an * Schedule an item for republishing. This should be called whenever an
* existing live item <code>item</code> should be refreshed in the file * existing live item <code>item</code> should be refreshed in the file
@ -300,16 +286,16 @@ public class QueueManager implements Runnable {
} }
QueueEntryCollection q = new QueueEntryCollection( QueueEntryCollection q = new QueueEntryCollection(
item.getID()); item.getID());
while (q.next()) { while (q.next()) {
if ( q.isUnpublishTask() if (q.isUnpublishTask()
|| q.isPublishTask() ) { || q.isPublishTask()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Deleting existing (un|new)publish task " s_log.debug("Deleting existing (un|new)publish task "
+ q.getID()); + q.getID());
} }
q.delete(); q.delete();
} else if ( q.isRepublishTask() ) { } else if (q.isRepublishTask()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Aborting because there is already a republish " s_log.debug("Aborting because there is already a republish "
+ q.getID()); + q.getID());
@ -339,11 +325,11 @@ public class QueueManager implements Runnable {
} }
Assert.isTrue(liveItem != null && liveItem.isLiveVersion(), Assert.isTrue(liveItem != null && liveItem.isLiveVersion(),
"Item is not live"); "Item is not live");
Assert.isTrue(source != null && source.isLiveVersion(), Assert.isTrue(source != null && source.isLiveVersion(),
"Source is not live"); "Source is not live");
Assert.isTrue(destination != null && destination.isLiveVersion(), Assert.isTrue(destination != null && destination.isLiveVersion(),
"Destination is not live"); "Destination is not live");
// for move put itemId as destination folder ID, for parent_id source // for move put itemId as destination folder ID, for parent_id source
// folder ID we do not need any other information for move // folder ID we do not need any other information for move
@ -354,8 +340,8 @@ public class QueueManager implements Runnable {
} }
private static void queue(ContentItem item, String task) { private static void queue(ContentItem item, String task) {
Assert.isTrue( !(item instanceof ContentBundle), Assert.isTrue(!(item instanceof ContentBundle),
"Cannot queue content bundle " + item ); "Cannot queue content bundle " + item);
Assert.isTrue(item.isLiveVersion(), "Item is not live"); Assert.isTrue(item.isLiveVersion(), "Item is not live");
ACSObject parent = item.getParent(); ACSObject parent = item.getParent();
@ -374,12 +360,12 @@ public class QueueManager implements Runnable {
String task, String task,
String destination) { String destination) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Queue " + task + " for " + item.getOID() + " on all hosts"); s_log.debug("Queue " + task + " for " + item.getOID()
+ " on all hosts");
} }
DestinationStub dest = PublishToFile.getDestination( DestinationStub dest = PublishToFile.getDestination(
item.getSpecificObjectType() item.getSpecificObjectType());
);
// No destination configured for this object type, lets // No destination configured for this object type, lets
// get outta here, since they obviously don't want to // get outta here, since they obviously don't want to
// p2fs it.... // p2fs it....
@ -388,7 +374,7 @@ public class QueueManager implements Runnable {
} }
DomainCollection hosts = Host.retrieveAll(); DomainCollection hosts = Host.retrieveAll();
while ( hosts.next() ) { while (hosts.next()) {
Host host = (Host) hosts.getDomainObject(); Host host = (Host) hosts.getDomainObject();
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
@ -410,8 +396,7 @@ public class QueueManager implements Runnable {
String destination, String destination,
Host host) { Host host) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Queue item " + item + " for " + s_log.debug("Queue item " + item + " for " + task + " on " + host);
task + " on " + host);
} }
QueueEntry q = QueueEntry.create(item, QueueEntry q = QueueEntry.create(item,
@ -425,8 +410,6 @@ public class QueueManager implements Runnable {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Routines from here down involved with processing the queue. // Routines from here down involved with processing the queue.
// //
/** /**
* Start watching and processing the queue. This method spawns a * Start watching and processing the queue. This method spawns a
* background thread that processes the queue. Queue processing starts * background thread that processes the queue. Queue processing starts
@ -439,11 +422,12 @@ public class QueueManager implements Runnable {
* has any entries. * has any entries.
*/ */
public static void startWatchingQueue(int startupDelay, int pollDelay) { public static void startWatchingQueue(int startupDelay, int pollDelay) {
if ( startupDelay > 0 ) { if (startupDelay > 0) {
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("Going to start queue processing."); s_log.info("Going to start queue processing.");
} }
s_queueThread = new Thread( new QueueManager(startupDelay, pollDelay) ); s_queueThread =
new Thread(new QueueManager(startupDelay, pollDelay));
s_queueThread.setDaemon(true); s_queueThread.setDaemon(true);
s_queueThread.setName("cms-p2fs-queue"); s_queueThread.setName("cms-p2fs-queue");
s_queueThread.start(); s_queueThread.start();
@ -464,8 +448,6 @@ public class QueueManager implements Runnable {
s_keepWatchingQueue = false; s_keepWatchingQueue = false;
} }
/*** /***
* Watch queue for entries to process. The main routine that starts * Watch queue for entries to process. The main routine that starts
* queue processing. * queue processing.
@ -477,13 +459,12 @@ public class QueueManager implements Runnable {
HashSet failedItems = new HashSet(); HashSet failedItems = new HashSet();
while ( sleep(m_pollDelay) && s_keepWatchingQueue ) { while (sleep(m_pollDelay) && s_keepWatchingQueue) {
// synchronized( Scheduler.class ) { // synchronized( Scheduler.class ) {
//while there are more entries in queue process them.HashSet //while there are more entries in queue process them.HashSet
//is used to store the failed items and for checking that //is used to store the failed items and for checking that
//they do not get processed again. //they do not get processed again.
while ( processQueueItems(failedItems) ) while (processQueueItems(failedItems));
;
// clear failed items // clear failed items
failedItems.clear(); failedItems.clear();
@ -499,8 +480,8 @@ public class QueueManager implements Runnable {
try { try {
Thread.sleep(n * 1000); Thread.sleep(n * 1000);
return true; return true;
} catch ( InterruptedException e ) { } catch (InterruptedException e) {
s_log.error( "Waiting was interrupted."); s_log.error("Waiting was interrupted.");
return false; return false;
} }
} }
@ -525,11 +506,11 @@ public class QueueManager implements Runnable {
s_log.warn("Ignoring uncaught exception", e); s_log.warn("Ignoring uncaught exception", e);
} finally { } finally {
try { try {
if ( query != null ) { if (query != null) {
query.close(); query.close();
} }
if ( txn.inTxn() ) { if (txn.inTxn()) {
txn.abortTxn(); txn.abortTxn();
s_log.info("Aborting transaction"); s_log.info("Aborting transaction");
} }
@ -548,7 +529,8 @@ public class QueueManager implements Runnable {
* This method exists so that we can test p2fs without the * This method exists so that we can test p2fs without the
* transaction management code. * transaction management code.
*/ */
private static boolean processQueueItemsInternal(DataQuery query, HashSet failedItems) { private static boolean processQueueItemsInternal(DataQuery query,
HashSet failedItems) {
Host host = Web.getConfig().getCurrentHost(); Host host = Web.getConfig().getCurrentHost();
boolean hasMore = false; boolean hasMore = false;
@ -558,7 +540,7 @@ public class QueueManager implements Runnable {
query.setParameter("maximumFailCount", s_maximumFailCount); query.setParameter("maximumFailCount", s_maximumFailCount);
int entryCount = 0; int entryCount = 0;
while ( query.next() && entryCount < s_blockSize.intValue() ) { while (query.next() && entryCount < s_blockSize.intValue()) {
DataObject dobj = (DataObject) query.get("queueEntry"); DataObject dobj = (DataObject) query.get("queueEntry");
QueueEntry qe = new QueueEntry(dobj); QueueEntry qe = new QueueEntry(dobj);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
@ -566,7 +548,7 @@ public class QueueManager implements Runnable {
} }
BigDecimal itemId = qe.getItemId(); BigDecimal itemId = qe.getItemId();
if ( !failedItems.contains(itemId) ) { if (!failedItems.contains(itemId)) {
try { try {
if (entryCount == 0) { if (entryCount == 0) {
// Tell the publish listener that we are about // Tell the publish listener that we are about
@ -580,17 +562,20 @@ public class QueueManager implements Runnable {
s_publishListener.doTask(qe); s_publishListener.doTask(qe);
qe.delete(); // successfully processed item, delete from queue qe.delete(); // successfully processed item, delete from queue
} catch ( PublishToFileException e ) { } catch (PublishToFileException e) {
flagError(itemId, "PublishToFileException.", e, qe, failedItems); flagError(itemId, "PublishToFileException.", e, qe,
} catch ( Exception e ) { failedItems);
flagError(itemId, "Task " + qe + " failed:", e, qe, failedItems); } catch (Exception e) {
flagError(itemId, "Task " + qe + " failed:", e, qe,
failedItems);
} }
entryCount++; entryCount++;
} }
} }
if ( entryCount > 0 ) if (entryCount > 0) {
s_publishListener.transactionEnd(); s_publishListener.transactionEnd();
}
hasMore = !query.isAfterLast(); hasMore = !query.isAfterLast();
@ -598,19 +583,19 @@ public class QueueManager implements Runnable {
} }
/** /**
* Get items to process * Get items to process
* @return Query for fetching block to process. * @return Query for fetching block to process.
*/ */
static DataQuery getBlockQuery() { static DataQuery getBlockQuery() {
DataQuery query = SessionManager.getSession() DataQuery query = SessionManager.getSession().retrieveQuery(
.retrieveQuery("com.arsdigita.cms.publishToFile.getBlock"); "com.arsdigita.cms.publishToFile.getBlock");
if ("GroupByParent".equals(s_blockSelectMethod)) if ("GroupByParent".equals(s_blockSelectMethod)) {
query.addOrder("queueEntry.parentId, queueEntry.sortOrder"); query.addOrder("queueEntry.parentId, queueEntry.sortOrder");
else } else {
query.addOrder("queueEntry.sortOrder"); query.addOrder("queueEntry.sortOrder");
}
return query; return query;
} }
@ -620,16 +605,13 @@ public class QueueManager implements Runnable {
// Flag that queue entry failed // Flag that queue entry failed
failedItems.add(itemId); failedItems.add(itemId);
Long failCount = qe.getFailCount(); Long failCount = qe.getFailCount();
s_log.error( exName + " itemId=" + itemId + s_log.error(exName + " itemId=" + itemId + " task=" + qe
" task=" + qe + + " destination=" + qe.getDestination() + " failCount="
" destination=" + qe.getDestination() + " failCount=" + failCount + + failCount + " error=" + e.getMessage(), e);
" error=" + e.getMessage(), e);
DataOperation operation = SessionManager.getSession(). DataOperation operation = SessionManager.getSession().
retrieveDataOperation( retrieveDataOperation(
"com.arsdigita.cms.publishToFile.flagPublishFailed" "com.arsdigita.cms.publishToFile.flagPublishFailed");
);
operation.setParameter("id", qe.getID()); operation.setParameter("id", qe.getID());
operation.execute(); operation.execute();
} }
} }

View File

@ -57,13 +57,12 @@ import org.w3c.dom.Document;
* @version $Id: XSLTemplate.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: XSLTemplate.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public final class XSLTemplate { public final class XSLTemplate {
public static final String versionId = public static final String versionId =
"$Id: XSLTemplate.java 287 2005-02-22 00:29:02Z sskracic $" + "$Id: XSLTemplate.java 287 2005-02-22 00:29:02Z sskracic $"
"$Author: sskracic $" + + "$Author: sskracic $"
"$DateTime: 2004/08/16 18:10:38 $"; + "$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(XSLTemplate.class); private static final Logger s_log = Logger.getLogger(XSLTemplate.class);
private final URL m_source; private final URL m_source;
private final Templates m_templates; private final Templates m_templates;
private final List m_dependents; private final List m_dependents;
@ -93,12 +92,12 @@ public final class XSLTemplate {
s_log.debug("Getting new templates object"); s_log.debug("Getting new templates object");
final TransformerFactory factory = final TransformerFactory factory =
TransformerFactory.newInstance(); TransformerFactory.newInstance();
factory.setURIResolver(resolver); factory.setURIResolver(resolver);
factory.setErrorListener(listener); factory.setErrorListener(listener);
m_templates = factory.newTemplates m_templates = factory.newTemplates(resolver.resolve(m_source.
(resolver.resolve(m_source.toString(), null)); toString(), null));
s_log.debug("Done getting new templates"); s_log.debug("Done getting new templates");
} catch (TransformerConfigurationException ex) { } catch (TransformerConfigurationException ex) {
@ -175,8 +174,8 @@ public final class XSLTemplate {
final Result result, final Result result,
final ErrorListener listener) { final ErrorListener listener) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Transforming " + source + " and sending it to " + s_log.debug("Transforming " + source + " and sending it to "
result + " using error listener " + listener); + result + " using error listener " + listener);
} }
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
@ -189,9 +188,7 @@ public final class XSLTemplate {
final Transformer transformer = newTransformer(); final Transformer transformer = newTransformer();
transformer.setErrorListener(listener); transformer.setErrorListener(listener);
if (s_log.isDebugEnabled()) { s_log.debug("Transforming the XML source document");
s_log.debug("Transforming the XML source document");
}
transformer.transform(source, result); transformer.transform(source, result);
@ -268,14 +265,14 @@ public final class XSLTemplate {
*/ */
public final boolean isModified() { public final boolean isModified() {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Checking if the XSL files for " + this + " " + s_log.debug("Checking if the XSL files for " + this + " "
"have been modified and need to be re-read"); + "have been modified and need to be re-read");
} }
final Iterator iter = m_dependents.iterator(); final Iterator iter = m_dependents.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final URL url = Templating.transformURL((URL)iter.next()); final URL url = Templating.transformURL((URL) iter.next());
Assert.exists(url, URL.class); Assert.exists(url, URL.class);
if (url.getProtocol().equals("file")) { if (url.getProtocol().equals("file")) {
@ -283,16 +280,16 @@ public final class XSLTemplate {
if (file.lastModified() > m_created.getTime()) { if (file.lastModified() > m_created.getTime()) {
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("File " + file + " was modified " + s_log.info("File " + file + " was modified " + file.
file.lastModified()); lastModified());
} }
return true; return true;
} }
} else { } else {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("The URL is not to a file; assuming " + s_log.debug("The URL is not to a file; assuming " + url
url + " is not modified"); + " is not modified");
} }
} }
} }
@ -317,7 +314,7 @@ public final class XSLTemplate {
*/ */
public void toZIP(OutputStream os, public void toZIP(OutputStream os,
String base) String base)
throws IOException { throws IOException {
final ZipOutputStream zos = new ZipOutputStream(os); final ZipOutputStream zos = new ZipOutputStream(os);
@ -330,7 +327,7 @@ public final class XSLTemplate {
final Iterator sheets = getDependents().iterator(); final Iterator sheets = getDependents().iterator();
while (sheets.hasNext()) { while (sheets.hasNext()) {
URL xsl = (URL)sheets.next(); URL xsl = (URL) sheets.next();
if (xsl.getProtocol().equals(srcProto)) { if (xsl.getProtocol().equals(srcProto)) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Outputting file " + xsl); s_log.debug("Outputting file " + xsl);
@ -344,14 +341,15 @@ public final class XSLTemplate {
IO.copy(xsl.openStream(), zos); IO.copy(xsl.openStream(), zos);
} else { } else {
s_log.warn("Not outputting file " + xsl + s_log.warn("Not outputting file " + xsl
" because its not under protocol " + srcProto); + " because its not under protocol " + srcProto);
} }
} }
zos.finish(); zos.finish();
} }
private static class Log4JErrorListener implements ErrorListener { private static class Log4JErrorListener implements ErrorListener {
public void warning(TransformerException e) throws TransformerException { public void warning(TransformerException e) throws TransformerException {
log(Level.WARN, e); log(Level.WARN, e);
} }
@ -360,13 +358,14 @@ public final class XSLTemplate {
log(Level.ERROR, e); log(Level.ERROR, e);
} }
public void fatalError(TransformerException e) throws TransformerException { public void fatalError(TransformerException e) throws
TransformerException {
log(Level.FATAL, e); log(Level.FATAL, e);
} }
private static void log(Level level, TransformerException ex) { private static void log(Level level, TransformerException ex) {
s_log.log(level, "Transformer " + level + ": " + s_log.log(level, "Transformer " + level + ": " + ex.
ex.getLocationAsString() + ": " + ex.getMessage(), getLocationAsString() + ": " + ex.getMessage(),
ex); ex);
} }
} }

View File

@ -37,38 +37,34 @@ import org.apache.log4j.Logger;
public final class XMLConfig extends AbstractConfig { public final class XMLConfig extends AbstractConfig {
public final static String versionId = public final static String versionId =
"$Id: XMLConfig.java 1393 2006-11-28 09:12:32Z sskracic $" + "$Id: XMLConfig.java 1393 2006-11-28 09:12:32Z sskracic $"
"$Author: sskracic $" + + "$Author: sskracic $"
"$DateTime: 2004/08/16 18:10:38 $"; + "$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(XMLConfig.class);
private static final Logger s_log = Logger.getLogger
(XMLConfig.class);
private static XMLConfig s_config; private static XMLConfig s_config;
// supported XSL transformer implementations // supported XSL transformer implementations
private static final String RESIN = private static final String RESIN =
"com.caucho.xsl.Xsl"; "com.caucho.xsl.Xsl";
private static final String JD_XSLT = private static final String JD_XSLT =
"jd.xml.xslt.trax.TransformerFactoryImpl"; "jd.xml.xslt.trax.TransformerFactoryImpl";
private static final String XSLTC = private static final String XSLTC =
"org.apache.xalan.xsltc.trax.TransformerFactoryImpl"; "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
private static final String SAXON = private static final String SAXON =
"com.icl.saxon.TransformerFactoryImpl"; "com.icl.saxon.TransformerFactoryImpl";
private static final String SAXON_HE =
"net.sf.saxon.TransformerFactoryImpl";
private static final String XALAN = private static final String XALAN =
"org.apache.xalan.processor.TransformerFactoryImpl"; "org.apache.xalan.processor.TransformerFactoryImpl";
// supported documentBuilder implementations // supported documentBuilder implementations
private static final String DOM_XERCES = private static final String DOM_XERCES =
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"; "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
private static final String DOM_RESIN = private static final String DOM_RESIN =
"com.caucho.xml.parsers.XmlDocumentBuilderFactory"; "com.caucho.xml.parsers.XmlDocumentBuilderFactory";
// supported SAX parser implementations // supported SAX parser implementations
private static final String SAX_XERCES = private static final String SAX_XERCES =
"org.apache.xerces.jaxp.SAXParserFactoryImpl"; "org.apache.xerces.jaxp.SAXParserFactoryImpl";
private static final String SAX_RESIN = private static final String SAX_RESIN =
"com.caucho.xml.parsers.XmlSAXParserFactory"; "com.caucho.xml.parsers.XmlSAXParserFactory";
/** /**
* Returns the singleton configuration record for the XML functionality * Returns the singleton configuration record for the XML functionality
@ -84,22 +80,18 @@ public final class XMLConfig extends AbstractConfig {
return s_config; return s_config;
} }
private final Parameter m_xfmr = new StringParameter(
private final Parameter m_xfmr = new StringParameter "waf.xml.xsl_transformer", Parameter.REQUIRED, "saxon");
("waf.xml.xsl_transformer", Parameter.REQUIRED, "saxon"); private final Parameter m_builder = new StringParameter(
"waf.xml.dom_builder", Parameter.REQUIRED, "xerces");
private final Parameter m_builder = new StringParameter private final Parameter m_parser = new StringParameter("waf.xml.sax_parser",
("waf.xml.dom_builder", Parameter.REQUIRED, "xerces"); Parameter.REQUIRED,
"xerces");
private final Parameter m_parser = new StringParameter private Parameter m_activateFullTimeFormatter = new BooleanParameter(
("waf.xml.sax_parser", Parameter.REQUIRED, "xerces"); "waf.xml.activate_full_date_formatter",
Parameter.OPTIONAL,
private Parameter m_activateFullTimeFormatter = new BooleanParameter new Boolean(
("waf.xml.activate_full_date_formatter", false));
Parameter.OPTIONAL, new Boolean(false));
/** /**
* Constructs an empty XMLConfig object following the singelton pattern. * Constructs an empty XMLConfig object following the singelton pattern.
@ -108,7 +100,6 @@ public final class XMLConfig extends AbstractConfig {
* it does not work with the associated classes AbstractConfig and * it does not work with the associated classes AbstractConfig and
* ConfigRegistry because they can currently not deal with a private constructor * ConfigRegistry because they can currently not deal with a private constructor
*/ */
// private XMLConfig() { // private XMLConfig() {
public XMLConfig() { public XMLConfig() {
@ -120,10 +111,7 @@ public final class XMLConfig extends AbstractConfig {
loadInfo(); loadInfo();
} }
/* ************ public getter / setter section ************ */ /* ************ public getter / setter section ************ */
/** /**
* Returns the XSL Transformer factory class name to use. * Returns the XSL Transformer factory class name to use.
* *
@ -136,12 +124,20 @@ public final class XMLConfig extends AbstractConfig {
String m_key = (String) get(m_xfmr); String m_key = (String) get(m_xfmr);
// Defined values: saxon (default)|jd.xslt|resin|xalan|xsltc // Defined values: saxon (default)|jd.xslt|resin|xalan|xsltc
if(m_key.toLowerCase().equals("xsltc")) return XSLTC; if (m_key.toLowerCase().equals("xsltc")) {
if(m_key.toLowerCase().equals("xalan")) return XALAN ; return XSLTC;
if(m_key.toLowerCase().equals("resin")) return RESIN; } else if (m_key.toLowerCase().equals("xalan")) {
if(m_key.toLowerCase().equals("jd.xslt")) return JD_XSLT; return XALAN;
// return defaultValue } else if (m_key.toLowerCase().equals("resin")) {
return SAXON; return RESIN;
} else if (m_key.toLowerCase().equals("jd.xslt")) {
return JD_XSLT;
} else if (m_key.toLowerCase().equals("saxonhe")) {
return SAXON_HE;
} else {
// return defaultValue
return SAXON;
}
} }
/** /**
@ -156,8 +152,11 @@ public final class XMLConfig extends AbstractConfig {
String m_key = (String) get(m_builder); String m_key = (String) get(m_builder);
// Defined values: xerces (default)|resin // Defined values: xerces (default)|resin
if(m_key.toLowerCase().equals("resin")) return DOM_RESIN; if (m_key.toLowerCase().equals("resin")) {
else return DOM_XERCES; return DOM_RESIN;
} else {
return DOM_XERCES;
}
} }
/** /**
@ -172,8 +171,11 @@ public final class XMLConfig extends AbstractConfig {
String m_key = (String) get(m_parser); String m_key = (String) get(m_parser);
// Defined values: xerces (default)|resin // Defined values: xerces (default)|resin
if(m_key.toLowerCase().equals("resin")) return SAX_RESIN; if (m_key.toLowerCase().equals("resin")) {
else return SAX_XERCES; return SAX_RESIN;
} else {
return SAX_XERCES;
}
} }
/** /**
@ -187,7 +189,6 @@ public final class XMLConfig extends AbstractConfig {
* Sets the activateFullTimeFormatter flag. * Sets the activateFullTimeFormatter flag.
*/ */
public void setActivateFullTimeFormatter(boolean activateFullTimeFormatter) { public void setActivateFullTimeFormatter(boolean activateFullTimeFormatter) {
set (m_activateFullTimeFormatter,new Boolean(activateFullTimeFormatter)); set(m_activateFullTimeFormatter, new Boolean(activateFullTimeFormatter));
} }
} }

View File

@ -55,6 +55,7 @@ public class GreetingItem extends AbstractComponent {
public Element generateXML(HttpServletRequest request, public Element generateXML(HttpServletRequest request,
HttpServletResponse response) { HttpServletResponse response) {
long start = System.currentTimeMillis();
ContentItem item = (ContentItem) getObject(); ContentItem item = (ContentItem) getObject();
if (null == item || !item.isLive()) { if (null == item || !item.isLive()) {
return null; return null;

View File

@ -21,7 +21,6 @@ public class CompareFilter implements Filter {
private final boolean allOption; private final boolean allOption;
private final boolean allOptionIsDefault; private final boolean allOptionIsDefault;
private final boolean propertyIsNumeric; private final boolean propertyIsNumeric;
private final boolean includeNull;
private Map<String, Option> options = new LinkedHashMap<String, Option>(); private Map<String, Option> options = new LinkedHashMap<String, Option>();
private String value; private String value;
@ -29,14 +28,13 @@ public class CompareFilter implements Filter {
final String label, final String label,
final boolean allOption, final boolean allOption,
final boolean allOptionIsDefault, final boolean allOptionIsDefault,
final boolean propertyIsNumeric, final boolean propertyIsNumeric
final boolean includeNull) { ) {
this.property = property; this.property = property;
this.label = label; this.label = label;
this.allOption = allOption; this.allOption = allOption;
this.allOptionIsDefault = allOptionIsDefault; this.allOptionIsDefault = allOptionIsDefault;
this.propertyIsNumeric = propertyIsNumeric; this.propertyIsNumeric = propertyIsNumeric;
this.includeNull = includeNull;
} }
@Override @Override
@ -45,14 +43,15 @@ public class CompareFilter implements Filter {
} }
public CompareFilter addOption(final String label, final String value) { public CompareFilter addOption(final String label, final String value) {
return addOption(label, Operators.EQ, value); return addOption(label, Operators.EQ, value, false);
} }
public CompareFilter addOption(final String label, public CompareFilter addOption(final String label,
final Operators operator, final Operators operator,
final String value) { final String value,
final boolean includeNull) {
Option option; Option option;
option = new Option(label, operator, value); option = new Option(label, operator, value, includeNull);
options.put(label, option); options.put(label, option);
return this; return this;
} }
@ -113,7 +112,7 @@ public class CompareFilter implements Filter {
filter.append('\''); filter.append('\'');
} }
if (includeNull) { if (selectedOption.getIncludeNull()) {
filter.append(String.format(" or %s is null", property)); filter.append(String.format(" or %s is null", property));
} }
@ -173,13 +172,16 @@ public class CompareFilter implements Filter {
private final String label; private final String label;
private final Operators operator; private final Operators operator;
private final String value; private final String value;
private final boolean includeNull;
public Option(final String label, public Option(final String label,
final Operators operator, final Operators operator,
final String value) { final String value,
final boolean includeNull) {
this.label = label; this.label = label;
this.operator = operator; this.operator = operator;
this.value = value; this.value = value;
this.includeNull = includeNull;
} }
public String getLabel() { public String getLabel() {
@ -193,5 +195,9 @@ public class CompareFilter implements Filter {
public String getValue() { public String getValue() {
return value; return value;
} }
public boolean getIncludeNull() {
return includeNull;
}
} }
} }

View File

@ -142,16 +142,14 @@ public class CustomizableObjectList extends ComplexObjectList {
final String label, final String label,
final boolean allOption, final boolean allOption,
final boolean allOptionIsDefault, final boolean allOptionIsDefault,
final boolean propertyIsNumeric, final boolean propertyIsNumeric) {
final boolean includeNull) {
CompareFilter filter; CompareFilter filter;
filter = new CompareFilter(property, filter = new CompareFilter(property,
label, label,
allOption, allOption,
allOptionIsDefault, allOptionIsDefault,
propertyIsNumeric, propertyIsNumeric);
includeNull);
filters.put(label, filter); filters.put(label, filter);
return filter; return filter;

View File

@ -13,7 +13,7 @@
<xrd:attributes rule="exclude"> <xrd:attributes rule="exclude">
<xrd:property name="/object/organizationDescription"/> <xrd:property name="/object/organizationDescription"/>
</xrd:attributes> </xrd:attributes>
<xrd:associations rule="include"> <!--<xrd:associations rule="include">
<xrd:property name="/object/addendum"/> <xrd:property name="/object/addendum"/>
<xrd:property name="/object/contacts"/> <xrd:property name="/object/contacts"/>
<xrd:property name="/object/contacts/person"/> <xrd:property name="/object/contacts/person"/>
@ -30,7 +30,7 @@
<xrd:property name="/object/persons/contacts"/> <xrd:property name="/object/persons/contacts"/>
<xrd:property name="/object/persons/contacts/address"/> <xrd:property name="/object/persons/contacts/address"/>
<xrd:property name="/object/persons/contacts/contactentries"/> <xrd:property name="/object/persons/contacts/contactentries"/>
</xrd:associations> </xrd:associations>-->
</xrd:adapter> </xrd:adapter>
</xrd:context> </xrd:context>

View File

@ -47,8 +47,8 @@
now.get(java.util.GregorianCalendar.DATE)); now.get(java.util.GregorianCalendar.DATE));
objList.addCompareFilter("projectend", "projectstatus", true, true, false) objList.addCompareFilter("projectend", "projectstatus", true, true, false)
.addOption("ongoing", CompareFilter.Operators.GTEQ, today) .addOption("ongoing", CompareFilter.Operators.GTEQ, today, true)
.addOption("finished", CompareFilter.Operators.LT, today); .addOption("finished", CompareFilter.Operators.LT, today, false);
objList.addSortField("title", "title asc"); objList.addSortField("title", "title asc");
objList.getDefinition().addOrder(objList.getOrder(request.getParameter("sort"))); objList.getDefinition().addOrder(objList.getOrder(request.getParameter("sort")));