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;
  }
  public void handlerCreate(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      AdminService admin,
      ExtendedMap formItems)
      throws VerticalAdminException, VerticalEngineException {

    User user = securityService.getLoggedInAdminConsoleUser();

    // Enforce unique names
    String name = formItems.getString("name");
    if (admin.getContentTypeKeyByName(name) > -1) {
      addError(7, "name", name);
    }

    String xmlData = buildContentTypeXML(formItems, false);

    ContentHandlerKey contentHandlerKey =
        new ContentHandlerKey(formItems.getString("contenthandlerkey"));
    ContentHandlerEntity contentHandler = contentHandlerDao.findByKey(contentHandlerKey);
    ContentHandlerName contentHandlerName = ContentHandlerName.parse(contentHandler.getClassName());
    String errorInConfig = validateConfig(contentHandlerName, xmlData);

    if (this.hasErrors() || errorInConfig != null) {
      if (errorInConfig != null) {
        String moduleXML = formItems.getString("module", "");
        addError(2, "module", moduleXML);
        formItems.put("errorInConfig", errorInConfig);
      }
      handlerForm(request, response, session, admin, formItems);
      return;
    }

    admin.createContentType(user, xmlData);

    MultiValueMap queryParams = new MultiValueMap();
    queryParams.put("page", formItems.get("page"));
    queryParams.put("op", "browse");
    redirectClientToAdminPath("adminpage", queryParams, request, response);
  }