mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Add TransactionFilter.
This commit is contained in:
30
src/main/scala/util/TransactionFilter.scala
Normal file
30
src/main/scala/util/TransactionFilter.scala
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import javax.servlet._
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import javax.servlet.http.HttpServletRequest
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the transaction with the open session in view pattern.
|
||||||
|
*/
|
||||||
|
class TransactionFilter extends Filter {
|
||||||
|
|
||||||
|
private val logger = LoggerFactory.getLogger(classOf[TransactionFilter])
|
||||||
|
|
||||||
|
def init(config: FilterConfig) = {}
|
||||||
|
|
||||||
|
def destroy(): Unit = {}
|
||||||
|
|
||||||
|
def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain): Unit = {
|
||||||
|
if(req.asInstanceOf[HttpServletRequest].getRequestURI().startsWith("/assets/")){
|
||||||
|
// assets don't need transaction
|
||||||
|
chain.doFilter(req, res)
|
||||||
|
} else {
|
||||||
|
// TODO begin transaction!
|
||||||
|
logger.debug("TODO begin transaction")
|
||||||
|
chain.doFilter(req, res)
|
||||||
|
logger.debug("TODO end transaction")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,6 +21,16 @@
|
|||||||
<url-pattern>/git/*</url-pattern>
|
<url-pattern>/git/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>TransactionFilter</filter-name>
|
||||||
|
<filter-class>util.TransactionFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>TransactionFilter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>BasicAuthenticationFilter</filter-name>
|
<filter-name>BasicAuthenticationFilter</filter-name>
|
||||||
<filter-class>util.BasicAuthenticationFilter</filter-class>
|
<filter-class>util.BasicAuthenticationFilter</filter-class>
|
||||||
|
|||||||
Reference in New Issue
Block a user