# HG changeset patch
# User casties
# Date 1282753748 -7200
# Node ID e758a49258e875bcf1e7503f963b5ef381692b50
# Parent 87cb3dc2aa12f53281efe7bd2e3569bfd4e48980# Parent 9936604d466e3c44d8a2609519848f33f2801629
Merge with 9936604d466e3c44d8a2609519848f33f2801629 (changes to HEAD)
diff -r 9936604d466e -r e758a49258e8 client/digitallibrary/WEB-INF/digilib-config.xml
--- a/client/digitallibrary/WEB-INF/digilib-config.xml Wed Jul 14 16:36:42 2010 +0200
+++ b/client/digitallibrary/WEB-INF/digilib-config.xml Wed Aug 25 18:29:08 2010 +0200
@@ -58,5 +58,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 9936604d466e -r e758a49258e8 client/digitallibrary/WEB-INF/web.xml
--- a/client/digitallibrary/WEB-INF/web.xml Wed Jul 14 16:36:42 2010 +0200
+++ b/client/digitallibrary/WEB-INF/web.xml Wed Aug 25 18:29:08 2010 +0200
@@ -54,40 +54,16 @@
digilib.servlet.Texter
-
-
-
- Raster
-
-
- The servlet for rastered SVG.
-
-
- digilib.servlet.Raster
-
-
-
+
- Mapper
+ PDFCache
- The servlet to create image maps.
+ The servlet for PDF.
- digilib.servlet.Mapper
-
-
-
-
-
- Relato
-
-
- The relato servlet
-
-
- Relato
+ digilib.servlet.PDFCache
@@ -145,47 +121,21 @@
/authenticated/servlet/Texter/*
-
+
- Raster
+ PDFCache
- /servlet/Raster/*
+ /servlet/PDFCache/*
- Raster
-
-
- /authenticated/servlet/Raster/*
-
-
-
-
-
- Mapper
+ PDFCache
- /servlet/Mapper/*
-
-
-
-
- Mapper
-
-
- /authenticated/servlet/Mapper/*
-
-
-
-
-
- Relato
-
-
- /Relato
+ /authenticated/servlet/PDFCache/*
diff -r 9936604d466e -r e758a49258e8 client/digitallibrary/pdf/error.jsp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/digitallibrary/pdf/error.jsp Wed Aug 25 18:29:08 2010 +0200
@@ -0,0 +1,13 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+
+
+
+
+Error
+
+
+Error
+Während der Verarbeitung ihrer Anfrage trat ein Fehler auf. Möglicherweise sind die übergebenen Parameter fehlerhaft.
+
+
diff -r 9936604d466e -r e758a49258e8 client/digitallibrary/pdf/wip.jsp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/digitallibrary/pdf/wip.jsp Wed Aug 25 18:29:08 2010 +0200
@@ -0,0 +1,14 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+
+
+
+
+
+Work in progress ...
+
+
+Bitte warten ...
+ihre Anfrage wird bearbeitet. Der Download beginnt automatisch, sobald das Dokument fertig generiert ist.
+
+
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/auth/AuthOps.java
--- a/servlet/src/digilib/auth/AuthOps.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/auth/AuthOps.java Wed Aug 25 18:29:08 2010 +0200
@@ -81,7 +81,7 @@
* @throws AuthOpException Exception thrown on error.
* @return List of Strings with role names.
*/
- public List rolesForPath(String filepath, HttpServletRequest request)
+ public List rolesForPath(String filepath, HttpServletRequest request)
throws AuthOpException;
/** Authorization roles needed for request.
@@ -95,7 +95,7 @@
* @throws AuthOpException Exception thrown on error.
* @return List of Strings with role names.
*/
- public List rolesForPath(DigilibRequest request)
+ public List rolesForPath(DigilibRequest request)
throws AuthOpException;
/** Test request authorization against a list of roles.
@@ -103,13 +103,13 @@
* @param request ServletRequest with address information.
* @return true if the user information in the request authorizes one of the roles.
*/
- public boolean isRoleAuthorized(List roles, HttpServletRequest request);
+ public boolean isRoleAuthorized(List roles, HttpServletRequest request);
/** Test request authorization against a list of roles.
* @param roles List of Strings with role names.
* @param request ServletRequest with address information.
* @return true if the user information in the request authorizes one of the roles.
*/
- public boolean isRoleAuthorized(List roles, DigilibRequest request);
+ public boolean isRoleAuthorized(List roles, DigilibRequest request);
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/auth/AuthOpsImpl.java
--- a/servlet/src/digilib/auth/AuthOpsImpl.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/auth/AuthOpsImpl.java Wed Aug 25 18:29:08 2010 +0200
@@ -21,7 +21,6 @@
package digilib.auth;
import java.util.List;
-import java.util.ListIterator;
import javax.servlet.http.HttpServletRequest;
@@ -56,7 +55,7 @@
*/
public boolean isAuthRequired(String filepath, HttpServletRequest request) throws AuthOpException {
// check permissions
- List rolesRequired = rolesForPath(filepath, request);
+ List rolesRequired = rolesForPath(filepath, request);
return (rolesRequired != null);
}
@@ -66,7 +65,7 @@
public boolean isAuthRequired(DigilibRequest request)
throws AuthOpException {
// check permissions
- List rolesRequired = rolesForPath(request);
+ List rolesRequired = rolesForPath(request);
return (rolesRequired != null);
}
@@ -80,7 +79,7 @@
* @return List of Strings with role names.
*/
public boolean isAuthorized(String filepath, HttpServletRequest request) throws AuthOpException {
- List rolesAllowed = rolesForPath(filepath, request);
+ List rolesAllowed = rolesForPath(filepath, request);
return isRoleAuthorized(rolesAllowed, request);
}
@@ -89,7 +88,7 @@
*/
public boolean isAuthorized(DigilibRequest request)
throws AuthOpException {
- List rolesAllowed = rolesForPath(request);
+ List rolesAllowed = rolesForPath(request);
return isRoleAuthorized(rolesAllowed, request);
}
@@ -98,11 +97,8 @@
* @param request ServletRequest with address information.
* @return true if the user information in the request authorizes one of the roles.
*/
- public boolean isRoleAuthorized(List roles, HttpServletRequest request) {
- ListIterator r = roles.listIterator();
- String s = "";
- while (r.hasNext()) {
- s = (String)r.next();
+ public boolean isRoleAuthorized(List roles, HttpServletRequest request) {
+ for (String s: roles) {
logger.debug("Testing role: "+s);
if (request.isUserInRole(s)) {
logger.debug("Role Authorized");
@@ -115,11 +111,8 @@
/**
* @see digilib.auth.AuthOps#isRoleAuthorized(java.util.List, digilib.servlet.DigilibRequest)
*/
- public boolean isRoleAuthorized(List roles, DigilibRequest request) {
- ListIterator r = roles.listIterator();
- String s = "";
- while (r.hasNext()) {
- s = (String)r.next();
+ public boolean isRoleAuthorized(List roles, DigilibRequest request) {
+ for (String s: roles) {
logger.debug("Testing role: "+s);
if (((HttpServletRequest)request.getServletRequest()).isUserInRole(s)) {
logger.debug("Role Authorized");
@@ -131,8 +124,8 @@
public abstract void init() throws AuthOpException;
- public abstract List rolesForPath(String filepath, HttpServletRequest request) throws AuthOpException;
+ public abstract List rolesForPath(String filepath, HttpServletRequest request) throws AuthOpException;
- public abstract List rolesForPath(DigilibRequest request) throws AuthOpException;
+ public abstract List rolesForPath(DigilibRequest request) throws AuthOpException;
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/auth/HashTree.java
--- a/servlet/src/digilib/auth/HashTree.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/auth/HashTree.java Wed Aug 25 18:29:08 2010 +0200
@@ -20,7 +20,10 @@
package digilib.auth;
-import java.util.*;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
/**
* Tree representation wrapper for a HashMap.
@@ -37,7 +40,7 @@
*/
public class HashTree {
- private Map table;
+ private Map table;
private String twigSep = "/";
@@ -53,7 +56,7 @@
* @param twig_separator
* @param leaf_separator
*/
- public HashTree(Map t, String twig_separator, String leaf_separator) {
+ public HashTree(Map t, String twig_separator, String leaf_separator) {
table = t;
twigSep = twig_separator;
leafSep = leaf_separator;
@@ -73,10 +76,10 @@
* @param branch
* @return
*/
- List match(String branch) {
+ List match(String branch) {
String b = "";
String m;
- LinkedList matches = new LinkedList();
+ LinkedList matches = new LinkedList();
// split branch
StringTokenizer twig = new StringTokenizer(branch, twigSep);
@@ -87,7 +90,7 @@
} else {
b += twigSep + twig.nextToken();
}
- m = (String) table.get(b);
+ m = table.get(b);
if (m != null) {
if (m.indexOf(leafSep) < 0) {
// single leaf
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/auth/XMLAuthOps.java
--- a/servlet/src/digilib/auth/XMLAuthOps.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/auth/XMLAuthOps.java Wed Aug 25 18:29:08 2010 +0200
@@ -69,8 +69,8 @@
*/
public void init() throws AuthOpException {
logger.debug("xmlauthops.init (" + configFile + ")");
- Map pathList = null;
- Map ipList = null;
+ Map pathList = null;
+ Map ipList = null;
try {
// load authPaths
XMLListLoader pathLoader =
@@ -105,7 +105,7 @@
* @throws AuthOpException Exception thrown on error.
* @return List of Strings with role names.
*/
- public List rolesForPath(String filepath, HttpServletRequest request)
+ public List rolesForPath(String filepath, HttpServletRequest request)
throws digilib.auth.AuthOpException {
logger.debug("rolesForPath ("
+ filepath
@@ -114,13 +114,13 @@
+ "]");
// check if the requests address provides a role
- List provided = authIPs.match(request.getRemoteAddr());
+ List provided = authIPs.match(request.getRemoteAddr());
if ((provided != null) && (provided.contains("ALL"))) {
// ALL switches off checking;
return null;
}
// which roles are required?
- List required = authPaths.match(filepath);
+ List required = authPaths.match(filepath);
// do any provided roles match?
if ((provided != null) && (required != null)) {
for (int i = 0; i < provided.size(); i++) {
@@ -136,7 +136,7 @@
/**
* @see digilib.auth.AuthOps#rolesForPath(digilib.servlet.DigilibRequest)
*/
- public List rolesForPath(DigilibRequest request) throws AuthOpException {
+ public List rolesForPath(DigilibRequest request) throws AuthOpException {
logger.debug("rolesForPath ("
+ request.getFilePath()
+ ") by ["
@@ -144,14 +144,14 @@
+ "]");
// check if the requests address provides a role
- List provided =
+ List provided =
authIPs.match(request.getServletRequest().getRemoteAddr());
if ((provided != null) && (provided.contains("ALL"))) {
// ALL switches off checking;
return null;
}
// which roles are required?
- List required = authPaths.match(request.getFilePath());
+ List required = authPaths.match(request.getFilePath());
// do any provided roles match?
if ((provided != null) && (required != null)) {
for (int i = 0; i < provided.size(); i++) {
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/image/DocuImage.java
--- a/servlet/src/digilib/image/DocuImage.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/image/DocuImage.java Wed Aug 25 18:29:08 2010 +0200
@@ -219,6 +219,12 @@
/**
* Returns a list of supported image formats
*/
- public Iterator getSupportedFormats();
+ public Iterator getSupportedFormats();
+
+ /**
+ * returns the underlying image as java.awt.Image (if possible, or null)
+ * @return
+ */
+ public java.awt.Image getAwtImage();
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/image/DocuImageImpl.java
--- a/servlet/src/digilib/image/DocuImageImpl.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/image/DocuImageImpl.java Wed Aug 25 18:29:08 2010 +0200
@@ -20,9 +20,11 @@
package digilib.image;
+import java.awt.Image;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.util.Iterator;
import java.util.LinkedList;
@@ -157,10 +159,52 @@
// emtpy implementation
}
- public Iterator getSupportedFormats() {
- List empty = new LinkedList();
+ public Iterator getSupportedFormats() {
+ List empty = new LinkedList();
return empty.iterator();
}
-
+
+ @Override
+ public void crop(int xoff, int yoff, int width, int height)
+ throws ImageOpException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Image getAwtImage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getHeight() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+ @Override
+ public int getWidth() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void loadImage(ImageFile f) throws FileOpException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void scale(double scaleX, double scaleY) throws ImageOpException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void writeImage(String mt, OutputStream ostream)
+ throws FileOpException {
+ // TODO Auto-generated method stub
+ }
+
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/image/ImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Aug 25 18:29:08 2010 +0200
@@ -117,7 +117,7 @@
}
/* returns a list of supported image formats */
- public Iterator getSupportedFormats() {
+ public Iterator getSupportedFormats() {
String[] formats = ImageIO.getReaderFormatNames();
return Arrays.asList(formats).iterator();
}
@@ -140,9 +140,9 @@
*/
RandomAccessFile raf = new RandomAccessFile(f, "r");
ImageInputStream istream = ImageIO.createImageInputStream(raf);
- Iterator readers = ImageIO.getImageReaders(istream);
+ Iterator readers = ImageIO.getImageReaders(istream);
if (readers.hasNext()) {
- ImageReader reader = (ImageReader) readers.next();
+ ImageReader reader = readers.next();
/* are there more readers? */
logger.debug("ImageIO: this reader: " + reader.getClass());
while (readers.hasNext()) {
@@ -202,11 +202,11 @@
// Iterator readers = ImageIO.getImageReaders(istream);
String mt = f.getMimetype();
logger.debug("File type:" + mt);
- Iterator readers = ImageIO.getImageReadersByMIMEType(mt);
+ Iterator readers = ImageIO.getImageReadersByMIMEType(mt);
if (!readers.hasNext()) {
throw new FileOpException("Unable to load File!");
}
- reader = (ImageReader) readers.next();
+ reader = readers.next();
/* are there more readers? */
logger.debug("ImageIO: this reader: " + reader.getClass());
while (readers.hasNext()) {
@@ -562,7 +562,7 @@
img = null;
}
- public Image getImage(){
+ public Image getAwtImage(){
return (Image) img;
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/image/JAIDocuImage.java
--- a/servlet/src/digilib/image/JAIDocuImage.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/image/JAIDocuImage.java Wed Aug 25 18:29:08 2010 +0200
@@ -20,6 +20,7 @@
package digilib.image;
+import java.awt.Image;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.image.RenderedImage;
@@ -84,20 +85,19 @@
}
/* returns a list of supported image formats */
- public Iterator getSupportedFormats() {
- Enumeration codecs = ImageCodec.getCodecs();
- List formats = new ArrayList(5);
- for (Object codec = codecs.nextElement(); codecs.hasMoreElements(); codec = codecs
- .nextElement()) {
- logger
- .debug("known format:"
- + ((ImageCodec) codec).getFormatName());
- formats.add(((ImageCodec) codec).getFormatName());
- }
- logger.debug("tilecachesize:"
- + JAI.getDefaultInstance().getTileCache().getMemoryCapacity());
- return formats.iterator();
- }
+ @SuppressWarnings("unchecked") // ImageCodec.getCodecs() returns a naked Enumeration
+ public Iterator getSupportedFormats() {
+ Enumeration codecs = ImageCodec.getCodecs();
+ List formats = new ArrayList();
+ for (ImageCodec codec = codecs.nextElement(); codecs.hasMoreElements(); codec = codecs
+ .nextElement()) {
+ logger.debug("known format:"+codec.getFormatName());
+ formats.add(codec.getFormatName());
+ }
+ logger.debug("tilecachesize:"
+ + JAI.getDefaultInstance().getTileCache().getMemoryCapacity());
+ return formats.iterator();
+ }
/* Check image size and type and store in ImageFile f */
public boolean identify(ImageFile imgf) throws IOException {
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/image/JAIImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Wed Aug 25 18:29:08 2010 +0200
@@ -20,6 +20,7 @@
package digilib.image;
+import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.renderable.ParameterBlock;
import java.io.File;
@@ -98,11 +99,11 @@
RandomAccessFile rf = new RandomAccessFile(f.getFile(), "r");
ImageInputStream istream = new FileImageInputStream(rf);
//Iterator readers = ImageIO.getImageReaders(istream);
- Iterator readers = ImageIO.getImageReadersByMIMEType(f.getMimetype());
+ Iterator readers = ImageIO.getImageReadersByMIMEType(f.getMimetype());
if (! readers.hasNext()) {
throw new FileOpException("Unable to load File!");
}
- reader = (ImageReader) readers.next();
+ reader = readers.next();
logger.debug("JAIImageIO: this reader: " + reader.getClass());
while (readers.hasNext()) {
logger.debug(" next reader: " + readers.next().getClass());
@@ -166,7 +167,13 @@
}
}
- /* (non-Javadoc)
+ @Override
+ public Image getAwtImage() {
+ // TODO Auto-generated method stub
+ return (Image) img;
+ }
+
+ /* (non-Javadoc)
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/io/AliasingDocuDirCache.java
--- a/servlet/src/digilib/io/AliasingDocuDirCache.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/io/AliasingDocuDirCache.java Wed Aug 25 18:29:08 2010 +0200
@@ -23,8 +23,8 @@
package digilib.io;
import java.io.File;
-import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import digilib.servlet.DigilibConfiguration;
@@ -45,7 +45,7 @@
throws FileOpException {
// create standard DocuDirCache
super(baseDirs, fileClasses, dlConfig);
- Map pathMap = null;
+ Map pathMap = null;
// read alias config file
try {
// load into pathMap
@@ -63,18 +63,16 @@
* load map entries into cache
*/
- for (Iterator i = pathMap.keySet().iterator(); i.hasNext();) {
- String link = (String) i.next();
- String dir = (String) pathMap.get(link);
- if (dir == null) {
+ for (Entry linkdir: pathMap.entrySet()) {
+ if (linkdir.getValue() == null) {
logger.error("Key mismatch in mapping file!");
break;
}
- DocuDirectory destDir = new DocuDirectory(dir, this);
+ DocuDirectory destDir = new DocuDirectory(linkdir.getValue(), this);
if (destDir.isValid()) {
- logger.debug("Aliasing dir: " + link);
+ logger.debug("Aliasing dir: " + linkdir.getKey());
// add the alias name
- putName(FileOps.normalName(link), destDir);
+ putName(FileOps.normalName(linkdir.getKey()), destDir);
// add the real dir
putDir(destDir);
}
@@ -87,13 +85,12 @@
* @param name
* @param newdir
*/
- public void putName(String name, DocuDirectory newdir) {
- if (map.containsKey(name)) {
- logger
- .warn("Duplicate key in AliasingDocuDirCache.put -- ignored!");
- } else {
- map.put(name, newdir);
- }
- }
+ public void putName(String name, DocuDirectory newdir) {
+ if (map.containsKey(name)) {
+ logger.warn("Duplicate key in AliasingDocuDirCache.put -- ignored!");
+ } else {
+ map.put(name, newdir);
+ }
+ }
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/io/DocuDirCache.java
--- a/servlet/src/digilib/io/DocuDirCache.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/io/DocuDirCache.java Wed Aug 25 18:29:08 2010 +0200
@@ -24,7 +24,6 @@
import java.io.File;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -42,7 +41,7 @@
Logger logger = Logger.getLogger(this.getClass());
/** HashMap of directories */
- Map map = null;
+ Map map = null;
/** names of base directories */
String[] baseDirNames = null;
@@ -74,7 +73,7 @@
public DocuDirCache(String[] bd, int[] fileClasses,
DigilibConfiguration dlConfig) {
baseDirNames = bd;
- map = new HashMap();
+ map = new HashMap();
this.fileClasses = fileClasses;
safeDirIndex = dlConfig.getAsBoolean("safe-dir-index");
}
@@ -87,7 +86,7 @@
*/
public DocuDirCache(String[] bd) {
baseDirNames = bd;
- map = new HashMap();
+ map = new HashMap();
// default file class is CLASS_IMAGE
fileClasses = new int[1];
fileClasses[0] = FileOps.CLASS_IMAGE;
@@ -149,11 +148,9 @@
* find all children and their children.
* @return
*/
- public List getChildren(String dirname, boolean recurse) {
- List l = new LinkedList();
- for (Iterator i = map.keySet().iterator(); i.hasNext();) {
- String n = (String) i.next();
- DocuDirectory dd = (DocuDirectory) map.get(n);
+ public List getChildren(String dirname, boolean recurse) {
+ List l = new LinkedList();
+ for (DocuDirectory dd: map.values()) {
if (recurse) {
if (dd.getDirName().startsWith(dirname)) {
l.add(dd);
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/io/DocuDirectory.java
--- a/servlet/src/digilib/io/DocuDirectory.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/io/DocuDirectory.java Wed Aug 25 18:29:08 2010 +0200
@@ -25,7 +25,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -37,7 +36,7 @@
public class DocuDirectory extends Directory {
/** list of files (DocuDirent) */
- private ArrayList[] list = null;
+ private List> list = null;
/** directory object is valid (exists on disk) */
private boolean isValid = false;
@@ -49,13 +48,13 @@
private String dirName = null;
/** directory metadata */
- private Map dirMeta = null;
+ private MetadataMap dirMeta = null;
/** state of metadata is valid */
private boolean metaChecked = false;
/** unresolved file metadata */
- private Map unresolvedFileMeta = null;
+ private Map unresolvedFileMeta = null;
/** time of last access of this object (not the filesystem) */
private long objectATime = 0;
@@ -90,7 +89,13 @@
protected void initDir() {
String baseDirName = cache.getBaseDirNames()[0];
// clear directory first
- list = new ArrayList[FileOps.NUM_CLASSES];
+ //list = new ArrayList[FileOps.NUM_CLASSES];
+
+ list = new ArrayList>(FileOps.NUM_CLASSES);
+ // create empty list
+ for (int i=0; i < FileOps.NUM_CLASSES; ++i) {
+ list.add(null);
+ }
isValid = false;
dirMTime = 0;
// the first directory has to exist
@@ -102,7 +107,7 @@
*
*/
public int size() {
- return ((list != null) && (list[0] != null)) ? list[0].size() : 0;
+ return ((list != null) && (list.get(0) != null)) ? list.get(0).size() : 0;
}
/**
@@ -112,7 +117,7 @@
* fileClass
*/
public int size(int fc) {
- return ((list != null) && (list[fc] != null)) ? list[fc].size() : 0;
+ return ((list != null) && (list.get(fc) != null)) ? list.get(fc).size() : 0;
}
/**
@@ -122,10 +127,10 @@
* @return
*/
public ImageFileset get(int index) {
- if ((list == null) || (list[0] == null) || (index >= list[0].size())) {
+ if ((list == null) || (list.get(0) == null) || (index >= list.get(0).size())) {
return null;
}
- return (ImageFileset) list[0].get(index);
+ return (ImageFileset) list.get(0).get(index);
}
/**
@@ -137,10 +142,10 @@
* @return
*/
public DocuDirent get(int index, int fc) {
- if ((list == null) || (list[fc] == null) || (index >= list[fc].size())) {
+ if ((list == null) || (list.get(fc) == null) || (index >= list.get(fc).size())) {
return null;
}
- return (DocuDirent) list[fc].get(index);
+ return (DocuDirent) list.get(fc).get(index);
}
/**
@@ -221,10 +226,10 @@
int numFiles = fileList.length;
if (numFiles > 0) {
// create new list
- list[fileClass] = new ArrayList(numFiles);
+ list.set(fileClass, new ArrayList(numFiles));
// sort the file names alphabetically and iterate the list
// Arrays.sort(fileList); // not needed
- Map hints = FileOps.newHints(FileOps.HINT_BASEDIRS, dirs);
+ Map hints = FileOps.newHints(FileOps.HINT_BASEDIRS, dirs);
hints.put(FileOps.HINT_FILEEXT, scalext);
for (int i = 0; i < numFiles; i++) {
DocuDirent f = FileOps.fileForClass(fileClass, fileList[i],
@@ -232,11 +237,12 @@
// add the file to our list
// logger.debug(f.getName());
- list[fileClass].add(f);
+ list.get(fileClass).add(f);
f.setParent(this);
}
- // we sort the ArrayList, not the Array, for binarySearch to work
- Collections.sort(list[fileClass]);
+ // we sort the inner ArrayList (the list of files not the list of file types)
+ // for binarySearch to work (DocuDirent's natural sort order is by filename)
+ Collections.sort(list.get(fileClass));
}
}
// clear the scaled directories
@@ -282,12 +288,12 @@
XMLMetaLoader ml = new XMLMetaLoader();
try {
// read directory meta file
- Map fileMeta = ml.loadURL(mf.getAbsolutePath());
+ Map fileMeta = ml.loadURL(mf.getAbsolutePath());
if (fileMeta == null) {
return;
}
// meta for the directory itself is in the "" bin
- dirMeta = (Map) fileMeta.remove("");
+ dirMeta = fileMeta.remove("");
// read meta for files in this directory
readFileMeta(fileMeta, null);
// is there meta for other files left?
@@ -334,25 +340,24 @@
* @param fc
* fileClass
*/
- protected void readFileMeta(Map fileMeta, String relPath) {
+ protected void readFileMeta(Map fileMeta, String relPath) {
if (list == null) {
// there are no files
return;
}
String path = (relPath != null) ? (relPath + "/") : "";
// go through all file classes
- for (int nc = 0; nc < list.length; nc++) {
+ for (int nc = 0; nc < list.size(); nc++) {
int fc = cache.getFileClasses()[nc];
- if (list[fc] == null) {
+ if (list.get(fc) == null) {
continue;
}
// iterate through the list of files in this directory
- for (Iterator i = list[fc].iterator(); i.hasNext();) {
- DocuDirent f = (DocuDirent) i.next();
+ for (DocuDirent f: list.get(fc)) {
// prepend path to the filename
String fn = path + f.getName();
// look up meta for this file and remove from dir
- Map meta = (Map) fileMeta.remove(fn);
+ MetadataMap meta = fileMeta.remove(fn);
if (meta != null) {
// store meta in file
f.setFileMeta(meta);
@@ -361,13 +366,13 @@
}
}
- protected void notifyChildMeta(Map childmeta) {
- List children = cache.getChildren(this.dirName, true);
+ protected void notifyChildMeta(MetadataMap childmeta) {
+ List children = cache.getChildren(this.dirName, true);
if (children.size() > 0) {
- for (Iterator i = children.iterator(); i.hasNext();) {
+ /*for (DocuDirectory d: children) {
// TODO: finish this!
//((DocuDirectory) i.next()).readFileMeta()
- }
+ }*/
}
}
@@ -416,13 +421,13 @@
return -1;
}
}
- List fileList = list[fc];
+ List fileList = list.get(fc);
// empty directory?
if (fileList == null) {
return -1;
}
- // search for exact match
+ // search for exact match (DocuDirent does compareTo)
// OBS: fileList needs to be sorted first (see )!
int idx = Collections.binarySearch(fileList, fn);
if (idx >= 0) {
@@ -449,8 +454,8 @@
return -1;
}
- private boolean isBaseInList(List fl, int idx, String fn) {
- String dfn = FileOps.basename(((DocuDirent) fl.get(idx))
+ private boolean isBaseInList(List fl, int idx, String fn) {
+ String dfn = FileOps.basename((fl.get(idx))
.getName());
return (dfn.equals(fn)||dfn.equals(FileOps.basename(fn)));
}
@@ -470,7 +475,7 @@
int fc = FileOps.classForFilename(fn);
int i = indexOf(fn, fc);
if (i >= 0) {
- return (DocuDirent) list[0].get(i);
+ return (DocuDirent) list.get(0).get(i);
}
return null;
}
@@ -489,7 +494,7 @@
public DocuDirent find(String fn, int fc) {
int i = indexOf(fn, fc);
if (i >= 0) {
- return (DocuDirent) list[fc].get(i);
+ return (DocuDirent) list.get(fc).get(i);
}
return null;
}
@@ -531,7 +536,7 @@
/**
* @return Hashtable
*/
- public Map getDirMeta() {
+ public MetadataMap getDirMeta() {
return dirMeta;
}
@@ -560,7 +565,7 @@
* @param dirMeta
* The dirMeta to set
*/
- public void setDirMeta(Map dirMeta) {
+ public void setDirMeta(MetadataMap dirMeta) {
this.dirMeta = dirMeta;
}
diff -r 9936604d466e -r e758a49258e8 servlet/src/digilib/io/DocuDirent.java
--- a/servlet/src/digilib/io/DocuDirent.java Wed Jul 14 16:36:42 2010 +0200
+++ b/servlet/src/digilib/io/DocuDirent.java Wed Aug 25 18:29:08 2010 +0200
@@ -33,12 +33,12 @@
* @author casties
*
*/
-public abstract class DocuDirent implements Comparable {
+public abstract class DocuDirent implements Comparable