use settings from ${user.home}/forkalsrud.org/

This commit is contained in:
Erik Forkalsrud 2010-02-06 13:38:43 -08:00
parent a6d3fc333f
commit 639ab48cd1
6 changed files with 27 additions and 168 deletions

4
.gitignore vendored
View file

@ -2,4 +2,8 @@
cache.properties
/build
/db
/.classpath
/.project
/.settings
/.springBeans

View file

@ -43,16 +43,13 @@
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
<configuration>
<webAppSourceDirectory>${basedir}/webapp</webAppSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>1.5</wtpversion>
<wtpContextName>album</wtpContextName>
<wtpContextName>photo</wtpContextName>
<wtpdefaultserver>J2EE Preview</wtpdefaultserver>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>

View file

@ -1,15 +0,0 @@
# point to our own maven repository
maven.repo.remote=http://www.forkalsrud.org/maven-proxy/repository
# warn about use of deprecated classes/methods
maven.compile.deprecation=true
# WAR plugin
#maven.war.final.name=ROOT.war
maven.war.src=webapp
# PMD plugin
maven.pmd.cpd.enable=true
#maven.jblanket.enable=true

View file

@ -1,134 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>1</pomVersion>
<artifactId>album</artifactId>
<name>album</name>
<groupId>forkalsrud</groupId>
<currentVersion>2</currentVersion>
<organization>
<name>forkalsrud.org</name>
<url>http://www.forkalsrud.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<package>org.forkalsrud.album</package>
<shortDescription>Photo Album</shortDescription>
<siteAddress>http://www.forkalsrud.org/album/</siteAddress>
<repository>
<connection>scm:pserver:forkalsrud.org:/home/cvsroot</connection>
</repository>
<developers>
<developer>
<name>Knut Forkalsrud</name>
<id>1</id>
<email>knut@forkalsrud.org</email>
<url>http://www.forkalsrud.org/~knut/</url>
<timezone>PST</timezone>
</developer>
<developer>
<name>Erik Forkalsrud</name>
<id>2</id>
<email>erik@forkalsrud.org</email>
<url>http://www.forkalsrud.org/~erik/</url>
<timezone>PST</timezone>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0.6</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>1.7</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.1</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.0</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>velocity-tools</groupId>
<artifactId>velocity-tools-view</artifactId>
<version>1.2</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>com.drew</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.3.1</version>
<type>jar</type>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>com.drew</groupId>
<artifactId>metadata-extractor-source</artifactId>
<type>source</type>
<jar>metadata-extractor-2.3.1-src.jar</jar>
<properties>
<war.bundle>false</war.bundle>
</properties>
</dependency>
<dependency>
<groupId>servletapi</groupId>
<artifactId>servletapi</artifactId>
<version>2.4</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<reports>
<report>maven-junit-report-plugin</report>
<report>maven-jcoverage-plugin</report>
<report>maven-pmd-plugin</report>
<report>maven-javadoc-plugin</report>
<report>maven-jdepend-plugin</report>
</reports>
</project>

View file

@ -1,6 +1,7 @@
package org.forkalsrud.album.web;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Calendar;
@ -83,17 +84,30 @@ public class AlbumServlet
public void init()
throws ServletException
{
Properties props = new Properties();
File forkalsrudOrg = new File(System.getProperty("user.home"), "forkalsrud.org");
if (! forkalsrudOrg.exists()) {
forkalsrudOrg.mkdirs();
}
File photoConf = new File(forkalsrudOrg, "photo.properties");
if (photoConf.exists()) {
try {
props.load(new FileReader(photoConf));
} catch (Exception e) {
throw new ServletException("unable to load settings from " + photoConf.getPath(), e);
}
}
log4jInit("/log4j.properties");
System.out.println("in init of Album");
base = new File(getServletConfig().getInitParameter("base")).getAbsoluteFile();
base = new File(props.getProperty("base", "photos")).getAbsoluteFile();
basePrefix = "/" + base.getName();
String dbDirName = getServletConfig().getInitParameter("dbdir");
String dbDirName = props.getProperty("dbdir");
File dbDir = dbDirName != null ? new File(dbDirName) : new File(System.getProperty("java.io.tmpdir"), "album");
dbDir.mkdir();
dbDir.mkdirs();
db.init(dbDir);
// cacheManager = CacheManager.create();
// imageCache = cacheManager.getCache("imageCache");
pictureScaler = new PictureScaler();
lastCacheFlushTime = System.currentTimeMillis();
}

View file

@ -4,10 +4,10 @@
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
id="photo"
version="2.5">
<display-name>album</display-name>
<display-name>photo</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
@ -15,14 +15,7 @@
<servlet>
<servlet-name>album</servlet-name>
<servlet-class>org.forkalsrud.album.web.AlbumServlet</servlet-class>
<init-param>
<param-name>base</param-name>
<param-value>photos</param-value>
</init-param>
<init-param>
<param-name>dbdir</param-name>
<param-value>db</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>