Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1257 → Rev 1256

/PhotoAlbum/trunk/src/ak/photoalbum/webapp/CacheForm.java
File deleted
/PhotoAlbum/trunk/src/ak/photoalbum/webapp/CacheAction.java
3,7 → 3,6
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
11,31 → 10,20
import org.apache.log4j.Logger;
import ak.photoalbum.logic.Logic;
 
public final class CacheAction
public final class BuildCacheAction
extends Action
{
private static final Logger logger = Logger.getLogger(CacheAction.class);
private static final Logger logger = Logger.getLogger(IndexAction.class);
 
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
CacheForm theForm = (CacheForm)form;
String branch = theForm.getBranch();
String action = theForm.getAction();
// FIXME: show progress bar
PathForm theForm = (PathForm)form;
String branch = theForm.getBranch();
 
if("build".equals(action))
Logic.getLogic().buildCache(branch);
else if("rebuild".equals(action))
Logic.getLogic().rebuildCache(branch);
else if("reload".equals(action))
Logic.getLogic().reloadCache(branch);
else if("delete".equals(action))
Logic.getLogic().deleteCache(branch);
else
throw new ServletException("unknown action");
// FIXME: show progress bar
Logic.getLogic().buildCache(branch);
 
return mapping.findForward("success");
}
/PhotoAlbum/trunk/src/ak/photoalbum/logic/Logic.java
130,24 → 130,6
getBranch(uri).getThumbnailer().buildCache();
}
 
public void rebuildCache(String uri)
throws IOException, LogicException
{
getBranch(uri).getThumbnailer().rebuildCache();
}
 
public void deleteCache(String uri)
throws IOException, LogicException
{
getBranch(uri).getThumbnailer().deleteCache();
}
 
public void reloadCache(String uri)
throws IOException, LogicException
{
getBranch(uri).getThumbnailer().reloadCache();
}
 
public void getEntry(String uri, String path, IndexEntry page,
IndexEntry index, IndexEntry prev, IndexEntry current, IndexEntry next)
throws IOException, SAXException, LogicException
/PhotoAlbum/trunk/src/ak/photoalbum/images/Thumbnailer.java
4,6 → 4,7
import java.util.HashMap;
import java.util.Comparator;
import java.util.Arrays;
import java.io.*; // FIXME
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
10,8 → 11,6
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Graphics;
177,17 → 176,6
buildCache(imagesRoot);
}
 
public void reloadCache()
throws IOException
{
logger.info("reload cache");
 
smallCache.clear();
mediumCache.clear();
dirCache.clear();
loadCaches(cacheDir);
}
 
protected void deleteCache(File dir)
throws IOException
{
354,15 → 342,8
"unknown type of cached " + file.getCanonicalPath());
}
 
if(origin != null && cache != null) {
if(origin != null && cache != null)
loadCacheInfo(file, origin, cache);
}
else {
file.delete();
 
if(logger.isDebugEnabled())
logger.debug("deleted (unknown origin)");
}
}
 
protected void loadCacheInfo(File file, File origin, Map cache)
398,6 → 379,8
 
if(children == null) return; // the dir does not exists
 
Arrays.sort(children, fileNameComparator);
 
for(int i = 0; i < children.length; i++) {
if(children[i].isDirectory())
loadCaches(children[i]);