Search in sources :

Example 1 with DocumentDepthProperties

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;
}
Also used : DocumentDepthProperties(org.apache.cxf.staxutils.DocumentDepthProperties) DepthRestrictingStreamReader(org.apache.cxf.staxutils.DepthRestrictingStreamReader)

Example 2 with DocumentDepthProperties

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;
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) DocumentDepthProperties(org.apache.cxf.staxutils.DocumentDepthProperties) HashMap(java.util.HashMap) PolicyTO(org.apache.syncope.common.lib.policy.PolicyTO)

Example 3 with DocumentDepthProperties

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;
}
Also used : DocumentDepthProperties(org.apache.cxf.staxutils.DocumentDepthProperties) DepthRestrictingStreamReader(org.apache.cxf.staxutils.DepthRestrictingStreamReader)

Example 4 with DocumentDepthProperties

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;
}
Also used : DocumentDepthProperties(org.apache.cxf.staxutils.DocumentDepthProperties) XMLStreamException(javax.xml.stream.XMLStreamException) JSONSequenceTooLargeException(org.codehaus.jettison.JSONSequenceTooLargeException) JAXBException(javax.xml.bind.JAXBException) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException)

Aggregations

DocumentDepthProperties (org.apache.cxf.staxutils.DocumentDepthProperties)4 DepthRestrictingStreamReader (org.apache.cxf.staxutils.DepthRestrictingStreamReader)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 JAXBException (javax.xml.bind.JAXBException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)1 PolicyTO (org.apache.syncope.common.lib.policy.PolicyTO)1 JSONSequenceTooLargeException (org.codehaus.jettison.JSONSequenceTooLargeException)1