protected final void init(Element xmlaRoot) throws XmlaException { if (NS_XMLA.equals(xmlaRoot.getNamespaceURI())) { String lname = xmlaRoot.getLocalName(); if ("Discover".equals(lname)) { method = Method.DISCOVER; initDiscover(xmlaRoot); } else if ("Execute".equals(lname)) { method = Method.EXECUTE; initExecute(xmlaRoot); } else { // Note that is code will never be reached because // the error will be caught in // DefaultXmlaServlet.handleSoapBody first StringBuilder buf = new StringBuilder(100); buf.append(MSG_INVALID_XMLA); buf.append(": Bad method name \""); buf.append(lname); buf.append("\""); throw new XmlaException( CLIENT_FAULT_FC, HSB_BAD_METHOD_CODE, HSB_BAD_METHOD_FAULT_FS, Util.newError(buf.toString())); } } else { // Note that is code will never be reached because // the error will be caught in // DefaultXmlaServlet.handleSoapBody first StringBuilder buf = new StringBuilder(100); buf.append(MSG_INVALID_XMLA); buf.append(": Bad namespace url \""); buf.append(xmlaRoot.getNamespaceURI()); buf.append("\""); throw new XmlaException( CLIENT_FAULT_FC, HSB_BAD_METHOD_NS_CODE, HSB_BAD_METHOD_NS_FAULT_FS, Util.newError(buf.toString())); } }
private void initProperties(Element propertiesRoot) throws XmlaException { Map<String, String> properties = new HashMap<String, String>(); Element[] childElems = XmlaUtil.filterChildElements(propertiesRoot, NS_XMLA, "PropertyList"); if (childElems.length == 1) { NodeList nlst = childElems[0].getChildNodes(); for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) { Node n = nlst.item(i); if (n instanceof Element) { Element e = (Element) n; if (NS_XMLA.equals(e.getNamespaceURI())) { String key = e.getLocalName(); String value = XmlaUtil.textInElement(e); if (LOGGER.isDebugEnabled()) { LOGGER.debug( "DefaultXmlaRequest.initProperties: " + " key=\"" + key + "\", value=\"" + value + "\""); } properties.put(key, value); } } } } else if (childElems.length > 1) { StringBuilder buf = new StringBuilder(100); buf.append(MSG_INVALID_XMLA); buf.append(": Wrong number of PropertyList elements: "); buf.append(childElems.length); throw new XmlaException( CLIENT_FAULT_FC, HSB_BAD_PROPERTIES_LIST_CODE, HSB_BAD_PROPERTIES_LIST_FAULT_FS, Util.newError(buf.toString())); } else { } this.properties = Collections.unmodifiableMap(properties); }
private void initRestrictions(Element restrictionsRoot) throws XmlaException { Map<String, List<String>> restrictions = new HashMap<String, List<String>>(); Element[] childElems = XmlaUtil.filterChildElements(restrictionsRoot, NS_XMLA, "RestrictionList"); if (childElems.length == 1) { NodeList nlst = childElems[0].getChildNodes(); for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) { Node n = nlst.item(i); if (n instanceof Element) { Element e = (Element) n; if (NS_XMLA.equals(e.getNamespaceURI())) { String key = e.getLocalName(); String value = XmlaUtil.textInElement(e); List<String> values; if (restrictions.containsKey(key)) { values = restrictions.get(key); } else { values = new ArrayList<String>(); restrictions.put(key, values); } if (LOGGER.isDebugEnabled()) { LOGGER.debug( "DefaultXmlaRequest.initRestrictions: " + " key=\"" + key + "\", value=\"" + value + "\""); } values.add(value); } } } } else if (childElems.length > 1) { StringBuilder buf = new StringBuilder(100); buf.append(MSG_INVALID_XMLA); buf.append(": Wrong number of RestrictionList elements: "); buf.append(childElems.length); throw new XmlaException( CLIENT_FAULT_FC, HSB_BAD_RESTRICTION_LIST_CODE, HSB_BAD_RESTRICTION_LIST_FAULT_FS, Util.newError(buf.toString())); } // If there is a Catalog property, // we have to consider it a constraint as well. String key = org.olap4j.metadata.XmlaConstants.Literal.CATALOG_NAME.name(); if (this.properties.containsKey(key) && !restrictions.containsKey(key)) { List<String> values; values = new ArrayList<String>(); restrictions.put(this.properties.get(key), values); if (LOGGER.isDebugEnabled()) { LOGGER.debug( "DefaultXmlaRequest.initRestrictions: " + " key=\"" + key + "\", value=\"" + this.properties.get(key) + "\""); } } this.restrictions = (Map) Collections.unmodifiableMap(restrictions); }