Diff for revision 1228
=== modified file 'src/com/pugh/sockso/web/ServerThread.java'
--- src/com/pugh/sockso/web/ServerThread.java 2010-02-18 08:48:35 +0000
+++ src/com/pugh/sockso/web/ServerThread.java 2010-02-19 17:19:39 +0000
@@ -70,11 +70,6 @@
try {
- //
- // create request/response objects, try and serve content according
- // to users preferred lang
- //
-
req = new HttpRequest( sv );
req.process( client.getInputStream() );
@@ -139,8 +134,6 @@
protected void process( final User user, final Request req, final Locale locale, final Response res ) throws Exception {
- if ( req.getResource().equals("/favicon.ico") ) { return; }
-
if ( p.get(Constants.WWW_LOG_REQUESTS_ENABLED).equals(p.YES) ) {
final RequestLogger logger = new DbRequestLogger( db );
logger.log( user, client.getInetAddress().getHostAddress(),
@@ -154,20 +147,43 @@
throw new BadRequestException(locale.getString("www.error.unknownRequest"), 400);
}
+ if ( loginRequired(user,action) ) {
+ res.redirect( "/user/login" );
+ }
+
else {
- // inject common dependencies...
- action.init(req, res, user, locale);
- if (p.get(Constants.WWW_USERS_REQUIRE_LOGIN).equals(p.YES) && user == null && action.requiresLogin()) {
- res.redirect("/user/login");
- } else {
- action.handleRequest();
- }
+ action.init( req, res, user, locale );
+ action.handleRequest();
}
}
/**
- * shows an error, and sends the status code in the response
+ * Indicates if the user needs to log in before running this action
+ *
+ * @param user
+ * @param action
+ *
+ * @return
+ *
+ */
+
+ protected boolean loginRequired( final User user, final WebAction action ) {
+
+ return p.get( Constants.WWW_USERS_REQUIRE_LOGIN ).equals( p.YES )
+ && user == null
+ && action.requiresLogin();
+
+ }
+
+ /**
+ * Shows an error, and sends the status code in the response
+ *
+ * @param e
+ * @param req
+ * @param res
+ * @param showStackTrace
+ *
*/
private void showException( final BadRequestException e, final Request req, final Response res, final boolean showStackTrace ) {
=== modified file 'templates/com/pugh/sockso/templates/web/IHeader.jamon'
--- templates/com/pugh/sockso/templates/web/IHeader.jamon 2009-05-26 11:49:49 +0000
+++ templates/com/pugh/sockso/templates/web/IHeader.jamon 2010-02-19 17:19:39 +0000
@@ -28,8 +28,7 @@
<title><% properties.get(Constants.WWW_TITLE) %><%if !title.equals("") %> - <% Utils.u2e(title) #n %></%if></title>
-<link href="/file/skins/<% skin %>/css/default.css" rel="stylesheet" type="text/css" />
-<link rel="shortcut icon" href="/file/skins/<% skin %>/images/favicon.ico" type="image/x-icon" />
+<& IHeaderIncludes; skin=skin; &>
<link rel="alternate" title="Latest Tracks" href="/rss/latest" type="application/rss+xml" />
=== added file 'templates/com/pugh/sockso/templates/web/IHeaderIncludes.jamon'
--- templates/com/pugh/sockso/templates/web/IHeaderIncludes.jamon 1970-01-01 00:00:00 +0000
+++ templates/com/pugh/sockso/templates/web/IHeaderIncludes.jamon 2010-02-19 17:19:39 +0000
@@ -0,0 +1,7 @@
+
+<%args>
+ String skin = null;
+</%args>
+
+<link href="/file/skins/<% skin %>/css/default.css" rel="stylesheet" type="text/css" />
+<link rel="shortcut icon" href="/file/skins/<% skin %>/images/favicon.ico" type="image/x-icon" />
=== modified file 'templates/com/pugh/sockso/templates/web/TFlexPlayer.jamon'
--- templates/com/pugh/sockso/templates/web/TFlexPlayer.jamon 2008-09-09 22:09:31 +0000
+++ templates/com/pugh/sockso/templates/web/TFlexPlayer.jamon 2010-02-19 17:19:39 +0000
@@ -19,6 +19,8 @@
<head>
<title>Sockso Player</title>
+<& IHeaderIncludes; skin=properties.get(Constants.WWW_SKIN,"original"); &>
+
<style type="text/css">
body {
margin: 5px;
=== modified file 'templates/com/pugh/sockso/templates/web/TJsPlayer.jamon'
--- templates/com/pugh/sockso/templates/web/TJsPlayer.jamon 2009-05-26 15:46:17 +0000
+++ templates/com/pugh/sockso/templates/web/TJsPlayer.jamon 2010-02-19 17:19:39 +0000
@@ -20,7 +20,7 @@
<head>
<title></title>
-<link rel="stylesheet" type="text/css" href="/file/skins/<% skin %>/css/default.css" />
+<& IHeaderIncludes; skin=skin; &>
<script type="text/javascript" src="/file/js/jquery.js"></script>
<script type="text/javascript" src="/file/js/swfobject.js"></script>
=== modified file 'templates/com/pugh/sockso/templates/web/TSharePopup.jamon'
--- templates/com/pugh/sockso/templates/web/TSharePopup.jamon 2010-01-04 20:39:10 +0000
+++ templates/com/pugh/sockso/templates/web/TSharePopup.jamon 2010-02-19 17:19:39 +0000
@@ -15,15 +15,11 @@
Properties properties = null;
</%args>
-<%java>
- final String skin = properties.get( Constants.WWW_SKIN, "original" );
-</%java>
-
<html>
<head>
<title><% locale.getString("www.title.sharePopup") %></title>
-<link href="/file/skins/<% skin %>/css/default.css" rel="stylesheet" type="text/css" />
+<& IHeaderIncludes; skin=properties.get(Constants.WWW_SKIN,"original"); &>
<style type="text/css">
=== modified file 'templates/com/pugh/sockso/templates/web/TXspfPlayer.jamon'
--- templates/com/pugh/sockso/templates/web/TXspfPlayer.jamon 2008-09-09 21:12:01 +0000
+++ templates/com/pugh/sockso/templates/web/TXspfPlayer.jamon 2010-02-19 17:19:39 +0000
@@ -19,6 +19,8 @@
<head>
<title>Sockso Player</title>
+<& IHeaderIncludes; skin=properties.get(Constants.WWW_SKIN,"original"); &>
+
<style type="text/css">
body {
margin: 5px;
=== modified file 'test/com/pugh/sockso/web/ServerThreadTest.java'
--- test/com/pugh/sockso/web/ServerThreadTest.java 2010-02-18 08:48:35 +0000
+++ test/com/pugh/sockso/web/ServerThreadTest.java 2010-02-19 17:19:39 +0000
@@ -64,19 +64,6 @@
}
- public void testSlashFaviconRequestsIgnored() throws Exception {
- TestRequest req = new TestRequest( "/favicon.ico" );
- boolean gotException = false;
- try {
- ServerThread s = new ServerThread( server, getSocket(""), db, p, r, null );
- s.process( null, req, null, null );
- }
- catch ( BadRequestException e ) {
- gotException = true;
- }
- assertFalse( gotException );
- }
-
/**
* returns a socket whose getInmputStream will produce
* a stream with the specified data