You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2008/02/22 15:32:36 UTC
svn commit: r630220 -
/lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java
Author: andreas
Date: Fri Feb 22 06:32:33 2008
New Revision: 630220
URL: http://svn.apache.org/viewvc?rev=630220&view=rev
Log:
OneForm editor: Skip validation for resource types without schema, handle empty document elements correctly (fixes bug 44467).
Modified:
lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java
Modified: lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java?rev=630220&r1=630219&r2=630220&view=diff
==============================================================================
--- lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java (original)
+++ lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java Fri Feb 22 06:32:33 2008
@@ -129,7 +129,14 @@
protected void validate(Document xml) throws Exception {
ResourceType resourceType = getSourceDocument().getResourceType();
Schema schema = resourceType.getSchema();
- ValidationUtil.validate(this.manager, xml, schema, new UsecaseErrorHandler(this));
+ if (schema == null) {
+ getLogger().info(
+ "No schema declared for resource type [" + resourceType.getName()
+ + "], skipping validation.");
+ }
+ else {
+ ValidationUtil.validate(this.manager, xml, schema, new UsecaseErrorHandler(this));
+ }
}
protected Document getXml() throws ParserConfigurationException, IOException {
@@ -163,6 +170,7 @@
/**
* Save the XML file
+ *
* @param content The content
* @param document The source
*/
@@ -178,6 +186,7 @@
/**
* Remove redundant namespaces
+ *
* @param namespaces The namespaces to remove
* @return The namespace string without the removed namespaces
*/
@@ -199,13 +208,17 @@
/**
* Add namespaces
+ *
* @param namespaces The namespaces to add
* @param content The content to add them to
* @return The content with the added namespaces
*/
private String addNamespaces(String namespaces, String content) {
- int i = content.indexOf(">");
- return content.substring(0, i) + " " + namespaces + content.substring(i);
+ String s = content.substring(0, content.indexOf(">"));
+ while (s.endsWith(" ") || s.endsWith("/")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ return s + " " + namespaces + content.substring(s.length());
}
protected String getEvent() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org