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/pub/SessionManager.java | 65 ++++++--------------- src/java/de/uhilger/filecms/api/FileMgr.java | 62 ++++++++++---------- src/java/de/uhilger/filecms/api/Api.java | 35 ++++++----- 3 files changed, 67 insertions(+), 95 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/Api.java b/src/java/de/uhilger/filecms/api/Api.java index 625e070..fc588bc 100644 --- a/src/java/de/uhilger/filecms/api/Api.java +++ b/src/java/de/uhilger/filecms/api/Api.java @@ -1,20 +1,22 @@ /* - * Nutzerverwaltung - User and role management in your browser - * Copyright (C) 2011-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 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ - */ + + 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; @@ -31,6 +33,7 @@ /** Zeiger zum Servlet-Kontext dieser Anwendung */ private ServletContext ctx; + /** Zeiger zum Request, der zur Ausfuehrung fuehrte */ private HttpServletRequest request; 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; - } - } diff --git a/src/java/de/uhilger/filecms/pub/SessionManager.java b/src/java/de/uhilger/filecms/pub/SessionManager.java index 3ebf15e..97bac3d 100644 --- a/src/java/de/uhilger/filecms/pub/SessionManager.java +++ b/src/java/de/uhilger/filecms/pub/SessionManager.java @@ -1,28 +1,25 @@ /* - * Nutzerverwaltung - User and role management in your browser - * Copyright (C) 2011-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 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ - */ + + 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.pub; -//import de.uhilger.um.api.Api; -//import static de.uhilger.um.api.UserMgr.MP_USER_DATA; -//import static de.uhilger.um.api.UserMgr.SQL_GET_USER_DATA; -//import static de.uhilger.um.api.UserMgr.WITHOUT_BLOBS; -//import de.uhilger.um.daten.UserData; import de.uhilger.filecms.api.Api; import java.util.logging.Logger; @@ -32,32 +29,6 @@ public class SessionManager extends Api { private static final Logger logger = Logger.getLogger(SessionManager.class.getName()); - - // /um/pub?c=de.uhilger.um.pub.SessionManager&m=getSessionUser - /* - public UserData getSessionUser() { - UserData userData = new UserData(); - userData.setFirstName("nicht angemeldet"); - userData.setLastName("nicht angemeldet"); - userData.setId("nicht angemeldet"); - userData.setEmail("nicht angemeldet"); - Object p = getRequest().getUserPrincipal(); - if(p instanceof Principal) { - String id = ((Principal) p).getName(); - logger.finer("User-ID: " + id); - List userDataList = getDb().select(getSql(SQL_GET_USER_DATA), getMapper(MP_USER_DATA), WITHOUT_BLOBS, id); - if(userDataList != null && userDataList.size() > 0) { - Object o = userDataList.get(0); - if(o instanceof UserData) { - userData = (UserData) o; - } - } - } else { - logger.finer("getUserPrincipal returned null or no Principal"); - } - return userData; - } -*/ public String expireSession() { getRequest().getSession().invalidate(); -- Gitblit v1.9.3