r1281 - in xwiki/trunk/src/main: java/com/xpn/xwiki java/com/xpn/xwiki/api java/com/xpn/xwiki/doc java/com/xpn/xwiki/objects/classes java/com/xpn/xwiki/objects/meta resources
Jeremi Joslin
jeremi at users.forge.objectweb.org
Tue Sep 5 13:22:53 CEST 2006
Author: jeremi
Date: 2006-09-05 13:22:51 +0200 (Tue, 05 Sep 2006)
New Revision: 1281
Modified:
xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java
xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java
xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java
xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java
xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/PropertyMetaClass.java
xwiki/trunk/src/main/resources/xwiki.hbm.xml
Log:
* Add a getValue function to be able to get the value stored in db without beeing modified by the custom display or yes/No special display.
* Add custom display for a class property
* add a function to remove all the objects from a document specified by a class name
* Deprecate some function with bad signature In XWiki.java
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006, XpertNet SARL, and individual contributors as indicated
* by the contributors.txt.
@@ -2330,7 +2329,8 @@
}
}
- public void SetUserDefaultGroup(XWikiContext context, String fullwikiname) throws XWikiException {
+
+ public void setUserDefaultGroup(String fullwikiname, XWikiContext context) throws XWikiException {
BaseClass gclass = getGroupClass(context);
XWikiDocument allgroupdoc = getDocument("XWiki.XWikiAllGroup", context);
@@ -2354,7 +2354,18 @@
}
}
- public void ProtectUserPage(XWikiContext context, String fullwikiname, String userRights, XWikiDocument doc) throws XWikiException {
+ /**
+ * @deprecated replaced by {@link #setUserDefaultGroup(String fullwikiname, XWikiContext context)}
+ * @param context
+ * @param fullwikiname
+ * @throws XWikiException
+ */
+ public void SetUserDefaultGroup(XWikiContext context, String fullwikiname) throws XWikiException {
+ setUserDefaultGroup(fullwikiname, context);
+ }
+
+
+ public void protectUserPage(String fullwikiname, String userRights, XWikiDocument doc, XWikiContext context) throws XWikiException {
BaseClass rclass = getRightsClass(context);
// Add protection to the page
BaseObject newrightsobject = (BaseObject) rclass.newObject(context);
@@ -2374,6 +2385,18 @@
doc.addObject(rclass.getName(), newuserrightsobject);
}
+ /**
+ * @deprecated replaced by {@link #protectUserPage(String,String,XWikiDocument,XWikiContext)}
+ * @param context
+ * @param fullwikiname
+ * @param userRights
+ * @param doc
+ * @throws XWikiException
+ */
+ public void ProtectUserPage(XWikiContext context, String fullwikiname, String userRights, XWikiDocument doc) throws XWikiException {
+ protectUserPage(fullwikiname, userRights, doc, context);
+ }
+
public User getUser(XWikiContext context) {
XWikiUser xwikiUser = context.getXWikiUser();
User user = new User(xwikiUser, context);
@@ -2409,7 +2432,21 @@
return getRightService().checkAccess(action, doc, context);
}
+
+ /**
+ * @deprecated replaced by {@link #include(String topic, boolean isForm, XWikiContext context)}
+ * @param topic
+ * @param context
+ * @param isForm
+ * @return
+ * @throws XWikiException
+ */
public String include(String topic, XWikiContext context, boolean isForm) throws XWikiException {
+ return include(topic, isForm, context);
+ }
+
+
+ public String include(String topic, boolean isForm, XWikiContext context) throws XWikiException {
String database = null, incdatabase = null;
Document currentdoc = null, currentcdoc = null, currenttdoc = null;
Document gcurrentdoc = null, gcurrentcdoc = null, gcurrenttdoc = null;
@@ -2851,7 +2888,7 @@
if (serverdoc.isNew()) {
// clear entry in virtual wiki cache
virtualWikiMap.flushEntry(wikiUrl);
-
+
// Create Wiki Server page
serverdoc.setStringValue("XWiki.XWikiServerClass", "server", wikiUrl);
serverdoc.setStringValue("XWiki.XWikiServerClass", "owner", wikiAdmin);
@@ -3878,7 +3915,7 @@
return dweb;
}
- public XWikiDocument renamePage(XWikiDocument doc, XWikiContext context, String newFullName) throws XWikiException {
+ public XWikiDocument renamePage(XWikiDocument doc, String newFullName, XWikiContext context) throws XWikiException {
XWikiDocument renamedDoc = doc.renameDocument(newFullName, context);
saveDocument(renamedDoc, context);
deleteDocument(doc, context);
@@ -3886,6 +3923,18 @@
return renamedDoc;
}
+ /**
+ * @deprecated replaced by {@link #renamePage(XWikiDocument doc, String newFullName, XWikiContext context)}
+ * @param doc
+ * @param context
+ * @param newFullName
+ * @return
+ * @throws XWikiException
+ */
+ public XWikiDocument renamePage(XWikiDocument doc, XWikiContext context, String newFullName) throws XWikiException {
+ return renamePage(doc, newFullName, context);
+ }
+
public BaseClass getClass(String fullName, XWikiContext context) throws XWikiException {
// Used to avoid recursive loading of documents if there are recursives usage of classes
BaseClass bclass = context.getBaseClass(fullName);
@@ -3957,4 +4006,17 @@
else
return false;
}
+
+ public String clearName(String name, XWikiContext context) {
+ name = name.replaceAll("[àâä]","a");
+ name = name.replaceAll("[éèêë]","e");
+ name = name.replaceAll("[îï]","i");
+ name = name.replaceAll("[ôö]","o");
+ name = name.replaceAll("[ùûü]","u");
+ name = name.replaceAll("[\"!?]","");
+ name = name.replaceAll("[_':,;]"," ");
+ name = name.replaceAll("\\s+","");
+ return name;
+
+ }
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -1,404 +1,405 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This 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 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author namphunghai
- * @author sdumitriu
- * @author thomas
- */
-
-package com.xpn.xwiki;
-
-
-// import com.xpn.xwiki.store.XWikiBatcher;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-
-import javax.servlet.ServletException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.hibernate.JDBCException;
-
-public class XWikiException extends Exception {
-
- private static final Log log = LogFactory.getLog(XWikiException.class);
-
- private int module;
- private int code;
- private Throwable exception;
- private Object[] args;
- private String message;
-
- // Module list
- public static final int MODULE_XWIKI = 0;
- public static final int MODULE_XWIKI_CONFIG = 1;
- public static final int MODULE_XWIKI_DOC = 2;
- public static final int MODULE_XWIKI_STORE = 3;
- public static final int MODULE_XWIKI_RENDERING = 4;
- public static final int MODULE_XWIKI_PLUGINS = 5;
- public static final int MODULE_XWIKI_PERLPLUGINS = 6;
- public static final int MODULE_XWIKI_CLASSES = 7;
- public static final int MODULE_XWIKI_USER = 8;
- public static final int MODULE_XWIKI_ACCESS = 9;
- public static final int MODULE_XWIKI_EMAIL = 10;
- public static final int MODULE_XWIKI_APP = 11;
- public static final int MODULE_XWIKI_EXPORT = 12;
- public static final int MODULE_XWIKI_DIFF = 13;
- public static final int MODULE_XWIKI_GROOVY = 14;
- public static final int MODULE_XWIKI_NOTIFICATION = 15;
- public static final int MODULE_XWIKI_CACHE = 16;
-
- public static final int MODULE_PLUGIN_LASZLO = 21;
-
- // Error list
- public static final int ERROR_XWIKI_UNKNOWN = 0;
- public static final int ERROR_XWIKI_NOT_IMPLEMENTED = 1;
- public static final int ERROR_XWIKI_DOES_NOT_EXIST = 2;
- public static final int ERROR_XWIKI_INIT_FAILED = 3;
- public static final int ERROR_XWIKI_MKDIR = 4;
-
- // Config
- public static final int ERROR_XWIKI_CONFIG_FILENOTFOUND = 1001;
- public static final int ERROR_XWIKI_CONFIG_FORMATERROR = 1002;
-
- // Doc
- public static final int ERROR_XWIKI_DOC_EXPORT = 2001;
- public static final int ERROR_DOC_XML_PARSING = 2002;
- public static final int ERROR_DOC_RCS_PARSING = 2003;
-
- // Store
- public static final int ERROR_XWIKI_STORE_CLASSINVOCATIONERROR = 3001;
- public static final int ERROR_XWIKI_STORE_FILENOTFOUND = 3002;
- public static final int ERROR_XWIKI_STORE_ARCHIVEFORMAT = 3003;
- public static final int ERROR_XWIKI_STORE_ATTACHMENT_ARCHIVEFORMAT = 3004;
-
- public static final int ERROR_XWIKI_STORE_RCS_SAVING_FILE = 3101;
- public static final int ERROR_XWIKI_STORE_RCS_READING_FILE = 3102;
- public static final int ERROR_XWIKI_STORE_RCS_DELETING_FILE = 3103;
- public static final int ERROR_XWIKI_STORE_RCS_READING_REVISIONS = 3103;
- public static final int ERROR_XWIKI_STORE_RCS_READING_VERSION = 3104;
- public static final int ERROR_XWIKI_STORE_RCS_SEARCH = 3111;
- public static final int ERROR_XWIKI_STORE_RCS_LOADING_ATTACHMENT = 3221;
- public static final int ERROR_XWIKI_STORE_RCS_SAVING_ATTACHMENT = 3222;
- public static final int ERROR_XWIKI_STORE_RCS_SEARCHING_ATTACHMENT = 3223;
- public static final int ERROR_XWIKI_STORE_RCS_DELETING_ATTACHMENT = 3224;
-
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_DOC = 3201;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_DOC = 3202;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_DOC = 3203;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_CANNOT_DELETE_UNLOADED_DOC = 3204;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_REVISIONS = 3203;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_VERSION = 3204;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_UNEXISTANT_VERSION = 3205;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_OBJECT = 3211;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_OBJECT = 3212;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_OBJECT = 3213;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_CLASS = 3221;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_CLASS = 3222;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SEARCH = 3223;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_ATTACHMENT = 3231;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT = 3232;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_ATTACHMENT = 3233;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT_LIST = 3234;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SEARCHING_ATTACHMENT = 3235;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_CHECK_EXISTS_DOC = 3236;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SWITCH_DATABASE = 3301;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_CREATE_DATABASE = 3401;
-
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_DOC = 3501;
- public static final int ERROR_XWIKI_STORE_JCR_READING_DOC = 3502;
- public static final int ERROR_XWIKI_STORE_JCR_DELETING_DOC = 3503;
- public static final int ERROR_XWIKI_STORE_JCR_CANNOT_DELETE_UNLOADED_DOC = 3504;
- public static final int ERROR_XWIKI_STORE_JCR_READING_REVISIONS = 3503;
- public static final int ERROR_XWIKI_STORE_JCR_READING_VERSION = 3504;
- public static final int ERROR_XWIKI_STORE_JCR_UNEXISTANT_VERSION = 3505;
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_OBJECT = 3511;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_OBJECT = 3512;
- public static final int ERROR_XWIKI_STORE_JCR_DELETING_OBJECT = 3513;
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_CLASS = 3521;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_CLASS = 3522;
- public static final int ERROR_XWIKI_STORE_JCR_SEARCH = 3523;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_ATTACHMENT = 3531;
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_ATTACHMENT = 3532;
- public static final int ERROR_XWIKI_STORE_JCR_DELETING_ATTACHMENT = 3533;
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_ATTACHMENT_LIST = 3534;
- public static final int ERROR_XWIKI_STORE_JCR_SEARCHING_ATTACHMENT = 3535;
- public static final int ERROR_XWIKI_STORE_JCR_CHECK_EXISTS_DOC = 3536;
- public static final int ERROR_XWIKI_STORE_JCR_SWITCH_DATABASE = 3601;
- public static final int ERROR_XWIKI_STORE_JCR_CREATE_DATABASE = 3701;
-
- public static final int ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION = 4001;
- public static final int ERROR_XWIKI_RENDERING_GROOVY_EXCEPTION = 4002;
-
- public static final int ERROR_XWIKI_PERLPLUGIN_START_EXCEPTION = 6001;
- public static final int ERROR_XWIKI_PERLPLUGIN_START = 6002;
- public static final int ERROR_XWIKI_PERLPLUGIN_PERLSERVER_EXCEPTION = 6003;
-
- public static final int ERROR_XWIKI_CLASSES_FIELD_DOES_NOT_EXIST = 7001;
- public static final int ERROR_XWIKI_CLASSES_FIELD_INVALID = 7002;
- public static final int ERROR_XWIKI_CLASSES_DIFF = 7003;
- public static final int ERROR_XWIKI_CLASSES_CUSTOMCLASSINVOCATIONERROR = 7004;
- public static final int ERROR_XWIKI_CLASSES_PROPERTY_CLASS_INSTANCIATION = 7005;
- public static final int ERROR_XWIKI_CLASSES_PROPERTY_CLASS_IN_METACLASS = 7006;
-
-
- public static final int ERROR_XWIKI_USER_INIT = 8001;
- public static final int ERROR_XWIKI_USER_CREATE = 8002;
- public static final int ERROR_XWIKI_USER_INACTIVE = 8003;
-
- public static final int ERROR_XWIKI_ACCESS_DENIED = 9001;
- public static final int ERROR_XWIKI_ACCESS_TOKEN_INVALID = 9002;
- public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_USERS = 9003;
- public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_GROUPS = 9004;
- public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_ADDING_USERS = 9005;
- public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_LISTING_USERS = 9006;
-
- public static final int ERROR_XWIKI_EMAIL_CANNOT_GET_VALIDATION_CONFIG = 10001;
- public static final int ERROR_XWIKI_EMAIL_CANNOT_PREPARE_VALIDATION_EMAIL = 10002;
- public static final int ERROR_XWIKI_EMAIL_ERROR_SENDING_EMAIL = 10003;
- public static final int ERROR_XWIKI_EMAIL_CONNECT_FAILED = 10004;
- public static final int ERROR_XWIKI_EMAIL_LOGIN_FAILED = 10005;
- public static final int ERROR_XWIKI_EMAIL_SEND_FAILED = 10006;
-
- public static final int ERROR_XWIKI_APP_TEMPLATE_DOES_NOT_EXIST = 11001;
- public static final int ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY = 11002;
- public static final int ERROR_XWIKI_APP_ATTACHMENT_NOT_FOUND = 11003;
- public static final int ERROR_XWIKI_APP_CREATE_USER = 11004;
- public static final int ERROR_XWIKI_APP_VALIDATE_USER = 11005;
- public static final int ERROR_XWIKI_APP_INVALID_CHARS = 11006;
- public static final int ERROR_XWIKI_APP_URL_EXCEPTION = 11007;
- public static final int ERROR_XWIKI_APP_UPLOAD_PARSE_EXCEPTION = 11008;
- public static final int ERROR_XWIKI_APP_UPLOAD_FILE_EXCEPTION = 11009;
- public static final int ERROR_XWIKI_APP_REDIRECT_EXCEPTION = 11010;
- public static final int ERROR_XWIKI_APP_SEND_RESPONSE_EXCEPTION = 11011;
- public static final int ERROR_XWIKI_APP_SERVICE_NOT_FOUND = 11012;
- public static final int ERROR_XWIKI_APP_FILE_EXCEPTION_MAXSIZE = 11013;
- public static final int ERROR_XWIKI_APP_JAVA_HEAP_SPACE = 11014;
-
- public static final int ERROR_XWIKI_EXPORT_XSL_FILE_NOT_FOUND = 12001;
- public static final int ERROR_XWIKI_EXPORT_PDF_FOP_FAILED = 12002;
- public static final int ERROR_XWIKI_EXPORT_XSL_FAILED = 12003;
- public static final int ERROR_XWIKI_DIFF_CONTENT_ERROR = 13001;
- public static final int ERROR_XWIKI_DIFF_RENDERED_ERROR = 13002;
- public static final int ERROR_XWIKI_DIFF_METADATA_ERROR = 13003;
- public static final int ERROR_XWIKI_DIFF_CLASS_ERROR = 13004;
- public static final int ERROR_XWIKI_DIFF_OBJECT_ERROR = 13005;
- public static final int ERROR_XWIKI_DIFF_XML_ERROR = 13005;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_LOCK = 13006;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_LOCK = 13007;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_LOCK = 13008;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_INVALID_MAPPING = 13009;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_MAPPING_INJECTION_FAILED = 13010;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_LINKS = 13011;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_LINKS = 13012;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_LINKS = 13013;
- public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_BACKLINKS = 13014;
-
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_LOCK = 13106;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_LOCK = 13107;
- public static final int ERROR_XWIKI_STORE_JCR_DELETING_LOCK = 13108;
- public static final int ERROR_XWIKI_STORE_JCR_INVALID_MAPPING = 13109;
- public static final int ERROR_XWIKI_STORE_JCR_MAPPING_INJECTION_FAILED = 13110;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_LINKS = 13111;
- public static final int ERROR_XWIKI_STORE_JCR_SAVING_LINKS = 13112;
- public static final int ERROR_XWIKI_STORE_JCR_DELETING_LINKS = 13113;
- public static final int ERROR_XWIKI_STORE_JCR_LOADING_BACKLINKS = 13114;
- public static final int ERROR_XWIKI_STORE_JCR_OTHER = 13130; // temporary
-
- public static final int ERROR_XWIKI_GROOVY_COMPILE_FAILED = 14001;
- public static final int ERROR_XWIKI_GROOVY_EXECUTION_FAILED = 14002;
-
- public static final int ERROR_XWIKI_NOTIFICATION = 15001;
-
- public static final int ERROR_CACHE_INITIALIZING = 16001;
-
- public static final int ERROR_LASZLO_INVALID_XML = 21001;
- public static final int ERROR_LASZLO_INVALID_DOTDOT = 21002;
-
-
- public XWikiException(int module, int code, String message, Throwable e, Object[] args) {
- setModule(module);
- setCode(code);
- setException(e);
- setArgs(args);
- setMessage(message);
- if (log.isTraceEnabled())
- log.trace(getMessage(), e);
- }
-
- public XWikiException(int module, int code, String message, Throwable e) {
- this(module, code, message, e, null);
- }
-
- public XWikiException(int module, int code, String message) {
- this(module, code, message, null, null);
- }
-
- public XWikiException() {
- }
-
- public int getModule() {
- return module;
- }
-
- public String getModuleName() {
- return "" + module;
- }
-
- public void setModule(int module) {
- this.module = module;
- }
-
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
- this.code = code;
- }
-
- public Throwable getException() {
- return exception;
- }
-
- public void setException(Throwable exception) {
- this.exception = exception;
- }
-
- public Object[] getArgs() {
- return args;
- }
-
- public void setArgs(Object[] args) {
- this.args = args;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public String getMessage() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Error number ");
- buffer.append(getCode());
- buffer.append(" in ");
- buffer.append(getModuleName());
- buffer.append(": ");
-
- if (message != null) {
- if (args == null)
- buffer.append(message);
- else {
- MessageFormat msgFormat = new MessageFormat(message);
- try {
- buffer.append(msgFormat.format(args));
- }
- catch (Exception e) {
- buffer.append("Cannot format message " + message + " with args ");
- for (int i = 0; i < args.length; i++) {
- if (i != 0)
- buffer.append(",");
- buffer.append(args[i]);
- }
- }
- }
- }
-
- if (exception != null) {
- buffer.append("\nWrapped Exception: ");
- buffer.append(exception.getMessage());
- }
- return buffer.toString();
- }
-
- public String getFullMessage() {
- StringBuffer buffer = new StringBuffer(getMessage());
- buffer.append("\n");
- buffer.append(getStackTraceAsString());
- buffer.append("\n");
- /*
- List list = XWikiBatcher.getSQLStats().getRecentSqlList();
- if (list.size() > 0) {
- buffer.append("Recent SQL:\n");
- for (int i = 0; i < list.size(); i++) {
- buffer.append(list.get(i));
- buffer.append("\n");
- }
- }
- */
- return buffer.toString();
- }
-
- public void printStackTrace(PrintWriter s) {
- super.printStackTrace(s);
- if (exception != null) {
- s.write("\n\nWrapped Exception:\n\n");
- if (exception.getCause()!=null)
- exception.getCause().printStackTrace(s);
- else if (exception instanceof org.hibernate.JDBCException) {
- (((JDBCException) exception).getSQLException()).printStackTrace(s);
- } else if (exception instanceof MethodInvocationException) {
- (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s);
- } else if (exception instanceof ServletException) {
- (((ServletException) exception).getRootCause()).printStackTrace(s);
- } else {
- exception.printStackTrace(s);
- }
- }
- }
-
- public void printStackTrace(PrintStream s) {
- super.printStackTrace(s);
- if (exception != null) {
- s.print("\n\nWrapped Exception:\n\n");
- if (exception.getCause()!=null)
- exception.getCause().printStackTrace(s);
- else if (exception instanceof org.hibernate.JDBCException) {
- (((JDBCException) exception).getSQLException()).printStackTrace(s);
- } else if (exception instanceof MethodInvocationException) {
- (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s);
- } else if (exception instanceof ServletException) {
- (((ServletException) exception).getRootCause()).printStackTrace(s);
- } else {
- exception.printStackTrace(s);
- }
- }
- }
-
- public String getStackTraceAsString() {
- StringWriter swriter = new StringWriter();
- PrintWriter pwriter = new PrintWriter(swriter);
- printStackTrace(pwriter);
- pwriter.flush();
- return swriter.getBuffer().toString();
- }
-
- public String getStackTraceAsString(Throwable e) {
- StringWriter swriter = new StringWriter();
- PrintWriter pwriter = new PrintWriter(swriter);
- e.printStackTrace(pwriter);
- pwriter.flush();
- return swriter.getBuffer().toString();
- }
-
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author namphunghai
+ * @author sdumitriu
+ * @author thomas
+ */
+
+package com.xpn.xwiki;
+
+
+// import com.xpn.xwiki.store.XWikiBatcher;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.MessageFormat;
+
+import javax.servlet.ServletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.hibernate.JDBCException;
+
+public class XWikiException extends Exception {
+
+ private static final Log log = LogFactory.getLog(XWikiException.class);
+
+ private int module;
+ private int code;
+ private Throwable exception;
+ private Object[] args;
+ private String message;
+
+ // Module list
+ public static final int MODULE_XWIKI = 0;
+ public static final int MODULE_XWIKI_CONFIG = 1;
+ public static final int MODULE_XWIKI_DOC = 2;
+ public static final int MODULE_XWIKI_STORE = 3;
+ public static final int MODULE_XWIKI_RENDERING = 4;
+ public static final int MODULE_XWIKI_PLUGINS = 5;
+ public static final int MODULE_XWIKI_PERLPLUGINS = 6;
+ public static final int MODULE_XWIKI_CLASSES = 7;
+ public static final int MODULE_XWIKI_USER = 8;
+ public static final int MODULE_XWIKI_ACCESS = 9;
+ public static final int MODULE_XWIKI_EMAIL = 10;
+ public static final int MODULE_XWIKI_APP = 11;
+ public static final int MODULE_XWIKI_EXPORT = 12;
+ public static final int MODULE_XWIKI_DIFF = 13;
+ public static final int MODULE_XWIKI_GROOVY = 14;
+ public static final int MODULE_XWIKI_NOTIFICATION = 15;
+ public static final int MODULE_XWIKI_CACHE = 16;
+
+ public static final int MODULE_PLUGIN_LASZLO = 21;
+
+ // Error list
+ public static final int ERROR_XWIKI_UNKNOWN = 0;
+ public static final int ERROR_XWIKI_NOT_IMPLEMENTED = 1;
+ public static final int ERROR_XWIKI_DOES_NOT_EXIST = 2;
+ public static final int ERROR_XWIKI_INIT_FAILED = 3;
+ public static final int ERROR_XWIKI_MKDIR = 4;
+
+ // Config
+ public static final int ERROR_XWIKI_CONFIG_FILENOTFOUND = 1001;
+ public static final int ERROR_XWIKI_CONFIG_FORMATERROR = 1002;
+
+ // Doc
+ public static final int ERROR_XWIKI_DOC_EXPORT = 2001;
+ public static final int ERROR_DOC_XML_PARSING = 2002;
+ public static final int ERROR_DOC_RCS_PARSING = 2003;
+
+ // Store
+ public static final int ERROR_XWIKI_STORE_CLASSINVOCATIONERROR = 3001;
+ public static final int ERROR_XWIKI_STORE_FILENOTFOUND = 3002;
+ public static final int ERROR_XWIKI_STORE_ARCHIVEFORMAT = 3003;
+ public static final int ERROR_XWIKI_STORE_ATTACHMENT_ARCHIVEFORMAT = 3004;
+
+ public static final int ERROR_XWIKI_STORE_RCS_SAVING_FILE = 3101;
+ public static final int ERROR_XWIKI_STORE_RCS_READING_FILE = 3102;
+ public static final int ERROR_XWIKI_STORE_RCS_DELETING_FILE = 3103;
+ public static final int ERROR_XWIKI_STORE_RCS_READING_REVISIONS = 3103;
+ public static final int ERROR_XWIKI_STORE_RCS_READING_VERSION = 3104;
+ public static final int ERROR_XWIKI_STORE_RCS_SEARCH = 3111;
+ public static final int ERROR_XWIKI_STORE_RCS_LOADING_ATTACHMENT = 3221;
+ public static final int ERROR_XWIKI_STORE_RCS_SAVING_ATTACHMENT = 3222;
+ public static final int ERROR_XWIKI_STORE_RCS_SEARCHING_ATTACHMENT = 3223;
+ public static final int ERROR_XWIKI_STORE_RCS_DELETING_ATTACHMENT = 3224;
+
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_DOC = 3201;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_DOC = 3202;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_DOC = 3203;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_CANNOT_DELETE_UNLOADED_DOC = 3204;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_REVISIONS = 3203;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_READING_VERSION = 3204;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_UNEXISTANT_VERSION = 3205;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_OBJECT = 3211;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_OBJECT = 3212;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_OBJECT = 3213;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_CLASS = 3221;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_CLASS = 3222;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SEARCH = 3223;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_ATTACHMENT = 3231;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT = 3232;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_ATTACHMENT = 3233;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT_LIST = 3234;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SEARCHING_ATTACHMENT = 3235;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_CHECK_EXISTS_DOC = 3236;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SWITCH_DATABASE = 3301;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_CREATE_DATABASE = 3401;
+
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_DOC = 3501;
+ public static final int ERROR_XWIKI_STORE_JCR_READING_DOC = 3502;
+ public static final int ERROR_XWIKI_STORE_JCR_DELETING_DOC = 3503;
+ public static final int ERROR_XWIKI_STORE_JCR_CANNOT_DELETE_UNLOADED_DOC = 3504;
+ public static final int ERROR_XWIKI_STORE_JCR_READING_REVISIONS = 3503;
+ public static final int ERROR_XWIKI_STORE_JCR_READING_VERSION = 3504;
+ public static final int ERROR_XWIKI_STORE_JCR_UNEXISTANT_VERSION = 3505;
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_OBJECT = 3511;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_OBJECT = 3512;
+ public static final int ERROR_XWIKI_STORE_JCR_DELETING_OBJECT = 3513;
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_CLASS = 3521;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_CLASS = 3522;
+ public static final int ERROR_XWIKI_STORE_JCR_SEARCH = 3523;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_ATTACHMENT = 3531;
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_ATTACHMENT = 3532;
+ public static final int ERROR_XWIKI_STORE_JCR_DELETING_ATTACHMENT = 3533;
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_ATTACHMENT_LIST = 3534;
+ public static final int ERROR_XWIKI_STORE_JCR_SEARCHING_ATTACHMENT = 3535;
+ public static final int ERROR_XWIKI_STORE_JCR_CHECK_EXISTS_DOC = 3536;
+ public static final int ERROR_XWIKI_STORE_JCR_SWITCH_DATABASE = 3601;
+ public static final int ERROR_XWIKI_STORE_JCR_CREATE_DATABASE = 3701;
+
+ public static final int ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION = 4001;
+ public static final int ERROR_XWIKI_RENDERING_GROOVY_EXCEPTION = 4002;
+
+ public static final int ERROR_XWIKI_PERLPLUGIN_START_EXCEPTION = 6001;
+ public static final int ERROR_XWIKI_PERLPLUGIN_START = 6002;
+ public static final int ERROR_XWIKI_PERLPLUGIN_PERLSERVER_EXCEPTION = 6003;
+
+ public static final int ERROR_XWIKI_CLASSES_FIELD_DOES_NOT_EXIST = 7001;
+ public static final int ERROR_XWIKI_CLASSES_FIELD_INVALID = 7002;
+ public static final int ERROR_XWIKI_CLASSES_DIFF = 7003;
+ public static final int ERROR_XWIKI_CLASSES_CUSTOMCLASSINVOCATIONERROR = 7004;
+ public static final int ERROR_XWIKI_CLASSES_PROPERTY_CLASS_INSTANCIATION = 7005;
+ public static final int ERROR_XWIKI_CLASSES_PROPERTY_CLASS_IN_METACLASS = 7006;
+ public static final int ERROR_XWIKI_CLASSES_CANNOT_PREPARE_CUSTOM_DISPLAY = 7007;
+
+
+ public static final int ERROR_XWIKI_USER_INIT = 8001;
+ public static final int ERROR_XWIKI_USER_CREATE = 8002;
+ public static final int ERROR_XWIKI_USER_INACTIVE = 8003;
+
+ public static final int ERROR_XWIKI_ACCESS_DENIED = 9001;
+ public static final int ERROR_XWIKI_ACCESS_TOKEN_INVALID = 9002;
+ public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_USERS = 9003;
+ public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_GROUPS = 9004;
+ public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_ADDING_USERS = 9005;
+ public static final int ERROR_XWIKI_ACCESS_EXO_EXCEPTION_LISTING_USERS = 9006;
+
+ public static final int ERROR_XWIKI_EMAIL_CANNOT_GET_VALIDATION_CONFIG = 10001;
+ public static final int ERROR_XWIKI_EMAIL_CANNOT_PREPARE_VALIDATION_EMAIL = 10002;
+ public static final int ERROR_XWIKI_EMAIL_ERROR_SENDING_EMAIL = 10003;
+ public static final int ERROR_XWIKI_EMAIL_CONNECT_FAILED = 10004;
+ public static final int ERROR_XWIKI_EMAIL_LOGIN_FAILED = 10005;
+ public static final int ERROR_XWIKI_EMAIL_SEND_FAILED = 10006;
+
+ public static final int ERROR_XWIKI_APP_TEMPLATE_DOES_NOT_EXIST = 11001;
+ public static final int ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY = 11002;
+ public static final int ERROR_XWIKI_APP_ATTACHMENT_NOT_FOUND = 11003;
+ public static final int ERROR_XWIKI_APP_CREATE_USER = 11004;
+ public static final int ERROR_XWIKI_APP_VALIDATE_USER = 11005;
+ public static final int ERROR_XWIKI_APP_INVALID_CHARS = 11006;
+ public static final int ERROR_XWIKI_APP_URL_EXCEPTION = 11007;
+ public static final int ERROR_XWIKI_APP_UPLOAD_PARSE_EXCEPTION = 11008;
+ public static final int ERROR_XWIKI_APP_UPLOAD_FILE_EXCEPTION = 11009;
+ public static final int ERROR_XWIKI_APP_REDIRECT_EXCEPTION = 11010;
+ public static final int ERROR_XWIKI_APP_SEND_RESPONSE_EXCEPTION = 11011;
+ public static final int ERROR_XWIKI_APP_SERVICE_NOT_FOUND = 11012;
+ public static final int ERROR_XWIKI_APP_FILE_EXCEPTION_MAXSIZE = 11013;
+ public static final int ERROR_XWIKI_APP_JAVA_HEAP_SPACE = 11014;
+
+ public static final int ERROR_XWIKI_EXPORT_XSL_FILE_NOT_FOUND = 12001;
+ public static final int ERROR_XWIKI_EXPORT_PDF_FOP_FAILED = 12002;
+ public static final int ERROR_XWIKI_EXPORT_XSL_FAILED = 12003;
+ public static final int ERROR_XWIKI_DIFF_CONTENT_ERROR = 13001;
+ public static final int ERROR_XWIKI_DIFF_RENDERED_ERROR = 13002;
+ public static final int ERROR_XWIKI_DIFF_METADATA_ERROR = 13003;
+ public static final int ERROR_XWIKI_DIFF_CLASS_ERROR = 13004;
+ public static final int ERROR_XWIKI_DIFF_OBJECT_ERROR = 13005;
+ public static final int ERROR_XWIKI_DIFF_XML_ERROR = 13005;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_LOCK = 13006;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_LOCK = 13007;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_LOCK = 13008;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_INVALID_MAPPING = 13009;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_MAPPING_INJECTION_FAILED = 13010;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_LINKS = 13011;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_SAVING_LINKS = 13012;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_DELETING_LINKS = 13013;
+ public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_BACKLINKS = 13014;
+
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_LOCK = 13106;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_LOCK = 13107;
+ public static final int ERROR_XWIKI_STORE_JCR_DELETING_LOCK = 13108;
+ public static final int ERROR_XWIKI_STORE_JCR_INVALID_MAPPING = 13109;
+ public static final int ERROR_XWIKI_STORE_JCR_MAPPING_INJECTION_FAILED = 13110;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_LINKS = 13111;
+ public static final int ERROR_XWIKI_STORE_JCR_SAVING_LINKS = 13112;
+ public static final int ERROR_XWIKI_STORE_JCR_DELETING_LINKS = 13113;
+ public static final int ERROR_XWIKI_STORE_JCR_LOADING_BACKLINKS = 13114;
+ public static final int ERROR_XWIKI_STORE_JCR_OTHER = 13130; // temporary
+
+ public static final int ERROR_XWIKI_GROOVY_COMPILE_FAILED = 14001;
+ public static final int ERROR_XWIKI_GROOVY_EXECUTION_FAILED = 14002;
+
+ public static final int ERROR_XWIKI_NOTIFICATION = 15001;
+
+ public static final int ERROR_CACHE_INITIALIZING = 16001;
+
+ public static final int ERROR_LASZLO_INVALID_XML = 21001;
+ public static final int ERROR_LASZLO_INVALID_DOTDOT = 21002;
+
+
+ public XWikiException(int module, int code, String message, Throwable e, Object[] args) {
+ setModule(module);
+ setCode(code);
+ setException(e);
+ setArgs(args);
+ setMessage(message);
+ if (log.isTraceEnabled())
+ log.trace(getMessage(), e);
+ }
+
+ public XWikiException(int module, int code, String message, Throwable e) {
+ this(module, code, message, e, null);
+ }
+
+ public XWikiException(int module, int code, String message) {
+ this(module, code, message, null, null);
+ }
+
+ public XWikiException() {
+ }
+
+ public int getModule() {
+ return module;
+ }
+
+ public String getModuleName() {
+ return "" + module;
+ }
+
+ public void setModule(int module) {
+ this.module = module;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public void setException(Throwable exception) {
+ this.exception = exception;
+ }
+
+ public Object[] getArgs() {
+ return args;
+ }
+
+ public void setArgs(Object[] args) {
+ this.args = args;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Error number ");
+ buffer.append(getCode());
+ buffer.append(" in ");
+ buffer.append(getModuleName());
+ buffer.append(": ");
+
+ if (message != null) {
+ if (args == null)
+ buffer.append(message);
+ else {
+ MessageFormat msgFormat = new MessageFormat(message);
+ try {
+ buffer.append(msgFormat.format(args));
+ }
+ catch (Exception e) {
+ buffer.append("Cannot format message " + message + " with args ");
+ for (int i = 0; i < args.length; i++) {
+ if (i != 0)
+ buffer.append(",");
+ buffer.append(args[i]);
+ }
+ }
+ }
+ }
+
+ if (exception != null) {
+ buffer.append("\nWrapped Exception: ");
+ buffer.append(exception.getMessage());
+ }
+ return buffer.toString();
+ }
+
+ public String getFullMessage() {
+ StringBuffer buffer = new StringBuffer(getMessage());
+ buffer.append("\n");
+ buffer.append(getStackTraceAsString());
+ buffer.append("\n");
+ /*
+ List list = XWikiBatcher.getSQLStats().getRecentSqlList();
+ if (list.size() > 0) {
+ buffer.append("Recent SQL:\n");
+ for (int i = 0; i < list.size(); i++) {
+ buffer.append(list.get(i));
+ buffer.append("\n");
+ }
+ }
+ */
+ return buffer.toString();
+ }
+
+ public void printStackTrace(PrintWriter s) {
+ super.printStackTrace(s);
+ if (exception != null) {
+ s.write("\n\nWrapped Exception:\n\n");
+ if (exception.getCause()!=null)
+ exception.getCause().printStackTrace(s);
+ else if (exception instanceof org.hibernate.JDBCException) {
+ (((JDBCException) exception).getSQLException()).printStackTrace(s);
+ } else if (exception instanceof MethodInvocationException) {
+ (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s);
+ } else if (exception instanceof ServletException) {
+ (((ServletException) exception).getRootCause()).printStackTrace(s);
+ } else {
+ exception.printStackTrace(s);
+ }
+ }
+ }
+
+ public void printStackTrace(PrintStream s) {
+ super.printStackTrace(s);
+ if (exception != null) {
+ s.print("\n\nWrapped Exception:\n\n");
+ if (exception.getCause()!=null)
+ exception.getCause().printStackTrace(s);
+ else if (exception instanceof org.hibernate.JDBCException) {
+ (((JDBCException) exception).getSQLException()).printStackTrace(s);
+ } else if (exception instanceof MethodInvocationException) {
+ (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s);
+ } else if (exception instanceof ServletException) {
+ (((ServletException) exception).getRootCause()).printStackTrace(s);
+ } else {
+ exception.printStackTrace(s);
+ }
+ }
+ }
+
+ public String getStackTraceAsString() {
+ StringWriter swriter = new StringWriter();
+ PrintWriter pwriter = new PrintWriter(swriter);
+ printStackTrace(pwriter);
+ pwriter.flush();
+ return swriter.getBuffer().toString();
+ }
+
+ public String getStackTraceAsString(Throwable e) {
+ StringWriter swriter = new StringWriter();
+ PrintWriter pwriter = new PrintWriter(swriter);
+ e.printStackTrace(pwriter);
+ pwriter.flush();
+ return swriter.getBuffer().toString();
+ }
+
}
\ No newline at end of file
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -46,7 +46,8 @@
import com.xpn.xwiki.doc.XWikiLock;
import com.xpn.xwiki.doc.XWikiDocumentArchive;
import com.xpn.xwiki.objects.BaseObject;
-import com.xpn.xwiki.objects.classes.BaseClass;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.classes.*;
import com.xpn.xwiki.stats.impl.DocumentStats;
import com.xpn.xwiki.util.TOCGenerator;
import com.xpn.xwiki.util.Util;
@@ -766,7 +767,21 @@
return getDoc().getObject(classOrFieldName);
}
+ public java.lang.Object getValue(String fieldName) {
+ Object object;
+ if (currentObj == null)
+ object = new Object(getDoc().getFirstObject(fieldName, context), context);
+ else
+ object = currentObj;
+ if (object!=null){
+ //com.xpn.xwiki.objects.classes.PropertyClass pclass = (PropertyClass) object.getBaseObject().getxWikiClass(context).get(fieldName);
+ //return getDoc().displayView(pclass, fieldName, object.getBaseObject(), context);
+ return ((BaseProperty)object.getBaseObject().safeget(fieldName)).getValue();
+ }
+ return null;
+ }
+
public String getTextArea() {
return com.xpn.xwiki.XWiki.getTextArea(doc.getContent(), context);
}
@@ -904,6 +919,10 @@
return getDoc().removeObject(obj.getBaseObject());
}
+ public boolean removeObjects(String className){
+ return getDoc().removeObjects(className);
+ }
+
public void delete() throws XWikiException {
if (hasAccessLevel("delete"))
context.getWiki().deleteDocument(getDocument(), context);
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -992,7 +992,7 @@
public void renamePage(XWikiDocument doc, String newFullName) throws XWikiException {
if (xwiki.getRightService().hasAccessLevel("edit", context.getUser(), doc.getFullName(), context)) {
- xwiki.renamePage(doc, context, newFullName);
+ xwiki.renamePage(doc, newFullName, context);
}
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -890,7 +890,10 @@
PropertyClass pclass = (PropertyClass) obj.getxWikiClass(context).get(fieldname);
String prefix = obj.getxWikiClass(context).getName() + "_" + obj.getNumber() + "_";
- if (type.equals("view")) {
+ if (pclass.isCustomDisplayed(context)){
+ pclass.displayCustom(result, fieldname, prefix, obj, context);
+ }
+ else if (type.equals("view")) {
pclass.displayView(result, fieldname, prefix, obj, context);
} else if (type.equals("rendered")) {
String fcontent = pclass.displayView(fieldname, prefix, obj, context);
@@ -2318,6 +2321,13 @@
return difflist;
}
+ /**
+ * Only do a copy and not a renaming
+ * @param docname
+ * @param context
+ * @return
+ * @throws XWikiException
+ */
public XWikiDocument renameDocument(String docname, XWikiContext context) throws XWikiException {
String oldname = getFullName();
if (oldname.equals(docname))
@@ -2585,6 +2595,26 @@
return true;
}
+ /**
+ * Remove all the object of the class in parameter
+ * @param className the class name of the objects to be removed
+ * @return
+ */
+ public boolean removeObjects(String className) {
+ Vector objects = getObjects(className);
+ if (objects==null)
+ return false;
+ Iterator it = objects.iterator();
+ while (it.hasNext()) {
+ BaseObject bobj = (BaseObject) it.next();
+ if (bobj != null) {
+ objects.set(bobj.getNumber(), null);
+ addObjectsToRemove(bobj);
+ }
+ }
+ return true;
+ }
+
// This method to split section according to title .
public List getSplitSectionsAccordingToTitle() throws XWikiException {
// pattern to match the title
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -27,15 +27,18 @@
import java.util.List;
import org.apache.ecs.xhtml.input;
+import org.apache.velocity.VelocityContext;
import org.dom4j.Element;
import org.dom4j.dom.DOMElement;
import org.hibernate.mapping.Property;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.api.Context;
import com.xpn.xwiki.objects.BaseCollection;
import com.xpn.xwiki.objects.BaseProperty;
import com.xpn.xwiki.objects.PropertyInterface;
+import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.objects.meta.MetaClass;
import com.xpn.xwiki.objects.meta.PropertyMetaClass;
@@ -185,7 +188,35 @@
return displayEdit(name, "", object, context);
}
+ public boolean isCustomDisplayed(XWikiContext context){
+ String disp = getCustomDisplay();
+ return disp != null && disp.length() > 0;
+ }
+ public void displayCustom(StringBuffer buffer, String fieldName, String prefix, BaseObject object, XWikiContext context) throws XWikiException {
+ String content = getCustomDisplay();
+
+ try {
+ VelocityContext vcontext = (VelocityContext) context.get("vcontext");
+ vcontext.put("name", fieldName);
+ vcontext.put("prefix", prefix);
+ vcontext.put("object", new com.xpn.xwiki.api.Object(object, context));
+ vcontext.put("type", context.getAction());
+ vcontext.put("context", new com.xpn.xwiki.api.Context(context));
+
+ BaseProperty prop = (BaseProperty) object.safeget(fieldName);
+ if (prop!=null)
+ vcontext.put("value", prop.getValue());
+
+ content = context.getWiki().parseContent(content, context);
+ } catch (Exception e) {
+ throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_CANNOT_PREPARE_CUSTOM_DISPLAY,
+ "Exception while preparing the custom display of " + fieldName, e, null);
+
+ }
+ buffer.append(content);
+ }
+
public BaseClass getxWikiClass(XWikiContext context) {
return getxWikiClass();
}
@@ -205,6 +236,14 @@
setStringValue("name", name);
}
+ public String getCustomDisplay() {
+ return getStringValue("customDisplay");
+ }
+
+ public void setCustomDisplay(String value) {
+ setLargeStringValue("customDisplay", value);
+ }
+
public String getPrettyName() {
return getStringValue("prettyName");
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/PropertyMetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/PropertyMetaClass.java 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/PropertyMetaClass.java 2006-09-05 11:22:51 UTC (rev 1281)
@@ -1,32 +1,29 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This 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 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
package com.xpn.xwiki.objects.meta;
import com.xpn.xwiki.objects.BaseCollection;
import com.xpn.xwiki.objects.PropertyInterface;
-import com.xpn.xwiki.objects.classes.BaseClass;
-import com.xpn.xwiki.objects.classes.BooleanClass;
-import com.xpn.xwiki.objects.classes.NumberClass;
-import com.xpn.xwiki.objects.classes.StringClass;
+import com.xpn.xwiki.objects.classes.*;
public class PropertyMetaClass extends BaseClass implements PropertyInterface {
@@ -45,12 +42,20 @@
name_class.setUnmodifiable(true);
name_class.setSize(40);
safeput("name", name_class);
+
StringClass prettyname_class = new StringClass(this);
prettyname_class.setName("prettyName");
prettyname_class.setPrettyName("Pretty Name");
prettyname_class.setSize(40);
safeput("prettyName", prettyname_class);
+ TextAreaClass customdisplay_class = new TextAreaClass(this);
+ customdisplay_class.setName("customDisplay");
+ customdisplay_class.setPrettyName("Custom Display");
+ customdisplay_class.setRows(5);
+ customdisplay_class.setSize(80);
+ safeput("customDisplay", customdisplay_class);
+
BooleanClass unmodif_class = new BooleanClass(this);
unmodif_class.setName("unmodifiable");
unmodif_class.setPrettyName("Unmodifiable");
Modified: xwiki/trunk/src/main/resources/xwiki.hbm.xml
===================================================================
--- xwiki/trunk/src/main/resources/xwiki.hbm.xml 2006-09-04 20:36:15 UTC (rev 1280)
+++ xwiki/trunk/src/main/resources/xwiki.hbm.xml 2006-09-05 11:22:51 UTC (rev 1281)
@@ -194,6 +194,9 @@
<property name="number" type="integer">
<column name="XWP_NUMBER" />
</property>
+ <property name="customDisplay" type="string">
+ <column name="XWP_CUSTOMDISPLAY" length="60000" />
+ </property>
<joined-subclass name="com.xpn.xwiki.objects.classes.NumberClass" table="xwikinumberclasses">
<key>
More information about the Xwiki-notifications
mailing list