Author: agilliland
Date: Fri Jan 13 17:20:38 2006
New Revision: 368944
URL: http://svn.apache.org/viewcvs?rev=368944&view=rev
Log:
code reformatting.
Modified:
incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
Modified:
incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java?rev=368944&r1=368943&r2=368944&view=diff
==============================================================================
---
incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
(original)
+++
incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
Fri Jan 13 17:20:38 2006
@@ -3,7 +3,6 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-
import org.apache.commons.collections.ExtendedProperties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -15,6 +14,7 @@
import org.roller.pojos.WeblogTemplate;
import org.roller.presentation.RollerContext;
+
/**
* This is a simple template file loader that loads templates
* from the Roller instance instead of plain files.
@@ -23,17 +23,14 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Lance Lavandowska</a>
* @version $Id: RollerResourceLoader.java,v 1.9 2005/01/15 03:32:49 snoopdave
Exp $
-*/
-public class RollerResourceLoader extends ResourceLoader
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(RollerResourceLoader.class);
-
- public void init( ExtendedProperties configuration)
- {
- if (mLogger.isDebugEnabled())
- {
- mLogger.debug(configuration);
+ */
+public class RollerResourceLoader extends ResourceLoader {
+
+ private static Log mLogger = LogFactory.getLog(RollerResourceLoader.class);
+
+ public void init(ExtendedProperties configuration) {
+ if (mLogger.isDebugEnabled()) {
+ mLogger.debug(configuration);
}
}
@@ -42,103 +39,92 @@
* null (which means that RollerContext may not have had a chance to call
* RollerFactory yet) ask RollerContext for Roller because it has the
* information necessary for RollerFactory to do its job.
+ *
* @return Roller
*/
- private Roller getRoller()
- {
- return RollerContext.getRoller( null );
+ private Roller getRoller() {
+ return RollerContext.getRoller( null );
}
-
- public boolean isSourceModified(Resource resource)
- {
+
+ public boolean isSourceModified(Resource resource) {
return (resource.getLastModified() !=
- readLastModified(resource, "checking timestamp"));
+ readLastModified(resource, "checking timestamp"));
}
-
- public long getLastModified(Resource resource)
- {
+
+
+ public long getLastModified(Resource resource) {
return readLastModified(resource, "getting timestamp");
}
-
+
/**
* Get an InputStream so that the Runtime can build a
* template with it.
*
- * @param name name of template
- * @return InputStream containing template
- */
- public InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- if (name == null || name.length() == 0)
- {
- throw new ResourceNotFoundException ("Need to specify a template
name!");
+ * @param name name of template
+ * @return InputStream containing template
+ */
+ public InputStream getResourceStream(String name)
+ throws ResourceNotFoundException {
+
+ if (name == null || name.length() == 0) {
+ throw new ResourceNotFoundException("Need to specify a template
name!");
}
-
- try
- {
+
+ try {
WeblogTemplate page = getPage( name );
- if (page == null)
- {
- throw new ResourceNotFoundException(
- "RollerResourceLoader: page \"" +
- name + "\" not found");
+ if (page == null) {
+ throw new ResourceNotFoundException(
+ "RollerResourceLoader: page \"" +
+ name + "\" not found");
}
return new ByteArrayInputStream(
page.getContents().getBytes("UTF-8") );
- }
- catch (UnsupportedEncodingException uex)
- {
+ } catch (UnsupportedEncodingException uex) {
// This should never actually happen. We expect UTF-8 in all JRE
installation.
- // This rethrows as a Runtime exception after logging.
+ // This rethrows as a Runtime exception after logging.
mLogger.error(uex);
throw new RuntimeException(uex);
- }
- catch (RollerException re)
- {
- String msg = "RollerResourceLoader Error: " +
- "database problem trying to load resource " + name;
+ } catch (RollerException re) {
+ String msg = "RollerResourceLoader Error: " +
+ "database problem trying to load resource " + name;
mLogger.error( msg, re );
- throw new ResourceNotFoundException (msg);
+ throw new ResourceNotFoundException(msg);
}
}
-
+
+
/**
- * Fetches the last modification time of the resource
+ * Fetches the last modification time of the resource
*
- * @param resource Resource object we are finding timestamp of
- * @param i_operation string for logging, indicating caller's intention
+ * @param resource Resource object we are finding timestamp of
+ * @param i_operation string for logging, indicating caller's intention
*
- * @return timestamp as long
+ * @return timestamp as long
*/
- private long readLastModified(Resource resource, String i_operation)
- {
+ private long readLastModified(Resource resource, String i_operation) {
+
/*
* get the template name from the resource
- */
+ */
String name = resource.getName();
- try
- {
+ try {
WeblogTemplate page = getPage( name );
- if (mLogger.isDebugEnabled())
- {
- mLogger.debug(name + ": resource=" +
resource.getLastModified() +
- " vs. page=" +
page.getLastModified().getTime());
+ if (mLogger.isDebugEnabled()) {
+ mLogger.debug(name + ": resource=" +
resource.getLastModified() +
+ " vs. page=" + page.getLastModified().getTime());
}
return page.getLastModified().getTime();
- }
- catch (RollerException re)
- {
+ } catch (RollerException re) {
mLogger.error( "Error " + i_operation, re );
}
return 0;
}
-
- public WeblogTemplate getPage(String id) throws RollerException
- {
- if (getRoller() == null) throw new RollerException(
- "RollerResourceLoader.getRoller() returned NULL");
+
+
+ public WeblogTemplate getPage(String id) throws RollerException {
+ if (getRoller() == null) throw new RollerException(
+ "RollerResourceLoader.getRoller() returned NULL");
return getRoller().getUserManager().retrievePage(id);
//retrievePageReadOnly( id );
}
-
+
}