private String validateConfig(ContentHandlerName contentHandlerName, String xmlData) {
    org.jdom.Element configEl;

    try {
      org.jdom.Element contentTypeEl = JDOMUtil.parseDocument(xmlData).getRootElement();
      org.jdom.Element moduleDataEl = contentTypeEl.getChild("moduledata");
      if (moduleDataEl == null) {
        configEl = contentTypeEl.getChild("config");
      } else {
        configEl = moduleDataEl.getChild("config");
      }

    } catch (IOException e) {
      throw new RuntimeException("Failed to validate content type config", e);
    } catch (JDOMException e) {
      throw new RuntimeException("Failed to validate content type config", e);
    }

    if (configEl != null) {
      // Parse the content type config... the parser will throw exceptions if anything is not
      // correctly written
      try {
        if (contentHandlerName.equals(ContentHandlerName.CUSTOM)) {
          final ContentTypeConfig contentTypeConfig =
              ContentTypeConfigParser.parse(contentHandlerName, configEl);
          contentTypeConfig.validate();
        }
      } catch (InvalidContentTypeConfigException e) {
        return e.getMessage();
      }
    }

    return null;
  }