コード例 #1
0
 private void initCommand(Element commandRoot) throws XmlaException {
   Element[] childElems = XmlaUtil.filterChildElements(commandRoot, NS_XMLA, "Statement");
   if (childElems.length != 1) {
     StringBuilder buf = new StringBuilder(100);
     buf.append(MSG_INVALID_XMLA);
     buf.append(": Wrong number of Statement elements: ");
     buf.append(childElems.length);
     throw new XmlaException(
         CLIENT_FAULT_FC,
         HSB_BAD_STATEMENT_CODE,
         HSB_BAD_STATEMENT_FAULT_FS,
         Util.newError(buf.toString()));
   }
   statement = XmlaUtil.textInElement(childElems[0]).replaceAll("\\r", "");
   drillthrough = statement.toUpperCase().indexOf("DRILLTHROUGH") != -1;
 }
コード例 #2
0
  private void initDiscover(Element discoverRoot) throws XmlaException {
    Element[] childElems = XmlaUtil.filterChildElements(discoverRoot, NS_XMLA, "RequestType");
    if (childElems.length != 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of RequestType elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_REQUEST_TYPE_CODE,
          HSB_BAD_REQUEST_TYPE_FAULT_FS,
          Util.newError(buf.toString()));
    }
    requestType = XmlaUtil.textInElement(childElems[0]); // <RequestType>

    childElems = XmlaUtil.filterChildElements(discoverRoot, NS_XMLA, "Properties");
    if (childElems.length != 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of Properties elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_PROPERTIES_CODE,
          HSB_BAD_PROPERTIES_FAULT_FS,
          Util.newError(buf.toString()));
    }
    initProperties(childElems[0]); // <Properties><PropertyList>

    childElems = XmlaUtil.filterChildElements(discoverRoot, NS_XMLA, "Restrictions");
    if (childElems.length != 1) {
      StringBuilder buf = new StringBuilder(100);
      buf.append(MSG_INVALID_XMLA);
      buf.append(": Wrong number of Restrictions elements: ");
      buf.append(childElems.length);
      throw new XmlaException(
          CLIENT_FAULT_FC,
          HSB_BAD_RESTRICTIONS_CODE,
          HSB_BAD_RESTRICTIONS_FAULT_FS,
          Util.newError(buf.toString()));
    }
    initRestrictions(childElems[0]); // <Restriciotns><RestrictionList>
  }
コード例 #3
0
  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);
  }
コード例 #4
0
  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);
  }