1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.commons.impl;
2021publicfinalclassXMLConstraints {
2223publicstaticfinalint MAX_STRING_LENGTH = 100 * 1024;
2425publicstaticfinalint MAX_EXTENSIONS_WIDTH;
26publicstaticfinalint MAX_EXTENSIONS_DEPTH;
2728publicstaticfinalint MAX_EXTENSIONS_WIDTH_DEFAULT = 1000;
29publicstaticfinalint MAX_EXTENSIONS_DEPTH_DEFAULT = 100;
3031publicstaticfinal String MAX_EXTENSIONS_WIDTH_SYSTEM_PROPERTY = "org.apache.chemistry.opencmis.XMLConstraints.maxExtensionWith";
32publicstaticfinal String MAX_EXTENSIONS_DEPTH_SYSTEM_PROPERTY = "org.apache.chemistry.opencmis.XMLConstraints.maxExtensionDepth";
3334static {
35int maxWidth = MAX_EXTENSIONS_WIDTH_DEFAULT;
36try {
37 String maxWidthStr = System.getProperty(MAX_EXTENSIONS_WIDTH_SYSTEM_PROPERTY);
38if (maxWidthStr != null) {
39 maxWidth = Integer.parseInt(maxWidthStr);
4041// check for sane values42if (maxWidth < 1 || maxWidth > 100000) {
43 maxWidth = MAX_EXTENSIONS_WIDTH_DEFAULT;
44 }
45 }
46 } catch (NumberFormatException e) {
47// ignore48 }
49 MAX_EXTENSIONS_WIDTH = maxWidth;
5051int maxDepth = MAX_EXTENSIONS_DEPTH_DEFAULT;
52try {
53 String maxDepthStr = System.getProperty(MAX_EXTENSIONS_DEPTH_SYSTEM_PROPERTY);
54if (maxDepthStr != null) {
55 maxDepth = Integer.parseInt(maxDepthStr);
5657// check for sane values58if (maxDepth < 1 || maxDepth > 10000) {
59 maxDepth = MAX_EXTENSIONS_DEPTH_DEFAULT;
60 }
61 }
62 } catch (NumberFormatException e) {
63// ignore64 }
65 MAX_EXTENSIONS_DEPTH = maxDepth;
66 }
6768privateXMLConstraints() {
69 }
70 }