NIHVIVO-208 Convert Log4J calls to Apache Commons Logging calls.
This commit is contained in:
parent
ca1e1d0489
commit
e110a0fde1
17 changed files with 108 additions and 100 deletions
|
@ -31,10 +31,8 @@ log4j.appender.AllAppender.layout=org.apache.log4j.PatternLayout
|
|||
log4j.appender.AllAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1}] %m%n
|
||||
|
||||
|
||||
log4j.rootLogger=WARN, AllAppender
|
||||
log4j.rootLogger=INFO, AllAppender
|
||||
|
||||
log4j.logger.org.apache.catalina=INFO
|
||||
log4j.logger.org.diretwebremoting=ERROR
|
||||
|
||||
log4j.logger.edu.cornell.mannlib.vitro.webapp.ConfigurationProperties=INFO
|
||||
log4j.logger.edu.cornell.mannlib.vitro.webapp.filestorage.updater.FileStorageUpdater=INFO
|
||||
|
|
|
@ -17,7 +17,8 @@ import javax.naming.Context;
|
|||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Loads the configuration properties from a properties file. The path to the
|
||||
|
@ -40,8 +41,8 @@ import org.apache.log4j.Logger;
|
|||
* @author jeb228
|
||||
*/
|
||||
public class ConfigurationProperties {
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(ConfigurationProperties.class);
|
||||
private static final Log log = LogFactory
|
||||
.getLog(ConfigurationProperties.class);
|
||||
|
||||
/**
|
||||
* The JNDI naming context where Tomcat stores environment attributes.
|
||||
|
@ -132,7 +133,7 @@ public class ConfigurationProperties {
|
|||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to close input stream", e);
|
||||
log.error("Failed to close input stream", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +144,7 @@ public class ConfigurationProperties {
|
|||
newMap.put(key, props.getProperty(key));
|
||||
}
|
||||
|
||||
LOG.info("Configuration properties are: " + newMap);
|
||||
log.info("Configuration properties are: " + newMap);
|
||||
|
||||
// Save an unmodifiable version of the Map
|
||||
return Collections.unmodifiableMap(newMap);
|
||||
|
@ -163,7 +164,7 @@ public class ConfigurationProperties {
|
|||
+ "\" failed. Is the context file missing?";
|
||||
Context envCtx = (Context) new InitialContext().lookup(JNDI_BASE);
|
||||
if (envCtx == null) {
|
||||
LOG.error(message);
|
||||
log.error(message);
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
|
||||
|
@ -173,7 +174,7 @@ public class ConfigurationProperties {
|
|||
+ "'. Is the context file set up correctly?";
|
||||
String configPath = (String) envCtx.lookup(PATH_CONFIGURATION);
|
||||
if (configPath == null) {
|
||||
LOG.error(message);
|
||||
log.error(message);
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,14 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
|
||||
public class ContactMailServlet extends VitroHttpServlet {
|
||||
private static final Logger LOG = Logger.getLogger(ContactMailServlet.class);
|
||||
private static final Log log = LogFactory.getLog(ContactMailServlet.class);
|
||||
|
||||
private final static String CONFIRM_PAGE = "/thankyou.jsp";
|
||||
private final static String ERR_PAGE = "/contact_err.jsp";
|
||||
|
@ -56,9 +57,9 @@ public class ContactMailServlet extends VitroHttpServlet {
|
|||
public static String getSmtpHostFromProperties() {
|
||||
String host = ConfigurationProperties.getProperty("Vitro.smtpHost");
|
||||
if (host != null && !host.equals("")) {
|
||||
LOG.debug("Found Vitro.smtpHost value of " + host);
|
||||
log.debug("Found Vitro.smtpHost value of " + host);
|
||||
} else {
|
||||
LOG.debug("No Vitro.smtpHost specified");
|
||||
log.debug("No Vitro.smtpHost specified");
|
||||
}
|
||||
return (host != null && host.length() > 0) ? host : null;
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ public class ContactMailServlet extends VitroHttpServlet {
|
|||
|
||||
if ("comment".equals(formType)) {
|
||||
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
||||
LOG.error("No contact mail address defined in current portal "+portal.getPortalId());
|
||||
log.error("No contact mail address defined in current portal "+portal.getPortalId());
|
||||
throw new Error(
|
||||
"To establish the Contact Us mail capability the system administrators must "
|
||||
+ "specify an email address in the current portal.");
|
||||
|
@ -135,9 +136,9 @@ public class ContactMailServlet extends VitroHttpServlet {
|
|||
deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form";
|
||||
} else if ("correction".equals(formType)) {
|
||||
if (portal.getCorrectionMail() == null || portal.getCorrectionMail().trim().length()==0) {
|
||||
LOG.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address");
|
||||
log.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address");
|
||||
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
||||
LOG.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId());
|
||||
log.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId());
|
||||
} else {
|
||||
deliverToArray = portal.getContactMail().split(",");
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ public class ContactMailServlet extends VitroHttpServlet {
|
|||
}
|
||||
recipientCount=(deliverToArray == null) ? 0 : deliverToArray.length;
|
||||
if (recipientCount == 0) {
|
||||
LOG.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
|
||||
log.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
|
||||
throw new Error(
|
||||
"To establish the Contact Us mail capability the system administrators must "
|
||||
+ "specify at least one email address in the current portal.");
|
||||
|
|
|
@ -26,7 +26,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||
|
@ -38,8 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
|||
import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest;
|
||||
|
||||
public class UploadImagesServlet extends VitroHttpServlet {
|
||||
private static final Logger log = Logger
|
||||
.getLogger(UploadImagesServlet.class);
|
||||
private static final Log log = LogFactory.getLog(UploadImagesServlet.class);
|
||||
|
||||
/** Recognized file extensions mapped to MIME-types. */
|
||||
private static final Map<String, String> RECOGNIZED_FILE_TYPES = createFileTypesMap();
|
||||
|
@ -146,12 +146,12 @@ public class UploadImagesServlet extends VitroHttpServlet {
|
|||
errors.add(e.getMessage());
|
||||
displayFailure(request, response, errors);
|
||||
} catch (IllegalStateException e) {
|
||||
log.error(e);
|
||||
log.error(e, e);
|
||||
errors.add(e.getMessage());
|
||||
displayFailure(request, response, errors);
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
log.error(e);
|
||||
log.error(e, e);
|
||||
errors.add(e.getMessage());
|
||||
displayFailure(rawRequest, response, errors);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
@ -23,14 +22,15 @@ import javax.mail.internet.InternetAddress;
|
|||
import javax.mail.internet.MimeMessage;
|
||||
import javax.servlet.ServletConfig;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
|
||||
public class ContactMailController extends FreeMarkerHttpServlet {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
.getLog(ContactMailController.class);
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOG = Logger.getLogger(ContactMailController.class);
|
||||
|
||||
private final static String SPAM_MESSAGE = "Your message was flagged as spam.";
|
||||
private final static String EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
|
||||
|
@ -56,9 +56,9 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
|||
public static String getSmtpHostFromProperties() {
|
||||
String host = ConfigurationProperties.getProperty("Vitro.smtpHost");
|
||||
if (host != null && !host.equals("")) {
|
||||
LOG.debug("Found Vitro.smtpHost value of " + host);
|
||||
log.debug("Found Vitro.smtpHost value of " + host);
|
||||
} else {
|
||||
LOG.debug("No Vitro.smtpHost specified");
|
||||
log.debug("No Vitro.smtpHost specified");
|
||||
}
|
||||
return (host != null && host.length() > 0) ? host : null;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
|||
|
||||
if ("contact".equals(formType)) {
|
||||
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
|
||||
LOG.error("No contact mail address defined in current portal "+portal.getPortalId());
|
||||
log.error("No contact mail address defined in current portal "+portal.getPortalId());
|
||||
throw new Error(
|
||||
"To establish the Contact Us mail capability the system administrators must "
|
||||
+ "specify an email address in the current portal.");
|
||||
|
@ -150,7 +150,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
|||
}
|
||||
recipientCount=(deliverToArray == null) ? 0 : deliverToArray.length;
|
||||
if (recipientCount == 0) {
|
||||
LOG.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
|
||||
log.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
|
||||
throw new Error(
|
||||
"To establish the Contact Us mail capability the system administrators must "
|
||||
+ "specify at least one email address in the current portal.");
|
||||
|
@ -196,7 +196,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
|||
outFile.close();
|
||||
}
|
||||
catch (IOException e){
|
||||
LOG.error("Can't open file to write email backup");
|
||||
log.error("Can't open file to write email backup");
|
||||
}
|
||||
|
||||
// Message was sent successfully
|
||||
|
@ -274,7 +274,8 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
|||
try {
|
||||
msg.setFrom( new InternetAddress( webuseremail, webusername ));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LOG.error("Can't set message sender with personal name " + webusername + " due to UnsupportedEncodingException");
|
||||
log.error("Can't set message sender with personal name " + webusername +
|
||||
" due to UnsupportedEncodingException");
|
||||
msg.setFrom( new InternetAddress( webuseremail ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.filestorage;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
|
@ -31,7 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|||
* </p>
|
||||
*/
|
||||
public class FileModelHelper {
|
||||
private static final Logger log = Logger.getLogger(FileModelHelper.class);
|
||||
private static final Log log = LogFactory.getLog(FileModelHelper.class);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Static methods -- the Individual holds all necessary references.
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.filestorage;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
||||
|
@ -11,7 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
|||
* Static methods to help when serving uploaded files.
|
||||
*/
|
||||
public class FileServingHelper {
|
||||
private static final Logger log = Logger.getLogger(FileServingHelper.class);
|
||||
private static final Log log = LogFactory.getLog(FileServingHelper.class);
|
||||
|
||||
private static final String DEFAULT_PATH = "/individual/";
|
||||
private static final String FILE_PATH = "/file/";
|
||||
|
|
|
@ -8,7 +8,8 @@ import java.io.File;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A collection of utility routines used by the file storage system. Routines
|
||||
|
@ -24,7 +25,7 @@ import org.apache.log4j.Logger;
|
|||
* </ul>
|
||||
*/
|
||||
public class FileStorageHelper {
|
||||
private static final Logger LOG = Logger.getLogger(FileStorageHelper.class);
|
||||
private static final Log log = LogFactory.getLog(FileStorageHelper.class);
|
||||
|
||||
public static final char HEX_ESCAPE_CHAR = '^';
|
||||
|
||||
|
@ -80,7 +81,7 @@ public class FileStorageHelper {
|
|||
result.append(hexEncodeCharacter(clear.charAt(i)));
|
||||
}
|
||||
|
||||
LOG.debug("Add hex encodings to '" + clear + "' giving '" + result
|
||||
log.debug("Add hex encodings to '" + clear + "' giving '" + result
|
||||
+ "'");
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ public class FileStorageHelper {
|
|||
char c = encoded.charAt(i);
|
||||
result.append(translateSingleCharacter(c, sources, targets));
|
||||
}
|
||||
LOG.debug("Add single character conversions to '" + encoded
|
||||
log.debug("Add single character conversions to '" + encoded
|
||||
+ "' giving '" + result + "'");
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ public class FileStorageHelper {
|
|||
char c = cleaned.charAt(i);
|
||||
result.append(translateSingleCharacter(c, targets, sources));
|
||||
}
|
||||
LOG.debug("Remove single character conversions from '" + cleaned
|
||||
log.debug("Remove single character conversions from '" + cleaned
|
||||
+ "' giving '" + result + "'");
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ public class FileStorageHelper {
|
|||
result.append(c);
|
||||
}
|
||||
}
|
||||
LOG.debug("Remove hex encodings from '" + encoded + "' giving '"
|
||||
log.debug("Remove hex encodings from '" + encoded + "' giving '"
|
||||
+ result + "'");
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ public class FileStorageHelper {
|
|||
String prefixed = applyPrefixChar(prefix, cleaned);
|
||||
String brokenUp = insertPathDelimiters(prefixed);
|
||||
String result = excludeWindowsWordsFromPath(brokenUp);
|
||||
LOG.debug("id2Path: id='" + id + "', namespaces='" + namespacesMap
|
||||
log.debug("id2Path: id='" + id + "', namespaces='" + namespacesMap
|
||||
+ "', path='" + result + "'");
|
||||
return result;
|
||||
}
|
||||
|
@ -276,7 +277,7 @@ public class FileStorageHelper {
|
|||
}
|
||||
path.append(prefixed.charAt(i));
|
||||
}
|
||||
LOG.debug("Insert path delimiters to '" + prefixed + "' giving '"
|
||||
log.debug("Insert path delimiters to '" + prefixed + "' giving '"
|
||||
+ path + "'");
|
||||
return path.toString();
|
||||
}
|
||||
|
|
|
@ -23,13 +23,14 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* The default implementation of {@link FileStorage}.
|
||||
*/
|
||||
public class FileStorageImpl implements FileStorage {
|
||||
private static final Logger log = Logger.getLogger(FileStorageImpl.class);
|
||||
private static final Log log = LogFactory.getLog(FileStorageImpl.class);
|
||||
|
||||
private final File baseDir;
|
||||
private final File rootDir;
|
||||
|
|
|
@ -16,7 +16,8 @@ import javax.servlet.UnavailableException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
|
@ -46,8 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
|||
* </p>
|
||||
*/
|
||||
public class FileServingServlet extends VitroHttpServlet {
|
||||
private static final Logger log = Logger
|
||||
.getLogger(FileServingServlet.class);
|
||||
private static final Log log = LogFactory.getLog(FileServingServlet.class);
|
||||
|
||||
private FileStorage fileStorage;
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class FileServingServlet extends VitroHttpServlet {
|
|||
try {
|
||||
in = fileStorage.getInputStream(uri, actualFilename);
|
||||
} catch (FileNotFoundException e) {
|
||||
log.error(e);
|
||||
log.error(e, e);
|
||||
response.sendError(SC_INTERNAL_SERVER_ERROR, e.toString());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ import org.apache.commons.fileupload.FileItem;
|
|||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A wrapper for a servlet request that holds multipart content. Parsing the
|
||||
|
@ -27,8 +28,8 @@ import org.apache.log4j.Logger;
|
|||
* here, to answer file-related requests.
|
||||
*/
|
||||
class MultipartHttpServletRequest extends FileUploadServletRequest {
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(MultipartHttpServletRequest.class);
|
||||
private static final Log log = LogFactory
|
||||
.getLog(MultipartHttpServletRequest.class);
|
||||
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
|
||||
|
@ -55,20 +56,20 @@ class MultipartHttpServletRequest extends FileUploadServletRequest {
|
|||
if (item.isFormField()) {
|
||||
addToParameters(parameters, item.getFieldName(), item
|
||||
.getString("UTF-8"));
|
||||
LOG.debug("Form field (parameter) " + item.getFieldName() + "="
|
||||
log.debug("Form field (parameter) " + item.getFieldName() + "="
|
||||
+ item.getString());
|
||||
} else {
|
||||
addToFileItems(files, item);
|
||||
LOG
|
||||
log
|
||||
.debug("File " + item.getFieldName() + ": "
|
||||
+ item.getName());
|
||||
}
|
||||
}
|
||||
|
||||
this.parameters = Collections.unmodifiableMap(parameters);
|
||||
LOG.debug("Parameters are: " + this.parameters);
|
||||
log.debug("Parameters are: " + this.parameters);
|
||||
this.files = Collections.unmodifiableMap(files);
|
||||
LOG.debug("Files are: " + this.files);
|
||||
log.debug("Files are: " + this.files);
|
||||
request.setAttribute(FILE_ITEM_MAP, this.files);
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ class MultipartHttpServletRequest extends FileUploadServletRequest {
|
|||
for (Entry<String, List<String>> entry : parameters.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue().toArray(EMPTY_ARRAY));
|
||||
}
|
||||
LOG.debug("resulting parameter map: " + result);
|
||||
log.debug("resulting parameter map: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import java.util.Set;
|
|||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.graph.Graph;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
|
@ -22,7 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.RDBGraphGenerator;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RegeneratingGraph;
|
||||
|
||||
public class JenaDataSourceSetupBase {
|
||||
private static final Logger LOG = Logger.getLogger(JenaDataSourceSetupBase.class);
|
||||
private static final Log log = LogFactory.getLog(JenaDataSourceSetupBase.class);
|
||||
|
||||
protected final static int DEFAULT_MAXWAIT = 10000, // ms
|
||||
DEFAULT_MAXACTIVE = 40,
|
||||
|
@ -79,7 +80,7 @@ public class JenaDataSourceSetupBase {
|
|||
}
|
||||
|
||||
protected BasicDataSource makeBasicDataSource(String dbDriverClassname, String jdbcUrl, String username, String password) {
|
||||
LOG.debug("makeBasicDataSource('" + dbDriverClassname + "', '"
|
||||
log.debug("makeBasicDataSource('" + dbDriverClassname + "', '"
|
||||
+ jdbcUrl + "', '" + username + "', '" + password + "')");
|
||||
BasicDataSource ds = new BasicDataSource();
|
||||
ds.setDriverClassName(dbDriverClassname);
|
||||
|
@ -118,7 +119,7 @@ public class JenaDataSourceSetupBase {
|
|||
//Graph g = maker.openGraph(JENA_DB_MODEL,false);
|
||||
//dbModel = ModelFactory.createModelForGraph(g);
|
||||
//maker.openModel(JENA_DB_MODEL);
|
||||
LOG.debug("Using database at "+ds.getUrl());
|
||||
log.debug("Using database at "+ds.getUrl());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
@ -131,17 +132,17 @@ public class JenaDataSourceSetupBase {
|
|||
|
||||
public static void readOntologyFilesInPathSet(String path,
|
||||
ServletContext ctx, Model model) {
|
||||
LOG.debug("Reading ontology files from '" + path + "'");
|
||||
log.debug("Reading ontology files from '" + path + "'");
|
||||
Set<String> paths = ctx.getResourcePaths(path);
|
||||
if (paths != null) {
|
||||
for (String p : paths) {
|
||||
LOG.info("Loading ontology file at " + p);
|
||||
log.info("Loading ontology file at " + p);
|
||||
InputStream ontologyInputStream = ctx.getResourceAsStream(p);
|
||||
try {
|
||||
model.read(ontologyInputStream, null);
|
||||
LOG.debug("...successful");
|
||||
log.debug("...successful");
|
||||
} catch (Throwable t) {
|
||||
LOG.error("Failed to load ontology file at '" + p + "'", t);
|
||||
log.error("Failed to load ontology file at '" + p + "'", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import javax.servlet.ServletContext;
|
|||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
|
@ -23,8 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.updater.FileStorageUpdater;
|
|||
* TODO
|
||||
*/
|
||||
public class UpdateUploadedFiles implements ServletContextListener {
|
||||
private static final Logger log = Logger
|
||||
.getLogger(UpdateUploadedFiles.class);
|
||||
private static final Log log = LogFactory.getLog(UpdateUploadedFiles.class);
|
||||
|
||||
/**
|
||||
* Nothing to do on teardown.
|
||||
|
|
|
@ -5,7 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
|||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.db.DBConnection;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
@ -15,8 +16,8 @@ import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
|
||||
public class VitroJenaModelMakerSetup implements ServletContextListener {
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(VitroJenaModelMakerSetup.class);
|
||||
private static final Log log = LogFactory
|
||||
.getLog(VitroJenaModelMakerSetup.class);
|
||||
|
||||
protected final static String DB_TYPE = "MySQL";
|
||||
|
||||
|
@ -35,9 +36,9 @@ public class VitroJenaModelMakerSetup implements ServletContextListener {
|
|||
ModelMaker mMaker = ModelFactory.createModelRDBMaker(dbConn);
|
||||
VitroJenaModelMaker vjmm = new VitroJenaModelMaker(mMaker);
|
||||
arg0.getServletContext().setAttribute("vitroJenaModelMaker", vjmm);
|
||||
LOG.debug("VitroJenaModelMaker set up");
|
||||
log.debug("VitroJenaModelMaker set up");
|
||||
} catch (Throwable t) {
|
||||
LOG.error("Unable to set up default VitroJenaModelMaker", t);
|
||||
log.error("Unable to set up default VitroJenaModelMaker", t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,13 @@ import java.io.StringReader;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.tidy.Tidy;
|
||||
|
||||
public class MakeTidy {
|
||||
private static final Logger log = Logger.getLogger(MakeTidy.class);
|
||||
private static PrintWriter outFile = new PrintWriter(new LoggingWriter(log,
|
||||
Level.INFO));
|
||||
private static final Log log = LogFactory.getLog(MakeTidy.class);
|
||||
private static PrintWriter outFile = new PrintWriter(new LoggingWriter(log));
|
||||
|
||||
public String process(String value) {
|
||||
Tidy tidy = new Tidy(); // obtain a new Tidy instance
|
||||
|
@ -47,14 +46,15 @@ public class MakeTidy {
|
|||
return outputStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link Writer} that sends its output to a log file, at INFO level.
|
||||
*/
|
||||
private static class LoggingWriter extends Writer {
|
||||
private final Logger logger;
|
||||
private final Level level;
|
||||
private final Log logger;
|
||||
private String buffer;
|
||||
|
||||
LoggingWriter(Logger logger, Level level) {
|
||||
LoggingWriter(Log logger) {
|
||||
this.logger = logger;
|
||||
this.level = level;
|
||||
this.buffer = "";
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class MakeTidy {
|
|||
if (lineEnd == -1) {
|
||||
return;
|
||||
} else {
|
||||
logger.log(level, buffer.substring(0, lineEnd).trim());
|
||||
logger.info(buffer.substring(0, lineEnd).trim());
|
||||
buffer = buffer.substring(lineEnd + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
|
|||
import net.djpowell.sparqltag.SelectTag;
|
||||
import net.djpowell.sparqltag.SparqlTag;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
|
@ -37,6 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.IterableAdaptor;
|
|||
*/
|
||||
|
||||
public class ListSparqlTag extends SelectTag {
|
||||
private static final Log log = LogFactory.getLog(ListSparqlTag.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,7 +46,7 @@ public class ListSparqlTag extends SelectTag {
|
|||
* the queryExecution gets closed.
|
||||
*/
|
||||
public void doTag() throws JspException {
|
||||
trc.debug("CollectionSparqlTag.doTag()");
|
||||
log.debug("CollectionSparqlTag.doTag()");
|
||||
|
||||
SparqlTag container = ((SparqlTag)SimpleTagSupport.findAncestorWithClass(this, SparqlTag.class));
|
||||
if (container == null) {
|
||||
|
@ -55,7 +57,7 @@ public class ListSparqlTag extends SelectTag {
|
|||
|
||||
Query query = parseQuery();
|
||||
QueryExecution qex = QueryExecutionFactory.create(query, model, qparams);
|
||||
trc.debug("query executed");
|
||||
log.debug("query executed");
|
||||
|
||||
ResultSet results;
|
||||
model.enterCriticalSection(Lock.READ);
|
||||
|
@ -64,16 +66,16 @@ public class ListSparqlTag extends SelectTag {
|
|||
List<Map<String,RDFNode>> resultList = new LinkedList<Map<String,RDFNode>>();
|
||||
|
||||
for( QuerySolution qs : IterableAdaptor.adapt( (Iterator<QuerySolution>)results ) ){
|
||||
trc.debug("found solution");
|
||||
log.debug("found solution");
|
||||
HashMap<String,RDFNode> map1 = new HashMap<String,RDFNode>();
|
||||
for( String name : IterableAdaptor.adapt((Iterator<String>)qs.varNames())){
|
||||
RDFNode value = qs.get(name);
|
||||
if( trc.isDebugEnabled() ){trc.debug(name + ": " + value.toString() );}
|
||||
if( log.isDebugEnabled() ){log.debug(name + ": " + value.toString() );}
|
||||
map1.put(name, value);
|
||||
}
|
||||
resultList.add(map1);
|
||||
}
|
||||
trc.debug("setting " + var + " to a list of size " + resultList.size() );
|
||||
log.debug("setting " + var + " to a list of size " + resultList.size() );
|
||||
getJspContext().setAttribute(var, resultList);
|
||||
} finally {
|
||||
model.leaveCriticalSection();
|
||||
|
@ -88,6 +90,4 @@ public class ListSparqlTag extends SelectTag {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger trc = Logger.getLogger(ListSparqlTag.class);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -25,7 +26,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddObjectPropStmt;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditDataPropStmt;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditObjPropStmt;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
|
@ -33,8 +33,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
public class SelfEditingPolicySetupTest extends AbstractTestClass {
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(SelfEditingPolicySetupTest.class);
|
||||
private static final Log log = LogFactory
|
||||
.getLog(SelfEditingPolicySetupTest.class);
|
||||
|
||||
/** We may edit objects in this arbitrary namespace. */
|
||||
private static final String SAFE_NS = "http://test.mannlib.cornell.edu/ns/01#";
|
||||
|
@ -272,7 +272,7 @@ public class SelfEditingPolicySetupTest extends AbstractTestClass {
|
|||
AddObjectPropStmt whatToAuth = new AddObjectPropStmt(uriOfSub,
|
||||
uriOfPred, uriOfObj);
|
||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||
LOG.debug(dec);
|
||||
log.debug(dec);
|
||||
Assert.assertNotNull(dec);
|
||||
Assert.assertEquals(expectedAuthorization, dec.getAuthorized());
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ public class SelfEditingPolicySetupTest extends AbstractTestClass {
|
|||
EditObjPropStmt whatToAuth = new EditObjPropStmt(uriOfSub, uriOfPred,
|
||||
uriOfObj);
|
||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||
LOG.debug(dec);
|
||||
log.debug(dec);
|
||||
Assert.assertNotNull(dec);
|
||||
Assert.assertEquals(expectedAuthorization, dec.getAuthorized());
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ public class SelfEditingPolicySetupTest extends AbstractTestClass {
|
|||
|
||||
EditDataPropStmt whatToAuth = new EditDataPropStmt(dps);
|
||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||
LOG.debug(dec);
|
||||
log.debug(dec);
|
||||
Assert.assertNotNull(dec);
|
||||
Assert.assertEquals(expectedAuthorization, dec.getAuthorized());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue