# HG changeset patch
# User robcast
# Date 1293008074 -3600
# Node ID beeedf90cb81613b97b406939999edfb65fa7448
# Parent 34701340922e0f28434aec88c2199a36deacd4e4# Parent fd2ef7e461198ef4a9d9a02459be2057038d600d
Merge from HEAD
fd2ef7e461198ef4a9d9a02459be2057038d600d
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/WEB-INF/classes/info.txt
--- a/client/digitallibrary/WEB-INF/classes/info.txt Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-# hier zusaetzliche klassen zum kompilieren, diese muessen im laufenden
-# tomcat system in WEB-INF/lib sein.
-
-export CLASSPATH=$CLASSPATH:/opt/javalibs/xerces/xercesImpl.jar:/opt/javalibs/xerces/xml-apis.jar:/opt/javalibs/xalan/bin/xalan.jar:/opt/tomcat/common/lib/servlet-api.jar
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/contexto/contexto.jsp
--- a/client/digitallibrary/contexto/contexto.jsp Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-<%@ page language="java" %>
-<%@ page import="java.io.*" %>
-<%@ page import="java.net.*" %>
-
-<%
- digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest();
- dlRequest.setWithRequest(request);
-
-%>
-
-<%
- // Possible parameters
- String htmlPage = request.getParameter("htmlPage");
- // neu eingebaut - christian
- // @beat: kannst du das zeugs bitte checken und mir sagen, ob du
- // dagegen bist oder nicht. es ist ein uebler hack, der keine
- // kontrollmechanismen hat, aber im moment halt meinen anspruechen
- // genuegt. (den import von java.net.* ist auch von mir)
- String htmlURL = request.getParameter("htmlURL");
- String xmlURL = request.getParameter("xmlURL");
- String xslURL = request.getParameter("xslURL");
- String fileName = request.getParameter("fn");
- String pageNumber = request.getParameter("pn");
-
- // funcktioniert leider nicht - christian
- //System.setProperty("http.proxyHost", "proxy.unibe.ch");
- //System.setProperty("http.proxyPort", "8080");
-
- if(htmlPage != null) {
- response.getWriter().println(htmlPage);
- // neue parameterart eingebaut - christian
- } else if(htmlURL != null) {
- try {
- URL u = new URL(htmlURL);
- String content_type = u.openConnection().getContentType();
- InputStream is = u.openStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- //response.setContentType(content_type);
- String aLine;
- while ((aLine = br.readLine()) != null) {
- response.getWriter().println(aLine);
- }
- } catch (Exception e) {
- response.getWriter().println(e);
- }
- } else if((xmlURL != null) && (xslURL != null)) {
- out.println("xsl");
- response.sendRedirect("http://sophia.unibe.ch:8080/xslt/ApplyXSLT?URL="+ xmlURL + "&xslURL=" + xslURL);
- } else if(fileName != null && pageNumber != null) {
- response.sendRedirect("http://hera.unibe.ch:8080/alcatraz/servlet/Texter?fn=" + fileName + "&pn=" + pageNumber);
- }
-%>
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/digilib-new.html
--- a/client/digitallibrary/digilib-new.html Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,366 +0,0 @@
-
-
-
-
-
- The new digilib
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/dlContext-xml.jsp
--- a/client/digitallibrary/dlContext-xml.jsp Tue Dec 21 12:16:33 2010 +0100
+++ b/client/digitallibrary/dlContext-xml.jsp Wed Dec 22 09:54:34 2010 +0100
@@ -27,7 +27,7 @@
int pn = dlRequest.getAsInt("pn");
String fn = dlRequest.getFilePath();
String ctx = "";
-digilib.io.DocuDirent f = dirCache.getFile(fn, pn, digilib.io.FileOps.CLASS_IMAGE);
+digilib.io.DocuDirent f = dirCache.getFile(fn, pn, digilib.io.FileOps.FileClass.IMAGE);
if (f != null) {
//ctx = "hasfile:"+f.getName();
f.checkMeta();
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/modules/cm_separator.gif
Binary file client/digitallibrary/modules/cm_separator.gif has changed
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/modules/imago.js
--- a/client/digitallibrary/modules/imago.js Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,441 +0,0 @@
-/*
-
-Copyright (C) 2003 WTWG, Uni Bern
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-
-Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4
-
-*/
-
-/*************************************************************************
- * imago.js : digilib-module *
- * *
- * desc: adds different image manipulation functions. *
- * *
- *************************************************************************/
-
-
-/**
- * brightness (value of brightness between -255 - +255)
- */
-function brightness(value) {
-
- if ( (value >= -255) && (value <= 255) ) {
-
- dlParams.brgt.value = value;
- display(3);
-
- }
-
-}
-
-
-/**
- * contrast (value of contrast - range?)
- */
-function contrast(value) {
-
- dlParams.cont.value = parseFloat(value);
- display(3);
-
-}
-
-
-/**
- * brightness/contrast in one call
- */
-function brightnessContrast(brightness, contrast) {
-
- dlParams.cont.value = parseFloat(contrast);
-
- if ( (brightness >= -255) && (brightness <= 255) ) {
-
- dlParams.brgt.value = parseFloat(brightness);
- display(3);
-
- }
-
-}
-
-
-/**
- * mirror (horizontal or vertical)
- */
-function mirror(direction) {
-
- if ( direction == 'v' ) {
- if ( dlParams.mo.value.indexOf('vmir') > -1 ) {
- removeMoFlag('vmir');
- } else {
- addMoFlag('vmir');
- }
- }
-
- if ( direction == 'h' ) {
- if ( dlParams.mo.value.indexOf('hmir') > -1 ) {
- removeMoFlag('hmir');
- } else {
- addMoFlag('hmir');
- }
- }
-
- display(3);
-
-}
-
-
-/**
- * rotation
- */
-function rotation(value) {
-
- value = parseFloat(value) % 360;
-
- if ( value < 0 ) {
- value += 360;
- }
-
- dlParams.rot.value = value;
- display(3);
-
-}
-
-
-/**
- * rgb add (r/g/b, each value from -255 to +255)
- */
-function rgba(value) {
-
- values = value.split("/");
-
- if ( values.length != 3 ) {
- alert ("Illegal parameter format (r/g/b)");
- } else if ( (values[0] < -255) || (values[0] > 255) ) {
- alert ("Illegal red additioner (-255 to 255)");
- } else if ( (values[1] < -255) || (values[1] > 255) ) {
- alert ("Illegal green additioner (-255 to 255)");
- } else if ( (values[2] < -255) || (values[2] > 255) ) {
- alert ("Illegal blue additioner (-255 to 255)");
- } else {
-
- dlParams.rgba.value = value;
- display(3);
-
- }
-}
-
-
-/**
- * rgb mutiply (r/g/b, range?)
- */
-function rgbm(value) {
-
- values = value.split("/");
-
- if ( values.length != 3 ) {
- alert ("Illegal parameter format (r/g/b)");
- } else if ( !isFinite(values[0]) ) {
- alert ("Illegal red exponent");
- } else if ( !isFinite(values[1]) ) {
- alert ("Illegal green exponent");
- } else if ( !isFinite(values[2]) ) {
- alert ("Illegal blue exponent");
- } else {
-
- dlParams.rgbm.value = value;
- display(3);
-
- }
-}
-
-
-/**
- * rgba/rgbm in one call
- */
-function colors(rgba, rgbm) {
-
- add = rgba.split("/");
- mult = rgba.split("/");
-
- if ( (add.length) == 3 && (mult.length == 3) &&
- (add[0] >= -255) && (add[0] <= 255) &&
- (add[1] >= -255) && (add[1] <= 255) &&
- (add[2] >= -255) && (add[2] <= 255) &&
- (isFinite(mult[0])) &&
- (isFinite(mult[1])) &&
- (isFinite(mult[2])) ) {
-
- dlParams.rgba.value = rgba;
- dlParams.rgbm.value = rgbm;
-
- display(3);
-
- }
-}
-
-
-/**
- * pixel by pixel view of images
- */
-function pixelByPixel() {
-
- removeMoFlag('osize');
-
- addMoFlag('clip');
-
- // change scale to 1
- dlParams.ws.value = 1.0;
-
- display(3);
-
-}
-
-
-/**
- * original size view of images
- */
-function originalSize(dpi_v, dpi_h) {
-
- removeMoFlag('clip');
-
- addMoFlag('osize');
-
- // change scale to 1
- dlParams.ws.value = 1.0;
-
- dlParams.ddpix.value = cropFloat(dpi_h);
- dlParams.ddpiy.value = cropFloat(dpi_v);
-
- display(3);
-
-}
-
-
-/**
- * scale (overriding old one)
- * as pixel by pixel is some kind of scale, it does turn scale factor to 1
- * if chosen. also if a scale factor is chosen,
- * then pixel by pixel is turned off.
- */
-function scale(factor) {
-
- dlParams.ws.value = factor;
-
- removeMoFlag('clip');
- removeMoFlag('osize');
-
- display(3);
-
-}
-
-
-/**
- * placeMarks (overriding old one)
- * take care of rotation and mirroring when placing marks
- */
-function placeMarks() {
-
- if ( dlParams.mk.value != '' ) {
-
- var mark = dlParams.mk.value.split(";");
- var mark_count = mark.length;
-
- // maximum of marks is 8
- // we do not report this error because this is already done in function 'mark'
- if ( mark_count > 8 ) mark_count = 8;
-
- var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.lay1.clip.width);
- var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.lay1.clip.height);
-
- // catch the cases where the picture had not been loaded already and
- // make a timeout so that the coordinates are calculated with the real dimensions
- if ( (picWidth > 30) || (document.pic.complete) ) {
-
- var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left;
- var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top;
-
- for (var i = 0; i < mark_count; i++) {
- mark[i] = mark[i].split("/");
-
- if ( (parseFloat(mark[i][0]) >= parseFloat(dlParams.wx.value)) &&
- (parseFloat(mark[i][1]) >= parseFloat(dlParams.wy.value)) &&
- (parseFloat(mark[i][0]) <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) &&
- (parseFloat(mark[i][1]) <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) {
-
- mark[i][0] = (mark[i][0] - dlParams.wx.value)/dlParams.ww.value;
- mark[i][1] = (mark[i][1] - dlParams.wy.value)/dlParams.wh.value;
-
- // mirror
- if ( dlParams.mo.value.indexOf('hmir') > -1 ) {
- mark[i][0] = 1 - mark[i][0];
- }
- if ( dlParams.mo.value.indexOf('vmir') > -1 ) {
- mark[i][1] = 1 - mark[i][1];
- }
-
- // just the beginning - not working currently
- var ang_rad = dlParams.rot.value*2*3.1415926/360;
-
- var ws = Math.sin(ang_rad)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth;
- var wc = (Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth;
-
- var hs = (Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight;
- var hc = Math.cos(ang_rad)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight;
-
- var origPicWidth = Math.sqrt(Math.pow(wc, 2) + Math.pow(hs, 2));
- var origPicHeight = Math.sqrt(Math.pow(ws, 2) + Math.pow(hc, 2));
- // end of the beginning ;-)
-
- mark[i][0] = parseInt(xOffset + picWidth * mark[i][0]);
- mark[i][1] = parseInt(yOffset + picHeight * mark[i][1]);
-
- if ( (document.all) || (typeof(document.getElementById) == "function") ) {
- // suboptimal to place -5 pixels and not half size of mark-image
- // should be changed in the future
- document.getElementById("dot" + i).style.left = mark[i][0]-5;
- document.getElementById("dot" + i).style.top = mark[i][1]-5;
- document.getElementById("dot" + i).style.visibility = "visible";
- } else {
- document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5);
- document.layers[i+1].visibility = "show";
- }
- }
- }
-
- } else {
- setTimeout("placeMarks()", 100);
- }
- }
-}
-
-
-/****
- * helper functions
- ****/
-
-/**
- * Point (overriding old one)
- * constructor holding different values of a point
- * depending also on mirror or rotation
- */
-function Point(evt) {
-
- if ( document.all ) {
-
- this.pageX = parseInt(document.body.scrollLeft+event.clientX);
- this.pageY = parseInt(document.body.scrollLeft+event.clientY);
-
- this.x = this.pageX-parseInt(document.all.lay1.style.left);
- this.y = this.pageY-parseInt(document.all.lay1.style.top);
-
- // mirror
- if ( dlParams.mo.value.indexOf('hmir') > -1 ) {
- this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.all.lay1.offsetWidth));
- } else {
- this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth));
- }
- if ( dlParams.mo.value.indexOf('vmir') > -1 ) {
- this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.all.lay1.offsetHeight));
- } else {
- this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight));
- }
-
- } else {
-
- this.pageX = parseInt(evt.pageX);
- this.pageY = parseInt(evt.pageY);
-
- if ( typeof(document.getElementById) == "function" ) {
-
- this.x = this.pageX-parseInt(document.getElementById("lay1").style.left);
- this.y = this.pageY-parseInt(document.getElementById("lay1").style.top);
-
- // mirror
- if ( dlParams.mo.value.indexOf('hmir') > -1 ) {
- this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.pic.offsetWidth));
- } else {
- this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth));
- }
- if ( dlParams.mo.value.indexOf('vmir') > -1 ) {
- this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.pic.offsetHeight));
- } else {
- this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight));
- }
-
- } else {
-
- this.x = this.pageX-document.lay1.left;
- this.y = this.pageY-document.lay1.top;
-
- // mirror
- if ( dlParams.mo.value.indexOf('hmir') > -1 ) {
- this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.lay1.clip.width));
- } else {
- this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width));
- }
- if ( dlParams.mo.value.indexOf('vmir') > -1 ) {
- this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.lay1.clip.height));
- } else {
- this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height));
- }
-
- }
-
- }
-
- return this;
-
-}
-
-
-/**
- * removeMoFlag from mo parameter
- */
-function removeMoFlag(name) {
-
- if ( dlParams.mo.value != '' ) {
-
- var idx_comma_after = dlParams.mo.value.indexOf(name + ',');
- var idx_comma_before = dlParams.mo.value.indexOf(',' + name);
- var idx_nocomma = dlParams.mo.value.indexOf(name);
-
- if ( idx_comma_after > -1 ) {
- dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_after) + dlParams.mo.value.slice(idx_comma_after+name.length+1);
- }else if ( idx_comma_before > -1 ) {
- dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_before) + dlParams.mo.value.slice(idx_comma_before+name.length+1);
- } else if ( idx_nocomma > -1 ) {
- dlParams.mo.value = dlParams.mo.value.slice(0, idx_nocomma) + dlParams.mo.value.slice(idx_nocomma+name.length);
- }
- }
-
-}
-
-
-/**
- * addMoFlag from mo parameter
- */
-function addMoFlag(name) {
-
- if ( dlParams.mo.value.indexOf(name) == -1 ) {
-
- if ( dlParams.mo.value.length > 0 ) {
- dlParams.mo.value += ',' + name;
- } else {
- dlParams.mo.value = name;
- }
- }
-
-}
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/modules/newReferences.js
--- a/client/digitallibrary/modules/newReferences.js Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
-
-Copyright (C) 2003 WTWG, Uni Bern
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-
-Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4
-
-*/
-
-/*************************************************************************
- * newReferences.js : digilib-module *
- * *
- * desc: creates references in the new parameter format (key-value) *
- * *
- *************************************************************************/
-
-
-/**
- * ref, overriding original one
- */
-function ref(select) {
-
- var hyperlinkRef = baseUrl + "/digilib.jsp?";
-
- if ( select >= 2 ) {
-
- // no original size is referenced at the moment,
- // because the dpi values are not constant from user to user
- removeMoFlag('osize');
-
- var parameterString = '';
-
- for ( param in dlParams ) {
- if ( (dlParams[param].detail < 9) && (dlParams[param].defaultValue != dlParams[param].value) ) {
- parameterString += "&" + param + "=" + dlParams[param].value;
- }
- }
-
- if (select == 2) {
- parameterString += "&lv=3"; // level three
- parameterString = parameterString.slice(1);
- prompt("Alcatraz-style HTML link", hyperlinkRef + parameterString);
- } else {
- parameterString += "&lv=1"; // i just really want the image
- parameterString = parameterString.slice(1);
- return hyperlinkRef + parameterString;
- }
-
- } else {
-
- var parameterString = '';
-
- parameterString += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+";
- parameterString += dlParams.mo.value + "+" + dlParams.mk.value;
-
- if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) {
- parameterString += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value;
- parameterString += "+" + dlParams.wh.value;
- }
-
- if ( select == 1 ) {
- prompt("Link for HTML-documents", hyperlinkRef + parameterString);
- }
-
- if ( select == 0 ) {
- prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + parameterString + "}{TEXT}");
- }
- }
-}
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/astro.xml
--- a/client/digitallibrary/relato/astro.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/blank.html
--- a/client/digitallibrary/relato/blank.html Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/compare.xml
--- a/client/digitallibrary/relato/compare.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/digicat-digilib.xml
--- a/client/digitallibrary/relato/digicat-digilib.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/digilib-digilib.xml
--- a/client/digitallibrary/relato/digilib-digilib.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/neugebauer.xml
--- a/client/digitallibrary/relato/neugebauer.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/picture.xml
--- a/client/digitallibrary/relato/picture.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/relato.js
--- a/client/digitallibrary/relato/relato.js Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-top.name = 'f';
-
-if ( !top.focused )
- top.focused = new Object();
-
-
-function identify() {
- return 'Relato v0.1';
-}
-
-
-function frameSelected() {
- return top.focused != '';
-}
-
-
-function frameSelectable(name) {
- // created by xls
- var frames = protectedFrames();
- var selectable = true;
- for (var i=0; i 0) {
- for ( i=0; i < current.frames.length; i++ ) {
- if (!current.frames[i].name) {
- current.frames[i].name = name + i;
- }
- if (frameSelectable(current.frames[i].name)) {
- current.frames[i].addEventListener( 'click', focusListener, true );
- if (current.frames[i].name == nameOfSelectedFrame()) {
- top.focused = current.frames[i];
- }
- } else {
- if (current.frames[i] == selectedFrameObject()) {
- top.focused = '';
- }
- }
- current.frames[i].addEventListener( 'unload', unloadListener, true );
- init_rec( current.frames[i], current.frames[i].name );
- }
- }
-}
-
-
-function listFrames() {
-
- var frames = new Array();
-
- function listFrames_rec( current ) {
-
- if (current.frames.length > 0) {
- for (var i=0; i < current.frames.length; i++) {
- listFrames_rec(current.frames[i]);
- }
- } else {
- frames.push(current);
- }
- }
-
- listFrames_rec(top);
-
- return frames;
-
-}
-
-
-function getXML() {
- query_string = location.search;
- query_string.search(/xml=([^\&]*)\&/);
- return RegExp.$1;
-}
-
-
-function blink() {
- orig_color = top.focused.document.bgColor;
- top.focused.document.bgColor="black";
- setTimeout('top.focused.document.bgColor="' + orig_color + '"', 100);
-}
-
-
-function focusListener( event ) {
-
- var active = this;
-
- if ( event.ctrlKey ) {
- active = this.parent;
- }
-
- // can be used in future to mark several frames
- // markActiveFrame_rec( top, active );
-
- top.focused = active;
-
- blink();
-
- // just debug information
- window.status = top.focused.name;
-}
-
-
-function unloadListener( event ) {
- setTimeout('init()', 250);
-}
-
-
-function markActiveFrame_rec(current, active) {
-
- if ( current.frames.length > 0 ) {
- for ( i=0; i < current.frames.length; i++ ) {
- markActiveFrame_rec( current.frames[i], active );
- }
- } else {
- if ( current.name.indexOf(active.name) == 0 ) {
- current.document.bgColor = '#444444';
- } else {
- current.document.bgColor = '#666666';
- }
- }
-}
-
-
-function loadFocusedFrame(url) {
-
- if (frameSelected()) {
- top.focused.location.href = url;
- setTimeout( 'top.init()', 1000 );
- } else {
- noFrameSelected();
- }
-}
-
-
-function loadNamedFrame(url, framename) {
-
- desired = loadNamedFrame_rec(top, framename);
- if ( desired ) {
- desired.location.href = url;
- setTimeout( 'top.init()', 1000 );
- } else {
- alert( "Error - a frame with this name does not exist!" );
- }
-}
-
-function loadNamedFrame_rec(current, framename) {
-
- if ( current.frames.length > 0 ) {
- for ( i=0; i < current.frames.length; i++ ) {
- thisone = loadNamedFrame_rec(current.frames[i], framename);
- if (thisone) {
- return thisone;
- }
- }
- } else {
- if (current.name == framename) {
- return current;
- } else {
- return null;
- }
- }
-}
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/relato.xsl
--- a/client/digitallibrary/relato/relato.xsl Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function () {
- if (frameSelected()) {
-
- if (nameOfSelectedFrame() == "") {
- id = selectedFrameObject();
- if (typeof(id.) == 'function') {
- return id.(.arguments[0], .arguments[1], .arguments[2], .arguments[3]);
- }
- }
-
- } else {
-
-
- // alert message
- noFrameSelected();
-
-
- // be quiet
- return false;
-
-
- }
- }
-
-
-
-
- function dynamicButtons() {
- var btns = '';
-
- btns += '#|';
- return btns.slice(1);
- }
-
-
-
- function protectedFrames() {
- var frames = new Array ();
-
- frames.push('');
- return frames;
- }
-
-
-
- top.focused.name = '';
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/type.xml
--- a/client/digitallibrary/relato/type.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/relato/work.xml
--- a/client/digitallibrary/relato/work.xml Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In order to use relato you need to have a frame capable browser.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/xul/alcatraz.xpi
Binary file client/digitallibrary/xul/alcatraz.xpi has changed
diff -r 34701340922e -r beeedf90cb81 client/digitallibrary/xul/install.html
--- a/client/digitallibrary/xul/install.html Tue Dec 21 12:16:33 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-
-
-
-Install Alcatraz for Firefox
-
-
-
-
-
-
- Alcatraz XUL Package for Firefox
-Contains a sidebar, a toolbar and the jslib-package from mozdev
-Installation:
-
-
-
-
-Christian Luginbuehl
-
-
-
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/DocuImage.java
--- a/servlet/src/digilib/image/DocuImage.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/DocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -25,6 +25,8 @@
import java.io.OutputStream;
import java.util.Iterator;
+import javax.servlet.ServletException;
+
import digilib.io.ImageFile;
import digilib.io.FileOpException;
import digilib.io.ImageInput;
@@ -70,10 +72,11 @@
*
* @param mt mime-type of the image to be sent.
* @param res ServletResponse where the image is sent.
- * @throws FileOpException Exception thrown on any error.
+ * @throws ServletException Exception thrown on sending data.
+ * @throws ImageOpException Exception in other cases.
*/
public void writeImage(String mt, OutputStream ostream)
- throws FileOpException;
+ throws ServletException, ImageOpException;
/** The width of the current image in pixel.
*
@@ -86,6 +89,12 @@
* @return Image height in pixels.
*/
public int getHeight();
+
+ /** The size of the current image in pixel.
+ *
+ * @return
+ */
+ public ImageSize getSize();
/** The mime-type of the current image.
*
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/DocuImageImpl.java
--- a/servlet/src/digilib/image/DocuImageImpl.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/DocuImageImpl.java Wed Dec 22 09:54:34 2010 +0100
@@ -28,6 +28,8 @@
import java.util.LinkedList;
import java.util.List;
+import javax.servlet.ServletException;
+
import org.apache.log4j.Logger;
import digilib.io.FileOpException;
@@ -56,6 +58,9 @@
/** image mime-type */
protected String mimeType = null;
+ /** image size */
+ protected ImageSize imgSize = null;
+
/**
* Returns the quality.
* @return int
@@ -154,15 +159,25 @@
}
public int getHeight() {
- // TODO Auto-generated method stub
+ ImageSize is = getSize();
+ if (is != null) {
+ return is.getHeight();
+ }
return 0;
}
public int getWidth() {
- // TODO Auto-generated method stub
+ ImageSize is = getSize();
+ if (is != null) {
+ return is.getWidth();
+ }
return 0;
}
+ public ImageSize getSize() {
+ return imgSize;
+ }
+
public void loadImage(ImageFile f) throws FileOpException {
// TODO Auto-generated method stub
@@ -174,7 +189,7 @@
}
public void writeImage(String mt, OutputStream ostream)
- throws FileOpException {
+ throws ServletException, ImageOpException {
// TODO Auto-generated method stub
}
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/ImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -45,6 +45,7 @@
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
+import javax.servlet.ServletException;
import digilib.io.FileOpException;
import digilib.io.FileOps;
@@ -57,7 +58,7 @@
/** image object */
protected BufferedImage img;
-
+
/** interpolation type */
protected RenderingHints renderHint;
@@ -89,33 +90,28 @@
}
}
- public int getHeight() {
- int h = 0;
- try {
- if (img == null) {
- h = reader.getHeight(0);
- } else {
- h = img.getHeight();
- }
- } catch (IOException e) {
- logger.debug("error in getHeight", e);
- }
- return h;
- }
-
- public int getWidth() {
- int w = 0;
- try {
- if (img == null) {
- w = reader.getWidth(0);
- } else {
- w = img.getWidth();
- }
- } catch (IOException e) {
- logger.debug("error in getHeight", e);
- }
- return w;
- }
+ /* returns the size of the current image */
+ public ImageSize getSize() {
+ ImageSize is = null;
+ // TODO: do we want to cache imageSize?
+ int h = 0;
+ int w = 0;
+ try {
+ if (img == null) {
+ // get size from ImageReader
+ h = reader.getHeight(0);
+ w = reader.getWidth(0);
+ } else {
+ // get size from image
+ h = img.getHeight();
+ w = img.getWidth();
+ }
+ is = new ImageSize(w, h);
+ } catch (IOException e) {
+ logger.debug("error in getSize:", e);
+ }
+ return is;
+ }
/* returns a list of supported image formats */
public Iterator getSupportedFormats() {
@@ -230,7 +226,7 @@
/* write image of type mt to Stream */
public void writeImage(String mt, OutputStream ostream)
- throws FileOpException {
+ throws ImageOpException, ServletException {
logger.debug("writeImage");
// setup output
ImageWriter writer = null;
@@ -256,7 +252,7 @@
writer = (ImageWriter) ImageIO.getImageWritersByFormatName(
"jpeg").next();
if (writer == null) {
- throw new FileOpException("Unable to get JPEG writer");
+ throw new ImageOpException("Unable to get JPEG writer");
}
ImageWriteParam param = writer.getDefaultWriteParam();
if (quality > 1) {
@@ -277,18 +273,19 @@
writer = (ImageWriter) ImageIO.getImageWritersByFormatName(
"png").next();
if (writer == null) {
- throw new FileOpException("Unable to get PNG writer");
+ throw new ImageOpException("Unable to get PNG writer");
}
writer.setOutput(imgout);
logger.debug("writing");
writer.write(img);
} else {
// unknown mime type
- throw new FileOpException("Unknown mime type: " + mt);
+ throw new ImageOpException("Unknown mime type: " + mt);
}
} catch (IOException e) {
- throw new FileOpException("Error writing image.");
+ logger.error("Error writing image:", e);
+ throw new ServletException("Error writing image:", e);
} finally {
// clean up
if (writer != null) {
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/ImageWorker.java
--- a/servlet/src/digilib/image/ImageWorker.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/ImageWorker.java Wed Dec 22 09:54:34 2010 +0100
@@ -33,7 +33,6 @@
/**
* render and return the image
*/
- @Override
public DocuImage call() throws FileOpException, IOException, ImageOpException {
logger.debug("image worker starting");
@@ -73,8 +72,7 @@
docuImage.loadSubimage(jobinfo.getFileToLoad(), loadRect, (int) subsamp);
- logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getWidth()
- + "x" + docuImage.getHeight());
+ logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getSize());
docuImage.scale(scaleXY, scaleXY);
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/JAIDocuImage.java
--- a/servlet/src/digilib/image/JAIDocuImage.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/JAIDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -40,6 +40,7 @@
import javax.media.jai.RenderedOp;
import javax.media.jai.operator.TransposeDescriptor;
import javax.media.jai.operator.TransposeType;
+import javax.servlet.ServletException;
import com.sun.media.jai.codec.ImageCodec;
@@ -50,6 +51,10 @@
import digilib.io.ImageInput;
/** A DocuImage implementation using Java Advanced Imaging Library. */
+/**
+ * @author casties
+ *
+ */
public class JAIDocuImage extends ImageInfoDocuImage {
protected RenderedImage img;
@@ -175,8 +180,7 @@
}
/* Write the current image to an OutputStream. */
- public void writeImage(String mt, OutputStream ostream)
- throws FileOpException {
+ public void writeImage(String mt, OutputStream ostream) throws ServletException, ImageOpException {
try {
// setup output
ParameterBlock pb3 = new ParameterBlock();
@@ -188,39 +192,33 @@
pb3.add("PNG");
} else {
// unknown mime type
- throw new FileOpException("Unknown mime type: " + mt);
+ throw new ImageOpException("Unknown mime type: " + mt);
}
// render output
JAI.create("encode", pb3);
- } catch (IOException e) {
- throw new FileOpException("Error writing image.");
+ } catch (RuntimeException e) {
+ // JAI likes to throw RuntimeExceptions
+ throw new ServletException("Error writing image:", e);
}
}
- /**
- * The width of the curent image in pixel.
- *
- * @return Image width in pixels.
- */
- public int getWidth() {
- if (img != null) {
- return img.getWidth();
- }
- return 0;
- }
-
- /**
- * The height of the curent image in pixel.
- *
- * @return Image height in pixels.
- */
- public int getHeight() {
- if (img != null) {
- return img.getHeight();
- }
- return 0;
- }
+ /* returns the current image size
+ * @see digilib.image.DocuImageImpl#getSize()
+ */
+ public ImageSize getSize() {
+ ImageSize is = null;
+ // TODO: do we want to cache imgSize?
+ int h = 0;
+ int w = 0;
+ if (img != null) {
+ // get size from image
+ h = img.getHeight();
+ w = img.getWidth();
+ is = new ImageSize(w, h);
+ }
+ return is;
+ }
/* scales the current image */
public void scale(double scale, double scaleY) throws ImageOpException {
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/image/JAIImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -35,6 +35,7 @@
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
import javax.media.jai.JAI;
+import javax.servlet.ServletException;
import digilib.io.FileOpException;
import digilib.io.ImageFile;
@@ -54,33 +55,29 @@
return true;
}
- public int getHeight() {
- int h = 0;
- try {
- if (img == null) {
- h = reader.getHeight(0);
- } else {
- h = img.getHeight();
- }
- } catch (IOException e) {
- logger.debug("error in getHeight", e);
- }
- return h;
- }
+ /* returns the size of the current image */
+ public ImageSize getSize() {
+ ImageSize is = null;
+ // TODO: can we cache imageSize?
+ int h = 0;
+ int w = 0;
+ try {
+ if (img == null) {
+ // get size from ImageReader
+ h = reader.getHeight(0);
+ w = reader.getWidth(0);
+ } else {
+ // get size from image
+ h = img.getHeight();
+ w = img.getWidth();
+ }
+ is = new ImageSize(w, h);
+ } catch (IOException e) {
+ logger.debug("error in getSize:", e);
+ }
+ return is;
+ }
- public int getWidth() {
- int w = 0;
- try {
- if (img == null) {
- w = reader.getWidth(0);
- } else {
- w = img.getWidth();
- }
- } catch (IOException e) {
- logger.debug("error in getHeight", e);
- }
- return w;
- }
/* Load an image file into the Object. */
public void loadImage(ImageFile f) throws FileOpException {
@@ -147,7 +144,7 @@
/* Write the current image to an OutputStream. */
public void writeImage(String mt, OutputStream ostream)
- throws FileOpException {
+ throws ImageOpException, ServletException {
logger.debug("writeImage");
try {
// setup output
@@ -160,12 +157,12 @@
pb3.add("PNG");
} else {
// unknown mime type
- throw new FileOpException("Unknown mime type: " + mt);
+ throw new ImageOpException("Unknown mime type: " + mt);
}
// render output
JAI.create("ImageWrite", pb3);
- } catch (IOException e) {
- throw new FileOpException("Error writing image.");
+ } catch (RuntimeException e) {
+ throw new ServletException("Error writing image.");
}
}
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/pdf/PDFFileWorker.java
--- a/servlet/src/digilib/pdf/PDFFileWorker.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/pdf/PDFFileWorker.java Wed Dec 22 09:54:34 2010 +0100
@@ -45,7 +45,6 @@
this.streamWorker = new PDFStreamWorker(dlConfig, outstream, job_info, imageJobCenter);
}
- @Override
public File call() throws Exception {
OutputStream outstream = streamWorker.call();
outstream.flush();
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/servlet/PDFCache.java
--- a/servlet/src/digilib/servlet/PDFCache.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/servlet/PDFCache.java Wed Dec 22 09:54:34 2010 +0100
@@ -184,7 +184,7 @@
try {
ServletOps.sendFile(getCacheFile(docid), "application/pdf", getDownloadFilename(pdfji), response);
//sendFile(docid, getDownloadFilename(pdfji), response);
- } catch (IOException e) {
+ } catch (Exception e) {
// sending didn't work
logger.error(e.getMessage());
}
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/servlet/Scaler.java
--- a/servlet/src/digilib/servlet/Scaler.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/servlet/Scaler.java Wed Dec 22 09:54:34 2010 +0100
@@ -19,6 +19,7 @@
import digilib.auth.AuthOps;
import digilib.image.DocuImage;
import digilib.image.ImageJobDescription;
+import digilib.image.ImageOpException;
import digilib.image.ImageWorker;
import digilib.io.DocuDirCache;
import digilib.io.DocuDirectory;
@@ -249,6 +250,9 @@
logger.debug("Job Processing Time: "
+ (System.currentTimeMillis() - startTime) + "ms");
+ } catch (ImageOpException e) {
+ logger.error(e.getClass() + ": " + e.getMessage());
+ digilibError(errMsgType, Error.IMAGE, null, response);
} catch (IOException e) {
logger.error(e.getClass() + ": " + e.getMessage());
digilibError(errMsgType, Error.FILE, null, response);
@@ -306,7 +310,7 @@
// default: image
ServletOps.sendFile(img, null, null, response);
}
- } catch (IOException e) {
+ } catch (Exception e) {
logger.error("Error sending error!", e);
}
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/servlet/ServletOps.java
--- a/servlet/src/digilib/servlet/ServletOps.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/servlet/ServletOps.java Wed Dec 22 09:54:34 2010 +0100
@@ -23,17 +23,20 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import digilib.image.DocuImage;
+import digilib.image.ImageOpException;
import digilib.io.FileOpException;
import digilib.io.FileOps;
@@ -187,19 +190,17 @@
* name of the download file (for application/x)
* @param res
* ServletResponse where the image file will be sent.
- *
- * @throws FileOpException
- * Exception is thrown for a IOException.
- * @throws IOException
+ * @throws ImageOpException
+ * @throws ServletException Exception on sending data.
*/
public static void sendFile(File f, String mt, String name, HttpServletResponse response)
- throws FileOpException, IOException {
+ throws ImageOpException, ServletException {
logger.debug("sendRawFile(" + mt + ", " + f + ")");
if (mt == null) {
// auto-detect mime-type
mt = FileOps.mimeForFile(f);
if (mt == null) {
- throw new FileOpException("Unknown file type.");
+ throw new ImageOpException("Unknown file type.");
}
}
response.setContentType(mt);
@@ -211,18 +212,23 @@
}
response.addHeader("Content-Disposition", "attachment; filename=\""+name+"\"");
}
- FileInputStream inFile = new FileInputStream(f);
- OutputStream outStream = response.getOutputStream();
- response.setContentLength( (int) f.length());
- byte dataBuffer[] = new byte[4096];
- int len;
- while ((len = inFile.read(dataBuffer)) != -1) {
- // copy out file
- outStream.write(dataBuffer, 0, len);
- outStream.flush();
+ try {
+ FileInputStream inFile = new FileInputStream(f);
+ OutputStream outStream = response.getOutputStream();
+ response.setContentLength( (int) f.length());
+ byte dataBuffer[] = new byte[4096];
+ int len;
+ while ((len = inFile.read(dataBuffer)) != -1) {
+ // copy out file
+ outStream.write(dataBuffer, 0, len);
+ outStream.flush();
+ }
+ response.flushBuffer();
+ inFile.close();
+ } catch (IOException e) {
+ logger.error("Error sending file:", e);
+ throw new ServletException("Error sending file:", e);
}
- response.flushBuffer();
- inFile.close();
}
/**
@@ -231,28 +237,35 @@
* @param img
* @param mimeType
* @param response
- * @throws FileOpException
- * @throws IOException
+ * @throws ImageOpException
+ * @throws ServletException Exception on sending data.
*/
public static void sendImage(DocuImage img, String mimeType,
- HttpServletResponse response) throws FileOpException, IOException {
- OutputStream outstream = response.getOutputStream();
- // setup output -- if mime type is set use that otherwise
- // if source is JPG then dest will be JPG else it's PNG
- if (mimeType == null) {
- mimeType = img.getMimetype();
+ HttpServletResponse response) throws ImageOpException,
+ ServletException {
+ try {
+ OutputStream outstream = response.getOutputStream();
+ // setup output -- if mime type is set use that otherwise
+ // if source is JPG then dest will be JPG else it's PNG
+ if (mimeType == null) {
+ mimeType = img.getMimetype();
+ }
+ if ((mimeType.equals("image/jpeg") || mimeType.equals("image/jp2") || mimeType
+ .equals("image/fpx"))) {
+ mimeType = "image/jpeg";
+ } else {
+ mimeType = "image/png";
+ }
+ // write the image
+ response.setContentType(mimeType);
+ img.writeImage(mimeType, outstream);
+ outstream.flush();
+ } catch (IOException e) {
+ logger.error("Error sending image:", e);
+ throw new ServletException("Error sending image:", e);
+ } finally {
+ img.dispose();
}
- if ((mimeType.equals("image/jpeg") || mimeType.equals("image/jp2") || mimeType
- .equals("image/fpx"))) {
- mimeType = "image/jpeg";
- } else {
- mimeType = "image/png";
- }
-
- // write the image
- img.writeImage(mimeType, outstream);
- outstream.flush();
- img.dispose();
}
}
\ No newline at end of file
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/servlet/Texter.java
--- a/servlet/src/digilib/servlet/Texter.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/servlet/Texter.java Wed Dec 22 09:54:34 2010 +0100
@@ -28,6 +28,7 @@
import org.apache.log4j.Logger;
import digilib.auth.AuthOps;
+import digilib.image.ImageOpException;
import digilib.io.DocuDirCache;
import digilib.io.FileOpException;
import digilib.io.FileOps;
@@ -150,7 +151,7 @@
}
}
- } catch (FileOpException e) {
+ } catch (ImageOpException e) {
logger.error("ERROR: File IO Error: ", e);
try {
ServletOps.htmlMessage("ERROR: File IO Error: " + e, response);
diff -r 34701340922e -r beeedf90cb81 servlet/src/digilib/util/DigilibJobCenter.java
--- a/servlet/src/digilib/util/DigilibJobCenter.java Tue Dec 21 12:16:33 2010 +0100
+++ b/servlet/src/digilib/util/DigilibJobCenter.java Wed Dec 22 09:54:34 2010 +0100
@@ -13,8 +13,6 @@
import org.apache.log4j.Logger;
-import digilib.image.DocuImage;
-
/** Wrapper around ExecutionService.
*
* @author casties
@@ -32,10 +30,13 @@
/** label for this job center */
private String label = "";
- /**
+ /** Create a DigilibJobcenter with the given number of threads and queue length.
+ * If prestart=true it starts the threads in the thread pool.
+ *
* @param maxThreads
- * @param label TODO
- * @param maxQueueLength
+ * @param maxQueueLen
+ * @param prestart
+ * @param label
*/
public DigilibJobCenter(int maxThreads, int maxQueueLen, boolean prestart, String label) {
super();
@@ -59,17 +60,6 @@
return executor.submit(job);
}
- /** Returns if the service is not overloaded.
- *
- * @return
- */
- public boolean canRun() {
- int jql = getWaitingJobs();
- int jrl = getRunningJobs();
- logger.debug(label+" canRun: waiting jobs="+jql+" running jobs="+jrl);
- return (jql <= maxQueueLen);
- }
-
/** Returns if the service is overloaded.
*
* @return
@@ -81,10 +71,16 @@
return (jql > maxQueueLen);
}
+ /** Returns the number of currently running jobs.
+ * @return
+ */
public int getRunningJobs() {
return ((ThreadPoolExecutor)executor).getActiveCount();
}
+ /** Returns the number of currently waiting jobs.
+ * @return
+ */
public int getWaitingJobs() {
BlockingQueue jq = ((ThreadPoolExecutor)executor).getQueue();
int jql = jq.size();
@@ -107,6 +103,11 @@
return maxQueueLen;
}
+ /** Shuts down the Executor.
+ * Tries to stop running threads and returns a list of waiting threads.
+ *
+ * @return
+ */
public List shutdownNow() {
return executor.shutdownNow();
}