Example usage for javax.xml.stream XMLStreamException getLocalizedMessage

List of usage examples for javax.xml.stream XMLStreamException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.deegree.services.wms.controller.WMSController.java

private void getFeatureInfo(Map<String, String> map, final HttpResponseBuffer response, Version version)
        throws OWSException, IOException, MissingDimensionValue, InvalidDimensionValue {

    Pair<FeatureCollection, LinkedList<String>> pair;
    String format;/*ww w.  j a v a 2  s  .  c  o  m*/
    List<String> queryLayers;
    boolean geometries;
    FeatureType type = null;
    ICRS crs;
    Map<String, String> nsBindings = new HashMap<String, String>();

    LinkedList<String> headers = new LinkedList<String>();
    org.deegree.protocol.wms.ops.GetFeatureInfo fi = new org.deegree.protocol.wms.ops.GetFeatureInfo(map,
            version);
    checkGetFeatureInfo(version, fi);
    crs = fi.getCoordinateSystem();
    geometries = fi.returnGeometries();
    queryLayers = map(fi.getQueryLayers(), CollectionUtils.<LayerRef>getToStringMapper());

    RenderingInfo info = new RenderingInfo(fi.getInfoFormat(), fi.getWidth(), fi.getHeight(), false, null,
            fi.getEnvelope(), 0.28, map);
    format = fi.getInfoFormat();
    info.setFormat(format);
    info.setFeatureCount(fi.getFeatureCount());
    info.setX(fi.getX());
    info.setY(fi.getY());
    pair = new Pair<FeatureCollection, LinkedList<String>>(service.getFeatures(fi, headers), headers);

    FeatureCollection col = pair.first;
    addHeaders(response, pair.second);
    format = format == null ? "application/vnd.ogc.gml" : format;
    response.setContentType(format);
    response.setCharacterEncoding("UTF-8");

    Map<String, String> fismap = new HashMap<String, String>();
    fismap.put("LAYERS", reduce("", queryLayers, getStringJoiner(",")));
    GetFeatureInfoSchema fis = new GetFeatureInfoSchema(fismap);
    List<FeatureType> schema = service.getSchema(fis);
    for (FeatureType ft : schema) {
        type = ft;
        if (ft.getSchema() != null) {
            nsBindings.putAll(ft.getSchema().getNamespaceBindings());
        }
    }

    String loc = getHttpGetURL() + "request=GetFeatureInfoSchema&layers=" + join(",", queryLayers);

    try {
        FeatureInfoParams params = new FeatureInfoParams(nsBindings, col, format, geometries, loc, type, crs);
        featureInfoManager.serializeFeatureInfo(params, new StandardFeatureInfoContext(response));
        response.flushBuffer();
    } catch (XMLStreamException e) {
        throw new IOException(e.getLocalizedMessage(), e);
    }
}

From source file:org.onehippo.repository.scxml.RepositorySCXMLRegistry.java

private String naturalizeXMLStreamExceptionMessage(final XMLStreamException xse) {
    String naturalized = xse.getLocalizedMessage();
    final Matcher m = XML_STREAM_EXCEPTION_MESSAGE_PATTERN.matcher(naturalized);

    if (m.find()) {
        final String errorInfo = m.group(2);
        if (StringUtils.isNotEmpty(errorInfo)) {
            final String[] tokens = StringUtils.split(errorInfo, "#?&");
            if (!ArrayUtils.isEmpty(tokens)) {
                final Location location = xse.getLocation();
                final StringBuilder sbTemp = new StringBuilder().append("XML Stream Error at (L")
                        .append(location.getLineNumber()).append(":C").append(location.getColumnNumber())
                        .append("). Cause: ")
                        .append(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(tokens[0]), " "));
                if (tokens.length > 1) {
                    sbTemp.append(" (").append(StringUtils.join(tokens, ", ", 1, tokens.length)).append(")");
                }/*w w  w  .  j a  va  2 s . c om*/
                naturalized = sbTemp.toString();
            }
        }
    }

    return naturalized;
}