commit 94c82cf8f19e3c01657205fe07aa2dcf076d2c45 from: leo date: Tue Feb 7 21:08:46 2006 UTC refactoring toward snipsnap.api and fixing redundancy bugs commit - 38d6902abcd0b0df66b7f3fa21bc0dbaf3c9a184 commit + 94c82cf8f19e3c01657205fe07aa2dcf076d2c45 blob - e18fd28ce14d3a2be37d715ceb339c75cac22e24 blob + e86862a28e464828cb71b81ea128aa5125deb316 --- build.xml +++ build.xml @@ -29,8 +29,8 @@ - - + + @@ -133,10 +133,10 @@ - - - - + + + + @@ -190,38 +190,38 @@ + srcdir="${src}" destdir="${target}/ant"> + classname="org.snipsnap.util.PropertyConstantBuilder" + classpath="${target}/ant"/> + properties="${src}/org/snipsnap/config/defaults.conf" + file="${target}/ant/config.stub" prefix="app." + /> + tofile="${src}/snipsnap/api/config/Configuration.java" filtering="true" overwrite="true"> + properties="${src}/org/snipsnap/config/globals.conf" + file="${target}/ant/globals.stub" prefix="app." + /> + tofile="${src}/org/snipsnap/config/Globals.java" filtering="true" overwrite="true"> @@ -229,30 +229,55 @@ - - - + + + - + + srcdir="${src}" + destdir="${target}/api" + classpathref="all.classpath"> + + + + + + + + + + + + + + + + + + + + - + - + @@ -293,9 +318,9 @@ + srcdir="${src}" + destdir="${target}/server" + classpathref="server.classpath"> @@ -316,9 +341,9 @@ + srcdir="${src}" + classpathref="all.classpath" + destdir="${target}/util"> @@ -345,20 +370,20 @@ + srcdir="${src}" + classpathref="test.classpath" + destdir="${target}/test" + includes="org/snipsnap/test/**"/> + srcdir="${src}" + classpathref="test.classpath" + destdir="${target}/default/WEB-INF/classes" + excludes="org/snipsnap/admin/**, org/snipsnap/server/**"> @@ -387,22 +412,22 @@ + verbose="1" srcdir="${src}/apps/default" + classpathref="all.classpath" + webinc="${target}/jsp/web.inc"> + srcdir="${target}/jsp/source" + destdir="${target}/jsp/classes" + cache="${target}/jsp/dependencies" + classpathref="all.classpath"/> + srcdir="${target}/jsp/source" + classpath="${src}/apps/default/WEB-INF/lib/snipsnap-servlets.jar" + classpathref="all.classpath" + destdir="${target}/jsp/classes"> @@ -411,21 +436,21 @@ + verbose="1" srcdir="${src}" + package="org.snipsnap.jsp" + classpathref="all.classpath"> + srcdir="${target}/jsp/source" + destdir="${target}/jsp/classes" + cache="${target}/jsp/dependencies" + classpathref="all.classpath"/> + srcdir="${target}/jsp/source" + classpath="${src}/apps/default/WEB-INF/lib/snipsnap-servlets.jar" + classpathref="all.classpath" + destdir="${target}/jsp/classes"> @@ -451,7 +476,7 @@ + file="${src}/apps/default/WEB-INF/classes/i18n/messages_en.properties"/> @@ -461,8 +486,8 @@ + tofile="${target}/webapp/WEB-INF/web.xml" + file="${src}/apps/default/WEB-INF/web-xml.tmpl" overwrite="true"> @@ -472,7 +497,7 @@ + todir="${target}/webapp/WEB-INF/classes/defaults"> @@ -483,10 +508,10 @@ - - - - + + + + @@ -513,7 +538,7 @@ - + @@ -523,26 +548,27 @@ - + + verbose="1" + classpathref="all.classpath" + webinc="${target}/installer/jsp/web.inc"> + srcdir="${target}/installer/jsp/source" + destdir="${target}/installer/jsp/classes" + cache="${target}/installer/jsp/dependencies" + classpathref="all.classpath"/> + srcdir="${target}/installer/jsp/source" + classpath="${target}/installer/webapp/WEB-INF/lib/installer-servlets.jar" + classpathref="all.classpath" + destdir="${target}/installer/jsp/classes"> @@ -550,15 +576,16 @@ + srcdir="${src}" + classpathref="all.classpath" + destdir="${target}/installer/servlets"> - + @@ -600,8 +627,8 @@ + tofile="${target}/installer/webapp/WEB-INF/web.xml" + file="${src}/apps/installer/WEB-INF/web-xml.tmpl" overwrite="true"> @@ -651,14 +678,14 @@ + sourcepath="src" + excludepackagenames="org.snipsnap.test.*" + defaultexcludes="yes" + destdir="docs/api" + author="true" + version="true" + use="true" + windowtitle="SnipSnap API"> SnipSnap]]> Copyright © 2001-2004 Matthias L. Jugel, Stephan J. Schmidt. All Rights Reserved .]]> blob - 2e0c6d6fb5f61a116c4a5c0ca9f1d7915ed4622c blob + 9033ca3bbf50b8fbbfbadd95ff0b22c58fc673c3 --- conf/libs.properties +++ conf/libs.properties @@ -2,4 +2,6 @@ rome.jar=rome-0.5.jar jdom.jar=jdom-1.0.jar spring-core.jar=spring-core.jar spring-beans.jar=spring-beans.jar +jdbcstorage.jar=jdbcstorage-1.0-alpha-1.jar search-ng.jar=search-ng-1.0-alpha-1.jar +rss-ng.jar=rss-ng-1.0-alpha-1.jar \ No newline at end of file blob - 521f2e062918f91e1e4ee0a8a08c06e1a4ef2151 blob + 554f80e4c1cbc259c14d7413d226c937b60497d6 Binary files lib/jdbcstorage-1.0-alpha-1.jar and lib/jdbcstorage-1.0-alpha-1.jar differ blob - c090defcc531bbfdbb620137f4f92194b6bcfc82 blob + d031bd9b57b4ca6f5567487acc6d487f56feaafa Binary files lib/rss-ng-1.0-alpha-1.jar and lib/rss-ng-1.0-alpha-1.jar differ blob - 084f2faabe4b636c262c3e7afc4860979e6b1c4d blob + 6789de8caa694edd5a8336c65b6341801e1e7205 --- src/apps/default/WEB-INF/classes/i18n/setup_de.properties +++ src/apps/default/WEB-INF/classes/i18n/setup_de.properties @@ -387,6 +387,15 @@ config.guide.expert = \ Diese Einstellungen können die Funktionsweise von SnipSnap erheblich verändern und \ sollten nur mit großer Sorgfalt geändert werden. SnipSnap kann durch Verändern \ dieser Einstellungen unbrauchbar werden! +config.app.auth = Authentifizierungsschema +config.app.auth.text = \ + Wählen Sie hier die Art und Weise der Authentifizierung der Benutzer. Es stehen \ + neben dem Standard auch noch Basic und Digest, sowie Zertifikatbasierte Methoden \ + zur Verfügung. +config.app.auth.cookie = Formularbasiert (Standard) +config.app.auth.basic = Einfache Browserabfrage (Basic) +config.app.auth.digest = Browserabfrage (Digest) +config.app.auth.certificate = Benutzerzertifikat config.app.start.snip = Start Snip config.app.start.snip.text = \ Üblicherweise ist 'start' die Startseite Ihrer SnipSnap site. Sie können \ blob - aae677585e8331ef650fae7c46639f59a57a7d6b blob + 1d2f95671e783823d7169e030c170ee6ff631b68 --- src/apps/default/WEB-INF/classes/i18n/setup_en.properties +++ src/apps/default/WEB-INF/classes/i18n/setup_en.properties @@ -369,6 +369,15 @@ config.guide.expert = \ These settings may heavily change the way SnipSnap works and should be \ changed with care. Changing some of these values may make SnipSnap \ unusable! +config.app.auth = Authentication Scheme +config.app.auth.text = \ + Select your preferred authentication scheme here. SnipSnap supports next to its \ + default cookie and form based scheme, basic and digest browser authentication as \ + well as certificate based authentication. +config.app.auth.cookie = Form and Cookie (default) +config.app.auth.basic = Basic Browser Auth +config.app.auth.digest = Digest Browser Auth +config.app.auth.certificate = Client Certificate config.app.start.snip = Start Snip config.app.start.snip.text = \ Normally 'start' is the home page of the SnipSnap site. You can redirect \ blob - fe3339928b9e97882560119a10962d806b686d57 blob + 5abe85d3d47912a943723f33460d87c12ecffa8e --- src/apps/default/admin/config/expert.jsp +++ src/apps/default/admin/config/expert.jsp @@ -14,6 +14,29 @@ + + + +
+
+ + <%-- + + --%> +

blob - 40c6992c7bb85960a40e92b30ef8e29b7ba2a438 blob + 677aca4157bc5baca67560bf9ebd0375f0cbb820 --- src/apps/default/main.jsp +++ src/apps/default/main.jsp @@ -6,7 +6,6 @@ <%@ page import="snipsnap.api.snip.SnipSpace, snipsnap.api.app.Application, - snipsnap.api.snip.SnipSpaceFactory, snipsnap.api.container.Components, snipsnap.api.snip.Snip, java.util.Collection, @@ -66,7 +65,7 @@ <% - SnipSpace space = (SnipSpace)org.snipsnap.container.Components.getComponent(SnipSpace.class); + SnipSpace space = (SnipSpace) Components.getComponent(SnipSpace.class); for(int i = 1; space.exists("snipsnap-portlet-"+i) || space.exists("SnipSnap/portlet/"+i); i++) { Snip snip = space.load("snipsnap-portlet-"+i); if(null == snip) { @@ -76,8 +75,8 @@ pageContext.removeAttribute("view_handler"); pageContext.removeAttribute("mime_type"); - String viewHandler = null; - String type = null; + String viewHandler; + String type; Collection mimeTypes = snip.getLabels().getLabels("TypeLabel"); if (!mimeTypes.isEmpty()) { Iterator handlerIt = mimeTypes.iterator(); blob - 1679badb9876e80ca1b95135e65f136c4779a693 blob + d602e364f20c0f068e40214952115a000d92790e --- src/org/snipsnap/app/ApplicationManager.java +++ src/org/snipsnap/app/ApplicationManager.java @@ -25,6 +25,8 @@ package org.snipsnap.app; +import snipsnap.api.storage.ApplicationStorage; + import java.util.Collection; import java.util.Map; import java.util.Iterator; blob - cee37cfc9f0cbe239833674d5814a87933107443 (mode 644) blob + /dev/null --- src/org/snipsnap/app/ApplicationStorage.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -package org.snipsnap.app; - -import java.util.Map; -import java.util.Properties; - -/** - * ApplicationStorage is a DAO for applications. - * - * @author Stephan J. Schmidt - * @version $Id$ - */ - -public interface ApplicationStorage { - public final static String OID = "OID"; - public final static String PREFIX = "prefix"; - public final static String NAME = "name"; - - - public Map getApplications(); - public void removeApplication(String oid); - public Properties createApplication(String name, String prefix); -} blob - 42eb040fb3bac87d83941e97802809a9ae4d121a blob + 1ef5b6f767a469316fe5f3dc8e165d74a0fb9272 --- src/org/snipsnap/app/PropertyFileApplicationStorage.java +++ src/org/snipsnap/app/PropertyFileApplicationStorage.java @@ -25,7 +25,6 @@ */ package org.snipsnap.app; -import snipsnap.api.config.Configuration; import org.snipsnap.config.Globals; import org.snipsnap.jdbc.UIDGenerator; import org.radeox.util.logging.Logger; @@ -40,8 +39,8 @@ import java.util.Properties; import java.util.HashMap; import java.util.Iterator; -import snipsnap.api.app.*; import snipsnap.api.app.Application; +import snipsnap.api.storage.ApplicationStorage; public class PropertyFileApplicationStorage implements ApplicationStorage { private final static String PREFIX_FILE = "prefix.properties"; blob - 7701189c2189adf2f28da1cbe867920ec928424f blob + ecf5dc7db3c860984d8074f713e213eeb45fabf9 --- src/org/snipsnap/config/Configuration.java.tmpl +++ src/org/snipsnap/config/Configuration.java.tmpl @@ -22,8 +22,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * --LICENSE NOTICE-- */ -package org.snipsnap.config; +package snipsnap.api.config; +import org.snipsnap.config.Globals; + import java.util.Locale; import java.util.Properties; import java.io.InputStream; blob - 8cc78a2af4b1f5cf3b7bdc2ccc797384b65999f5 blob + 3753b05733c2698f429a614bb5c2c927e86433e5 --- src/org/snipsnap/config/ConfigurationManager.java +++ src/org/snipsnap/config/ConfigurationManager.java @@ -24,20 +24,19 @@ */ package org.snipsnap.config; -import org.snipsnap.notification.Consumer; +import org.radeox.util.logging.Logger; +import snipsnap.api.notification.Consumer; import org.snipsnap.notification.Message; import org.snipsnap.notification.MessageService; -import snipsnap.api.snip.Snip; -import snipsnap.api.config.*; import snipsnap.api.config.Configuration; import snipsnap.api.container.Components; -import org.radeox.util.logging.Logger; +import snipsnap.api.snip.Snip; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.io.ByteArrayInputStream; -import java.io.IOException; /** * Manages configurations of this web application (different contexts) @@ -64,9 +63,11 @@ public class ConfigurationManager implements Consumer prefixMap = new HashMap(); } - public snipsnap.api.config.Configuration addConfiguration(String oid, Configuration config) { - if(config.isInstalled()) { - MessageService service = (MessageService)Components.getComponent(MessageService.class); + public Configuration addConfiguration(String oid, Configuration config) { + if (config.isInstalled()) { + System.err.println("Registering configuration manager at message service ..."); + MessageService service = (MessageService) Components.getComponent(MessageService.class); + System.err.println("MessageService: "+service); service.register(this); } configMap.put(oid, config); @@ -75,8 +76,8 @@ public class ConfigurationManager implements Consumer } public void removeConfiguration(String oid) { - Configuration config = (Configuration)configMap.get(oid); - if(config != null) { + Configuration config = (Configuration) configMap.get(oid); + if (config != null) { configMap.remove(oid); prefixMap.remove(config); } @@ -87,7 +88,7 @@ public class ConfigurationManager implements Consumer } public String checkForPrefix(String prefix) { - return (String)prefixMap.get(prefix); + return (String) prefixMap.get(prefix); } public Iterator getOids() { @@ -95,16 +96,16 @@ public class ConfigurationManager implements Consumer } public void consume(Message messsage) { - if(Message.SNIP_MODIFIED.equals(messsage.getType())) { - Snip snip = (snipsnap.api.snip.Snip)messsage.getValue(); - if("SnipSnap/config".equals(snip.getName())) { + if (Message.SNIP_MODIFIED.equals(messsage.getType())) { + Snip snip = (snipsnap.api.snip.Snip) messsage.getValue(); + if ("SnipSnap/config".equals(snip.getName())) { String appOid = snip.getApplication(); Configuration config = getConfiguration(appOid); try { - Logger.log("reloading config for: "+appOid); + Logger.log("reloading config for: " + appOid); config.load(new ByteArrayInputStream(snip.getContent().getBytes())); } catch (IOException e) { - System.err.println("ConfigurationManager: unable to reload configuration: "+e); + System.err.println("ConfigurationManager: unable to reload configuration: " + e); e.printStackTrace(); } } blob - a98229c2d24ad01a45ecc4c9a868488cfae1d609 blob + c50cf3eaf342aa5cf00e4e5e70001d3d1306814a --- src/org/snipsnap/config/InitializeDatabase.java +++ src/org/snipsnap/config/InitializeDatabase.java @@ -25,8 +25,8 @@ package org.snipsnap.config; import snipsnap.api.app.Application; +import snipsnap.api.storage.ApplicationStorage; import org.snipsnap.app.ApplicationManager; -import org.snipsnap.app.ApplicationStorage; import snipsnap.api.container.Components; import org.snipsnap.snip.HomePage; import snipsnap.api.snip.Snip; @@ -36,7 +36,6 @@ import org.snipsnap.snip.label.RenderEngineLabel; import org.snipsnap.user.Permissions; import org.snipsnap.user.Roles; import snipsnap.api.user.User; -import snipsnap.api.config.*; import snipsnap.api.config.Configuration; import org.snipsnap.user.UserManager; import org.snipsnap.user.UserManagerFactory; blob - 2946cc1053e84aa7621620661245d80d81e51c03 blob + 8660d77edcd0d484d6e68a7daa16f8dcac34fdc8 --- src/org/snipsnap/config/defaults.conf +++ src/org/snipsnap/config/defaults.conf @@ -37,6 +37,7 @@ app.name = SnipSnap app.tagline = The easy Weblog and Wiki Software app.logo = app.prefix = / +app.auth = Cookie # # - locale app.timezone = GMT+00 blob - 110a52c684a727db6ebfe52f0c5978543e40254f (mode 644) blob + /dev/null --- src/org/snipsnap/container/Components.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.snipsnap.container; - -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -import java.util.Collection; - -public class Components { - public final static String DEFAULT_ENGINE = "defaultRenderEngine"; - - private static Container container; - - public static synchronized Container getContainer() { - if (null == container) { - container = new PicoContainer(); - container.init(); - } - - return container; - } - - public static Object getComponent(Class c) { - return getContainer().getComponent(c); - } - - public static Object getComponent(String id) { - return getContainer().getComponent(id); - } - - public static Collection findComponents(Class c) { - return getContainer().findComponents(c); - } -} blob - beb02fe553fdecc0cf7dd58e4fb0f2f3496420c5 blob + 8eb7926600edfe79b8f81b028f5203d6e97393a5 --- src/org/snipsnap/container/MessageLogService.java +++ src/org/snipsnap/container/MessageLogService.java @@ -26,7 +26,7 @@ package org.snipsnap.container; import org.snipsnap.notification.MessageService; -import org.snipsnap.notification.Consumer; +import snipsnap.api.notification.Consumer; import org.snipsnap.notification.Message; blob - 348d1da118b06758b1f1e7b2ad4e4ffdda2712ce blob + 515aedefb582fa2b6069b26a5fd706265ad9aba9 --- src/org/snipsnap/container/PicoContainer.java +++ src/org/snipsnap/container/PicoContainer.java @@ -7,7 +7,7 @@ import org.picocontainer.defaults.DefaultComponentAdap import org.picocontainer.defaults.DefaultPicoContainer; import org.radeox.util.Service; import org.snipsnap.app.ApplicationManager; -import org.snipsnap.app.ApplicationStorage; +import snipsnap.api.storage.ApplicationStorage; import org.snipsnap.app.JDBCApplicationStorage; import org.snipsnap.app.PropertyFileApplicationStorage; import org.snipsnap.components.IndexerService; @@ -35,7 +35,9 @@ import org.snipsnap.versioning.*; import org.snipsnap.versioning.cookbook.CookbookDifferenceService; import org.snipsnap.xmlrpc.*; import snipsnap.api.snip.SnipSpace; -import snipsnap.api.container.*; +import snipsnap.api.storage.SnipStorage; +import snipsnap.api.storage.UserStorage; +import snipsnap.api.storage.VersionStorage; import javax.sql.DataSource; import java.util.ArrayList; blob - 1ecd23cd7c906544358a48a1ef1f393de915021f blob + 69b6b78b3ae510f7eb94ab1c3aaee73ded09d625 --- src/org/snipsnap/net/NewUserServlet.java +++ src/org/snipsnap/net/NewUserServlet.java @@ -69,7 +69,7 @@ public class NewUserServlet extends HttpServlet { try { request = new MultipartWrapper(request, config.getEncoding() != null ? config.getEncoding() : "UTF-8"); } catch (IllegalArgumentException e) { - Logger.warn("FileUploadServlet: multipart/form-data wrapper:" + e.getMessage()); + Logger.warn("NewUserServlet: multipart/form-data wrapper:" + e.getMessage()); } } blob - c3c1b622b58be40dd44a0de4921960b9d4d3bb8d blob + 063bce6efd8e2bda209bc328d2dd00e3474c6631 --- src/org/snipsnap/net/PluginServlet.java +++ src/org/snipsnap/net/PluginServlet.java @@ -27,7 +27,6 @@ package org.snipsnap.net; import groovy.text.SimpleTemplateEngine; import groovy.text.Template; import org.radeox.util.logging.Logger; -import org.snipsnap.container.Components; import org.snipsnap.snip.label.TypeLabel; import org.snipsnap.user.Permissions; import org.snipsnap.user.Roles; @@ -54,6 +53,7 @@ import snipsnap.api.snip.SnipSpace; import snipsnap.api.snip.Snip; import snipsnap.api.plugin.ServletPlugin; import snipsnap.api.app.Application; +import snipsnap.api.container.Components; public class PluginServlet extends HttpServlet { private Map extTypeMap = new HashMap(); blob - d51678b75c7a8b4c92276b2f9f68e6ff575b7657 blob + 67f41ee142ff770ff8bd275ade60bfde54e9ced4 --- src/org/snipsnap/net/admin/SetupExpert.java +++ src/org/snipsnap/net/admin/SetupExpert.java @@ -39,6 +39,7 @@ public class SetupExpert implements SetupHandler { } public Map setup(HttpServletRequest request, HttpServletResponse response, Configuration config, Map errors) { + config.setAuth(request.getParameter(Configuration.APP_AUTH)); String startSnip = request.getParameter(Configuration.APP_START_SNIP); config.setStartSnip(null == startSnip || "".equals(startSnip) ? "start" : startSnip); config.setPermCreateSnip(allowDeny(request.getParameter(Configuration.APP_PERM_CREATESNIP))); blob - 78bbdb7a188e5fafd0df30974cfcc834f5256f70 blob + c5c685aa054df3649f9fe4469459285ffc540bc2 --- src/org/snipsnap/net/filter/InitFilter.java +++ src/org/snipsnap/net/filter/InitFilter.java @@ -39,6 +39,7 @@ import snipsnap.api.snip.Snip; import snipsnap.api.snip.SnipLink; import snipsnap.api.snip.SnipSpace; import snipsnap.api.user.User; +import snipsnap.api.container.Components; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -312,8 +313,13 @@ public class InitFilter implements Filter { session.setAttribute("space", snipsnap.api.snip.SnipSpaceFactory.getInstance()); // check for a logged in user - SessionService service = (SessionService) snipsnap.api.container.Components.getComponent(SessionService.class); + SessionService service = (SessionService) Components.getComponent(SessionService.class); User user = service.getUser(request, (HttpServletResponse) response); + if(null == user) { + // someone else did something and is responsible for status codes + return; + } + app.setUser(user, session); Iterator paramIt = request.getParameterMap().keySet().iterator(); blob - 47a05aa1aeb12a9b7e7881880855b33ba95f339c blob + 4a6e037d114afdb0c4be775c9e16bd373855d3eb --- src/org/snipsnap/net/iCalServlet.java +++ src/org/snipsnap/net/iCalServlet.java @@ -72,7 +72,7 @@ public class iCalServlet extends HttpServlet { password = auth.substring(auth.indexOf(':') + 1); } - User user = ((AuthenticationService) snipsnap.api.container.Components.getComponent(AuthenticationService.class)).authenticate(login, password); + User user = ((AuthenticationService) Components.getComponent(AuthenticationService.class)).authenticate(login, password); if (user == null) { response.setHeader("WWW-Authenticate", "Basic realm=\"SnipSnap\""); response.setStatus(WD_UNAUTHORIZED); blob - b9abc1c2b56a97168944986ef52b9441ff3fdefb (mode 644) blob + /dev/null --- src/org/snipsnap/notification/Consumer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -package org.snipsnap.notification; - - -/** - * Simple Consumer interface to consume Messages from MessageService - * - * @author Stephan J. Schmidt - * @version $Id$ - */ - -public interface Consumer { - public void consume(Message message); -} blob - 158ad291e1cd167b3412d9b6955cf776427d1a8c blob + 453aff44d1a917f254c9a7dc31231fbf32e92c22 --- src/org/snipsnap/notification/MessageService.java +++ src/org/snipsnap/notification/MessageService.java @@ -25,11 +25,7 @@ package org.snipsnap.notification; -import snipsnap.api.app.Application; -import snipsnap.api.config.Configuration; -import org.snipsnap.notification.jabber.JabberNotifier; -import snipsnap.api.snip.Snip; -import snipsnap.api.user.User; +import snipsnap.api.notification.Consumer; import java.util.ArrayList; import java.util.Iterator; @@ -48,6 +44,7 @@ public class MessageService { private List consumers; public MessageService() { + System.err.println("Creating new MessageService: "+this); consumers = new ArrayList(); } blob - d33b137f68394890a40114dd88517efd27c5c694 blob + edb208178a95d2209ad131873e1bbba95cd2b5c7 --- src/org/snipsnap/notification/NotificationService.java +++ src/org/snipsnap/notification/NotificationService.java @@ -29,8 +29,8 @@ import snipsnap.api.app.Application; import snipsnap.api.config.Configuration; import org.snipsnap.notification.jabber.JabberNotifier; import snipsnap.api.snip.Snip; -import snipsnap.api.user.User; import snipsnap.api.container.Components; +import snipsnap.api.notification.Consumer; import java.util.ArrayList; import java.util.Iterator; blob - 453ba0500999ce96e120c876f35224796a18a258 blob + 5eb52c12efbdee55de724181ac52a0ca090355df --- src/org/snipsnap/render/macro/loader/GroovyMacroLoader.java +++ src/org/snipsnap/render/macro/loader/GroovyMacroLoader.java @@ -29,12 +29,10 @@ import groovy.lang.GroovyClassLoader; import org.radeox.macro.Macro; import org.radeox.macro.MacroLoader; import org.radeox.macro.Repository; -import snipsnap.api.container.Components; -import org.snipsnap.notification.Consumer; +import snipsnap.api.notification.Consumer; import org.snipsnap.notification.Message; import org.snipsnap.notification.MessageService; import snipsnap.api.snip.Snip; -import snipsnap.api.snip.SnipSpace; import java.io.ByteArrayInputStream; import java.io.InputStream; blob - 1a227dece8469782cfa23a8dae5cfc1131ece740 blob + e9848ee5ec8c2bb28ca04c01b9ef717bd446af9f --- src/org/snipsnap/snip/SnipSpaceImpl.java +++ src/org/snipsnap/snip/SnipSpaceImpl.java @@ -29,16 +29,16 @@ import org.apache.lucene.search.Hits; import org.radeox.util.logging.Logger; import snipsnap.api.app.Application; import org.snipsnap.app.ApplicationManager; -import org.snipsnap.app.ApplicationStorage; +import snipsnap.api.storage.ApplicationStorage; import snipsnap.api.container.Components; import org.snipsnap.notification.Message; import org.snipsnap.notification.MessageService; import org.snipsnap.snip.storage.CacheSnipStorage; import org.snipsnap.snip.storage.CacheStorage; -import org.snipsnap.snip.storage.CacheableStorage; +import snipsnap.api.storage.CacheableStorage; import org.snipsnap.snip.storage.MemorySnipStorage; import org.snipsnap.snip.storage.QuerySnipStorage; -import org.snipsnap.snip.storage.SnipStorage; +import snipsnap.api.storage.SnipStorage; import org.snipsnap.user.Digest; import org.snipsnap.util.ApplicationAwareMap; import org.snipsnap.util.Queue; @@ -57,7 +57,6 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; -import snipsnap.api.snip.*; import snipsnap.api.snip.Snip; /** blob - c00defa04d89100c3b9d0eee2e503f213fb86743 blob + 21060bbc902e0f06b0d13acf474e6baff91810fd --- src/org/snipsnap/snip/storage/CacheSnipStorage.java +++ src/org/snipsnap/snip/storage/CacheSnipStorage.java @@ -26,6 +26,7 @@ package org.snipsnap.snip.storage; import snipsnap.api.snip.Snip; +import snipsnap.api.storage.SnipStorage; import org.snipsnap.util.ApplicationAwareMap; import java.sql.Timestamp; blob - d334539b0ddc74c7080a77da408a45f87259de0a (mode 644) blob + /dev/null --- src/org/snipsnap/snip/storage/CacheableStorage.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of "SnipSnap Wiki/Weblog". -* -* Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel -* All Rights Reserved. -* -* Please visit http://snipsnap.org/ for updates and contact. -* -* --LICENSE NOTICE-- -* 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* --LICENSE NOTICE-- -*/ - -package org.snipsnap.snip.storage; - -import org.snipsnap.util.ApplicationAwareMap; - -public interface CacheableStorage { - void setCache(ApplicationAwareMap cache); -} blob - 0c9f05abafe32ad97fe9f68c1c7c010d90aaa720 blob + 9c09525acb2cef8b7bddcdf5793df7da50eedd91 --- src/org/snipsnap/snip/storage/FileSnipStorage.java +++ src/org/snipsnap/snip/storage/FileSnipStorage.java @@ -32,11 +32,12 @@ import org.snipsnap.snip.Links; import snipsnap.api.snip.Snip; import org.snipsnap.snip.SnipFactory; import org.snipsnap.snip.attachment.Attachments; -import snipsnap.api.label.Labels; +import snipsnap.api.storage.SnipStorage; +import snipsnap.api.storage.CacheableStorage; import org.snipsnap.user.Permissions; import org.snipsnap.util.ApplicationAwareMap; import org.snipsnap.versioning.VersionInfo; -import org.snipsnap.versioning.VersionStorage; +import snipsnap.api.storage.VersionStorage; import java.io.File; import java.io.IOException; blob - 897105320dbf439bbc37deb262e3539787f754bd blob + ddc94c6a32ad4779cb982ae15d444aa26c5f9ffd --- src/org/snipsnap/snip/storage/FileUserStorage.java +++ src/org/snipsnap/snip/storage/FileUserStorage.java @@ -28,6 +28,7 @@ package org.snipsnap.snip.storage; import org.radeox.util.logging.Logger; import snipsnap.api.app.Application; import snipsnap.api.user.User; +import snipsnap.api.storage.UserStorage; import java.io.File; import java.io.FileInputStream; blob - 4ffa9000d3dde8b05e2ce70515badcf83cea318a blob + b2eefba3d1aa9eb35c7fa451d5643d8d2c6897da --- src/org/snipsnap/snip/storage/MemorySnipStorage.java +++ src/org/snipsnap/snip/storage/MemorySnipStorage.java @@ -30,7 +30,9 @@ import org.snipsnap.util.PartialSearcher; import org.snipsnap.util.ApplicationAwareMap; import snipsnap.api.app.Application; import org.snipsnap.app.ApplicationManager; -import org.snipsnap.app.ApplicationStorage; +import snipsnap.api.storage.ApplicationStorage; +import snipsnap.api.storage.SnipStorage; +import snipsnap.api.storage.CacheableStorage; import java.sql.Timestamp; import java.util.*; blob - 2e8f0fad536435b43beae93b842f805c4234e1a3 blob + 8da7aabfdaba6b3ce8f4826c217dfb76c062b2a7 --- src/org/snipsnap/snip/storage/QuerySnipStorage.java +++ src/org/snipsnap/snip/storage/QuerySnipStorage.java @@ -25,8 +25,8 @@ package org.snipsnap.snip.storage; -import snipsnap.api.app.Application; import snipsnap.api.snip.Snip; +import snipsnap.api.storage.SnipStorage; import org.snipsnap.snip.SnipPostNameComparator; import org.snipsnap.snip.storage.query.QueryKit; import org.snipsnap.snip.storage.query.SnipComparator; blob - d17afeca85d5378e0e40a3d1437de3227a0bdb26 (mode 644) blob + /dev/null --- src/org/snipsnap/snip/storage/SnipStorage.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -package org.snipsnap.snip.storage; - -import snipsnap.api.snip.Snip; - -import java.sql.Timestamp; -import java.util.List; - -/** - * Interface that describes SnipStorage backends for SnipSnap - * - * @author Stephan J. Schmidt - * @version $Id$ - */ - -public interface SnipStorage { - // Basic manipulation methods Load,Store,Create,Remove - public Snip[] match(String pattern); - - public Snip[] match(String start, String end); - - public Snip storageLoad(String name); - - public void storageStore(List snips); - - public void storageStore(Snip snip); - - public Snip storageCreate(String name, String content); - - public void storageRemove(Snip snip); - - // Finder methods - public int storageCount(); - - public List storageAll(); - - public List storageAll(String applicationOid); - - public List storageByHotness(int size); - - // find all Snips with the cUser matching the login - public List storageByUser(String login); - - public List storageByDateSince(Timestamp date); - - public List storageByRecent(String applicationOid, int size); - - public List storageByComments(Snip parent); - - // find all Snips matching the parent - public List storageByParent(Snip parent); - - public List storageByParentNameOrder(Snip parent, int count); - - public List storageByParentModifiedOrder(Snip parent, int count); - - public List storageByDateInName(String nameSpace, String start, String end); - -} blob - 54212de0a1a1cdf9ff50bc9168b96c0b6a6178b4 (mode 644) blob + /dev/null --- src/org/snipsnap/snip/storage/UserStorage.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -package org.snipsnap.snip.storage; - -import snipsnap.api.user.User; - -import java.util.List; - -/** - * Storage backend for User data - * - * @author Stephan J. Schmidt - * @version $Id$ - */ - -public interface UserStorage { - /** - * Store an user in to the backend - * - * @param user User to store - */ - public void storageStore(User user); - - /** - * Create a new user in the backend - * - * @param login Login name of the user - * @param passwd Credential of the user - * @param email Email adress of the user - * @return - */ - public User storageCreate(String login, String passwd, String email); - - /** - * Remove an user from the backend - * - * @param user User to remove - */ - public void storageRemove(User user); - - /** - * Return the number of users in the backend - * - * @return - */ - public int storageUserCount(); - - /** - * Load a user from the backend - * - * @param login Login of the user to load - * @return - */ - - public User storageLoad(String login); - - /** - * Return a list of all users - * - * @return - */ - public List storageAll(); -} blob - 78308b90047d503186bacafa07f385e6d4d997ee blob + 86b27e44521f89d2afbfcb5899722b049515fcd5 --- src/org/snipsnap/test/user/DefaultPermissionManagerTest.java +++ src/org/snipsnap/test/user/DefaultPermissionManagerTest.java @@ -57,6 +57,9 @@ public class DefaultPermissionManagerTest extends Test public User authenticate(String login, String passwd, boolean encrypted) { return null; } + public User authenticate(String login) { + return null; + } public boolean isAuthenticated(User user) { return false; blob - 0ef7e05b21efdfc25894cf9fdfc7c1e1e1f6e095 blob + 0489d68f55a1d56a174b3712047e42ab78a93951 --- src/org/snipsnap/user/AuthenticationService.java +++ src/org/snipsnap/user/AuthenticationService.java @@ -33,5 +33,6 @@ public interface AuthenticationService { public User authenticate(String login, String passwd, boolean encrypted); public User authenticate(String login, String passwd); + public User authenticate(String login); public boolean isAuthenticated(snipsnap.api.user.User user); } blob - a13f370dc18c1269ad43c72738ee9bd07d2902d0 blob + 6f7ab233436aab404e290b763aafe31cd3e2b6df --- src/org/snipsnap/user/DefaultAuthenticationService.java +++ src/org/snipsnap/user/DefaultAuthenticationService.java @@ -1,7 +1,6 @@ package org.snipsnap.user; -import org.snipsnap.snip.storage.UserStorage; -import snipsnap.api.user.*; +import snipsnap.api.storage.UserStorage; import snipsnap.api.user.User; /* @@ -59,6 +58,21 @@ public class DefaultAuthenticationService implements A } } + /** Used for password-less login, i.e. X509Certificate + */ + public User authenticate(String login) { + User user = storage.storageLoad(login); + + //@TODO split authenticate and lastLogin + if (null != user) { + user.lastLogin(); + storage.storageStore(user); + return user; + } else { + return null; + } + } + public boolean isAuthenticated(User user) { return user != null && !(user.isGuest() || user.isNonUser()); } blob - 182da1e952edf19377a01220d1badb335fb92839 blob + 4d327e40da0e8bee4a7c06e9da3c7c5bab0a9cf7 --- src/org/snipsnap/user/DefaultUserManager.java +++ src/org/snipsnap/user/DefaultUserManager.java @@ -24,8 +24,7 @@ */ package org.snipsnap.user; -import snipsnap.api.container.Components; -import org.snipsnap.snip.storage.UserStorage; +import snipsnap.api.storage.UserStorage; import org.snipsnap.util.ApplicationAwareMap; import org.snipsnap.util.ApplicationAwareIntegerMap; import org.snipsnap.jdbc.IntHolder; @@ -33,7 +32,6 @@ import org.snipsnap.jdbc.IntHolder; import java.sql.Timestamp; import java.util.*; -import snipsnap.api.user.*; import snipsnap.api.user.User; /** blob - 6ef92f9725986a95e66ec129b0677727251d1e99 blob + 4b8a176ed43a861d85e9bfac3b567d47e7beb06f --- src/org/snipsnap/user/PasswordService.java +++ src/org/snipsnap/user/PasswordService.java @@ -1,12 +1,11 @@ package org.snipsnap.user; -import org.snipsnap.snip.storage.UserStorage; +import snipsnap.api.storage.UserStorage; import java.util.Random; import java.util.Map; import java.util.HashMap; -import snipsnap.api.user.*; import snipsnap.api.user.User; /* blob - aebb07aebeacb567c395c0a120de3d02bcdb44b1 blob + 1912efd28dbb1cefb64ccf1c5a811b8153384a55 --- src/org/snipsnap/versioning/DefaultVersionManager.java +++ src/org/snipsnap/versioning/DefaultVersionManager.java @@ -25,7 +25,7 @@ package org.snipsnap.versioning; -import snipsnap.api.snip.Snip; +import snipsnap.api.storage.VersionStorage; import org.snipsnap.snip.SnipFactory; import java.util.List; blob - fc8ca5b51524279e6956740ba4e10518800a2f8e (mode 644) blob + /dev/null --- src/org/snipsnap/versioning/VersionStorage.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of "SnipSnap Wiki/Weblog". - * - * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel - * All Rights Reserved. - * - * Please visit http://snipsnap.org/ for updates and contact. - * - * --LICENSE NOTICE-- - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * --LICENSE NOTICE-- - */ - -package org.snipsnap.versioning; - -import snipsnap.api.snip.Snip; - -import java.util.List; - -/** - * Stores versions of snips - * - * @author Stephan J. Schmidt - * @version $Id$ - */ - -public interface VersionStorage { - - /** - * Return a list of VersionInfo objects for the - * given snip. Objects should be ordered by decreasing version - * - * @param snip Snip for which the revision should be loaded - * @return - */ - public List getVersionHistory(Snip snip); - - /** - * Load a version of a snip from the storage - * - * @param snip Example of a snip to load - * @param version Version number - * @return - */ - public Snip loadVersion(Snip snip, int version); - - /** - * Stora a version of a snip in the storage. - * - * @param snip Snip to store - */ - public void storeVersion(Snip snip); -} blob - 6f1993937ac2099c9e8caf8174ebc5b2c12964f5 blob + c01b2c2af205e8de8591537447415b3bcfa7e979 --- src/org/snipsnap/xmlrpc/SnipSnapHandler.java +++ src/org/snipsnap/xmlrpc/SnipSnapHandler.java @@ -30,7 +30,6 @@ import org.snipsnap.config.ConfigurationManager; import org.snipsnap.config.ConfigurationProxy; import org.snipsnap.config.Globals; import org.snipsnap.config.InitializeDatabase; -import org.snipsnap.container.Components; import org.snipsnap.snip.XMLSnipExport; import org.snipsnap.snip.XMLSnipImport; import org.snipsnap.snip.storage.SnipSerializer; @@ -56,6 +55,7 @@ import snipsnap.api.snip.Snip; import snipsnap.api.app.Application; import snipsnap.api.user.User; import snipsnap.api.config.Configuration; +import snipsnap.api.container.Components; /** * Handles XML-RPC calls for the SnipSnap API blob - 47519555010466ead598f0aab7dbc98ed2218548 blob + 1e4a52f8c84e2c07303a9633c625004b43382ed8 --- src/org/snipsnap/xmlrpc/WeblogsPing.java +++ src/org/snipsnap/xmlrpc/WeblogsPing.java @@ -27,22 +27,18 @@ package org.snipsnap.xmlrpc; import org.radeox.util.logging.Logger; import snipsnap.api.app.Application; -import snipsnap.api.config.Configuration; import snipsnap.api.snip.Snip; import snipsnap.api.snip.SnipSpace; import org.snipsnap.xmlrpc.ping.PingHandler; import org.snipsnap.notification.Message; import org.snipsnap.notification.MessageService; -import org.snipsnap.notification.Consumer; +import snipsnap.api.notification.Consumer; import snipsnap.api.container.Components; -import org.apache.xmlrpc.XmlRpc; import java.io.BufferedReader; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; blob - 02b27616f1bf843ba86b613b9ba367f3894d13bf blob + 309abf051a1cd0843cce3af7144adebcc0fe4b86 --- src/snipsnap/api/config/Configuration.java +++ src/snipsnap/api/config/Configuration.java @@ -88,8 +88,8 @@ public interface Configuration extends Globals { // EASY ACCESS // automatically created interface/constants stub from - // /Users/stephan/src/snipsnap/trunk/src/org/snipsnap/config/defaults.conf - // generated on 4/6/05 7:40 PM + // /Users/leo/src/Projects/SnipSnap/core/trunk/src/org/snipsnap/config/defaults.conf + // generated on 2/7/06 9:58 PM // constant/getter for 'app.admin.email' public final static String APP_ADMIN_EMAIL = "app.admin.email"; public String getAdminEmail(); @@ -102,6 +102,10 @@ public interface Configuration extends Globals { public final static String APP_ADMIN_PASSWORD = "app.admin.password"; public String getAdminPassword(); public String setAdminPassword(String value); + // constant/getter for 'app.auth' + public final static String APP_AUTH = "app.auth"; + public String getAuth(); + public String setAuth(String value); // constant/getter for 'app.configured' public final static String APP_CONFIGURED = "app.configured"; public String getConfigured(); blob - 77925f4728d3d4432aca3765e36c929aa18b346a blob + d9990feb9c93827a2eaa00b32f963d8525d977e7 --- src/snipsnap/api/container/Components.java +++ src/snipsnap/api/container/Components.java @@ -26,33 +26,41 @@ package snipsnap.api.container; */ import org.snipsnap.container.Container; -import org.snipsnap.container.PicoContainer; import java.util.Collection; public class Components { - public final static String DEFAULT_ENGINE = "defaultRenderEngine"; + private static final String DEFAULT_CONTAINER_SERVICE = "org.snipsnap.container.PicoContainer"; + public final static String DEFAULT_ENGINE = "defaultRenderEngine"; - private static Container container; + private static Container container; - public static synchronized Container getContainer() { - if (null == container) { - container = new PicoContainer(); - container.init(); - } - - return container; + public static synchronized Container getContainer() { + if (null == container) { + try { + container = (Container) Class.forName(DEFAULT_CONTAINER_SERVICE).newInstance(); + container.init(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } } - public static Object getComponent(Class c) { - return getContainer().getComponent(c); - } + return container; + } - public static Object getComponent(String id) { - return getContainer().getComponent(id); - } + public static Object getComponent(Class c) { + return getContainer().getComponent(c); + } - public static Collection findComponents(Class c) { - return getContainer().findComponents(c); - } + public static Object getComponent(String id) { + return getContainer().getComponent(id); + } + + public static Collection findComponents(Class c) { + return getContainer().findComponents(c); + } } blob - /dev/null blob + be1cdda2f894038757086cd5d030f6e9ba0f67c7 (mode 644) --- /dev/null +++ src/snipsnap/api/notification/Consumer.java @@ -0,0 +1,40 @@ +/* + * This file is part of "SnipSnap Wiki/Weblog". + * + * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel + * All Rights Reserved. + * + * Please visit http://snipsnap.org/ for updates and contact. + * + * --LICENSE NOTICE-- + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * --LICENSE NOTICE-- + */ + +package snipsnap.api.notification; + +import org.snipsnap.notification.Message; + + +/** + * Simple Consumer interface to consume Messages from MessageService + * + * @author Stephan J. Schmidt + * @version $Id: Consumer.java 1606 2004-05-17 10:56:18Z leo $ + */ + +public interface Consumer { + public void consume(Message message); +} blob - /dev/null blob + 502259f49fe0c0a793f6a9f9d55f4d5827eeab08 (mode 644) --- /dev/null +++ src/snipsnap/api/storage/ApplicationStorage.java @@ -0,0 +1,47 @@ +/* + * This file is part of "SnipSnap Wiki/Weblog". + * + * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel + * All Rights Reserved. + * + * Please visit http://snipsnap.org/ for updates and contact. + * + * --LICENSE NOTICE-- + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * --LICENSE NOTICE-- + */ + +package snipsnap.api.storage; + +import java.util.Map; +import java.util.Properties; + +/** + * ApplicationStorage is a DAO for applications. + * + * @author Stephan J. Schmidt + * @version $Id: ApplicationStorage.java 1257 2003-12-11 13:36:55Z leo $ + */ + +public interface ApplicationStorage { + public final static String OID = "OID"; + public final static String PREFIX = "prefix"; + public final static String NAME = "name"; + + + public Map getApplications(); + public void removeApplication(String oid); + public Properties createApplication(String name, String prefix); +} blob - /dev/null blob + 69e6385faa58563b4a210134ff9980286b3ca497 (mode 644) --- /dev/null +++ src/snipsnap/api/storage/CacheableStorage.java @@ -0,0 +1,32 @@ +/* +* This file is part of "SnipSnap Wiki/Weblog". +* +* Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel +* All Rights Reserved. +* +* Please visit http://snipsnap.org/ for updates and contact. +* +* --LICENSE NOTICE-- +* 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., 675 Mass Ave, Cambridge, MA 02139, USA. +* --LICENSE NOTICE-- +*/ + +package snipsnap.api.storage; + +import org.snipsnap.util.ApplicationAwareMap; + +public interface CacheableStorage { + void setCache(ApplicationAwareMap cache); +} blob - /dev/null blob + 7ff806d8b0027d1c273afa75efea72642be5adb8 (mode 644) --- /dev/null +++ src/snipsnap/api/storage/SnipStorage.java @@ -0,0 +1,83 @@ +/* + * This file is part of "SnipSnap Wiki/Weblog". + * + * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel + * All Rights Reserved. + * + * Please visit http://snipsnap.org/ for updates and contact. + * + * --LICENSE NOTICE-- + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * --LICENSE NOTICE-- + */ + +package snipsnap.api.storage; + +import snipsnap.api.snip.Snip; + +import java.sql.Timestamp; +import java.util.List; + +/** + * Interface that describes SnipStorage backends for SnipSnap + * + * @author Stephan J. Schmidt + * @version $Id: SnipStorage.java 1816 2005-04-06 17:56:22Z stephan $ + */ + +public interface SnipStorage { + // Basic manipulation methods Load,Store,Create,Remove + public Snip[] match(String pattern); + + public Snip[] match(String start, String end); + + public Snip storageLoad(String name); + + public void storageStore(List snips); + + public void storageStore(Snip snip); + + public Snip storageCreate(String name, String content); + + public void storageRemove(Snip snip); + + // Finder methods + public int storageCount(); + + public List storageAll(); + + public List storageAll(String applicationOid); + + public List storageByHotness(int size); + + // find all Snips with the cUser matching the login + public List storageByUser(String login); + + public List storageByDateSince(Timestamp date); + + public List storageByRecent(String applicationOid, int size); + + public List storageByComments(Snip parent); + + // find all Snips matching the parent + public List storageByParent(Snip parent); + + public List storageByParentNameOrder(Snip parent, int count); + + public List storageByParentModifiedOrder(Snip parent, int count); + + public List storageByDateInName(String nameSpace, String start, String end); + +} blob - /dev/null blob + 22af4f17dd8d388a1188cd935da1b6c15b1dbe82 (mode 644) --- /dev/null +++ src/snipsnap/api/storage/UserStorage.java @@ -0,0 +1,86 @@ +/* + * This file is part of "SnipSnap Wiki/Weblog". + * + * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel + * All Rights Reserved. + * + * Please visit http://snipsnap.org/ for updates and contact. + * + * --LICENSE NOTICE-- + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * --LICENSE NOTICE-- + */ + +package snipsnap.api.storage; + +import snipsnap.api.user.User; + +import java.util.List; + +/** + * Storage backend for User data + * + * @author Stephan J. Schmidt + * @version $Id: UserStorage.java 1816 2005-04-06 17:56:22Z stephan $ + */ + +public interface UserStorage { + /** + * Store an user in to the backend + * + * @param user User to store + */ + public void storageStore(User user); + + /** + * Create a new user in the backend + * + * @param login Login name of the user + * @param passwd Credential of the user + * @param email Email adress of the user + * @return + */ + public User storageCreate(String login, String passwd, String email); + + /** + * Remove an user from the backend + * + * @param user User to remove + */ + public void storageRemove(User user); + + /** + * Return the number of users in the backend + * + * @return + */ + public int storageUserCount(); + + /** + * Load a user from the backend + * + * @param login Login of the user to load + * @return + */ + + public User storageLoad(String login); + + /** + * Return a list of all users + * + * @return + */ + public List storageAll(); +} blob - /dev/null blob + 1bc7f82cb60d2210dc6ec2214f8f899b734d5e9a (mode 644) --- /dev/null +++ src/snipsnap/api/storage/VersionStorage.java @@ -0,0 +1,65 @@ +/* + * This file is part of "SnipSnap Wiki/Weblog". + * + * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel + * All Rights Reserved. + * + * Please visit http://snipsnap.org/ for updates and contact. + * + * --LICENSE NOTICE-- + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * --LICENSE NOTICE-- + */ + +package snipsnap.api.storage; + +import snipsnap.api.snip.Snip; + +import java.util.List; + +/** + * Stores versions of snips + * + * @author Stephan J. Schmidt + * @version $Id: VersionStorage.java 1816 2005-04-06 17:56:22Z stephan $ + */ + +public interface VersionStorage { + + /** + * Return a list of VersionInfo objects for the + * given snip. Objects should be ordered by decreasing version + * + * @param snip Snip for which the revision should be loaded + * @return list of version infos + */ + public List getVersionHistory(Snip snip); + + /** + * Load a version of a snip from the storage + * + * @param snip Example of a snip to load + * @param version Version number + * @return version of a snip + */ + public Snip loadVersion(Snip snip, int version); + + /** + * Stora a version of a snip in the storage. + * + * @param snip Snip to store + */ + public void storeVersion(Snip snip); +}