Permalink
Browse files

* Step 1 in removing lift deprecated methods.

** Fixed compiler erros from Ldap code.
  • Loading branch information...
1 parent 6d55cd3 commit 03a56715617f9cae801c4774ee04997952d179ce @fmpwizard fmpwizard committed May 3, 2012
Showing with 95 additions and 506 deletions.
  1. +8 −8 core/json-ext/src/main/scala/net/liftweb/json/ext/JodaTimeSerializer.scala
  2. +2 −2 core/json/src/main/scala/net/liftweb/json/Formats.scala
  3. +4 −4 core/util/src/main/scala/net/liftweb/util/BindHelpers.scala
  4. +1 −1 core/util/src/main/scala/net/liftweb/util/ListHelpers.scala
  5. +5 −259 core/util/src/main/scala/net/liftweb/util/Log.scala
  6. +0 −118 core/util/src/main/scala/net/liftweb/util/Slf4jLogger.scala
  7. +1 −1 persistence/ldap/src/main/scala/net/liftweb/ldap/LDAPProtoUser.scala
  8. +4 −45 persistence/ldap/src/main/scala/net/liftweb/ldap/LdapVendor.scala
  9. +1 −1 persistence/ldap/src/test/scala/net/liftweb/ldap/LdapSpec.scala
  10. +5 −5 persistence/mapper/src/main/scala/net/liftweb/mapper/HasManyThrough.scala
  11. +1 −1 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedForeignKey.scala
  12. +1 −1 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedPassword.scala
  13. +4 −4 persistence/mapper/src/main/scala/net/liftweb/mapper/Mapper.scala
  14. +1 −2 persistence/mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala
  15. +2 −2 persistence/mapper/src/main/scala/net/liftweb/mapper/OneToMany.scala
  16. +2 −2 persistence/mapper/src/main/scala/net/liftweb/mapper/ProtoExtendedSession.scala
  17. +6 −6 persistence/mapper/src/main/scala/net/liftweb/mapper/ProtoUser.scala
  18. +2 −2 persistence/mapper/src/test/scala/net/liftweb/mapper/MapperSpec.scala
  19. +1 −1 web/testkit/src/main/scala/net/liftweb/mocks/MockHttpServletRequest.scala
  20. +1 −1 web/webkit/src/main/scala/net/liftweb/builtin/snippet/Embed.scala
  21. +1 −1 web/webkit/src/main/scala/net/liftweb/http/LiftMerge.scala
  22. +4 −1 web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala
  23. +2 −2 web/webkit/src/main/scala/net/liftweb/http/S.scala
  24. +28 −28 web/webkit/src/main/scala/net/liftweb/http/js/jquery/JqJsCmds.scala
  25. +1 −1 web/webkit/src/main/scala/net/liftweb/http/provider/HTTPProvider.scala
  26. +1 −1 web/webkit/src/main/scala/net/liftweb/mockweb/MockWeb.scala
  27. +1 −1 web/webkit/src/test/scala/net/liftweb/http/NamedCometPerTabSpec.scala
  28. +4 −4 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
  29. +1 −1 web/wizard/src/main/scala/net/liftweb/wizard/Wizard.scala
@@ -22,12 +22,12 @@ import org.joda.time._
import JsonDSL._
object JodaTimeSerializers {
- def all = List(DurationSerializer(), InstantSerializer(), DateTimeSerializer(),
- DateMidnightSerializer(), IntervalSerializer(), LocalDateSerializer(),
- LocalTimeSerializer(), PeriodSerializer())
+ def all = List(DurationSerializer, InstantSerializer, DateTimeSerializer,
+ DateMidnightSerializer, IntervalSerializer(), LocalDateSerializer(),
+ LocalTimeSerializer(), PeriodSerializer)
}
-case class PeriodSerializer extends CustomSerializer[Period](format => (
+case object PeriodSerializer extends CustomSerializer[Period](format => (
{
case JString(p) => new Period(p)
case JNull => null
@@ -37,7 +37,7 @@ case class PeriodSerializer extends CustomSerializer[Period](format => (
}
))
-case class DurationSerializer extends CustomSerializer[Duration](format => (
+case object DurationSerializer extends CustomSerializer[Duration](format => (
{
case JInt(d) => new Duration(d.longValue)
case JNull => null
@@ -47,7 +47,7 @@ case class DurationSerializer extends CustomSerializer[Duration](format => (
}
))
-case class InstantSerializer extends CustomSerializer[Instant](format => (
+case object InstantSerializer extends CustomSerializer[Instant](format => (
{
case JInt(i) => new Instant(i.longValue)
case JNull => null
@@ -62,7 +62,7 @@ object DateParser {
format.dateFormat.parse(s).map(_.getTime).getOrElse(throw new MappingException("Invalid date format " + s))
}
-case class DateTimeSerializer extends CustomSerializer[DateTime](format => (
+case object DateTimeSerializer extends CustomSerializer[DateTime](format => (
{
case JString(s) => new DateTime(DateParser.parse(s, format))
case JNull => null
@@ -72,7 +72,7 @@ case class DateTimeSerializer extends CustomSerializer[DateTime](format => (
}
))
-case class DateMidnightSerializer extends CustomSerializer[DateMidnight](format => (
+case object DateMidnightSerializer extends CustomSerializer[DateMidnight](format => (
{
case JString(s) => new DateMidnight(DateParser.parse(s, format))
case JNull => null
@@ -166,8 +166,8 @@ trait TypeHints {
* Chooses most specific class.
*/
def hintFor(clazz: Class[_]): String = components.filter(_.containsHint_?(clazz))
- .map(th => (th.hintFor(clazz), th.classFor(th.hintFor(clazz)).getOrElse(error("hintFor/classFor not invertible for " + th))))
- .sort((x, y) => delta(x._2, clazz) - delta(y._2, clazz) < 0).head._1
+ .map(th => (th.hintFor(clazz), th.classFor(th.hintFor(clazz)).getOrElse(error("hintFor/classFor not invertible for " + th))))
+ .sort((x, y) => (delta(x._2, clazz) - delta(y._2, clazz)) < 0).head._1
def classFor(hint: String): Option[Class[_]] = {
def hasClass(h: TypeHints) =
@@ -816,14 +816,14 @@ trait BindHelpers {
implicit def strToBPAssoc(in: String): BindParamAssoc = new BindParamAssoc(in)
/**
- * transforms a Symbol to a BindParamAssoc object which can be associated to a BindParam object
- * using the --> operator.<p/>
- * Usage: <code>'David --> "name"</code>
+ * transforms a Symbol to a SuperArrowAssoc object which can be associated to a BindParam object
+ * using the -> operator.<p/>
+ * Usage: <code>'David -> "name"</code>
*
* @deprecated use -> instead
*/
@deprecated("use -> instead")
- implicit def symToBPAssoc(in: Symbol): BindParamAssoc = new BindParamAssoc(in.name)
+ implicit def symToBPAssoc(in: Symbol): SuperArrowAssoc = new SuperArrowAssoc(in.name)
/**
* Experimental extension to bind which passes in an additional "parameter" from the XHTML to the transform
@@ -168,7 +168,7 @@ trait ListHelpers {
* Convert a java.util.Enumeration to a List[T]
*/
def enumToList[T](enum: java.util.Enumeration[T]): List[T] =
- scala.collection.JavaConversions.asIterator(enum).toList
+ scala.collection.JavaConversions.enumerationAsScalaIterator(enum).toList
/**
* Convert a java.util.Enumeration to a List[String] using the toString method on each element
@@ -17,11 +17,8 @@
package net.liftweb
package util
-import java.util.Properties
import Helpers._
-import org.apache.log4j._
-import org.apache.log4j.xml._
-import common.{Logger => _, _}
+import common._
/**
* Function object that can be used in Logger.setup
@@ -58,268 +55,17 @@ object LoggingAutoConfigurer {
def apply(): () => Unit = () => {
// Try to configure log4j only if we find the SLF4J Log4j bindings
findClass("Log4jLoggerAdapter",List("org.slf4j.impl")) map {_ =>
- // Avoid double init
- if (!LogBoot.log4JInited) {
- LogBoot.log4JInited = true
- findTheFile("log4j.xml", "log4j.props") match {
- case Full(url) => _root_.net.liftweb.common.Log4j.withFile(url)()
- case _ => _root_.net.liftweb.common.Log4j.withConfig(LogBoot.defaultProps)()
- }
+ findTheFile("log4j.xml", "log4j.props") match {
+ case Full(url) => _root_.net.liftweb.common.Log4j.withFile(url)()
+ case _ => _root_.net.liftweb.common.Log4j.withConfig(Log4j.defaultProps)()
}
}
+
// Try to configure logback
findClass("Logger", List("ch.qos.logback.classic")) map {_ =>
findTheFile("logback.xml") map {url => Logback.withFile(url)()}
}
-
()
}
}
-
-/**
- * A thin wrapper around log4j.
- *
- * @deprecated Use net.liftweb.common.Logger
- */
-@deprecated("Use net.liftweb.common.Logger") object Log extends LiftLogger {
- lazy val rootLogger: LiftLogger = LogBoot.loggerByName("lift")
-
- @deprecated("Use net.liftweb.common.Logger") override def trace(msg: => AnyRef) = rootLogger.trace(msg)
- @deprecated("Use net.liftweb.common.Logger") override def trace(msg: => AnyRef, t: => Throwable) = rootLogger.trace(msg, t)
-
- @deprecated("Use net.liftweb.common.Logger") override def assertLog(assertion: Boolean, msg: => String) = rootLogger.assertLog(assertion, msg)
-
- @deprecated("Use net.liftweb.common.Logger") override def isEnabledFor(level: LiftLogLevels.Value) = rootLogger.isEnabledFor(level)
- @deprecated("Use net.liftweb.common.Logger") override def isDebugEnabled = rootLogger.isDebugEnabled
- @deprecated("Use net.liftweb.common.Logger") override def debug(msg: => AnyRef) = rootLogger.debug(msg)
- // override def debugF(msg: => AnyRef) = debug(msg)
- @deprecated("Use net.liftweb.common.Logger") override def debug(msg: => AnyRef, t: => Throwable) = rootLogger.debug(msg, t)
-
- @deprecated("Use net.liftweb.common.Logger") override def isErrorEnabled = rootLogger.isEnabledFor(LiftLogLevels.Error)
- @deprecated("Use net.liftweb.common.Logger") override def error(msg: => AnyRef) = rootLogger.error(msg)
- // override def errorF(msg: => AnyRef) = error(msg)
- @deprecated("Use net.liftweb.common.Logger") override def error(msg: => AnyRef, t: => Throwable) = rootLogger.error(msg, t)
-
- @deprecated("Use net.liftweb.common.Logger") override def fatal(msg: AnyRef) = rootLogger.fatal(msg)
- // override def fatalF(msg: AnyRef) = fatal(msg)
- @deprecated("Use net.liftweb.common.Logger") override def fatal(msg: AnyRef, t: Throwable) = rootLogger.fatal(msg, t)
-
- @deprecated("Use net.liftweb.common.Logger") override def level = rootLogger.level
- @deprecated("Use net.liftweb.common.Logger") override def level_=(level: LiftLogLevels.Value) = rootLogger.level = level
- @deprecated("Use net.liftweb.common.Logger") override def name = rootLogger.name
- // def parent = rootLogger.parent
-
- @deprecated("Use net.liftweb.common.Logger") override def isInfoEnabled = rootLogger.isInfoEnabled
- @deprecated("Use net.liftweb.common.Logger") override def info(msg: => AnyRef) = rootLogger.info(msg)
- /**
- * @deprecated Use Schemifier.infoF
- */
- @deprecated("Use Schemifier.infoF") def infoF(msg: => AnyRef) = info(msg)
- @deprecated("Use net.liftweb.common.Logger") override def info(msg: => AnyRef, t: => Throwable) = rootLogger.info(msg, t)
-
-
- // def isEnabledFor(level: Priority) = rootLogger.isEnabledFor(level)
-
- @deprecated("Use net.liftweb.common.Logger") override def isWarnEnabled = rootLogger.isWarnEnabled
- @deprecated("Use net.liftweb.common.Logger") override def warn(msg: => AnyRef) = rootLogger.warn(msg)
- // def warnF(msg: => AnyRef) = warn(msg)
- @deprecated("Use net.liftweb.common.Logger") override def warn(msg: => AnyRef, t: => Throwable) = rootLogger.warn(msg, t)
-
- @deprecated("Use net.liftweb.common.Logger") def never(msg: => AnyRef) {}
-
- /**
- * @deprecated Use Schemifier.neverF
- */
- @deprecated("Use Schemifier.neverF") def neverF(msg: => AnyRef) {}
- @deprecated("Use net.liftweb.common.Logger") def never(msg: => AnyRef, t: => Throwable) {}
-
- @deprecated("Use net.liftweb.common.Logger") override def isTraceEnabled = rootLogger.isTraceEnabled
-}
-
-/**
- * This object provides logging setup utilities.
- *
- * To provide your own log4j configuration,add either a log4j.props file or log4j.xml
- * file to your classpath.
- *
- * If you want to provide a configuration file for a subset of your application
- * or for a specifig environment, Lift expects configuration files to be named
- * in a manner relating to the context in which they are being used. The standard
- * name format is:
- *
- * <pre>
- * modeName.hostName.userName.filename.extension
- * </pre>
- *
- * with hostName and userName being optional, and modeName being one of
- * 'test', 'staging', 'production', 'pilot', 'profile', or 'default.
- * Thus, if you name your log4j config file 'default.log4j.xml' or
- * 'default.log4j.props' it will be picked up correctly.
- */
-@deprecated("Use net.liftweb.common.Logger") object LogBoot {
- @deprecated("Use net.liftweb.common.Logger") lazy val checkConfig: Boolean = loggerSetup()
-
- // Prevent double initialization of log4j by new/old logging code
- private[util] var log4JInited = false
-
- @deprecated("Use net.liftweb.common.Logger") var loggerSetup: () => Boolean = _log4JSetup _
-
- @deprecated("Use net.liftweb.common.Logger") var defaultProps =
- """<?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
- <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <appender name="appender" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.SimpleLayout"/>
- </appender>
- <root>
- <priority value ="INFO"/>
- <appender-ref ref="appender"/>
- </root>
- </log4j:configuration>
- """
-
- @deprecated("Use net.liftweb.common.Logger") def _log4JSetup() =
- {
- if (log4JInited) {
- true
- } else {
- log4JInited = true
- def log4jIsConfigured = LogManager.getLoggerRepository.getCurrentLoggers.hasMoreElements
- def findTheFile: Box[(java.net.URL, String)] = (first(Props.toTry.flatMap(f => List(f()+"log4j.props", f()+"log4j.xml")))
- (name =>tryo(getClass.getResource(name)).filter(_ ne null).map(s => (s, name))))
-
- val (log4jUrl, fileName) = findTheFile match {
- case Full((url, name)) => (Full(url), Full(name))
- case _ => (Empty, Empty)
- }
-
- for (url <- log4jUrl; name <- fileName) {
- if (name.endsWith(".xml")) {
- val domConf = new DOMConfigurator
- domConf.doConfigure(url, LogManager.getLoggerRepository())
- } else PropertyConfigurator.configure(url)
- }
-
- if (!log4jUrl.isDefined && !log4jIsConfigured) {
- val domConf = new DOMConfigurator
- val defPropBytes = defaultProps.toString.getBytes("UTF-8")
- val is = new java.io.ByteArrayInputStream(defPropBytes)
- domConf.doConfigure(is, LogManager.getLoggerRepository())
- }
- true
- }
- }
-
- private def _loggerCls(clz: Class[AnyRef]): LiftLogger = if (checkConfig) new Log4JLogger(Logger.getLogger(clz)) else NullLogger
- private def _logger(name: String): LiftLogger = if (checkConfig) new Log4JLogger(Logger.getLogger(name)) else NullLogger
-
- @deprecated("Use net.liftweb.common.Logger") var loggerByName: String => LiftLogger = _logger
- @deprecated("Use net.liftweb.common.Logger") var loggerByClass: Class[AnyRef] => LiftLogger = _loggerCls _
-}
-
-@deprecated("Use net.liftweb.common.Logger") object NullLogger extends LiftLogger {
-
-}
-/**
- * @deprecated Use net.liftweb.common.Logger
- */
-@deprecated("Use net.liftweb.common.Logger") trait LiftLogger {
- def isTraceEnabled: Boolean = false
- def trace(msg: => AnyRef): Unit = ()
- def trace(msg: => AnyRef, t: => Throwable): Unit = ()
-
- def assertLog(assertion: Boolean, msg: => String): Unit = ()
-
- def isDebugEnabled: Boolean = false
- def debug(msg: => AnyRef): Unit = ()
- def debug(msg: => AnyRef, t: => Throwable): Unit = ()
-
- def isErrorEnabled: Boolean = false
- def error(msg: => AnyRef): Unit = ()
- def error(msg: => AnyRef, t: => Throwable): Unit = ()
-
- def fatal(msg: AnyRef): Unit = ()
- def fatal(msg: AnyRef, t: Throwable): Unit = ()
-
- def level: LiftLogLevels.Value = LiftLogLevels.Off
- def level_=(level: LiftLogLevels.Value): Unit = ()
- def name: String = "Null"
- // def parent = logger.getParent
-
- def isInfoEnabled: Boolean = false
- def info(msg: => AnyRef): Unit = ()
- def info(msg: => AnyRef, t: => Throwable): Unit = ()
-
- def isEnabledFor(level: LiftLogLevels.Value): Boolean = false
-
- def isWarnEnabled: Boolean = false
- def warn(msg: => AnyRef): Unit = ()
- def warn(msg: => AnyRef, t: => Throwable): Unit = ()
-}
-
-@deprecated("Use net.liftweb.common.Logger") object LiftLogLevels extends Enumeration {
- @deprecated("Use net.liftweb.common.Logger") val All = Value(1, "All")
- @deprecated("Use net.liftweb.common.Logger") val Trace = Value(3, "Trace")
- @deprecated("Use net.liftweb.common.Logger") val Debug = Value(5, "Debug")
- @deprecated("Use net.liftweb.common.Logger") val Warn = Value(7, "Warn")
- @deprecated("Use net.liftweb.common.Logger") val Error = Value(9, "Error")
- @deprecated("Use net.liftweb.common.Logger") val Fatal = Value(11, "Fatal")
- @deprecated("Use net.liftweb.common.Logger") val Info = Value(13, "Info")
- @deprecated("Use net.liftweb.common.Logger") val Off = Value(15, "Off")
-}
-
-@deprecated("Use net.liftweb.common.Logger") class Log4JLogger(val logger: Logger) extends LiftLogger {
- override def isTraceEnabled = logger.isTraceEnabled
- override def trace(msg: => AnyRef) = if (isTraceEnabled) logger.trace(msg)
- override def trace(msg: => AnyRef, t: => Throwable) = if (isTraceEnabled) logger.trace(msg, t)
-
- override def assertLog(assertion: Boolean, msg: => String) = if (assertion) logger.assertLog(assertion, msg)
-
- override def isDebugEnabled = logger.isDebugEnabled
- override def debug(msg: => AnyRef) = if (isDebugEnabled) logger.debug(msg)
- override def debug(msg: => AnyRef, t: => Throwable) = if (isDebugEnabled) logger.debug(msg, t)
-
- override def isErrorEnabled = logger.isEnabledFor(Level.ERROR)
- override def error(msg: => AnyRef) = if (isErrorEnabled) logger.error(msg)
- override def error(msg: => AnyRef, t: => Throwable) = if (isErrorEnabled) logger.error(msg, t)
-
- override def fatal(msg: AnyRef) = logger.fatal(msg)
- override def fatal(msg: AnyRef, t: Throwable) = logger.fatal(msg, t)
-
- override def level = logger.getLevel match {
- case Level.ALL => LiftLogLevels.All
- case Level.DEBUG => LiftLogLevels.Debug
- case Level.ERROR => LiftLogLevels.Error
- case Level.WARN => LiftLogLevels.Warn
- case Level.FATAL => LiftLogLevels.Fatal
- case Level.INFO => LiftLogLevels.Info
- case Level.TRACE => LiftLogLevels.Trace
- case Level.OFF => LiftLogLevels.Off
- }
-
- val liftToLog4J: PartialFunction[LiftLogLevels.Value, Level] = {
- case LiftLogLevels.All => Level.ALL
- case LiftLogLevels.Debug => Level.DEBUG
- case LiftLogLevels.Error => Level.ERROR
- case LiftLogLevels.Warn => Level.WARN
- case LiftLogLevels.Fatal => Level.FATAL
- case LiftLogLevels.Info => Level.INFO
- case LiftLogLevels.Trace => Level.TRACE
- case LiftLogLevels.Off => Level.OFF
- }
-
- override def isEnabledFor(level: LiftLogLevels.Value): Boolean = logger.isEnabledFor(liftToLog4J(level))
- override def level_=(level: LiftLogLevels.Value) = logger.setLevel(liftToLog4J(level) )
- override def name = logger.getName
-
- override def isInfoEnabled = logger.isInfoEnabled
- override def info(msg: => AnyRef) = if (isInfoEnabled) logger.info(msg)
- override def info(msg: => AnyRef, t: => Throwable) = if (isInfoEnabled) logger.info(msg, t)
-
- def isEnabledFor(level: Priority) = logger.isEnabledFor(level)
-
- override def isWarnEnabled = isEnabledFor(Level.WARN)
- override def warn(msg: => AnyRef) = if (isWarnEnabled) logger.warn(msg)
- override def warn(msg: => AnyRef, t: => Throwable) = if (isWarnEnabled) logger.warn(msg, t)
-}
Oops, something went wrong.

0 comments on commit 03a5671

Please sign in to comment.