Author: fmui
Date: Tue May 24 07:15:13 2016
New Revision: 1745309
URL: http://svn.apache.org/viewvc?rev=1745309&view=rev
Log:
CMIS-975: made XML constraints configurable
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstraints.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLWalker.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstraints.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstraints.java?rev=1745309&r1=1745308&r2=1745309&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstraints.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConstraints.java
Tue May 24 07:15:13 2016
@@ -25,6 +25,33 @@ public final class XMLConstraints {
public static final int MAX_STRING_LENGTH = 100 * 1024;
- public static final int MAX_EXTENSIONS_WIDTH = 500;
- public static final int MAX_EXTENSIONS_DEPTH = 20;
+ public static final int MAX_EXTENSIONS_WIDTH;
+ public static final int MAX_EXTENSIONS_DEPTH;
+
+ public static final String MAX_EXTENSIONS_WIDTH_SYSTEM_PROPERTY =
"org.apache.chemistry.opencmis.XMLConstraints.maxExtensionWith";
+ public static final String MAX_EXTENSIONS_DEPTH_SYSTEM_PROPERTY =
"org.apache.chemistry.opencmis.XMLConstraints.maxExtensionDepth";
+
+ static {
+ int maxWidth = 1000;
+ try {
+ String maxWidthStr =
System.getProperty(MAX_EXTENSIONS_WIDTH_SYSTEM_PROPERTY);
+ if (maxWidthStr != null) {
+ maxWidth = Integer.parseInt(maxWidthStr);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ MAX_EXTENSIONS_WIDTH = maxWidth;
+
+ int maxDepth = 100;
+ try {
+ String maxDepthStr =
System.getProperty(MAX_EXTENSIONS_DEPTH_SYSTEM_PROPERTY);
+ if (maxDepthStr != null) {
+ maxDepth = Integer.parseInt(maxDepthStr);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ MAX_EXTENSIONS_DEPTH = maxDepth;
+ }
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLWalker.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLWalker.java?rev=1745309&r1=1745308&r2=1745309&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLWalker.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLWalker.java
Tue May 24 07:15:13 2016
@@ -105,7 +105,8 @@ public abstract class XMLWalker<T> {
}
if (extensions.size() + 1 > XMLConstraints.MAX_EXTENSIONS_WIDTH) {
- throw new CmisInvalidArgumentException("Too many extensions!");
+ throw new CmisInvalidArgumentException("Too many extensions! (More
than "
+ + XMLConstraints.MAX_EXTENSIONS_WIDTH + " extensions.)");
}
extensions.add(handleExtensionLevel(parser, 0));
@@ -144,7 +145,8 @@ public abstract class XMLWalker<T> {
}
} else if (event == XMLStreamConstants.START_ELEMENT) {
if (level + 1 > XMLConstraints.MAX_EXTENSIONS_DEPTH) {
- throw new CmisInvalidArgumentException("Extensions tree
too deep!");
+ throw new CmisInvalidArgumentException("Extensions tree
too deep! (More than "
+ + XMLConstraints.MAX_EXTENSIONS_DEPTH + "
levels.)");
}
if (children == null) {
@@ -152,7 +154,8 @@ public abstract class XMLWalker<T> {
}
if (children.size() + 1 > XMLConstraints.MAX_EXTENSIONS_WIDTH)
{
- throw new CmisInvalidArgumentException("Extensions tree
too wide!");
+ throw new CmisInvalidArgumentException("Extensions tree
too wide! (More than "
+ + XMLConstraints.MAX_EXTENSIONS_WIDTH + "
extensions on one level.)");
}
children.add(handleExtensionLevel(parser, level + 1));