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