Author: mfortun Date: 2011-05-13 11:00:49 +0200 (Fri, 13 May 2011) New Revision: 886 Url: http://nuiton.org/repositories/revision/wikitty/886 Log: * add default value for login * remove old class used in old publication implementation * remove system.out used for dev Removed: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractActionOnWikitty.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionLogin.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/LogoutInterceptor.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogin.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogout.java trunk/wikitty-publication/src/main/webapp/login.jsp Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,56 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public abstract class AbstractAction implements WikittyPublicationAction { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(AbstractAction.class); - - protected String mapping = null; - - @Override - public String getMapping() { - return mapping; - } - - @Override - public void setMapping(String mapping) { - this.mapping = mapping; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractActionOnWikitty.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractActionOnWikitty.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractActionOnWikitty.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,177 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.wikitty.WikittyUtil; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.publication.entities.WikittyPubData; -import org.nuiton.wikitty.publication.entities.WikittyPubDataHelper; -import org.nuiton.wikitty.publication.entities.WikittyPubText; -import org.nuiton.wikitty.publication.entities.WikittyPubTextHelper; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.Search; - -import java.util.List; - -/** - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public abstract class AbstractActionOnWikitty extends AbstractAction { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(AbstractActionOnWikitty.class); - - static final public int ARG_QUERY = 0; - static final public String ARG_MIMETYPE = "mimetype"; - static final public String ARG_CONTENT_FIELD = "contentField"; - static final public String SEARCH_SEPARATOR = ":"; - - abstract protected String getExampleUsage(); - - /** - * Recherche le type mime dont on a besoin. - * Par defaut recherche dans les arguments si on a dans l'ordre de preference - * <li> ARG_MIMETYPE + SEARCH_SEPARATOR + name - * (ex: mimetype:MyCommand.name:df=text/plain) - * <li> ARG_MIMETYPE - * (ex: mimetype=MyCommand.mimetype) - * <li> si w a l'extension WikittyPubText alors on prend la valeur du champs mimetype - * <li> si w a l'extension WikittyPubData alors on prend la valeur du champs mimetype - * <li> on retourne null - * - * @param context - * @param name la chaine utilise pour faire la recherche du wikitty - * @param w le wikitty trouve grace a name - * @return le mimetype ou null - */ - protected String getMimeType(WikittyPublicationContext context, - String name, Wikitty w) { - // looking for mimetype field - String mimetype = context.getArgument( - ARG_MIMETYPE + SEARCH_SEPARATOR + name, null); - if (mimetype == null) { - mimetype = context.getArgument(ARG_MIMETYPE, null); - } - if (mimetype != null) { - int i = mimetype.indexOf(WikittyUtil.FQ_FIELD_NAME_SEPARATOR); - if (i > 0) { // perhaps fully qualified field - String extName = WikittyExtension.extractExtensionName(mimetype); - String fieldName = WikittyExtension.extractFieldName(mimetype); - if (w.hasField(extName, fieldName)) { - // mimetype target field in wikitty - // replace with field value - mimetype = w.getFieldAsString(extName, fieldName); - } - } - } else if (w.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) { - mimetype = WikittyPubTextHelper.getMimeType(w); - } else if (w.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) { - mimetype = WikittyPubDataHelper.getMimeType(w); - } - return mimetype; - } - - /** - * Retourne le critere pour recherche l'objet sur lequel faire l'action. - * Le nom du critere doit etre convenablement positionné avec la chaine - * qui a permit la recherche - * - * @param context - * @return - */ - protected Criteria searchCriteria(List<String> subContext) { - Criteria result; - if (subContext.size() <= 0) { - result = null; - } else { - String searchString = subContext.get(ARG_QUERY); - if (searchString.contains(SEARCH_SEPARATOR)) { - // on a un field=value - String[] arg = searchString.split(SEARCH_SEPARATOR); - result = Search.query().eq(arg[0], arg[1]).criteria(searchString); - } else { - // on a pas le champs, alors par defaut on recherche dans - // WikittyPubText.name et WikittyPubData.name - result = Search.query().or() - .eq(WikittyPubText.FQ_FIELD_WIKITTYPUBTEXT_NAME, searchString) - .eq(WikittyPubData.FQ_FIELD_WIKITTYPUBDATA_NAME, searchString) - .criteria(searchString); - } - } - return result; - } - - /** - * Recherche le champs contenant le content dont on a besoin. - * Par defaut recherche dans les arguments si on a dans l'ordre de preference - * <li> ARG_CONTENT_FIELD + SEARCH_SEPARATOR + name - * (ex: contentField:MyCommand.name:df=MyCommand.script) - * <li> ARG_CONTENT_FIELD - * (ex: contentField=MyCommand.script) - * <li> si w a l'extension WikittyPubText alors on prend le champs content - * <li> si w a l'extension WikittyPubData alors on prend le champs content - * <li> on retourne null - * - * @param context - * @param name la chaine utilise pour faire la recherche du wikitty - * @param w le wikitty trouve grace a name - * @return le champs contenant le content ou null - */ - protected String getContentFieldName(WikittyPublicationContext context, - String name, Wikitty w) { - String contentField = context.getArgument( - ARG_CONTENT_FIELD + SEARCH_SEPARATOR + name, null); - if (contentField == null) { - contentField = context.getArgument(ARG_CONTENT_FIELD, null); - } - if (contentField == null) { - if (w.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) { - contentField = WikittyPubText.FQ_FIELD_WIKITTYPUBTEXT_CONTENT; - } else if (w.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) { - contentField = WikittyPubData.FQ_FIELD_WIKITTYPUBDATA_CONTENT; - } - } - return contentField; - } - - protected String getError(WikittyPublicationContext context) { - context.setContentType("text/html"); - String result = String.format( - "<h1>bad query %s</h1>" - + "Usage example" - + "<pre>%s</pre>", context.getRequest().getPathInfo(), getExampleUsage()); - return result; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,242 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.CollectionUtil; -import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.WikittyUtil; -import org.nuiton.wikitty.entities.FieldType; -import org.nuiton.wikitty.entities.FieldType.TYPE; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.entities.WikittyImpl; -import org.nuiton.wikitty.publication.entities.WikittyPubData; -import org.nuiton.wikitty.publication.entities.WikittyPubDataHelper; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.operators.Element; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class ActionEdit extends AbstractActionOnWikitty { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(ActionError.class); - - static final protected String exampleUsage = "edit/WikittyPubText.name=Wiki\n" - + "edit/Tuto\n" - + "edit/WikittyPubText.name=Tuto\n" - + "edit/Command.id=df\n"; - - protected ApplicationConfig appConfig; - - public ActionEdit(ApplicationConfig appConfig) { - this.appConfig = appConfig; - } - - @Override - public Object doAction(WikittyPublicationContext context) { - String result; - Wikitty w; - - WikittyProxy proxy = context.getWikittyProxy(); - - if (context.getArguments().containsKey("delete")) { - // on nous demande supprimer le wikitty, on l'efface et on - // affichera un wikitty vide - String id = context.getArguments().get("id"); - proxy.delete(id); - // apres un effacement on reprend l'edition d'un tout nouveau - // wikitty - w = new WikittyImpl(); - } else { - // recherche du Wikitty a editer ou creation d'un nouveau si - // necessaire - Criteria criteria = searchCriteria(context.getMandatoryArguments()); - if (criteria == null) { - w = new WikittyImpl(); - } else { - w = proxy.findByCriteria(criteria); - } - - // si on ne retrouve pas le wikitty, mais qu'il vient d'etre cree - // pour l'edition, on recree un wikitty avec ce meme identifiant - if (w == null - && "0.0".equals(context.getArguments().get("version"))) { - // c'est un nouvel objet, il n'a pas encore ete sauve, mais on - // veut le faire - String id = context.getArguments().get("id"); - w = new WikittyImpl(id); - } - - if (w == null) { - // si le wikitty est null, et qu'on etait pas en edition - // cela signifie qu'on ne retrouve pas le wikitty a editer - // on creer un nouveau wikitty vide que l'on editera - w = new WikittyImpl(); - } else { - // on met a jour le wikitty avec les infos trouvees dans les - // arguments - - // ajout des extensions deja existante si necessaire - String extensions = context.getArgument("extensions", null); - if (extensions != null) { - String[] exts = StringUtil.split(extensions - .replace("[", "").replace("]", ""), ","); - for (String extName : exts) { - WikittyExtension ext = proxy - .restoreExtensionLastVersion(extName); - if (ext != null) { - w.addExtension(ext); - } - } - } - - // ajout de l'extension demande par l'utilisateur - String extName = context.getArgument("newExtension", null); - if (extName != null && !"".equals(extName)) { - WikittyExtension ext = proxy - .restoreExtensionLastVersion(extName); - if (ext != null) { - w.addExtension(ext); - } - } - - Map<String, Object> args = new HashMap<String, Object>(); - args.putAll(context.getArguments()); - args.putAll(context.getArgumentFiles()); - for (Map.Entry<String, Object> field : args.entrySet()) { - String key = field.getKey(); - Object value = null; - if (key.contains(WikittyUtil.FQ_FIELD_NAME_SEPARATOR)) { - String ext = WikittyExtension.extractExtensionName(key); - String fieldName = WikittyExtension - .extractFieldName(key); - - if (w.hasField(ext, fieldName)) { - if (!"true".equals(context.getArgument("isNull-" - + key, "false"))) { - - value = field.getValue(); - } - - FieldType extFieldType = w.getExtension(ext) - .getFieldType(fieldName); - if (extFieldType.isCollection() - && extFieldType.getType() == TYPE.STRING - && value != null) { - - String valueString = value.toString(); - - valueString = new String(valueString.substring( - 1, valueString.length() - 1)); - - Collection<String> list = new ArrayList<String>(); - - String[] valuesString = StringUtil.split( - valueString, ","); - - for (String element : valuesString) { - list.add(element.trim()); - } - - w.setField(ext, fieldName, list); - - } else { - w.setField(ext, fieldName, value); - } - // si w est un WikittyPubData on essai de mettre a - // jour si besoin les champs mimetype et name - if (ext.equals(WikittyPubData.EXT_WIKITTYPUBDATA) - && fieldName - .equals(WikittyPubData.FIELD_WIKITTYPUBDATA_CONTENT)) { - if (null == WikittyPubDataHelper.getName(w)) { - WikittyPubDataHelper.setName( - w, - String.valueOf(args.get(key - + "-filename"))); - } - if (null == WikittyPubDataHelper.getMimeType(w)) { - WikittyPubDataHelper.setMimeType( - w, - String.valueOf(args.get(key - + "-contentType"))); - } - } - } - } - } - - if (context.getArguments().containsKey("store")) { - // on nous demande la sauvegarde - proxy.store(w); - } - } - } - - // forward l'affichage de la page vers la jsp d'edition - context.setContentType("forward/jsp"); - context.getRequest().setAttribute(ActionEval.CONTEXT_VAR, context); - context.getRequest().setAttribute(ActionEval.WIKITTY_VAR, w); - result = "/WEB-INF/jsp/edit.jsp"; - - return result; - } - - /** - * create url to edit wikitty object, assume that edition already start add - * context.getActionName() return edit action name. - * - * @param context - * @param w - * @return - */ - public String makeUrl(WikittyPublicationContext context, Wikitty w) { - String url = getMapping() + "/" + Element.ELT_ID + SEARCH_SEPARATOR - + w.getId(); - url = context.makeUrl(url); - return url; - } - - @Override - protected String getExampleUsage() { - return exampleUsage; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,86 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - - -import javax.servlet.http.HttpServletRequest; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ExceptionUtil; - -/** - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class ActionError extends AbstractAction { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(ActionError.class); - - protected Throwable error = null; - - public ActionError(Throwable error) { - this.error = error; - } - - @Override - public Object doAction(WikittyPublicationContext context) { - error.printStackTrace(); - - HttpServletRequest req = context.getRequest(); - String result = "<html><body>Error: " - + "<br>context: " + context - + "<br>" - + "<br>getContextPath: " + req.getContextPath() - + "<br>getMethod: " + req.getMethod() - + "<br>getPathInfo: " + req.getPathInfo() - + "<br>getPathTranslated: " + req.getPathTranslated() - + "<br>getQueryString: " + req.getQueryString() - + "<br>getRemoteUser: " + req.getRemoteUser() - + "<br>getRequestURI: " + req.getRequestURI() - + "<br>getRequestURI: " + req.getRequestURI() - + "<br>getRequestedSessionId: " + req.getRequestedSessionId() - + "<br>getServletPath: " + req.getServletPath() - + "<br>getCharacterEncoding: " + req.getCharacterEncoding() - + "<br>getContentType: " + req.getContentType() - + "<br>getLocalAddr: " + req.getLocalAddr() - + "<br>getLocalName: " + req.getLocalName() - + "<br>getProtocol: " + req.getProtocol() - + "<br>getRemoteAddr: " + req.getRemoteAddr() - + "<br>getRemoteHost: " + req.getRemoteHost() - + "<br>getScheme: " + req.getScheme() - + "<br>getServerName: " + req.getServerName() - + "<br>" - + "<br>error:<pre>" + StringEscapeUtils.escapeHtml(ExceptionUtil.stackTrace(error)) + "</pre>" - + "</body></html>"; - return result; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,186 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.script.Bindings; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.ScriptEvaluator; -import org.nuiton.wikitty.WikittyException; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.publication.entities.WikittyPubText; -import org.nuiton.wikitty.search.Criteria; - -/** - * Permet d'evaluer un WikittyPubText et de retourner la valeur de l'evaluation. - * La variable de nom {@link WikittyPublicationContext#CONTEXT_VAR} et de type - * {@link WikittyPublicationContext} est positionnee dans l'environnement - * d'evaluation. - * - * Le script doit positionner convenablement la valeur de - * {@link WikittyPublicationContext#setContentType(java.lang.String)} par - * rapport a l'objet retourne - * - * L'evaluateur est recherche via la valeur du champs - * {@link WikittyPubText#getMimeType()}. - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class ActionEval extends AbstractActionOnWikitty { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(ActionError.class); - - /** variable contenant l'instance de la classe ActionEval */ - static final public String EVAL_VAR = "wpEval"; - /** variable name use to put context in script and jsp */ - static final public String CONTEXT_VAR = "wpContext"; - /** contient la liste des arguments mandatory non encore utilise */ - static final public String SUBCONTEXT_VAR = "wpSubContext"; - /** - * contient le nom de la page WikittyPubText (ex: Wiki) ou la requete ayant - * permis de trouver la page (ex: MyScript.name=df) - */ - static final public String PAGE_NAME_VAR = "wpPage"; - /** - * contient le wikitty utilise comme script - */ - static final public String WIKITTY_VAR = "wpWikitty"; - - static final protected String exampleUsage = - "eval/WikittyPubText.name=Wiki/WikittyPubText.content?mimetype=WikittyPubText.mimetype\n" - + "eval/Tuto\n" - + "eval/Tuto/WikittyPubText.content\n" - + "eval/WikittyPubText.name=Tuto/WikittyPubText.content\n" - + "eval/WikittyPubText.name=Tuto/WikittyPubText.content?mimetype=WikittyPubText.mimetype\n" - + "eval/Command.id=df/Command.script?mimetype=Command.mimetype\n"; - - protected ApplicationConfig appConfig; - protected ScriptEngineManager scriptEnginManager; - - public ActionEval(ApplicationConfig appConfig) { - this.appConfig = appConfig; - - scriptEnginManager = new ScriptEngineManager(); - } - - public Object doAction(WikittyPublicationContext context, List<String> subContext) { - log.info("path " + subContext); - - Object result; - - Criteria criteria = searchCriteria(subContext); - - if (criteria == null) { - // rien a evaluer, on retourne une chaine vide - result = ""; - } else { - WikittyProxy proxy = context.getWikittyProxy(); - Wikitty w = proxy.findByCriteria(criteria); - - if (w == null) { - context.setContentType("text/plain"); - result = String.format( - "no data found for criteria '%s'", criteria); - } else { - String contentField = getContentFieldName(context, criteria.getName(), w); - - if (contentField == null) { - result = getError(context); - } else { - String extName = WikittyExtension.extractExtensionName(contentField); - String fieldName = WikittyExtension.extractFieldName(contentField); - - String mimetype = getMimeType(context, criteria.getName(), w); - String content = w.getFieldAsString(extName, fieldName); - - // supprime de subcontext ce qui a ete utilise dans cette methode - subContext = new ArrayList<String>(subContext.subList(1, subContext.size())); - - Map<String, Object> bindings = new HashMap<String, Object>(); - bindings.put(PAGE_NAME_VAR, criteria.getName()); - bindings.put(CONTEXT_VAR, context); - bindings.put(SUBCONTEXT_VAR, subContext); - bindings.put(WIKITTY_VAR, w); - bindings.put(EVAL_VAR, this); - - result = ScriptEvaluator.eval( - null, criteria.getName(), content, mimetype, bindings); - } - } - } - - return result; - } - - public Object doAction(WikittyPublicationContext context, String subContextAsText) { - Object result; - if (subContextAsText == null || "".equals(subContextAsText)) { - result = getError(context); - } else { - if (subContextAsText.startsWith("/")) { - subContextAsText = subContextAsText.substring(1); - } - String[] subContextArray = StringUtil.split(subContextAsText, "/"); - List<String> subContext = Arrays.asList(subContextArray); - result = doAction(context, subContext); - } - return result; - } - - @Override - public Object doAction(WikittyPublicationContext context) { - Object result; - if (context.getMandatoryArguments().size() <= 0) { - result = getError(context); - } else { - result = doAction(context, context.getMandatoryArguments()); - } - return result; - } - - @Override - protected String getExampleUsage() { - return exampleUsage; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionLogin.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionLogin.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionLogin.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,122 +0,0 @@ -package org.nuiton.wikitty.publication; - -import javax.servlet.http.Cookie; - -import org.nuiton.util.ApplicationConfig; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.entities.WikittyUser; -import org.nuiton.wikitty.entities.WikittyUserHelper; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.Search; - -/** - * Class for the login action. - * - * @author mfortun - * - */ -public class ActionLogin extends AbstractActionOnWikitty { - - static public String COOKIE_NAME = "wikittypublication"; - - static final protected String exampleUsage = ""; - - protected ApplicationConfig appConfig; - - public ActionLogin(ApplicationConfig appConfig) { - this.appConfig = appConfig; - } - - @Override - public Object doAction(WikittyPublicationContext context) { - - /* - * /login?login=moi&password=xxxx&succes=/eval/Wiki/WikiHello - - * - * /login?logout&succes=/eval/Wiki/WikiHello - */ - - String result = ""; - Wikitty w; - WikittyProxy proxy = context.getWikittyProxy(); - Cookie loginCookie = null; - - context.getRequest().getCookies(); - - - /* - *if logout option, remove our cookie. - */ - if (context.getArguments().containsKey("logout")) { - loginCookie = new Cookie(COOKIE_NAME, ""); - loginCookie.setMaxAge(0); - context.getResponse().addCookie(loginCookie); - } - - - - - if (context.getArguments().containsKey("login")) { - String login = context.getArguments().get("login"); - String password = context.getArguments().get("password"); - - String idUser = proxy.findIdByCriteria(this - .constructCriteriaOnUser(login)); - - result = login + idUser; - w = proxy.restore(idUser); - - boolean loginSucces = WikittyUserHelper.getPassword(w).equals(password); - - if (loginSucces){ - Cookie cook = new Cookie(COOKIE_NAME, "roger"); - // cook.setMaxAge(0) - - context.getResponse().addCookie(cook); - - } - - } - - - - - - - if (context.getArguments().containsKey("succes")) { - // faire un truc avec la chaine succes - } - - - /* - * verification de la présence d'un cookie si présence ok - * - * sinon proposer de loger sinon info de log on va créer cookie - * - * créer une session ? - */ - return result; - } - - @Override - protected String getExampleUsage() { - return exampleUsage; - - } - - protected Criteria constructCriteriaOnUser(String loginName) { - - Criteria criteriaOnLogin; - Search mainRequest = Search.query(); - - // wikitty user with the loginName - criteriaOnLogin = mainRequest.exteq(WikittyUser.EXT_WIKITTYUSER) - .eq(WikittyUser.FQ_FIELD_WIKITTYUSER_LOGIN, loginName) - .criteria(); - - return criteriaOnLogin; - } - -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,106 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.PagedResult; -import org.nuiton.wikitty.search.Search; -import org.nuiton.wikitty.search.operators.Element; - -/** - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class ActionView extends AbstractAction { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(ActionError.class); - - protected ApplicationConfig appConfig; - - public ActionView(ApplicationConfig appConfig) { - this.appConfig = appConfig; - } - - @Override - public Object doAction(WikittyPublicationContext context) { - WikittyProxy proxy = context.getWikittyProxy(); - - String r = context.getArguments().get("r"); - if (r == null || "".equals(r)) { - r = "*"; - } - String first = context.getArgument("first", "0"); - String end = context.getArgument("end", "100"); - int firstIndex = StringUtil.toInt(first); - int endIndex = StringUtil.toInt(end); - - - - Criteria criteria = Search.query().keyword(r).criteria(); - criteria.setFirstIndex(firstIndex); - criteria.setEndIndex(endIndex); - - PagedResult<Wikitty> pagedResult = proxy.findAllByCriteria(criteria); - - String id = context.getArguments().get("id"); - Wikitty w = proxy.restore(id); - - // forward l'affichage de la page vers la jsp d'edition - context.setContentType("forward/jsp"); - context.getRequest().setAttribute(ActionEval.CONTEXT_VAR, context); - context.getRequest().setAttribute(ActionEval.WIKITTY_VAR, w); - context.getRequest().setAttribute("pagedResult", pagedResult); - String result = "/WEB-INF/jsp/view.jsp"; - - return result; - } - - /** - * create url to edit wikitty object, assume that edition already start - * add context.getActionName() return edit action name. - * - * @param context - * @param w - * @return - */ - static public String makeUrl(WikittyPublicationContext context, Wikitty w) { - String url = context.getActionName() + "/" - + Element.ELT_ID + "=" + w.getId(); - url = context.makeUrl(url); - return url; - } - -} Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/LogoutInterceptor.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/LogoutInterceptor.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/LogoutInterceptor.java 2011-05-13 09:00:49 UTC (rev 886) @@ -42,9 +42,7 @@ @Override - public String intercept(ActionInvocation invocation) throws Exception { - System.out.println("passed logout"); - + public String intercept(ActionInvocation invocation) throws Exception { Map<String, Object> session = ActionContext.getContext().getSession(); WikittyPublicationSession.invalidate(session); String result = invocation.invoke(); Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,40 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - -/** - * each action can be used by multiple thread - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public interface WikittyPublicationAction { - public String getMapping(); - public void setMapping(String mapping); - public Object doAction(WikittyPublicationContext context); -} Deleted: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java 2011-05-13 09:00:49 UTC (rev 886) @@ -1,390 +0,0 @@ -/* - * #%L - * Wikitty :: publication - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 CodeLutin, Benjamin Poussin, Benjamin Poussin - * %% - * 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% - */ -package org.nuiton.wikitty.publication; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.ArgumentsParserException; -import org.nuiton.util.ObjectUtil; -import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.WikittyConfig; -import org.nuiton.wikitty.WikittyConfigOption; -import org.nuiton.wikitty.WikittyException; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.WikittyService; -import org.nuiton.wikitty.WikittyServiceFactory; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.entities.WikittyLabelAbstract; -import org.nuiton.wikitty.entities.WikittyTreeNodeAbstract; -import org.nuiton.wikitty.entities.WikittyUserAbstract; -import org.nuiton.wikitty.publication.entities.WikittyPubDataAbstract; -import org.nuiton.wikitty.publication.entities.WikittyPubTextAbstract; - -/** - * Context de la requete en cours. - * - * Les parametres de la requete sont parses et mis dans deux variables - * <li>arguments - * <li>argumentFiles - * - * un parametre simple sera dans arguments: - * <li> [filename]=[valeur du champs] - * - * un parametre de type upload aura des entrees dans les deux - * dans arguments: - * <li> [fieldname]-upload=true - * <li> [fieldname]-filename=[nom du fichier] - * <li> [fieldname]-contentType=[type mime du fichier] - * dans argumentFiles: - * <li> [fieldname]=[contenu binaire du fichier] - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class WikittyPublicationContext { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyPublicationContext.class); - - /** configuration option name FIXME poussin 20101206 use OptionDef */ - static final public String CONFIG_FILE = "wikitty.publication.config.pattern"; - static final public String ACTION_PREFIX = "wikitty.publication.action"; - - static final protected Map<String, WikittyService> services = - new HashMap<String, WikittyService>(); - static final protected Map<String, WikittyPublicationAction> actions = - new HashMap<String, WikittyPublicationAction>(); - - protected ApplicationConfig appConfig; - protected HttpServletRequest req; - protected HttpServletResponse resp; - protected String wsContext = null; - protected String actionName = null; - protected String path = ""; - protected List<String> mandatoryArguments = new ArrayList<String>(); - protected Map<String, String> arguments = new HashMap<String, String>(); - protected Map<String, byte[]> argumentFiles = new HashMap<String, byte[]>(); - protected WikittyProxy proxy = null; - - protected String contentType = "text/html"; - - public WikittyPublicationContext(ApplicationConfig appConfig) { - this.appConfig = appConfig; - - // force load of action in configuration - for(String key : appConfig.getFlatOptions().stringPropertyNames()) { - if (key.startsWith(ACTION_PREFIX)) { - String action = key.substring(ACTION_PREFIX.length() + 1); - getAction(action); - } - } - } - - /** - * add here all extension that WikittyService must know - */ - protected void addRequiredExtension(WikittyService ws) { - List<WikittyExtension> exts = new ArrayList<WikittyExtension>(); - - exts.addAll(WikittyUserAbstract.extensions); - exts.addAll(WikittyLabelAbstract.extensions); - exts.addAll(WikittyTreeNodeAbstract.extensions); - exts.addAll(WikittyPubTextAbstract.extensions); - exts.addAll(WikittyPubDataAbstract.extensions); - - ws.storeExtension(null, exts); - } - - /** - * set attributes: - * <li> req - * <li> wsContext - * <li> actionName - * <li> mandatoryArguments - * <li> arguments - * - * @param req - */ - public void parse(HttpServletRequest req, HttpServletResponse resp) { - this.req = req; - this.resp = resp; - - String path = req.getPathInfo(); - - // path start with '/' then comps[0] == empty - String[] comps = StringUtil.split(path, "/"); - if (comps.length > 0) { - wsContext = comps[1]; - } - if (comps.length > 1) { - actionName = comps[2]; - } - - - for (int i = 3; i < comps.length; i++) { - mandatoryArguments.add(comps[i]); - path += "/" + comps[i]; - } - - - boolean isMultipart = ServletFileUpload.isMultipartContent(getRequest()); - if (isMultipart == true) { - // Create a factory for disk-based file items - DiskFileItemFactory factory = new DiskFileItemFactory(); - // Create a new file upload handler - ServletFileUpload upload = new ServletFileUpload(factory); - // Process the uploaded items - // Parse the request - try { - List<FileItem> items = upload.parseRequest(getRequest()); - for (FileItem item : items) { - String name = item.getFieldName(); - if (item.isFormField()) { - String value = item.getString(); - arguments.put(name, value); - } else { - String filename = item.getName(); - String mime = item.getContentType(); - byte[] value = item.get(); - log.info(String.format( - "Argument file '%s' of type '%s'", - filename, mime)); - argumentFiles.put(name, value); - arguments.put(name+"-upload", "true"); - arguments.put(name+"-filename", filename); - arguments.put(name+"-contentType", mime); - } - } - } catch (FileUploadException eee) { - log.error("Can't get uploaded file", eee); - } - } else { - for (Enumeration<String> e = req.getParameterNames(); e.hasMoreElements();) { - String name = e.nextElement(); - String value = req.getParameter(name); - arguments.put(name, value); - } - } - log.info(String.format( - "path %s => ws: %s action: %s mandatoryArguments: %s arguments: %s", - path, wsContext, actionName, mandatoryArguments, arguments)); - } - - public HttpServletRequest getRequest() { - return req; - } - - public HttpServletResponse getResponse() { - return resp; - } - - public ApplicationConfig getAppConfig() { - return appConfig; - } - - /** - * le nom de l'action a faire - * @return - */ - public String getActionName() { - return actionName; - } - - /** - * le reste de l'url apres l'action - * @return - */ - public String getPath() { - return path; - } - - - public WikittyProxy getWikittyProxy() { - if (proxy == null) { - proxy = new WikittyProxy(getAppConfig(), getWikittyService()); - } - return proxy; - } - - /** - * add context to the url and parameter if necessary - * @param url - * @return - */ - public String makeUrl(String url) { - String finalUrl = url; - if (!finalUrl.startsWith("/")) { - finalUrl = "/" + finalUrl; - } - finalUrl = getRequest().getContextPath() + "/" + wsContext + finalUrl; - finalUrl = getResponse().encodeURL(finalUrl); - if (log.isInfoEnabled()) { - log.info(String.format("transforme url from '%s' to '%s'", url, finalUrl)); - } - return finalUrl; - } - - public WikittyService getWikittyService() { - WikittyService result = services.get(wsContext); - if (result == null) { - String patternConfigFilename = appConfig.getOption(CONFIG_FILE); - - // load default configuration for all wikitty service - String filename = String.format(patternConfigFilename, "default"); - log.info(String.format("Try to load config file '%s'", filename)); - ApplicationConfig wsConfigDefault; - - wsConfigDefault = WikittyConfig.getConfig(filename); - - // change juste data dir with context path - String dataDir = wsConfigDefault.getOption( - WikittyConfigOption.WIKITTY_DATA_DIR.getKey()); - wsConfigDefault.setOption( - WikittyConfigOption.WIKITTY_DATA_DIR.getKey(), - dataDir + File.separator + wsContext); - - // read specifique configuration with default config as default properties - filename = String.format(patternConfigFilename, wsContext); - log.info(String.format("Try to load config file '%s'", filename)); - ApplicationConfig wsConfig; - try { - wsConfig = new ApplicationConfig(wsConfigDefault.getFlatOptions(false)); - wsConfig.setConfigFileName(filename); - wsConfig.parse(null); - } catch (ArgumentsParserException eee) { - throw new WikittyException(String.format( - "Can't parse configuration %s", filename), eee); - } - synchronized (services) { - result = services.get(wsContext); - if (result == null) { - result = WikittyServiceFactory.buildWikittyService(wsConfig); - addRequiredExtension(result); - services.put(wsContext, result); - } - } - } - return result; - } - - public List<String> getMandatoryArguments() { - return mandatoryArguments; - } - - public Map<String, String> getArguments() { - return arguments; - } - - public Map<String, byte[]> getArgumentFiles() { - return argumentFiles; - } - - public String getArgument(String name, String defaultValue) { - String result = defaultValue; - if (getArguments().containsKey(name)) { - result = getArguments().get(name); - } - return result; - } - - public WikittyPublicationAction getAction() { - WikittyPublicationAction result = getAction(actionName); - return result; - } - - - public <E extends WikittyPublicationAction> E getAction(Class<E> actionClass) { - E result = null; - for (WikittyPublicationAction a : actions.values()) { - if (actionClass.isInstance(a)) { - result = (E)a; - break; - } - } - return result; - } - - public WikittyPublicationAction getAction(String actionName) { - if (log.isInfoEnabled()) { - log.info(String.format("Looking for class for '%s' action", actionName)); - } - WikittyPublicationAction result = actions.get(actionName); - if (result == null) { - String action = ACTION_PREFIX + "." + actionName; - log.info(String.format("try to load action %s", action)); - try { - Class<WikittyPublicationAction> clazz = (Class<WikittyPublicationAction>) - appConfig.getOptionAsClass(action); - Collection args = Collections.singleton(appConfig); - result = ObjectUtil.newInstance(clazz, args, true); - result.setMapping(actionName); - actions.put(actionName, result); - } catch (Exception eee) { - log.error(String.format("Can't find action %s", action), eee); - result = new ActionError(eee); - } - } - return result; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - @Override - public String toString() { - String path = req.getPathInfo(); - String result = String.format("WPContext [path: %s\n" - + " ws: %s\n" - + " action: %s\n" - + " mandatoryArguments: %s\n" - + " arguments: %s\n" - + "]", path, wsContext, actionName, mandatoryArguments, arguments); - return result; - } - -} Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogin.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogin.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogin.java 2011-05-13 09:00:49 UTC (rev 886) @@ -42,10 +42,10 @@ protected String login; protected String password; - protected String error = DEFAULT_ERROR; - static protected String DEFAULT_ERROR = "login.jsp"; - protected String success = DEFAULT_SUCCESS; - static protected String DEFAULT_SUCCESS = "index.jsp"; + protected String error; + static public String DEFAULT_ERROR = "login.jsp"; + protected String success; + static public String DEFAULT_SUCCESS = "index.jsp"; public String getLogin() { return login; Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogout.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogout.java 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/action/PublicationActionLogout.java 2011-05-13 09:00:49 UTC (rev 886) @@ -31,7 +31,6 @@ private static final long serialVersionUID = 4806944250461551896L; public String execute() { - System.out.println("logout"); WikittyPublicationSession.invalidate(session); return SUCCESS; } Modified: trunk/wikitty-publication/src/main/webapp/login.jsp =================================================================== --- trunk/wikitty-publication/src/main/webapp/login.jsp 2011-05-12 16:16:20 UTC (rev 885) +++ trunk/wikitty-publication/src/main/webapp/login.jsp 2011-05-13 09:00:49 UTC (rev 886) @@ -2,20 +2,36 @@ <%@page + import="org.nuiton.wikitty.publication.action.PublicationActionLogin"%> +<%@page import="org.nuiton.wikitty.publication.WikittyPublicationSession"%> <%@ taglib prefix="s" uri="/struts-tags"%> + +<% + String successValue = request.getParameter("success"); + String errorValue = request.getParameter("error"); + + if (successValue == null || successValue == "") { + successValue = PublicationActionLogin.DEFAULT_SUCCESS; + } + + //TODO mfortun-2011-05-13 find how to have default value configured by struts + if (errorValue == null || errorValue == "") { + errorValue = PublicationActionLogin.DEFAULT_ERROR; + } +%> + + <s:form action="login"> <p> - <input type="hidden" name="success" value="<%=request.getParameter("success") %>" /> - <input type="hidden" name="error" value="<%=request.getParameter("error") %>" /> + <input type="hidden" name="success" value="<%=successValue%>" /> <input + type="hidden" name="error" value="<%=errorValue%>" /> <s:textfield key="login" name="login" labelposition="top" labelSeparator=" :" /> - <br /> - <br /> - <s:password key="password" name="password" - labelposition="top" labelSeparator=" :" /> - <br /> - <br /> + <br /> <br /> + <s:password key="password" name="password" labelposition="top" + labelSeparator=" :" /> + <br /> <br /> <s:submit key="publication.login.submit" name="submit" /> </p> </s:form> \ No newline at end of file