use of org.apache.cxf.staxutils.DocumentDepthProperties in project cxf by apache.
the class AbstractJAXBProvider method createDepthReaderIfNeeded.
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) {
DocumentDepthProperties props = getDepthProperties();
if (props != null && props.isEffective()) {
reader = TransformUtils.createNewReaderIfNeeded(reader, is);
reader = new DepthRestrictingStreamReader(reader, props);
} else if (reader != null) {
reader = configureReaderRestrictions(reader);
}
return reader;
}
use of org.apache.cxf.staxutils.DocumentDepthProperties in project syncope by apache.
the class SyncopeClientFactoryBean method defaultJAXBProvider.
@SuppressWarnings({ "rawtypes" })
protected JAXBElementProvider<?> defaultJAXBProvider() {
JAXBElementProvider<?> defaultJAXBProvider = new JAXBElementProvider();
DocumentDepthProperties depthProperties = new DocumentDepthProperties();
depthProperties.setInnerElementCountThreshold(500);
defaultJAXBProvider.setDepthProperties(depthProperties);
Map<String, Object> marshallerProperties = new HashMap<>();
marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
defaultJAXBProvider.setMarshallerProperties(marshallerProperties);
Map<String, String> collectionWrapperMap = new HashMap<>();
collectionWrapperMap.put(PolicyTO.class.getName(), "policies");
defaultJAXBProvider.setCollectionWrapperMap(collectionWrapperMap);
return defaultJAXBProvider;
}
use of org.apache.cxf.staxutils.DocumentDepthProperties in project tomee by apache.
the class AbstractJAXBProvider method createDepthReaderIfNeeded.
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) {
DocumentDepthProperties props = getDepthProperties();
if (props != null && props.isEffective()) {
reader = TransformUtils.createNewReaderIfNeeded(reader, is);
reader = new DepthRestrictingStreamReader(reader, props);
} else if (reader != null) {
reader = configureReaderRestrictions(reader);
}
return reader;
}
use of org.apache.cxf.staxutils.DocumentDepthProperties in project cxf by apache.
the class JSONProvider method getDepthProperties.
protected DocumentDepthProperties getDepthProperties() {
DocumentDepthProperties depthProperties = super.getDepthProperties();
if (depthProperties != null) {
return depthProperties;
}
if (getContext() != null) {
String totalElementCountStr = (String) getContext().getContextualProperty(DocumentDepthProperties.TOTAL_ELEMENT_COUNT);
String innerElementCountStr = (String) getContext().getContextualProperty(DocumentDepthProperties.INNER_ELEMENT_COUNT);
String elementLevelStr = (String) getContext().getContextualProperty(DocumentDepthProperties.INNER_ELEMENT_LEVEL);
if (totalElementCountStr != null || innerElementCountStr != null || elementLevelStr != null) {
try {
int totalElementCount = totalElementCountStr != null ? Integer.parseInt(totalElementCountStr) : -1;
int elementLevel = elementLevelStr != null ? Integer.parseInt(elementLevelStr) : -1;
int innerElementCount = innerElementCountStr != null ? Integer.parseInt(innerElementCountStr) : -1;
return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount);
} catch (Exception ex) {
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
}
return null;
}
Aggregations