001: /*
002: Copyright (c) 2003 eInnovation Inc. All rights reserved
003:
004: This library is free software; you can redistribute it and/or modify it under the terms
005: of the GNU Lesser General Public License as published by the Free Software Foundation;
006: either version 2.1 of the License, or (at your option) any later version.
007:
008: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
009: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: See the GNU Lesser General Public License for more details.
011: */
012:
013: /*
014: * Created on Apr 18, 2003
015: */
016: package org.openedit.logger;
017:
018: import java.io.File;
019: import java.util.HashMap;
020: import java.util.Map;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024: import org.openedit.xml.FieldArchive;
025:
026: import com.openedit.OpenEditRuntimeException;
027: import com.openedit.page.manage.PageManager;
028: import com.openedit.users.UserManager;
029:
030: /**
031: * update the user log each time something changes there should probably a MAX
032: * length for the user log. This would be configured TODO: We should consider
033: * using org.apache.log4j.xml.XMLLayout for performance reasons
034: *
035: * @author cburkey
036: */
037: public class LogArchive {
038: protected Log log = LogFactory.getLog(LogArchive.class);
039: protected UserManager fieldUserManager;
040: // protected XmlArchive fieldLogFiles;
041: protected Map fieldLogDirectories;
042: protected PageManager fieldPageManager;
043: protected File fieldRootLogsDirectory;
044: protected FieldArchive fieldFieldArchive;
045:
046: public UserManager getUserManager() {
047: return fieldUserManager;
048: }
049:
050: public void setUserManager(UserManager inUserManager) {
051: fieldUserManager = inUserManager;
052: }
053:
054: // public XmlArchive getLogFiles()
055: // {
056: // return fieldLogFiles;
057: // }
058: //
059: // public void setLogFiles(XmlArchive inLogFiles)
060: // {
061: // fieldLogFiles = inLogFiles;
062: // }
063:
064: public Map getLogDirectories() {
065: if (fieldLogDirectories == null) {
066: fieldLogDirectories = new HashMap();
067: }
068: return fieldLogDirectories;
069: }
070:
071: public void setLogDirectories(Map inLogDirectories) {
072: fieldLogDirectories = inLogDirectories;
073: }
074:
075: public LogDirectory getLogDirectory(String inId) {
076: LogDirectory log = (LogDirectory) getLogDirectories().get(inId);
077: if (log == null) {
078: log = new LogDirectory();
079: log.setType(inId);
080: log.setPageManager(getPageManager());
081: log.setRootLogsDirectory(getRootLogsDirectory());
082: try {
083: log.init();
084: } catch (Exception ex) {
085: throw new OpenEditRuntimeException(ex);
086: }
087: getLogDirectories().put(inId, log);
088: }
089:
090: return log;
091: }
092:
093: public PageManager getPageManager() {
094: return fieldPageManager;
095: }
096:
097: public void setPageManager(PageManager fieldPageManager) {
098: this .fieldPageManager = fieldPageManager;
099: }
100:
101: public File getRootLogsDirectory() {
102: return fieldRootLogsDirectory;
103: }
104:
105: public void setRootLogsDirectory(File inRootLogsDirectory) {
106: fieldRootLogsDirectory = inRootLogsDirectory;
107: }
108:
109: public FieldArchive getFieldArchive() {
110: return fieldFieldArchive;
111: }
112:
113: public void setFieldArchive(FieldArchive inFieldArchive) {
114: fieldFieldArchive = inFieldArchive;
115: inFieldArchive.setConfigurationPath("/WEB-INF/logs/config/");
116: }
117:
118: }
|