Wikitty-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
December 2010
- 6 participants
- 128 discussions
r584 - trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services
by bpoussin@users.nuiton.org 09 Dec '10
by bpoussin@users.nuiton.org 09 Dec '10
09 Dec '10
Author: bpoussin
Date: 2010-12-09 10:29:49 +0100 (Thu, 09 Dec 2010)
New Revision: 584
Url: http://nuiton.org/repositories/revision/wikitty/584
Log:
add cache stat in debug log level
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java 2010-12-08 15:57:35 UTC (rev 583)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java 2010-12-09 09:29:49 UTC (rev 584)
@@ -77,6 +77,11 @@
*/
protected boolean allwaysRestoreCopies = false;
+ /** nombre de solicitation du cache */
+ protected long asked = 0;
+ /** nombre de fois que l'objet demande n'etait pas dans le cache */
+ protected long missed = 0;
+
/**
* Constructor with configuration.
*
@@ -104,6 +109,14 @@
}
}
+ protected void statAdd(int asked, int missed) {
+ this.asked += asked;
+ this.missed += missed;
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("cache stat (missed/asked): %s/%s", missed, asked));
+ }
+ }
+
/** wrap the wikitty or copy it according to allwaysRestoreCopies value */
protected Wikitty wrapWikitty(Wikitty wikitty) {
@@ -129,31 +142,6 @@
}
@Override
- public String login(String login, String password) {
- return ws.login(login, password);
- }
-
- @Override
- public void logout(String securityToken) {
- ws.logout(securityToken);
- }
-
- @Override
- public boolean canWrite(String securityToken, Wikitty wikitty) {
- return ws.canWrite(securityToken, wikitty);
- }
-
- @Override
- public boolean canDelete(String securityToken, String wikittyId) {
- return ws.canDelete(securityToken, wikittyId);
- }
-
- @Override
- public boolean canRead(String securityToken, String wikittyId) {
- return ws.canRead(securityToken, wikittyId);
- }
-
- @Override
public WikittyEvent clear(String securityToken) {
WikittyEvent result = ws.clear(securityToken);
cache.clearWikitty();
@@ -265,6 +253,8 @@
for (Wikitty w : tmp) {
result.add(wrapWikitty(w));
}
+
+ statAdd(ids.size(), notInCache.size());
return result;
}
@@ -386,6 +376,31 @@
//
@Override
+ public String login(String login, String password) {
+ return ws.login(login, password);
+ }
+
+ @Override
+ public void logout(String securityToken) {
+ ws.logout(securityToken);
+ }
+
+ @Override
+ public boolean canWrite(String securityToken, Wikitty wikitty) {
+ return ws.canWrite(securityToken, wikitty);
+ }
+
+ @Override
+ public boolean canDelete(String securityToken, String wikittyId) {
+ return ws.canDelete(securityToken, wikittyId);
+ }
+
+ @Override
+ public boolean canRead(String securityToken, String wikittyId) {
+ return ws.canRead(securityToken, wikittyId);
+ }
+
+ @Override
public void addWikittyServiceListener(WikittyListener listener, ServiceListenerType type) {
ws.addWikittyServiceListener(listener, type);
}
1
0
08 Dec '10
Author: bpoussin
Date: 2010-12-08 16:57:35 +0100 (Wed, 08 Dec 2010)
New Revision: 583
Url: http://nuiton.org/repositories/revision/wikitty/583
Log:
mark some methods as duplicate with same in other class
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:56:33 UTC (rev 582)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:57:35 UTC (rev 583)
@@ -102,10 +102,10 @@
static final protected FastDateFormat solrDateFormat = FastDateFormat.getInstance(
DATE_FORMAT, CANONICAL_TZ, CANONICAL_LOCALE);
- protected static final String FQ_FIELD_NAME_SEPARATOR = ".";
- protected static final String FQ_FIELD_NAME_SEPARATOR_REGEX = "\\.";
- protected static final String FQ_META_EXTENSION_SEPARATOR = ":";
- protected static final String FQ_META_EXTENSION_SEPARATOR_REGEX = ":";
+ public static final String FQ_FIELD_NAME_SEPARATOR = ".";
+ public static final String FQ_FIELD_NAME_SEPARATOR_REGEX = "\\.";
+ public static final String FQ_META_EXTENSION_SEPARATOR = ":";
+ public static final String FQ_META_EXTENSION_SEPARATOR_REGEX = ":";
// /** All date format parser used to convert string to date */
@@ -855,13 +855,19 @@
*/
}
- /** given a fully qualified field name, return the name of the extension */
+ /**
+ * given a fully qualified field name, return the name of the extension
+ * TODO poussin 20101208 redondant code with {@link WikittyExtension#extractExtensionName(java.lang.String)}
+ */
public static String getExtensionNameFromFQFieldName(String fqFieldName) {
String[] fqFieldElements = fqFieldName.split(FQ_FIELD_NAME_SEPARATOR_REGEX);
return fqFieldElements[0];
}
- /** given a fully qualified field name, return the name of the field */
+ /**
+ * given a fully qualified field name, return the name of the field
+ * TODO poussin 20101208 redondant code with {@link WikittyExtension#extractFieldName(java.lang.String)}
+ */
public static String getFieldNameFromFQFieldName(String fqFieldName) {
String[] fqFieldElements = fqFieldName.split(FQ_FIELD_NAME_SEPARATOR_REGEX);
return fqFieldElements[1];
1
0
r582 - trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities
by bpoussin@users.nuiton.org 08 Dec '10
by bpoussin@users.nuiton.org 08 Dec '10
08 Dec '10
Author: bpoussin
Date: 2010-12-08 16:56:33 +0100 (Wed, 08 Dec 2010)
New Revision: 582
Url: http://nuiton.org/repositories/revision/wikitty/582
Log:
use constant separator fq field
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/WikittyExtension.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/WikittyExtension.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/WikittyExtension.java 2010-12-08 15:55:22 UTC (rev 581)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/WikittyExtension.java 2010-12-08 15:56:33 UTC (rev 582)
@@ -220,7 +220,7 @@
* @throws WikittyException if bad fqFieldName format
*/
static public String extractExtensionName(String fqFieldName) {
- int i = fqFieldName.indexOf('.');
+ int i = fqFieldName.indexOf(WikittyUtil.FQ_FIELD_NAME_SEPARATOR);
if (i > 0) {
String result = fqFieldName.substring(0, i);
return result;
@@ -237,7 +237,7 @@
* @return return field name. Example 'login'
*/
static public String extractFieldName(String fqFieldName) {
- int i = fqFieldName.indexOf('.');
+ int i = fqFieldName.indexOf(WikittyUtil.FQ_FIELD_NAME_SEPARATOR);
if (i > 0) {
String result = fqFieldName.substring(i+1);
return result;
1
0
r581 - trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services
by bpoussin@users.nuiton.org 08 Dec '10
by bpoussin@users.nuiton.org 08 Dec '10
08 Dec '10
Author: bpoussin
Date: 2010-12-08 16:55:22 +0100 (Wed, 08 Dec 2010)
New Revision: 581
Url: http://nuiton.org/repositories/revision/wikitty/581
Log:
fix Anomalie #1135: Cannot store a Wikitty that got a new extension
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceSecurity.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceSecurity.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceSecurity.java 2010-12-08 15:47:38 UTC (rev 580)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceSecurity.java 2010-12-08 15:55:22 UTC (rev 581)
@@ -202,23 +202,22 @@
@Override
public WikittyEvent store(String securityToken,
Collection<Wikitty> wikitties, boolean force) {
- Collection<Wikitty> wikittiesToStore = checkStore(securityToken, wikitties);
- WikittyEvent result = ws.store(securityToken, wikittiesToStore, force);
+ checkStore(securityToken, wikitties);
+ WikittyEvent result = ws.store(securityToken, wikitties, force);
return result;
}
/**
- * FIXME poussin 20101028 pourquoi retourner une liste ? soit on a le droit
- * de faire un store sur tout, on bien on refuse avec une exception
- * verifier que result ne sert bien a rien (surtout pas a filtrer)
+ * Indique si on a bien le droit d'enregistrer tout les wikitties de la
+ * collection. Des que pour un wikitty on a pas les droits, une exception
+ * est levee.
*
* @param securityToken
* @param wikitties
* @return
*/
- protected Collection<Wikitty> checkStore(String securityToken, Collection<Wikitty> wikitties) {
+ protected void checkStore(String securityToken, Collection<Wikitty> wikitties) {
String userId = getUserId(securityToken);
- List<Wikitty> result = new ArrayList<Wikitty>();
for (Wikitty wikitty : wikitties) {
// usual case, a user want to store a wikitty
@@ -271,19 +270,24 @@
canChange = canWrite(securityToken, userId, concernedExtensionName, wikitty);
}
- if (canChange) {
- Object newValue = wikitty.getFqField(fqFieldDirtyName);
- oldVersion.setFqField(fqFieldDirtyName, newValue);
- } else {
+ // TODO poussin 20101208 quel est l'interet de faire cette copie ?
+ // surtout quelle ne fonctionne pas car le oldVersion n'a pas
+ // forcement toutes les extensions du nouveau wikitty
+ // Code supprime et remplace
+// if (canChange) {
+// Object newValue = wikitty.getFqField(fqFieldDirtyName);
+// oldVersion.setFqField(fqFieldDirtyName, newValue);
+// } else {
+// throw new SecurityException(_("user %s can't write field %s on wikitty %s",
+// userId, fqFieldDirtyName, wikitty));
+// }
+ if (!canChange) {
throw new SecurityException(_("user %s can't write field %s on wikitty %s",
userId, fqFieldDirtyName, wikitty));
}
}
}
-
- result.add(wikitty);
}
- return result;
}
@Override
1
0
08 Dec '10
Author: jcouteau
Date: 2010-12-08 16:47:38 +0100 (Wed, 08 Dec 2010)
New Revision: 580
Url: http://nuiton.org/repositories/revision/wikitty/580
Log:
Prevent NPE
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:31:51 UTC (rev 579)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:47:38 UTC (rev 580)
@@ -1072,10 +1072,10 @@
// Fixed poussin 20101208 le bout de code original qui pose probleme
// pour la conversion null. This is only modification
-// // Missing Value
-// if (value == null) {
-// return handleMissing(targetType);
-// }
+ // Missing Value
+ if (value == null) {
+ return null;
+ }
sourceType = value.getClass();
1
0
08 Dec '10
Author: bpoussin
Date: 2010-12-08 16:31:51 +0100 (Wed, 08 Dec 2010)
New Revision: 579
Url: http://nuiton.org/repositories/revision/wikitty/579
Log:
try to fix conversion date, add some methods that have bad visibility in BeanUtil :(
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:23:46 UTC (rev 578)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:31:51 UTC (rev 579)
@@ -1004,12 +1004,18 @@
/**
* redefinition du DateConverter car par defaut il ne support pas la valeur
- * null :(
+ * null :(.
+ *
+ * Ceci est un copier coller de DateConverter + AbstractConverter
+ * (et plus de copie/coller qu'il ne faut a cause de methode et de champs
+ * avec de mauvaise visibilite :()
*/
static private class WikittyDateConverter extends DateTimeConverter {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(WikittyDateConverter.class);
+ private static final String PACKAGE = "org.apache.commons.beanutils.converters.";
+
/**
* Construct a <b>java.util.Date</b> <i>Converter</i> that throws
* a <code>ConversionException</code> if an error occurs.
@@ -1065,7 +1071,7 @@
value = convertArray(value);
// Fixed poussin 20101208 le bout de code original qui pose probleme
- // pour la conversion null
+ // pour la conversion null. This is only modification
// // Missing Value
// if (value == null) {
// return handleMissing(targetType);
@@ -1131,6 +1137,39 @@
return type;
}
}
+
+ /**
+ * Provide a String representation of a <code>java.lang.Class</code>.
+ * @param type The <code>java.lang.Class</code>.
+ * @return The String representation.
+ */
+ String toString(Class type) {
+ String typeName = null;
+ if (type == null) {
+ typeName = "null";
+ } else if (type.isArray()) {
+ Class elementType = type.getComponentType();
+ int count = 1;
+ while (elementType.isArray()) {
+ elementType = elementType.getComponentType();
+ count++;
+ }
+ typeName = elementType.getName();
+ for (int i = 0; i < count; i++) {
+ typeName += "[]";
+ }
+ } else {
+ typeName = type.getName();
+ }
+ if (typeName.startsWith("java.lang.")
+ || typeName.startsWith("java.util.")
+ || typeName.startsWith("java.math.")) {
+ typeName = typeName.substring("java.lang.".length());
+ } else if (typeName.startsWith(PACKAGE)) {
+ typeName = typeName.substring(PACKAGE.length());
+ }
+ return typeName;
+ }
}
static public WikittyDateConverter dateConverter = new WikittyDateConverter();
1
0
08 Dec '10
Author: bpoussin
Date: 2010-12-08 16:23:46 +0100 (Wed, 08 Dec 2010)
New Revision: 578
Url: http://nuiton.org/repositories/revision/wikitty/578
Log:
try to fix conversion date error when date is null
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 14:30:26 UTC (rev 577)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:23:46 UTC (rev 578)
@@ -25,6 +25,7 @@
package org.nuiton.wikitty;
+import com.thoughtworks.xstream.converters.basic.DateConverter;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -60,6 +61,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.beanutils.converters.DateTimeConverter;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.FastDateFormat;
@@ -1000,6 +1002,138 @@
return result;
}
+ /**
+ * redefinition du DateConverter car par defaut il ne support pas la valeur
+ * null :(
+ */
+ static private class WikittyDateConverter extends DateTimeConverter {
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(WikittyDateConverter.class);
+
+ /**
+ * Construct a <b>java.util.Date</b> <i>Converter</i> that throws
+ * a <code>ConversionException</code> if an error occurs.
+ */
+ public WikittyDateConverter() {
+ super();
+ }
+
+ /**
+ * Construct a <b>java.util.Date</b> <i>Converter</i> that returns
+ * a default value if an error occurs.
+ *
+ * @param defaultValue The default value to be returned
+ * if the value to be converted is missing or an error
+ * occurs converting the value.
+ */
+ public WikittyDateConverter(Object defaultValue) {
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ @Override
+ protected Class getDefaultType() {
+ return Date.class;
+ }
+
+ /**
+ * Convert the input object into an output object of the
+ * specified type.
+ *
+ * @param type Data type to which this value should be converted
+ * @param value The input value to be converted
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
+ * successfully and no default is specified.
+ */
+ @Override
+ public Object convert(Class type, Object value) {
+
+ Class sourceType = value == null ? null : value.getClass();
+ Class targetType = primitive(type == null ? getDefaultType() : type);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Converting"
+ + (value == null ? "" : " '" + toString(sourceType) + "'")
+ + " value '" + value + "' to type '" + toString(targetType) + "'");
+ }
+
+ value = convertArray(value);
+
+ // Fixed poussin 20101208 le bout de code original qui pose probleme
+ // pour la conversion null
+// // Missing Value
+// if (value == null) {
+// return handleMissing(targetType);
+// }
+
+ sourceType = value.getClass();
+
+ try {
+ // Convert --> String
+ if (targetType.equals(String.class)) {
+ return convertToString(value);
+
+ // No conversion necessary
+ } else if (targetType.equals(sourceType)) {
+ if (log.isDebugEnabled()) {
+ log.debug(" No conversion required, value is already a "
+ + toString(targetType));
+ }
+ return value;
+
+ // Convert --> Type
+ } else {
+ Object result = convertToType(targetType, value);
+ if (log.isDebugEnabled()) {
+ log.debug(" Converted to " + toString(targetType)
+ + " value '" + result + "'");
+ }
+ return result;
+ }
+ } catch (Throwable t) {
+ return handleError(targetType, value, t);
+ }
+
+ }
+
+ /**
+ * Change primitve Class types to the associated wrapper class.
+ * @param type The class type to check.
+ * @return The converted type.
+ */
+ Class primitive(Class type) {
+ if (type == null || !type.isPrimitive()) {
+ return type;
+ }
+
+ if (type == Integer.TYPE) {
+ return Integer.class;
+ } else if (type == Double.TYPE) {
+ return Double.class;
+ } else if (type == Long.TYPE) {
+ return Long.class;
+ } else if (type == Boolean.TYPE) {
+ return Boolean.class;
+ } else if (type == Float.TYPE) {
+ return Float.class;
+ } else if (type == Short.TYPE) {
+ return Short.class;
+ } else if (type == Byte.TYPE) {
+ return Byte.class;
+ } else if (type == Character.TYPE) {
+ return Character.class;
+ } else {
+ return type;
+ }
+ }
+ }
+ static public WikittyDateConverter dateConverter = new WikittyDateConverter();
+
/**
* Copy all properties (get/set) from source to destination,
* except wikitty property
@@ -1010,6 +1144,7 @@
*/
static public void copyBean(Object source, Object dest) throws Exception {
BeanUtilsBean bu = BeanUtilsBean.getInstance();
+ bu.getConvertUtils().register(dateConverter, Date.class);
PropertyDescriptor[] origDescriptors =
bu.getPropertyUtils().getPropertyDescriptors(source);
1
0
08 Dec '10
Author: bpoussin
Date: 2010-12-08 15:30:26 +0100 (Wed, 08 Dec 2010)
New Revision: 577
Url: http://nuiton.org/repositories/revision/wikitty/577
Log:
add WikittyPublication analyse
Added:
trunk/wikitty-publication/src/site/
trunk/wikitty-publication/src/site/rst/
trunk/wikitty-publication/src/site/rst/wp-analyse.rst
Added: trunk/wikitty-publication/src/site/rst/wp-analyse.rst
===================================================================
--- trunk/wikitty-publication/src/site/rst/wp-analyse.rst (rev 0)
+++ trunk/wikitty-publication/src/site/rst/wp-analyse.rst 2010-12-08 14:30:26 UTC (rev 577)
@@ -0,0 +1,341 @@
+===================
+wikitty-publication
+===================
+
+But
+===
+
+Le but de la publication est de pouvoir créer des sites web en
+stockant les informations nécessaires directement dans wikitty.
+
+Contraintes
+===========
+
+La publication doit répondre à plusieurs contraintes:
+
+* stockage dans wikitty
+* développement en équipe aisé avec les outils habituels (éditeur,
+ svn, maven, ...)
+* gestion de l'authentification et des autorisations
+* multi-langue
+* multi-context (utilisation de plusieurs WikittyService par la même
+ instance de publication)
+* permettre le développement d'applications
+* déplacement aisé d'applications d'un WikittyService vers un autre
+ (partage d'application)
+* mise en production d'applications ainsi créées hors de wikitty pour
+ des besoins spécifiques
+
+Les actions
+===========
+
+L'idée général est d'avoir quelques actions de base mappées sur un
+path (ex: /view/ -> action view) Devant cette action on détermine sur
+quel context on fait l'action (WikittyService). Le reste de l'url sont
+des arguments pour l'action.
+
+Les actions de base sont:
+
+* ''login'' pour permettre de s'authentifier
+* ''view'' pour permettre de recherche des wikitties d'afficher la
+ liste des resultats et d'en voir un en détail
+* search
+
+ * vue list/détail
+
+* ''edit'' permet de créer, ajouter des extensions à un wikitty,
+ modifier les valeurs des champs, supprimer un objet
+
+ * create
+ * modif
+ * delete
+
+* ''raw'' permet de retourner la valeur d'un champs d'un wikitty dans
+ un typemime précis
+* ''eval'' permet d'évaluer un WikittyPubText
+* ''admin'' Analyse et admin du WikittyService
+
+ * import
+ * export
+ * synchro depuis un autre WikittyService (affichage des couples
+ WikittyPub???/Label dispo pour ensuite synchroniser une
+ application)
+ * proxy stat
+ * admin extension
+
+Pour cela on défini deux objets de publication:
+
+* WikittyPubText: pour les contenus textuels
+
+ * name: String unique=true notNull=true
+ * content: String multiline=true
+ * mimetype: String
+
+* WikittyPubData: pour les contenues binaires
+
+ * name: String unique=true notNull=true
+ * content: Binary
+ * mimetype: String
+
+Ensuite grâce à ces actions de bases on peut construire des
+applications complètement contenu dans le WikittyService (code,
+template, données)
+
+Format des URL
+==============
+
+la syntaxe complète d'une url est::
+
+ /[context]/[action]/[mandatory_args]?[args key=value]
+
+* ''context'' est le context pour trouver le bon WikittyService
+* ''action'' est le nom de l'action à effectuer, la classe gérant
+ cette action est trouvée dans le fichier de configuration
+* ''mandatory_args'' sont des arguments obligatoires pour l'action
+* ''args'' sont des arguments optionels pour l'action sout forme de
+ paramètre de requête
+
+Context
+=======
+
+Lorsque la demande HTTP arrive sur le server un
+WikittyPublicationContext est créé pour conservé le context de la
+demande. Ce context permet de récupérer un WikittyProxy pointant sur
+le bon WikittyService. Pour cela le fichier par defaut Wikitty est lu,
+la variable wikitty.data.directory est surchargée pour lui ajouter le
+context de l'url (pour différencier les espaces de stockage des
+différents context). Ensuite s'il existe un fichier spécifique de
+configuration de wikitty pour ce context il est lu pour permettre la
+surcharge de configuration spécifiquement pour un context. Les
+fichiers de configuration spécifique sont trouvé grâce au pattern de
+fichier trouvé dans la configuration de wikitty-publication.
+
+Recherche des actions
+=====================
+
+L'action est retrouvée grâce au fichier de configuration de
+wikitty-publication. On indique dans le fichier la classe héritant de
+WikittyPublicationAction permettant de gérer l'action demandée.
+
+Amélioration des URLs
+=====================
+
+Par défaut les actions recherchent ''WikittyPubText.name et
+WikittyPubData.name s'il n'y a pas de = dans l'argument obligatoire.''
+
+Par exemple les URLs suivantes sont équivalentes::
+
+ /eval/WikittyPubText.name=Wiki
+ /eval/Wiki
+
+ /raw/WikittyPubText.name=WikiLogo
+ /raw/WikiLogo
+
+Action eval
+===========
+
+Eval permet d'évaluer un WikittyPubText en fonction de son typemime,
+pour cela on utilise l'api javax.script. Plus il y a d'engine
+disponible plus il y aura de langage supporté. Par défaut seul le
+javascript (Rhino) est présent dans le JDK.
+
+Automatiquement on a accès dans les scripts aux variables:
+
+* ''WPContext'' qui est le context de publication
+* ''nextUrl'' est en fait la concatenation des arguments obligatoires
+ moins la page actuellement evaluée. ex:
+ /eval/Wiki/AutrePage/EtEncore => /AutrePage/EtEncore
+
+Action Login
+============
+
+Cette action si elle n'a pas d'argument affiche un formulaire pour
+demander un login et un password. Si l'action à les arguments login et
+password alors elle authentifie et crée le cookie nécessaire. En cas
+d'échec ou de succès si dans les arguments on retrouve les actions à
+faire on les faits sinon on affiche simplement le résultat.
+
+exemple d'url d'authentification::
+
+ /login?login=moi&password=xxxx&succes=/eval/Wiki/WikiHello&error=/eval/WikiBadLogin
+
+Si on a l'argument logout de présent dans les paramètres alors un
+logout est forcé. Par défaut si on demande un login et que
+l'utilisateur était déjà loggué alors un logout est aussi fait avant
+la nouvelle authentification.
+
+exemple d'url de logout forcé::
+
+ /login?logout&succes=/eval/Wiki/WikiHello
+
+Authentification
+================
+
+Une fois loggué le token est conservé dans un cookie pour permettre
+d'être authentifier pour plusieurs contexts (WikittyService) distinct
+en même temps.
+
+Développement d'application
+============================
+
+Le but est de pouvoir facilement développer des applications avec ces
+outils abituels (editor, svn, ...). Pour cela on utilise
+l'application d'extraction de WikittyPubText et WikittyPubData. Cette
+application permet de récupérer l'ensemble de ces types d'objet en
+fonction d'un Label qu'ils ont. Il faut donc que l'ensemble de ces
+objets pour une application donnée est un Label en commun.
+
+Si on a le WikittyPubText(''"Wiki", "<h1><%=...", "text/jsp"'') avec
+le Label ''org.chorem'' il deviendra sur le système de fichier
+/org/chorem/Wiki.jsp avec comme contenu le content du
+WikittyPubText. On procède de la même manière pour les
+WikittyPubData. L'application a un module de mapping entre le type
+mime et l'extension des fichiers.
+
+Les Labels recherchés sont récursif si besoin. Par exemple
+''org.chorem.bonzoms'' est un sous Label de ''org.chorem. ''Si l'on
+demande donc la récupération des WikittyPubText en récursif de
+''org.chorem ''on récupérera aussi les WikittyPubText qui ont le Label
+''org.chorem.bonzoms ''ou'' org.chorem.gepeto''.
+
+L'application de synchronisation est capable de récupérer (checkout)
+mais aussi de pousser (commit) les modifications.
+
+Lors du commit il est possible de pousser les modifications vers un
+autre context que le context initial. Par exemple si l'on récupère les
+fichiers depuis le context 'chorem' on peut repousser les fichiers
+dans le context 'chorem-test' et ainsi facilement faire des tests
+avant de pousser en production les changements.
+
+Il est ainsi possible de mettre les fichiers dans un svn classique si
+on le souhaite.
+
+commande de l'application de synchronisation:
+
+* ''checkout [--recursion (true|false)] [url du WikittyService] [Label à extraire] [directory local d'accueil]''
+* ''update [--recursion (true|false)] [--ws (url du WikittyService)] [répertoire à mettre à jour]''
+* ''commit [--recursion (true|false)] [--ws (url du WikittyService)] [répertoire à pousser]''
+* ''delete [--ws (url du WikittyService)] [répertoire ou fichier à supprimer]''
+* ''relocate [nouvelle url du WikittyService par defaut] [directory a relocaliser]''
+
+Il n'y a pas de add, tous les fichiers sont automatiquement commités.
+L'action relocate recherche le fichier ''.wikitty-publication/source''
+pour le modifier
+
+Lors du checkout un fichier .wikitty-publication-sync/source est créé
+dans le répertoire root du chekout contenant l'url source des fichiers
+et le label extrait. Si lors d'un commit ou delete l'url n'est pas
+indiqué, alors cette url sera utilisée par défaut. Dans chaque
+répertoire de l'application lors du ''checkout/update/commit'' la
+wikitty version de chaque fichier présent est mis dans le fichier
+.wikitty-publication/versions. Ce fichier est sous la forme d'un
+fichier de propriété avec en cle le nom du fichier/wikitty et valeur
+la version. Cela permet de ne pas autoriser le commit si des
+modifications ont été faite sur le serveur. Il faudra alors récupérer
+la version du serveur et fusionner avec la version local.
+
+Déploiement d'application
+=========================
+
+Il est bien sur possible d'utiliser l'application avec tous les
+sources dans Wikitty. Mais il est aussi possible d'utiliser
+l'application en extrayant les sources dans des fichiers et les
+packagers dans un war. Dans ce cas l'application est vigée et n'est
+plus modifiable à l'exécution. Pour cela on utilise la servlet
+WikittyPublicationExternalize qui au lieu d'aller chercher les
+WikittyPubText et WikittyPubData dans le WikittyService va les
+chercher sur le système de fichiers.
+
+Dans le mode externalize les jsp et autres resources peuvent être
+précompilées.
+
+On peut donc avoir deux modes de mise en production suivant la taille
+du site ou le moment de mise en production. Par exemple pour les sites
+à fort volume la solution externalizée sera privilégiée ou pour les
+sites qui souhaites mettre à deux endroit différent l'application et
+les données pour des raisons de sécurites.
+
+Au contraire lors d'une phase de prototypage ou si l'on souhaite
+pouvoir modifier facilement l'application on utiilsera le déploiement
+avec l'application dans Wikitty.
+
+Statistique d'accès au pages
+============================
+
+Le ''WikittyServiceAccesStat'' permet de mettre en place les stats sur
+le nombre de fois qu'un wikitty a été restoré. Lors d'un restore un
+WikittyAccesStat(restoredWikittyId, userId, tokenId) est créé et
+enregistré. Le service ''WikittyServiceAccesStat ''permet par
+configuration de déterminer quel type de wikitty doit-être
+monitoré. Pour monitorer l'utilisation d'une application il faut
+configurer le service pour monitorer les WikittyPubText et
+WikittyPubData.
+
+Il est ensuite possible de sortir les stats:
+
+* nombre d'accès à une page
+* nombre d'accès à une page pour un utilisateur donné
+* nombre d'accès à une page pour un utilisateur dans une session donnée
+* nombre de pages accèdées par un utilisateur
+* nombre de pages accèdées durant une session par un utilisateur
+
+Il est ensuite possible de croiser ces stats avec les ids des pages
+d'une application pour connaitre le nombre de solicitation d'un user à
+une application.
+
+Plugin Maven
+============
+
+Il serait intéressant d'avoir les goals suivant pour maven:
+
+* ''wp-commit'' pour commiter les fichiers sur un WikittyService
+* ''wp-run'' lance un conteneur de servlet avec le war
+ wikitty-publication, pousse les fichiers dans ce service pour tester
+ en local
+* ''wp-verify ''essaie de compiler tout ce qui est compilable pour
+ ressortir les erreurs
+* ''wp-package'' qui package l'application en mode externalize, et
+ précompile les jsp et autres resources
+
+Application Wiki
+================
+
+Cette application commence par un WikittyPubText qui se nome Wiki. De
+type text/jsp. Cette page est en fait le template général de
+l'application (bandeau, menu, footer). Il contient des appels à
+l'évaluation d'autres pages avec des paramètres. Lors de l'appel de
+l'eval de cette page, il est possible d'indiquer aussi sur l'url une
+autre page à évaluer.
+
+contenu de la page::
+
+ <html>
+ ...
+ <div id="bandeau"><img src="<%=context.makeUrl("/raw/WikiLogo")%>"/></div>
+ <div id="menu"><%=eval.doAction(context, "/WikiMenu")%></div>
+ <div id="content"><%=eval.doAction(context, nextUrl!=null?nextUrl:"/WikiHello")%></div>
+ ...
+ </html>
+
+Ici on affiche un Logo avec l'action ''raw''. On évalue ''WikiMenu''
+pour afficher le menu. Et on évalue le reste de l'url qui sert de page
+principale. S'il n'y a pas de suite à l'url alors par défaut on évalue
+''WikiHello''.
+
+L'url d'appel pourrait-être par exemple::
+
+ /eval/Wiki/Bonzomes.list
+
+Dans ce cas le content prendra le résultat de l'évalution de
+''Bonzomes.list''.
+
+Authorisation d'accès aux pages d'une application
+=================================================
+
+Une application est en fait stocké dans des Wikitties, une page de
+l'application est un WikittyPubText, il suffit donc de mettre les bons
+droits sur le wikitty de cette page pour permettre ou non aux
+personnes d'y accéder. Les données ont déjà la possibillté d'avoir des
+droits et ne sont retournés à l'utilisateur que s'il en a le droit.
+
+[TODO] réflechir comment faire pour le mode externalize
1
0
r576 - trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication
by bpoussin@users.nuiton.org 08 Dec '10
by bpoussin@users.nuiton.org 08 Dec '10
08 Dec '10
Author: bpoussin
Date: 2010-12-08 05:22:46 +0100 (Wed, 08 Dec 2010)
New Revision: 576
Url: http://nuiton.org/repositories/revision/wikitty/576
Log:
simplify url for WikittyPub(Data|Text)
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java 2010-12-07 16:21:53 UTC (rev 575)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java 2010-12-08 04:22:46 UTC (rev 576)
@@ -6,6 +6,10 @@
import org.nuiton.wikitty.WikittyProxy;
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;
@@ -14,7 +18,7 @@
* Elle peut-etre utilisee pour retourner une image ou un document stocke dans
* un champs d'un wikitty
*
- * Cette action prend deux arguments obligatoires
+ * Cette action prend deux arguments obligatoires (si pas WikittyPub(Text|Data)
* <li> l'argument de recherche du wikitty
* <li> le champs qu'il faut retourner en raw
*
@@ -23,7 +27,10 @@
*
* exemple
* <pre>
+ * ram/WikittyPubData.name=MonImage.jpg
+ * ram/WikittyPubText.name=Tuto
* ram/WikittyPubData.name=MonImage.jpg/WikittyPubData.content?mimetype=WikittyPubData.mimetype
+ * ram/WikittyPubData.name=MonImage.jpg/WikittyPubData.mimetype?mimetype=text/plain
* ram/WikittyPubText.name=Tuto/WikittyPubText.content?mimetype=WikittyPubText.mimetype
* ram/WikittyUser.login=admin/WikittyUser.password?mimetype=text/plain
* </pre>
@@ -59,7 +66,9 @@
WikittyProxy proxy = context.getWikittyProxy();
Object result = "no query";
- if (context.getMandatoryArguments().size() < 2) {
+ if (context.getMandatoryArguments().size() < 1 ||
+ (context.getMandatoryArguments().size() < 2
+ && !context.getMandatoryArguments().get(ARG_QUERY).startsWith("WikittyPub")) ) {
context.setContentType("text/html");
result = String.format("<html><head></head><body>"
+ "<h1>bad query</h1>"
@@ -90,8 +99,19 @@
}
}
context.setContentType(mimetype);
+ } else if (w.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) {
+ mimetype = WikittyPubTextHelper.getMimeType(w);
+ } else if (w.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) {
+ mimetype = WikittyPubDataHelper.getMimeType(w);
}
- String contentField = context.getMandatoryArguments().get(ARG_CONTENT_FIELD);
+ String contentField = null;
+ if (context.getMandatoryArguments().size() >= 2) {
+ contentField = context.getMandatoryArguments().get(ARG_CONTENT_FIELD);
+ } else 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;
+ }
String extName = WikittyExtension.extractExtensionName(contentField);
String fieldName = WikittyExtension.extractFieldName(contentField);
1
0
Author: bpoussin
Date: 2010-12-07 17:21:53 +0100 (Tue, 07 Dec 2010)
New Revision: 575
Url: http://nuiton.org/repositories/revision/wikitty/575
Log:
create new module wikitty-publication (proof of concept currently)
Added:
trunk/wikitty-publication/
trunk/wikitty-publication/LICENSE.txt
trunk/wikitty-publication/README.txt
trunk/wikitty-publication/changelog.txt
trunk/wikitty-publication/pom.xml
trunk/wikitty-publication/src/
trunk/wikitty-publication/src/main/
trunk/wikitty-publication/src/main/java/
trunk/wikitty-publication/src/main/java/org/
trunk/wikitty-publication/src/main/java/org/nuiton/
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.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/ActionRaw.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
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationServlet.java
trunk/wikitty-publication/src/main/resources/
trunk/wikitty-publication/src/main/resources/wikitty-publication-ws-default.properties
trunk/wikitty-publication/src/main/resources/wikitty-publication.properties
trunk/wikitty-publication/src/main/webapp/
trunk/wikitty-publication/src/main/webapp/WEB-INF/
trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/
trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/edit.jsp
trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/footer.jsp
trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/header.jsp
trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/view.jsp
trunk/wikitty-publication/src/main/webapp/WEB-INF/web.xml
trunk/wikitty-publication/src/main/webapp/css/
trunk/wikitty-publication/src/main/webapp/css/wikitty-publication.css
trunk/wikitty-publication/src/main/xmi/
trunk/wikitty-publication/src/main/xmi/wikitty-publication.properties
trunk/wikitty-publication/src/main/xmi/wikitty-publication.zargo
trunk/wikitty-publication/src/test/
trunk/wikitty-publication/src/test/java/
trunk/wikitty-publication/src/test/java/org/
trunk/wikitty-publication/src/test/java/org/nuiton/
trunk/wikitty-publication/src/test/java/org/nuiton/wikitty/
trunk/wikitty-publication/src/test/java/org/nuiton/wikitty/publication/
Added: trunk/wikitty-publication/LICENSE.txt
===================================================================
--- trunk/wikitty-publication/LICENSE.txt (rev 0)
+++ trunk/wikitty-publication/LICENSE.txt 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/wikitty-publication/pom.xml
===================================================================
--- trunk/wikitty-publication/pom.xml (rev 0)
+++ trunk/wikitty-publication/pom.xml 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>wikitty</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-publication</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-jdbc-impl</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-solr-impl</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Wikitty :: publication</name>
+
+ <description>Web publication for Wikitty</description>
+ <inceptionYear>2010</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>${project.build.directory}/generated-sources/models</directory>
+ <includes>
+ <include>*.objectmodel</include>
+ <include>*.properties</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>api-generation</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <inputs>
+ <input>zargo</input>
+ </inputs>
+ <fullPackagePath>org.nuiton.wikitty.publication.entities</fullPackagePath>
+ <defaultPackage>org.nuiton.wikitty.publication.entities</defaultPackage>
+ <extractedPackages>org.nuiton.wikitty.publication.entities</extractedPackages>
+ <templates>org.nuiton.wikitty.generator.WikittyMetaGenerator</templates>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/AbstractAction.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,33 @@
+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;
+ }
+
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEdit.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,134 @@
+package org.nuiton.wikitty.publication;
+
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.entities.WikittyExtension;
+import org.nuiton.wikitty.entities.WikittyImpl;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+import org.nuiton.wikitty.search.operators.Element;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ActionEdit 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 ActionEdit(ApplicationConfig appConfig) {
+ this.appConfig = appConfig;
+ }
+
+ @Override
+ public Object doAction(WikittyPublicationContext context) {
+ WikittyProxy proxy = context.getWikittyProxy();
+
+ String result = "no query";
+ if (context.getMandatoryArguments().size() > 0) {
+ log.info("args " + context.getMandatoryArguments());
+ String [] arg = context.getMandatoryArguments().get(0).split("=");
+
+ Wikitty w;
+ switch (arg.length) {
+ case 0:
+ // new wikitty without extension and edit
+ w = new WikittyImpl();
+ break;
+ case 1:
+ // new wikitty with one extension and edit
+ w = new WikittyImpl();
+ WikittyExtension ext = proxy.restoreExtensionLastVersion(arg[0]);
+ if (ext != null) {
+ w.addExtension(ext);
+ }
+ break;
+ default:
+ // find and edit
+ Criteria criteria = Search.query().eq(arg[0], arg[1]).criteria();
+ w = proxy.findByCriteria(criteria);
+ }
+
+ 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) {
+ context.setContentType("text/plain");
+ result = String.format(
+ "no data found for %s with value %s", arg[0], arg[1]);
+ } else {
+ if (context.getArguments().containsKey("delete")) {
+ String id = context.getArguments().get("id");
+ context.getWikittyProxy().delete(id);
+ } else if (context.getArguments().containsKey("store")) {
+ // change and store wikitty
+
+ // ajout des extensions si necessaire
+ String [] extNames = context.getRequest().getParameterValues("extensions");
+ if (extNames != null) {
+ for (String extName : extNames) {
+ WikittyExtension ext = proxy.restoreExtensionLastVersion(extName);
+ if (ext != null) {
+ w.addExtension(ext);
+ }
+ }
+ }
+
+ // modifie tous les champs presents dans le formulaire
+ for (Map.Entry<String, String> field : context.getArguments().entrySet()) {
+ if (field.getKey().contains(".")) {
+ String extName = WikittyExtension.extractExtensionName(field.getKey());
+ String fieldName = WikittyExtension.extractFieldName(field.getKey());
+
+ if (w.hasField(extName, fieldName)) {
+ w.setField(extName, fieldName, field.getValue());
+ }
+ }
+ }
+
+ // sauve le wikitty modifie
+ context.getWikittyProxy().store(w);
+ }
+
+ // forward l'affichage de la page vers la jsp d'edition
+ context.setContentType("forward/jsp");
+ context.getRequest().setAttribute(
+ WikittyPublicationContext.CONTEXT_VAR, context);
+ context.getRequest().setAttribute("wikitty", 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 + "=" + w.getId();
+ url = context.makeUrl(url);
+ return url;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionError.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,61 @@
+package org.nuiton.wikitty.publication;
+
+
+import javax.servlet.http.HttpServletRequest;
+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>" + ExceptionUtil.stackTrace(error) + "</pre>"
+ + "</body></html>";
+ return result;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionEval.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,99 @@
+package org.nuiton.wikitty.publication;
+
+import java.util.List;
+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.wikitty.WikittyException;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.publication.entities.WikittyPubText;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * 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 AbstractAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ActionError.class);
+
+ protected ApplicationConfig appConfig;
+ protected ScriptEngineManager scriptEnginManager;
+
+ public ActionEval(ApplicationConfig appConfig) {
+ this.appConfig = appConfig;
+
+ scriptEnginManager = new ScriptEngineManager();
+ }
+
+ @Override
+ public Object doAction(WikittyPublicationContext context) {
+ WikittyProxy proxy = context.getWikittyProxy();
+
+ Object result = "no query";
+ if (context.getMandatoryArguments().size() > 0) {
+ log.info("args " + context.getMandatoryArguments());
+ String [] arg = context.getMandatoryArguments().get(0).split("=");
+
+ Criteria criteria = Search.query().eq(arg[0], arg[1]).criteria();
+ WikittyPubText w = proxy.findByCriteria(WikittyPubText.class, criteria);
+ if (w == null) {
+ result = String.format(
+ "no data found for %s with value %s", arg[0], arg[1]);
+ } else {
+ String mimetype = w.getMimeType();
+ ScriptEngine scriptEngin = scriptEnginManager.getEngineByMimeType(mimetype);
+ if (scriptEngin == null) {
+ List<ScriptEngineFactory> factories =
+ scriptEnginManager.getEngineFactories();
+ String msgFactories = "";
+ for (ScriptEngineFactory f : factories) {
+ msgFactories += String.format(
+ "\n%s extensions: %s mimetypes: %s",
+ f.getEngineName(), f.getExtensions(), f.getMimeTypes());
+ }
+ throw new WikittyException(String.format(
+ "Can't find engine for %s(%s). Available engines: %s",
+ w.getName(), w.getMimeType(), msgFactories));
+ } else {
+ Bindings bindings = scriptEngin.createBindings();
+ bindings.put(WikittyPublicationContext.CONTEXT_VAR, context);
+ String script = w.getContent();
+ try {
+ result = scriptEngin.eval(script, bindings);
+ } catch (ScriptException eee) {
+ throw new WikittyException(String.format(
+ "Can't evaluated script %s(%s=>%s) script was\n%s",
+ w.getName(), w.getMimeType(),
+ scriptEngin.getFactory().getEngineName(), script), eee);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionRaw.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,105 @@
+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.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.entities.WikittyExtension;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ * Action permettant de retourner la valeur d'un champs d'un object.
+ * Elle peut-etre utilisee pour retourner une image ou un document stocke dans
+ * un champs d'un wikitty
+ *
+ * Cette action prend deux arguments obligatoires
+ * <li> l'argument de recherche du wikitty
+ * <li> le champs qu'il faut retourner en raw
+ *
+ * et un argument optionnel
+ * <li> le type mime du contenu qui peut-etre un champs de l'objet
+ *
+ * exemple
+ * <pre>
+ * ram/WikittyPubData.name=MonImage.jpg/WikittyPubData.content?mimetype=WikittyPubData.mimetype
+ * ram/WikittyPubText.name=Tuto/WikittyPubText.content?mimetype=WikittyPubText.mimetype
+ * ram/WikittyUser.login=admin/WikittyUser.password?mimetype=text/plain
+ * </pre>
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ActionRaw extends AbstractAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ActionError.class);
+
+ static final public int ARG_QUERY = 0;
+ static final public int ARG_CONTENT_FIELD = 1;
+ static final public String ARG_MIMETYPE = "mimetype";
+
+ static final protected String exampleUsage =
+ "ram/WikittyPubData.name=MonImage.jpg/WikittyPubData.content?mimetype=WikittyPubData.mimetype\n"
+ + "ram/WikittyPubText.name=Tuto/WikittyPubText.content?mimetype=WikittyPubText.mimetype\n"
+ + "ram/WikittyUser.login=admin/WikittyUser.password?mimetype=text/plain\n";
+
+ protected ApplicationConfig appConfig;
+
+ public ActionRaw(ApplicationConfig appConfig) {
+ this.appConfig = appConfig;
+ }
+
+ @Override
+ public Object doAction(WikittyPublicationContext context) {
+ WikittyProxy proxy = context.getWikittyProxy();
+
+ Object result = "no query";
+ if (context.getMandatoryArguments().size() < 2) {
+ context.setContentType("text/html");
+ result = String.format("<html><head></head><body>"
+ + "<h1>bad query</h1>"
+ + "Usage example"
+ + "<pre>%s</pre>"
+ + "</body></html>\n", exampleUsage);
+ } else {
+ log.info("args " + context.getMandatoryArguments());
+ String [] arg = context.getMandatoryArguments().get(ARG_QUERY).split("=");
+
+ Criteria criteria = Search.query().eq(arg[0], arg[1]).criteria();
+ Wikitty w = proxy.findByCriteria(criteria);
+ if (w == null) {
+ result = String.format(
+ "no data found for %s with value %s", arg[0], arg[1]);
+ } else {
+ // looking for mimetype field
+ String mimetype = context.getArguments().get(ARG_MIMETYPE);
+ if (mimetype != null) {
+ int i = mimetype.indexOf('.');
+ 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);
+ }
+ }
+ context.setContentType(mimetype);
+ }
+ String contentField = context.getMandatoryArguments().get(ARG_CONTENT_FIELD);
+ String extName = WikittyExtension.extractExtensionName(contentField);
+ String fieldName = WikittyExtension.extractFieldName(contentField);
+
+ result = w.getFieldAsObject(extName, fieldName);
+ }
+ }
+
+ return result;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/ActionView.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,87 @@
+package org.nuiton.wikitty.publication;
+
+import java.util.Map;
+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.entities.WikittyExtension;
+import org.nuiton.wikitty.entities.WikittyImpl;
+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(
+ WikittyPublicationContext.CONTEXT_VAR, context);
+ context.getRequest().setAttribute("r", r);
+ context.getRequest().setAttribute("first", first);
+ context.getRequest().setAttribute("end", end);
+ context.getRequest().setAttribute("wikitty", 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;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationAction.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,16 @@
+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);
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationContext.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,294 @@
+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.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.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;
+
+/**
+ *
+ * @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);
+
+ /** variable name use to put context in script and jsp */
+ static final public String CONTEXT_VAR = "WPContext";
+
+ /** 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 List<String> mandatoryArguments = new ArrayList<String>();
+ protected Map<String, String> arguments = new HashMap<String, String>();
+ 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]);
+ }
+ 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;
+ }
+
+ public String getActionName() {
+ return actionName;
+ }
+
+ 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");
+ ApplicationConfig wsConfigDefault;
+ try {
+ wsConfigDefault = new ApplicationConfig(filename);
+
+ // change juste data dir with context path
+ String dataDir = wsConfigDefault.getOption(
+ WikittyConfig.WikittyOption.WIKITTY_DATA_DIR.getKey());
+ wsConfigDefault.setOption(
+ WikittyConfig.WikittyOption.WIKITTY_DATA_DIR.getKey(),
+ dataDir + File.separator + wsContext);
+ } catch (ArgumentsParserException eee) {
+ throw new WikittyException(String.format(
+ "Can't parse configuration %s", filename), eee);
+ }
+
+ // read specifique configuration with default config as default properties
+ filename = String.format(patternConfigFilename, wsContext);
+ ApplicationConfig wsConfig;
+ try {
+ wsConfig = new ApplicationConfig(wsConfigDefault.getFlatOptions());
+ 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 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;
+ }
+
+}
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationServlet.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationServlet.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/WikittyPublicationServlet.java 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,107 @@
+package org.nuiton.wikitty.publication;
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+
+/**
+ * url:
+ * <pre>
+ * /[context]/[action]/[action argument]?[action argument]#[fragment]
+ * </pre>
+ *
+ * example:
+ * <pre>
+ * /codelutin/raw/WikittyPubData.name=lutin.jpg/WikittyPubData.content?mimetype=WikittyPubData.mimetype
+ * </pre>
+ *
+ * <li>la config du WikittyService sera lu dans la config
+ * wikitty.publication.config.pattern en remplacant %s par 'default'
+ * la valeur de 'wikitty.data.directory' est modifier pour lui ajouter le
+ * context par defaut en plus, puis le fichier de config specifique au context est lu
+ * qui peut alors ecraser 'wikitty.data.directory' et toutes les autres valeurs
+ * par defaut
+ * <li>l'action executee sera 'raw' la classe associee sera trouve dans le fichier
+ * de config WikittyPublication.
+ * <li> le reste sont des arguments specifique a l'action que l'action pourra
+ * trouver dans: {@link WikittyPublicationContext#getMandatoryArguments()} et
+ * {@link WikittyPublicationContext#getArguments()}.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class WikittyPublicationServlet extends HttpServlet {
+
+ static public ApplicationConfig appConfig;
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(WikittyPublicationServlet.class);
+
+ public void init() throws ServletException {
+ try {
+ appConfig = new ApplicationConfig();
+ appConfig.setConfigFileName("wikitty-publication.properties");
+ appConfig.parse(null);
+ } catch(ArgumentsParserException eee) {
+ throw new ServletException("Can't get filename config prefix", eee);
+ }
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ Object result;
+ WikittyPublicationContext context = new WikittyPublicationContext(appConfig);
+ try {
+ context.parse(req, resp);
+
+ if ("true".equals(context.getArguments().get("debug"))) {
+ // debug asked, not do action, but show context
+ result = context.toString();
+ context.setContentType("text/plain");
+ } else {
+ WikittyPublicationAction action = context.getAction();
+ result = action.doAction(context);
+ }
+ } catch (Throwable eee) {
+ WikittyPublicationAction action = new ActionError(eee);
+ result = action.doAction(context);
+ }
+
+ String contentType = context.getContentType();
+ if (contentType != null && contentType.startsWith("forward")) {
+ req.getRequestDispatcher(String.valueOf(result)).forward(req, resp);
+ } else {
+ if (contentType != null) {
+ resp.setContentType(contentType);
+ }
+ if (result instanceof byte[]) {
+ ServletOutputStream out = resp.getOutputStream();
+ out.write((byte[]) result);
+ out.flush();
+ } else {
+ PrintWriter out = resp.getWriter();
+ out.write(String.valueOf(result));
+ out.flush();
+ }
+ }
+ }
+
+}
Added: trunk/wikitty-publication/src/main/resources/wikitty-publication-ws-default.properties
===================================================================
--- trunk/wikitty-publication/src/main/resources/wikitty-publication-ws-default.properties (rev 0)
+++ trunk/wikitty-publication/src/main/resources/wikitty-publication-ws-default.properties 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,50 @@
+###
+# #%L
+# Wikitty :: publication
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2010 CodeLutin, 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%
+###
+wikitty.data.directory=./target/data
+wikitty.storage.jdbc.queryfile=wikitty-jdbc-query.properties
+wikitty.storage.jdbc.driver=org.h2.Driver
+wikitty.storage.jdbc.host=jdbc:h2:file:${wikitty.data.directory}/data/db
+wikitty.storage.jdbc.login=sa
+wikitty.storage.jdbc.password=
+wikitty.storage.jdbc.xadatasource=org.h2.jdbcx.JdbcDataSource
+wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.URL=${wikitty.storage.jdbc.host}
+wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.user=${wikitty.storage.jdbc.login}
+wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.password=${wikitty.storage.jdbc.password}
+wikitty.searchengine.solr.directory.data=${wikitty.data.directory}/data/solr
+wikitty.searchengine.solr.directory.factory=solr.StandardDirectoryFactory
+wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceStorage,\
+org.nuiton.wikitty.services.WikittyServiceNotifier,\
+org.nuiton.wikitty.services.WikittyServiceCached,\
+org.nuiton.wikitty.services.WikittyServiceSecurity
+wikitty.WikittyServiceStorage.components=org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC,\
+org.nuiton.wikitty.jdbc.WikittyStorageJDBC,\
+org.nuiton.wikitty.solr.WikittySearchEngineSolr
+wikitty.service.cache.listenevents=false
+wikitty.service.cache.allwaysRestoreCopies=false
+wikitty.service.event.propagate=false
+wikitty.service.event.listen=false
+wikitty.addon.export.threadnumber=1
+wikitty.addon.export.directory=${wikitty.data.directory}/export
+wikitty.addon.export.publicurl=file://${wikitty.data.directory}/export/
Added: trunk/wikitty-publication/src/main/resources/wikitty-publication.properties
===================================================================
--- trunk/wikitty-publication/src/main/resources/wikitty-publication.properties (rev 0)
+++ trunk/wikitty-publication/src/main/resources/wikitty-publication.properties 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,29 @@
+###
+# #%L
+# Wikitty :: publication
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2010 CodeLutin, 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%
+###
+wikitty.publication.config.pattern=wikitty-publication-ws-%s.properties
+wikitty.publication.action.edit=org.nuiton.wikitty.publication.ActionEdit
+wikitty.publication.action.eval=org.nuiton.wikitty.publication.ActionEval
+wikitty.publication.action.raw=org.nuiton.wikitty.publication.ActionRaw
+wikitty.publication.action.view=org.nuiton.wikitty.publication.ActionView
Added: trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/edit.jsp
===================================================================
--- trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/edit.jsp (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/edit.jsp 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,107 @@
+<%--
+ Document : edit
+ Created on : 6 d�c. 2010, 18:32:18
+ Author : poussin
+--%>
+
+<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
+<%@page import="org.nuiton.wikitty.entities.FieldType"%>
+<%@page import="java.util.Collection"%>
+<%@page import="org.nuiton.wikitty.WikittyProxy"%>
+<%@page import="org.nuiton.wikitty.WikittyService"%>
+<%@page import="org.nuiton.wikitty.entities.WikittyExtension"%>
+<%@page import="org.nuiton.wikitty.publication.ActionEdit"%>
+<%@page import="org.nuiton.wikitty.entities.Wikitty"%>
+<%@page import="org.nuiton.wikitty.publication.WikittyPublicationContext"%>
+
+<h1>Edit ${wikitty.id}</h1>
+
+<pre>${wikitty}</pre>
+
+<%
+WikittyPublicationContext context = (WikittyPublicationContext)
+ request.getAttribute(WikittyPublicationContext.CONTEXT_VAR);
+Wikitty wikitty = (Wikitty)request.getAttribute("wikitty");
+ActionEdit action = context.getAction(ActionEdit.class);
+String url = action.makeUrl(context, wikitty);
+%>
+
+<form action='<%=url%>' method="post">
+ <input type="hidden" name="id" value="${wikitty.id}" />
+ <input type="hidden" name="version" value="${wikitty.version}" />
+ <fieldset>
+ <legend><span class="legend">Extensions</span></legend>
+ <%
+ WikittyProxy proxy = context.getWikittyProxy();
+ Collection<String> allExt = proxy.getAllExtensionIds();
+ if (allExt != null && allExt.size() > 0) {
+ %>
+ <select name="extensions" size="10" multiple="multiple">
+ <%
+ for (String extId : allExt) {
+ String extName = WikittyExtension.computeName(extId);
+ String selected = wikitty.hasExtension(extName)?"selected":"";
+ %>
+ <option value="<%=extName%>" <%=selected%>><%=extName%></option>
+ <%
+ }
+ %>
+ </select>
+ <%
+ }
+ %>
+ </fieldset>
+
+ <%
+ int index = 0;
+ for (WikittyExtension ext : wikitty.getExtensions()) {
+ String extName = ext.getName();
+ %>
+ <fieldset>
+ <legend><span class="legend"><%=extName%></span></legend>
+ <%
+ for (String fieldName : ext.getFieldNames()) {
+ FieldType fieldType = wikitty.getExtension(extName).getFieldType(fieldName);
+ %>
+ <div>
+ <label for="<%=extName%>.<%=fieldName%>" tabindex="<%=++index%>"><span class="label"><%=fieldName%></span></label>
+ <%
+ switch(fieldType.getType()) {
+ case BOOLEAN:
+ boolean valueBool = wikitty.getFieldAsBoolean(ext.getName(), fieldName);
+ String checked = valueBool?"checked='true'":"";
+ %>
+ <input type="checkbox" name="<%=extName%>.<%=fieldName%>" value="true" <%=checked%>/>
+ <%
+ break;
+ default:
+ Object valueObject = wikitty.getFieldAsObject(ext.getName(), fieldName);
+ String valueString = "";
+ if (valueObject != null) {
+ valueString = String.valueOf(valueObject);
+ }
+
+ valueString = StringEscapeUtils.escapeHtml(valueString);
+ if (valueString.contains("\n") || "true".equals(fieldType.getTagValue("multiline"))) {
+ %>
+ <textarea cols="80" rows="20" name="<%=extName%>.<%=fieldName%>"><%=valueString%></textarea>
+ <%
+ } else {
+ %>
+ <input type="text" name="<%=extName%>.<%=fieldName%>" value="<%=valueString%>" />
+ <%
+ }
+ }
+ %>
+ <%=fieldType.toDefinition("")%>
+ </div>
+ <%
+ }
+ %>
+ </fieldset>
+ <%
+ }
+ %>
+ <input type="submit" name="store" value="Store" />
+ <input type="submit" name="delete" value="Delete" />
+</form>
Added: trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/footer.jsp
===================================================================
--- trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/footer.jsp (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/footer.jsp 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,9 @@
+<%--
+ Document : footer
+ Created on : 6 d�c. 2010, 19:21:22
+ Author : poussin
+--%>
+
+<div id="copyright"> Copyright Code Lutin 2010, AGPLv3 </div>
+ </body>
+</html>
Added: trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/header.jsp
===================================================================
--- trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/header.jsp (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/header.jsp 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,17 @@
+<%--
+ Document : header
+ Created on : 6 déc. 2010, 19:21:06
+ Author : poussin
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Wikitty</title>
+ <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/wikitty-publication.css">
+ </head>
+ <body>
Added: trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/view.jsp
===================================================================
--- trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/view.jsp (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/WEB-INF/jsp/view.jsp 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,51 @@
+<%--
+ Document : view
+ Created on : 7 d�c. 2010, 04:18:13
+ Author : poussin
+--%>
+
+<%@page import="org.nuiton.wikitty.publication.ActionEdit"%>
+<%@page import="org.nuiton.wikitty.publication.WikittyPublicationContext"%>
+<%@page import="org.nuiton.wikitty.search.PagedResult"%>
+<%@page import="org.nuiton.wikitty.entities.Wikitty"%>
+
+<h1>Wikitty View</h1>
+
+<%
+WikittyPublicationContext context = (WikittyPublicationContext)
+ request.getAttribute(WikittyPublicationContext.CONTEXT_VAR);
+PagedResult<Wikitty> pagedResult = (PagedResult<Wikitty>)request.getAttribute("pagedResult");
+Wikitty wikitty = (Wikitty)request.getAttribute("wikitty");
+
+ActionEdit actionEdit = context.getAction(ActionEdit.class);
+%>
+
+<form action="" method="post">
+ <div>
+ <textarea name="r" rows="4" cols="20"><%=request.getAttribute("r")%></textarea>
+ </div>
+ <label for="first">First</label> <input type="text" name="first" value="<%=context.getArgument("first", "0")%>" />
+ <label for="first">First</label> <input type="text" name="end" value="<%=context.getArgument("end", "100")%>" />
+ <input type="submit" name="id" value="Search"/>
+
+<pre>
+${wikitty}
+</pre>
+
+ <%=pagedResult.getFirstIndice()%>-<%=pagedResult.getFirstIndice() + pagedResult.size()%>/${pagedResult.numFound}
+ <table>
+ <%
+
+ for (Wikitty w : pagedResult.getAll()) {
+ %>
+ <tr>
+ <td><a href="<%=actionEdit.makeUrl(context, w)%>">edit</a></td>
+ <td><input type="submit" name="id" value="<%=w.getId()%>"/></td>
+ <td><%=w.getExtensionNames()%></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+</form>
+
\ No newline at end of file
Added: trunk/wikitty-publication/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/wikitty-publication/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/WEB-INF/web.xml 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
+ <!-- SERVLET -->
+ <display-name>Wikitty Publication</display-name>
+ <servlet>
+ <servlet-class>org.nuiton.wikitty.publication.WikittyPublicationServlet</servlet-class>
+ <servlet-name>Controller</servlet-name>
+ </servlet>
+ <welcome-file-list>
+ <welcome-file>/</welcome-file>
+ </welcome-file-list>
+ <!-- SERVLET MAPPING -->
+ <servlet-mapping>
+ <servlet-name>Controller</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/css/*</url-pattern>
+ </servlet-mapping>
+ <jsp-config>
+ <jsp-property-group>
+ <description>JSP page location</description>
+ <display-name>jsp</display-name>
+ <url-pattern>/WEB-INF/jsp/*</url-pattern>
+ <include-prelude>/WEB-INF/jsp/header.jsp</include-prelude>
+ <include-coda>/WEB-INF/jsp/footer.jsp</include-coda>
+ </jsp-property-group>
+ </jsp-config>
+</web-app>
Added: trunk/wikitty-publication/src/main/webapp/css/wikitty-publication.css
===================================================================
--- trunk/wikitty-publication/src/main/webapp/css/wikitty-publication.css (rev 0)
+++ trunk/wikitty-publication/src/main/webapp/css/wikitty-publication.css 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,6 @@
+label {
+ float : left;
+ width : 200px;
+ text-align: right;
+ padding: 0px 5px 0 0;
+}
Added: trunk/wikitty-publication/src/main/xmi/wikitty-publication.properties
===================================================================
--- trunk/wikitty-publication/src/main/xmi/wikitty-publication.properties (rev 0)
+++ trunk/wikitty-publication/src/main/xmi/wikitty-publication.properties 2010-12-07 16:21:53 UTC (rev 575)
@@ -0,0 +1,31 @@
+###
+# #%L
+# Wikitty :: api
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2010 CodeLutin, 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%
+###
+org.nuiton.wikitty.publication.entities.WikittyPubText.class.tagvalue.version=1.0
+org.nuiton.wikitty.publication.entities.WikittyPubText.attribute.name.tagvalue.unique=true
+org.nuiton.wikitty.publication.entities.WikittyPubText.attribute.name.tagvalue.notNull=true
+org.nuiton.wikitty.publication.entities.WikittyPubText.attribute.content.tagvalue.multiline=true
+org.nuiton.wikitty.publication.entities.WikittyPubData.class.tagvalue.version=1.0
+org.nuiton.wikitty.publication.entities.WikittyPubData.attribute.name.tagvalue.unique=true
+org.nuiton.wikitty.publication.entities.WikittyPubData.attribute.name.tagvalue.notNull=true
Added: trunk/wikitty-publication/src/main/xmi/wikitty-publication.zargo
===================================================================
(Binary files differ)
Property changes on: trunk/wikitty-publication/src/main/xmi/wikitty-publication.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0