From 8931b77df172c4a2a106d471a566479ac9c5f6b0 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Mon, 20 Feb 2017 08:30:53 +0000 Subject: [PATCH] Code aufgeraeumt --- src/java/de/uhilger/filecms/api/FileMgr.java | 62 +++++++++++++++---------------- 1 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java index d39ab79..89433b5 100644 --- a/src/java/de/uhilger/filecms/api/FileMgr.java +++ b/src/java/de/uhilger/filecms/api/FileMgr.java @@ -1,28 +1,41 @@ +/* + + Dateiverwaltung - File management in your browser + Copyright (C) 2017 Ulrich Hilger, http://uhilger.de + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +*/ + package de.uhilger.filecms.api; import de.uhilger.filesystem.FileRef; -import de.uhilger.transit.web.RequestKontext; -import de.uhilger.transit.web.WebKontext; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.security.Principal; import java.util.logging.Level; import java.util.logging.Logger; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; /** * * @author ulrich */ -public class FileMgr implements WebKontext, RequestKontext { +public class FileMgr extends Api { private static final Logger logger = Logger.getLogger(FileMgr.class.getName()); public static final String FILE_BASE = "fileBase"; - - private ServletContext ctx; - private HttpServletRequest req; public String hallo() { return "Hallo Welt!"; @@ -108,7 +121,12 @@ w.write(contents); w.flush(); w.close(); - savedFile = new FileRef(targetFile.getAbsolutePath(), targetFile.isDirectory(), targetFile.isHidden(), targetFile.lastModified(), targetFile.length()); + savedFile = new FileRef( + targetFile.getAbsolutePath(), + targetFile.isDirectory(), + targetFile.isHidden(), + targetFile.lastModified(), + targetFile.length()); } } } catch (IOException ex) { @@ -118,30 +136,10 @@ } private File getWebappsDir() { - File cfile = new File(this.getClass().getResource(this.getClass().getSimpleName() + ".class").getFile()); + File cfile = new File(this.getClass().getResource( + this.getClass().getSimpleName() + ".class").getFile()); String path = cfile.getAbsolutePath(); - return new File(path.substring(0, path.indexOf(req.getContextPath()))); + return new File(path.substring(0, path.indexOf(getRequest().getContextPath()))); } - - @Override - public ServletContext getServletContext() { - return ctx; - } - - @Override - public void setServletContext(ServletContext servletContext) { - this.ctx = servletContext; - } - - @Override - public HttpServletRequest getRequest() { - return req; - } - - @Override - public void setRequest(HttpServletRequest r) { - this.req = r; - } - } -- Gitblit v1.9.3