Mercurial > hg > digilib
changeset 1517:51486c82ed89
new DigilibBean instead of deprecated DocumentBean. Updated dirInfo-*.jsp etc. added auth_required information.
author | robcast |
---|---|
date | Fri, 06 May 2016 18:47:30 +0200 |
parents | 656feafc283f |
children | e6676b78dda7 |
files | common/src/main/java/digilib/conf/DigilibRequest.java servlet/src/main/java/digilib/servlet/DigilibBean.java servlet/src/main/java/digilib/servlet/DocumentBean.java webapp/pom.xml webapp/src/main/webapp/ImgInfo-json.jsp webapp/src/main/webapp/api/ImgInfo-json.jsp webapp/src/main/webapp/api/dirInfo-json.jsp webapp/src/main/webapp/api/dirInfo-xml.jsp webapp/src/main/webapp/dirInfo-xml.jsp |
diffstat | 9 files changed, 447 insertions(+), 131 deletions(-) [+] |
line wrap: on
line diff
--- a/common/src/main/java/digilib/conf/DigilibRequest.java Wed May 04 20:19:12 2016 +0200 +++ b/common/src/main/java/digilib/conf/DigilibRequest.java Fri May 06 18:47:30 2016 +0200 @@ -623,7 +623,7 @@ * Option string to be tested. * @return boolean * - * @deprecated use hasOption(String opt) for "mo"-options. + * @deprecated use {@llink #hasOption(String opt)} for "mo"-options. */ public boolean hasOption(String param, String opt) { String s = getAsString(param);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servlet/src/main/java/digilib/servlet/DigilibBean.java Fri May 06 18:47:30 2016 +0200 @@ -0,0 +1,305 @@ +package digilib.servlet; + +/* + * #%L + * + * DocumentBean -- digilib config access bean for JSP + * + * Digital Image Library servlet components + * + * %% + * Copyright (C) 2016 MPIWG Berlin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + * Author: Robert Casties (robcast@berlios.de) + */ + +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +import digilib.auth.AuthOpException; +import digilib.auth.AuthzOps; +import digilib.conf.DigilibServletConfiguration; +import digilib.conf.DigilibServletRequest; +import digilib.io.DocuDirCache; +import digilib.io.DocuDirectory; +import digilib.io.ImageSet; + +/** + * Java bean providing access to digilib configuration for JSPs. + * + * @author robcast + * + */ +public class DigilibBean { + + // general logger + private static Logger logger = Logger.getLogger("digilib.digibean"); + + // AuthOps object to check authorization + private AuthzOps authzOp; + + // use authorization database + private boolean useAuthorization = true; + + // DocuDirCache + private DocuDirCache dirCache = null; + + // DigilibConfiguration object + private DigilibServletConfiguration dlConfig = null; + + // current DigilibRequest object + private DigilibServletRequest dlRequest = null; + + // current DocuDirectory + private DocuDirectory dlDir = null; + + // current FileSet + private ImageSet dlImgset = null; + + // current Filepath + private String dlFn = null; + + /** + * Constructor for DigilibBean. + */ + public DigilibBean() { + logger.debug("new DigilibBean"); + } + + public DigilibBean(ServletConfig conf) { + logger.debug("new DigilibBean"); + try { + setConfig(conf); + } catch (Exception e) { + logger.fatal("ERROR: Unable to set config: ", e); + } + } + + public void setConfig(ServletConfig conf) throws ServletException { + logger.debug("setConfig"); + // get our ServletContext + ServletContext context = conf.getServletContext(); + // see if there is a Configuration instance + dlConfig = DigilibServletConfiguration.getCurrentConfig(context); + if (dlConfig == null) { + // no config + throw new ServletException("ERROR: No digilib configuration for DigilibBean!"); + } + // get cache + dirCache = (DocuDirCache) dlConfig.getValue(DigilibServletConfiguration.DIR_CACHE_KEY); + + /* + * authentication + */ + useAuthorization = dlConfig.getAsBoolean("use-authorization"); + authzOp = (AuthzOps) dlConfig.getValue("servlet.authz.op"); + if (useAuthorization && (authzOp == null)) { + throw new ServletException("ERROR: use-authorization configured but no AuthzOp!"); + } + } + + /** + * Returns if authorization is configured. + * + * @return + */ + public boolean isUseAuthorization() { + return this.useAuthorization; + } + + /** + * check if the request must be authorized to access filepath + */ + public boolean isAuthRequired() throws AuthOpException { + return isAuthRequired(dlRequest); + } + + /** + * check if the request must be authorized to access filepath + */ + public boolean isAuthRequired(DigilibServletRequest request) throws AuthOpException { + logger.debug("isAuthRequired"); + return useAuthorization ? authzOp.isAuthorizationRequired(request) : false; + } + + /** + * check if the request is allowed to access filepath + */ + public boolean isAuthorized() throws AuthOpException { + return isAuthorized(dlRequest); + } + + /** + * check if the request is allowed to access filepath + */ + public boolean isAuthorized(DigilibServletRequest request) throws AuthOpException { + logger.debug("isAuthorized"); + return useAuthorization ? authzOp.isAuthorized(request) : true; + } + + /** + * check for authenticated access and redirect if necessary + */ + public boolean doAuthentication(HttpServletResponse response) throws Exception { + logger.debug("doAuthentication-Method"); + return doAuthentication(dlRequest, response); + } + + /** + * check for authenticated access and redirect if necessary + */ + public boolean doAuthentication(DigilibServletRequest request, HttpServletResponse response) + throws Exception { + logger.debug("doAuthentication"); + if (!useAuthorization) { + // shortcut if no authorization + return true; + } + /* quick fix: add auth-url-path to base.url + if (isAuthRequired(request)) { + String baseUrl = request.getAsString("base.url"); + if (!baseUrl.endsWith(authURLPath)) { + request.setValue("base.url", baseUrl + "/" + authURLPath); + } + } + // check if we are already authenticated + if (((HttpServletRequest) request.getServletRequest()).getRemoteUser() == null) { + logger.debug("unauthenticated so far"); + // if not maybe we must? + if (isAuthRequired(request)) { + logger.debug("auth required, redirect"); + // we are not yet authenticated -> redirect + response.sendRedirect(request.getAsString("base.url") + + ((HttpServletRequest) request.getServletRequest()) + .getServletPath() + + "?" + + ((HttpServletRequest) request.getServletRequest()) + .getQueryString()); + } + } + */ + return true; + } + + + /** + * Sets the current DigilibRequest using a HttpServletRequest. + * + * @param request + */ + public void setRequest(HttpServletRequest request) throws Exception { + // create dlRequest + DigilibServletRequest dlRequest = new DigilibServletRequest(request, dlConfig); + // use for initialisation + setRequest(dlRequest); + } + + /** + * Sets the current DigilibRequest. + * + * @param dlRequest + * The dlRequest to set. + */ + public void setRequest(DigilibServletRequest dlRequest) throws Exception { + this.dlRequest = dlRequest; + this.dlFn = dlRequest.getFilePath(); + if (dirCache != null) { + // get information about the file(set) + dlImgset = (ImageSet) dirCache.getFile(dlFn, dlRequest.getAsInt("pn")); + if (dlImgset != null) { + // get information about the directory + dlDir = dirCache.getDirectory(dlFn); + } else { + dlDir = null; + } + } else { + dlImgset = null; + dlDir = null; + } + } + + /** + * get the number of pages/files in the directory + */ + public int getNumPages() throws Exception { + logger.debug("getNumPages"); + if (dlDir != null) { + return dlDir.size(); + } + return 0; + } + + /** + * get the number of image pages/files in the directory + */ + public int getNumPages(DigilibServletRequest request) throws Exception { + setRequest(request); + return getNumPages(); + } + + /** + * Returns the current DocuDirectory. + * + * @return + */ + public DocuDirectory getDirectory() { + return dlDir; + } + + /** + * Returns the current ImageSet. + * + * @return + */ + public ImageSet getImageSet() { + return dlImgset; + } + + /** + * Returns the current filepath (fn). + * + * @return + */ + public String getFilepath() { + return dlFn; + } + + + /** + * Returns the dlConfig. + * + * @return DigilibConfiguration + */ + public DigilibServletConfiguration getDlConfig() { + return dlConfig; + } + + /** + * Returns the dlRequest. + * + * @return + */ + public DigilibServletRequest getRequest() { + return dlRequest; + } + +}
--- a/servlet/src/main/java/digilib/servlet/DocumentBean.java Wed May 04 20:19:12 2016 +0200 +++ b/servlet/src/main/java/digilib/servlet/DocumentBean.java Fri May 06 18:47:30 2016 +0200 @@ -8,7 +8,7 @@ * Digital Image Library servlet components * * %% - * Copyright (C) 2001 - 2013 MPIWG Berlin + * Copyright (C) 2001 - 2016 MPIWG Berlin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -46,6 +46,13 @@ import digilib.io.ImageSet; import digilib.util.ImageSize; +/** + * Java bean providing access to digilib configuration and functionality for JSPs. + * + * @author robcast + * + * @deprecated use {@link digilib.servlet.DigilibBean} instead. + */ public class DocumentBean { // general logger @@ -92,12 +99,12 @@ // see if there is a Configuration instance dlConfig = DigilibServletConfiguration.getCurrentConfig(context); if (dlConfig == null) { - // create new Configuration - throw new ServletException("ERROR: No configuration!"); + // no config + throw new ServletException("ERROR: No digilib configuration for DocumentBean!"); } // get cache - dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); + dirCache = (DocuDirCache) dlConfig.getValue(DigilibServletConfiguration.DIR_CACHE_KEY); /* * authentication @@ -240,13 +247,6 @@ } /** - * get the number of pages/files of type fc in the directory - */ - public int getNumPages(DigilibServletRequest request, FileClass fc) throws Exception { - return getNumPages(request); - } - - /** * Returns the dlConfig. * * @return DigilibConfiguration @@ -255,10 +255,28 @@ return dlConfig; } + /** + * @return Returns the dlRequest. + */ + public DigilibServletRequest getRequest() { + return dlRequest; + } + + /** + * get the number of pages/files of type fc in the directory + * + * @deprecated use {@link #getNumPages(DigilibServletRequest request)} instead + */ + public int getNumPages(DigilibServletRequest request, FileClass fc) throws Exception { + return getNumPages(request); + } + /** * returns if the zoom area in the request can be moved * * @return + * + * only used by oldskin JSP */ public boolean canMoveRight() { float ww = dlRequest.getAsFloat("ww"); @@ -270,6 +288,8 @@ * returns if the zoom area in the request can be moved * * @return + * + * only used by oldskin JSP */ public boolean canMoveLeft() { float ww = dlRequest.getAsFloat("ww"); @@ -281,6 +301,8 @@ * returns if the zoom area in the request can be moved * * @return + * + * only used by oldskin JSP */ public boolean canMoveUp() { float wh = dlRequest.getAsFloat("wh"); @@ -292,6 +314,8 @@ * returns if the zoom area in the request can be moved * * @return + * + * only used by oldskin JSP */ public boolean canMoveDown() { float wh = dlRequest.getAsFloat("wh"); @@ -299,11 +323,4 @@ return (wh + wy < 1.0); } - /** - * @return Returns the dlRequest. - */ - public DigilibServletRequest getRequest() { - return dlRequest; - } - }
--- a/webapp/pom.xml Wed May 04 20:19:12 2016 +0200 +++ b/webapp/pom.xml Fri May 06 18:47:30 2016 +0200 @@ -353,5 +353,10 @@ <version>4.12</version> <scope>test</scope> </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jstl</artifactId> + <version>1.2</version> + </dependency> </dependencies> </project>
--- a/webapp/src/main/webapp/ImgInfo-json.jsp Wed May 04 20:19:12 2016 +0200 +++ b/webapp/src/main/webapp/ImgInfo-json.jsp Fri May 06 18:47:30 2016 +0200 @@ -2,7 +2,7 @@ #%L digilib-webapp %% - Copyright (C) 2003 - 2013 MPIWG Berlin + Copyright (C) 2003 - 2016 MPIWG Berlin %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,16 +20,13 @@ #L% Author: Robert Casties (robcast@berlios.de) --%><%@page language="java" - import="digilib.io.FileOps, - digilib.io.ImageFileSet, + import="digilib.io.ImageSet, digilib.io.ImageFile, digilib.util.ImageSize, - digilib.io.DocuDirCache, - digilib.conf.DigilibServletRequest, - digilib.conf.DigilibServletConfiguration" + digilib.servlet.DigilibBean" contentType="application/json"%><%! // create DocumentBean instance for all JSP requests -digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); +DigilibBean docBean = new DigilibBean(); // initialize DocumentBean instance in JSP init public void jspInit() { @@ -42,28 +39,28 @@ } %><% // parsing the query -DigilibServletRequest dlRequest = new DigilibServletRequest(request); -docBean.setRequest(dlRequest); -// dir cache -DigilibServletConfiguration dlConfig = docBean.getDlConfig(); -DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); +docBean.setRequest(request); // get file -FileOps.FileClass fc = FileOps.FileClass.IMAGE; -ImageFileSet imgFile = (ImageFileSet) dirCache.getFile(dlRequest.getFilePath(), dlRequest.getAsInt("pn"), fc); +ImageSet imgFile = docBean.getImageSet(); %>{<% - if (imgFile != null) { - imgFile.checkMeta(); - ImageFile img = (ImageFile) imgFile.getBiggest(); - ImageSize imgSize = img.getSize(); - %> - "filename" : "<%= imgFile.getName() %>", - "aspect" : <%= imgFile.getAspect() %>, +if (imgFile != null) { + imgFile.checkMeta(); + ImageFile img = (ImageFile) imgFile.getBiggest(); + ImageSize imgSize = img.getSize(); +%> + "filename" : "<%= img.getName() %>", +<% + if (docBean.isUseAuthorization()) { +%> "auth_required" : <%= !docBean.isAuthorized() %>, +<% + } +%> "aspect" : <%= imgFile.getAspect() %>, "dpi_x" : <%= imgFile.getResX() %>, "dpi_y" : <%= imgFile.getResY() %><% if (imgSize != null) { - %>, +%>, "width" : <%= imgSize.getWidth() %>, "height" : <%= imgSize.getHeight() %> <% }
--- a/webapp/src/main/webapp/api/ImgInfo-json.jsp Wed May 04 20:19:12 2016 +0200 +++ b/webapp/src/main/webapp/api/ImgInfo-json.jsp Fri May 06 18:47:30 2016 +0200 @@ -2,7 +2,7 @@ #%L digilib-webapp %% - Copyright (C) 2003 - 2013 MPIWG Berlin + Copyright (C) 2003 - 2016 MPIWG Berlin %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,16 +20,13 @@ #L% Author: Robert Casties (robcast@berlios.de) --%><%@page language="java" - import="digilib.io.FileOps, - digilib.io.ImageFileSet, + import="digilib.io.ImageSet, digilib.io.ImageFile, digilib.util.ImageSize, - digilib.io.DocuDirCache, - digilib.conf.DigilibServletRequest, - digilib.conf.DigilibServletConfiguration" + digilib.servlet.DigilibBean" contentType="application/json"%><%! // create DocumentBean instance for all JSP requests -digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); +DigilibBean docBean = new DigilibBean(); // initialize DocumentBean instance in JSP init public void jspInit() { @@ -42,29 +39,28 @@ } %><% // parsing the query -DigilibServletConfiguration dlConfig = docBean.getDlConfig(); -DigilibServletRequest dlRequest = new DigilibServletRequest(request, dlConfig); -docBean.setRequest(dlRequest); -// dir cache -DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); +docBean.setRequest(request); // get file -FileOps.FileClass fc = FileOps.FileClass.IMAGE; -ImageFileSet imgFile = (ImageFileSet) dirCache.getFile(dlRequest.getFilePath(), dlRequest.getAsInt("pn"), fc); +ImageSet imgFile = docBean.getImageSet(); %>{<% - if (imgFile != null) { - imgFile.checkMeta(); - ImageFile img = (ImageFile) imgFile.getBiggest(); - ImageSize imgSize = img.getSize(); - %> - "filename" : "<%= imgFile.getName() %>", - "authentication_required" : <%= docBean.isAuthRequired(dlRequest) %>, - "aspect" : <%= imgFile.getAspect() %>, +if (imgFile != null) { + imgFile.checkMeta(); + ImageFile img = (ImageFile) imgFile.getBiggest(); + ImageSize imgSize = img.getSize(); +%> + "filename" : "<%= img.getName() %>", +<% + if (docBean.isUseAuthorization()) { +%> "auth_required" : <%= !docBean.isAuthorized() %>, +<% + } +%> "aspect" : <%= imgFile.getAspect() %>, "dpi_x" : <%= imgFile.getResX() %>, "dpi_y" : <%= imgFile.getResY() %><% if (imgSize != null) { - %>, +%>, "width" : <%= imgSize.getWidth() %>, "height" : <%= imgSize.getHeight() %> <% }
--- a/webapp/src/main/webapp/api/dirInfo-json.jsp Wed May 04 20:19:12 2016 +0200 +++ b/webapp/src/main/webapp/api/dirInfo-json.jsp Fri May 06 18:47:30 2016 +0200 @@ -2,7 +2,7 @@ #%L digilib-webapp %% - Copyright (C) 2004 - 2013 MPIWG Berlin + Copyright (C) 2016 Bibliotheca Hertziana, MPIWG Berlin %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,18 +18,17 @@ License along with this program. If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>. #L% - Author: Robert Casties (robcast@berlios.de) + Authors: Robert Casties (robcast@users.sourceforge.net), Martin Raspe --%><%@ page language="java" - import="digilib.servlet.DocumentBean, + import="digilib.servlet.DigilibBean, digilib.conf.DigilibServletConfiguration, digilib.conf.DigilibServletRequest, - digilib.io.DocuDirCache, digilib.io.DocuDirectory, digilib.io.DocuDirent, digilib.io.FileOps, java.io.File"%><%! // create DocumentBean instance for all JSP requests -DocumentBean docBean = new DocumentBean(); +DigilibBean docBean = new DigilibBean(); // initialize DocumentBean instance in JSP init public void jspInit() { @@ -40,38 +39,41 @@ System.out.println(e); } } -%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ page contentType="application/json" %><% +%><%@ page contentType="application/json" %><% // process request -// get digilib config -DigilibServletConfiguration dlConfig = docBean.getDlConfig(); -// parsing the query -DigilibServletRequest dlRequest = new DigilibServletRequest(request); -// dir cache -DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); +docBean.setRequest(request); // get directory -DocuDirectory dir = dirCache.getDirectory(dlRequest.getFilePath()); -FileOps.FileClass fc = FileOps.FileClass.IMAGE; -int dirSize = dir != null ? dir.size(fc) : 0; - +DocuDirectory dir = docBean.getDirectory(); +int dirSize = docBean.getNumPages(); +%> +{<% +if (dir != null) { %> -{<% if (dir != null) { %> - "url-path" : "<%= dir.getDirName() %>", - "count" : "<%= dirSize %>", - "files" : [<% - if (!dlRequest.hasOption("mo", "dir")) { - for (int i = 0; i < dirSize; i++) { - DocuDirent f = dir.get(i, fc); - String fn = (f != null) ? f.getName() : "null"; -%> -{ + "url_path" : "<%= dir.getDirName() %>", +<% + if (docBean.isUseAuthorization()) { +%> "auth_required" : <%= ! docBean.isAuthorized() %>, +<% + } +%> "count" : "<%= dirSize %>", + "files" : [ +<% + if (!docBean.getRequest().hasOption("dir")) { + // list all files + for (int i = 0; i < dirSize; i++) { + DocuDirent f = dir.get(i); + String fn = (f != null) ? f.getName() : "null"; +%>{ "index" : <%= i+1 %>, - "fn" : "<%=digilib.io.FileOps.basename(fn)%>", - "file" : "<%=fn%>" + "fn" : "<%= FileOps.basename(fn) %>", + "file" : "<%= fn %>" }<% - if (i+1 < dirSize) {%>, -<%} - } // for + if (i+1 < dirSize) {%>, +<% } + } // for } // if not dironly - } // if dir %> -]} +]<% +} // if dir +%> +}
--- a/webapp/src/main/webapp/api/dirInfo-xml.jsp Wed May 04 20:19:12 2016 +0200 +++ b/webapp/src/main/webapp/api/dirInfo-xml.jsp Fri May 06 18:47:30 2016 +0200 @@ -18,18 +18,17 @@ License along with this program. If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>. #L% - Author: Robert Casties (robcast@berlios.de) + Author: Robert Casties (robcast@users.sourceforge.net) --%><%@ page language="java" - import="digilib.servlet.DocumentBean, + import="digilib.servlet.DigilibBean, digilib.conf.DigilibServletConfiguration, digilib.conf.DigilibServletRequest, - digilib.io.DocuDirCache, digilib.io.DocuDirectory, digilib.io.DocuDirent, digilib.io.FileOps, java.io.File"%><%! // create DocumentBean instance for all JSP requests -DocumentBean docBean = new DocumentBean(); +DigilibBean docBean = new DigilibBean(); // initialize DocumentBean instance in JSP init public void jspInit() { @@ -43,16 +42,10 @@ %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ page contentType="text/xml" %><?xml version="1.0" encoding="UTF-8" ?> <% // process request -// get digilib config -DigilibServletConfiguration dlConfig = docBean.getDlConfig(); -// parsing the query -DigilibServletRequest dlRequest = new DigilibServletRequest(request); -// dir cache -DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); +docBean.setRequest(request); // get directory -DocuDirectory dir = dirCache.getDirectory(dlRequest.getFilePath()); -FileOps.FileClass fc = FileOps.FileClass.IMAGE; -int dirSize = dir != null ? dir.size(fc) : 0; +DocuDirectory dir = docBean.getDirectory(); +int dirSize = docBean.getNumPages(); %><!-- Automatically generated XML snippet with directory info --> <dir><% if (dir != null) { %> @@ -60,14 +53,18 @@ <name><%= dir.getDirName() %></name> <fsname><%= dir.getDir().getPath() %></fsname> <% - if (!dlRequest.hasOption("mo", "dir")) { + if (docBean.isUseAuthorization()) { +%> <auth-required><%= ! docBean.isAuthorized() %></auth-required> +<% + } + if (!docBean.getRequest().hasOption("dir")) { for (int i = 0; i < dirSize; i++) { - DocuDirent f = dir.get(i, fc); + DocuDirent f = dir.get(i); String fn = (f != null) ? f.getName() : "null"; %> <file> <index><%= i+1 %></index> - <name><c:out value="<%=digilib.io.FileOps.basename(fn)%>"/></name> - <fsname><c:out value="<%=fn%>"/></fsname> + <name><c:out value="<%= FileOps.basename(fn) %>"/></name> + <fsname><c:out value="<%= fn %>"/></fsname> </file> <% } // for
--- a/webapp/src/main/webapp/dirInfo-xml.jsp Wed May 04 20:19:12 2016 +0200 +++ b/webapp/src/main/webapp/dirInfo-xml.jsp Fri May 06 18:47:30 2016 +0200 @@ -18,18 +18,17 @@ License along with this program. If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>. #L% - Author: Robert Casties (robcast@berlios.de) + Author: Robert Casties (robcast@users.sourceforge.net) --%><%@ page language="java" - import="digilib.servlet.DocumentBean, + import="digilib.servlet.DigilibBean, digilib.conf.DigilibServletConfiguration, digilib.conf.DigilibServletRequest, - digilib.io.DocuDirCache, digilib.io.DocuDirectory, digilib.io.DocuDirent, digilib.io.FileOps, java.io.File"%><%! // create DocumentBean instance for all JSP requests -DocumentBean docBean = new DocumentBean(); +DigilibBean docBean = new DigilibBean(); // initialize DocumentBean instance in JSP init public void jspInit() { @@ -43,16 +42,10 @@ %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ page contentType="text/xml" %><?xml version="1.0" encoding="UTF-8" ?> <% // process request -// get digilib config -DigilibServletConfiguration dlConfig = docBean.getDlConfig(); -// parsing the query -DigilibServletRequest dlRequest = new DigilibServletRequest(request); -// dir cache -DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); +docBean.setRequest(request); // get directory -DocuDirectory dir = dirCache.getDirectory(dlRequest.getFilePath()); -FileOps.FileClass fc = FileOps.FileClass.IMAGE; -int dirSize = dir != null ? dir.size(fc) : 0; +DocuDirectory dir = docBean.getDirectory(); +int dirSize = docBean.getNumPages(); %><!-- Automatically generated XML snippet with directory info --> <dir><% if (dir != null) { %> @@ -60,14 +53,18 @@ <name><%= dir.getDirName() %></name> <fsname><%= dir.getDir().getPath() %></fsname> <% - if (!dlRequest.hasOption("mo", "dir")) { + if (docBean.isUseAuthorization()) { +%> <auth-required><%= ! docBean.isAuthorized() %></auth-required> +<% + } + if (!docBean.getRequest().hasOption("dir")) { for (int i = 0; i < dirSize; i++) { - DocuDirent f = dir.get(i, fc); + DocuDirent f = dir.get(i); String fn = (f != null) ? f.getName() : "null"; %> <file> <index><%= i+1 %></index> - <name><c:out value="<%=digilib.io.FileOps.basename(fn)%>"/></name> - <fsname><c:out value="<%=fn%>"/></fsname> + <name><c:out value="<%= FileOps.basename(fn) %>"/></name> + <fsname><c:out value="<%= fn %>"/></fsname> </file> <% } // for