1 10 package mondrian.xmla.impl; 11 12 import java.io.OutputStream ; 13 import java.io.UnsupportedEncodingException ; 14 15 import mondrian.olap.Util; 16 import mondrian.xmla.*; 17 18 23 public class DefaultXmlaResponse implements XmlaResponse { 24 25 private static final String MSG_ENCODING_ERROR = "Encoding unsupported: "; 27 28 private SaxWriter writer; 29 private final String encoding; 30 31 public DefaultXmlaResponse(OutputStream outputStream, String encoding) { 32 this.encoding = encoding; 33 try { 34 writer = new DefaultSaxWriter(outputStream, this.encoding); 35 } catch (UnsupportedEncodingException uee) { 36 throw Util.newError(uee, MSG_ENCODING_ERROR + encoding); 37 } 38 } 39 40 public SaxWriter getWriter() { 41 return writer; 42 } 43 44 public void error(Throwable t) { 45 writer.completeBeforeElement("root"); 46 Throwable throwable = XmlaUtil.rootThrowable(t); 47 writer.startElement("Messages"); 48 writer.startElement("Error", new String [] { 49 "ErrorCode", throwable.getClass().getName(), 50 "Description", throwable.getMessage(), 51 "Source", "Mondrian", 52 "Help", "", 53 }); 54 writer.endElement(); writer.endElement(); } 57 58 } 59 60 | Popular Tags |