r1055 - in xwiki/trunk/src/main: java/com/xpn/xwiki/objects java/com/xpn/xwiki/store java/com/xpn/xwiki/web resources
Nguyen Viet Chung
chungnv at users.forge.objectweb.org
Mon Apr 24 09:28:24 CEST 2006
Author: chungnv
Date: 2006-04-24 09:28:24 +0200 (Mon, 24 Apr 2006)
New Revision: 1055
Modified:
xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseObject.java
xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java
xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropAddAction.java
xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropUpdateAction.java
xwiki/trunk/src/main/resources/ApplicationResources.properties
Log:
Fixed bug XWiki-246 . Creation of a new class property without naming it should be forbidden
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseObject.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseObject.java 2006-04-24 01:25:01 UTC (rev 1054)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseObject.java 2006-04-24 07:28:24 UTC (rev 1055)
@@ -149,8 +149,12 @@
while (it.hasNext()) {
Element pel = new DOMElement("property");
PropertyInterface bprop = (PropertyInterface)it.next();
- pel.add(bprop.toXML());
- oel.add(pel);
+
+ String pname = bprop.getName();
+ if(pname != null && !pname.trim().equals("") ) {
+ pel.add(bprop.toXML());
+ oel.add(pel);
+ }
}
return oel;
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2006-04-24 01:25:01 UTC (rev 1054)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2006-04-24 07:28:24 UTC (rev 1055)
@@ -704,8 +704,11 @@
throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_FIELD_INVALID,
"Field {0} in object {1} has an invalid name", null, args);
}
- if (!handledProps.contains(prop.getName()))
- saveXWikiProperty(prop, context, false);
+
+ String pname = prop.getName() ;
+ if(pname != null && !pname.trim().equals("") && !handledProps.contains(pname) ){
+ saveXWikiProperty(prop, context, false);
+ }
}
}
@@ -1107,7 +1110,10 @@
Iterator it = coll.iterator();
while (it.hasNext()) {
PropertyClass prop = (PropertyClass) it.next();
- saveXWikiClassProperty(prop, context, false);
+ String pname = prop.getName();
+ if(pname != null && !pname.trim().equals("") ) {
+ saveXWikiClassProperty(prop, context, false);
+ }
}
if (bTransaction) {
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropAddAction.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropAddAction.java 2006-04-24 01:25:01 UTC (rev 1054)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropAddAction.java 2006-04-24 07:28:24 UTC (rev 1055)
@@ -1,25 +1,25 @@
-/*
- * 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 sdumitriu
- */
+/*
+ * 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 sdumitriu
+ */
package com.xpn.xwiki.web;
import com.xpn.xwiki.XWiki;
@@ -41,6 +41,12 @@
XWikiDocument olddoc = (XWikiDocument) doc.clone();
String propName = ((PropAddForm) form).getPropName();
+
+ if(propName ==null || propName.equals("") || !propName.matches("\\w+") ){
+ context.put("message","propertynamenotcorrect");
+ return true;
+ }
+
String propType = ((PropAddForm) form).getPropType();
BaseClass bclass = doc.getxWikiClass();
bclass.setName(doc.getFullName());
@@ -63,4 +69,8 @@
sendRedirect(response, redirect);
return false;
}
+
+ public String render(XWikiContext context) throws XWikiException{
+ return "exception";
+ }
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropUpdateAction.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropUpdateAction.java 2006-04-24 01:25:01 UTC (rev 1054)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/web/PropUpdateAction.java 2006-04-24 07:28:24 UTC (rev 1055)
@@ -1,24 +1,24 @@
-/*
- * 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 sdumitriu
- */
+/*
+ * 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 sdumitriu
+ */
package com.xpn.xwiki.web;
import java.util.HashMap;
@@ -60,6 +60,12 @@
Map map = ((EditForm)form).getObject(name);
property.getxWikiClass(context).fromMap(map, property);
String newname = property.getName();
+
+ if(newname == null || newname.equals("") || !newname.matches("\\w+")){
+ context.put("message","propertynamenotcorrect");
+ return true;
+ }
+
if (newname.indexOf(" ")!=-1) {
newname = newname.replaceAll(" ","");
property.setName(newname);
@@ -91,4 +97,8 @@
sendRedirect(response, redirect);
return false;
}
+
+ public String render(XWikiContext context) throws XWikiException {
+ return "exception";
+ }
}
Modified: xwiki/trunk/src/main/resources/ApplicationResources.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-24 01:25:01 UTC (rev 1054)
+++ xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-24 07:28:24 UTC (rev 1055)
@@ -208,6 +208,7 @@
auth_active_check=Check Active fields for user authentication
advanced=Advance
errornotdefine=Error not define in XWikiException !
+propertynamenotcorrect=Property name only correct with a-zA-Z0-9 !
chartwizard=Chart Wizard
chwhide=hide
More information about the Xwiki-notifications
mailing list