@RequestMapping(method = RequestMethod.GET)
  public ModelAndView add(HttpSession session) {
    ModelAndView mav = new ModelAndView();

    ArgendataUser user = (ArgendataUser) session.getAttribute("user");

    DatasetForm dForm = new DatasetForm();

    dForm.setUsername(user.getUsername());

    mav.addObject("privateKey", properties.getReCaptchaPrivateKey());
    mav.addObject("publicKey", properties.getReCaptchaPublicKey());

    mav.addObject(dForm);

    return mav;
  }
  @RequestMapping(method = RequestMethod.POST)
  public ModelAndView add(DatasetForm datasetEntryForm, Errors errors, HttpSession session) {
    ModelAndView mav = new ModelAndView();

    validatorDataEntry.validate(datasetEntryForm, errors);
    if (errors.hasErrors()) {
      logger.error("Errores en la validacion del formulario");
      mav.addObject("privateKey", properties.getReCaptchaPrivateKey());
      mav.addObject("publicKey", properties.getReCaptchaPublicKey());
      mav.setViewName("dataset/add");
      return mav;
    }

    PreDataset aDataset = datasetEntryForm.build();

    // the resource's length will be calculated later on a separate thread.
    aDataset.setSize(0);

    ArgendataUser user = (ArgendataUser) session.getAttribute("user");

    if (!aDataset.getDistribution().equals("Download")) {
      aDataset.setFormat("");
      aDataset.setSize(0);
    }

    if (!user.isAdmin()) {
      try {
        aDataset.setSize(getResourceLength(aDataset));
        datasetService.store(aDataset);
      } catch (Exception e) {
        logger.error("No se pudo agregar el dataset al store relacional");
        logger.error(e.getMessage(), e);
        mav.setViewName("redirect:../static/error");
        return mav;
      }

      mav.setViewName("redirect:../user/home?state=1");
    } else {
      Dataset readyDataset = aDataset.toNoRelationalDataset();

      try {
        datasetService.store(readyDataset);
      } catch (Exception e) {
        logger.error("No se pudo agregar el dataset al store semántico");
        logger.error(e.getMessage(), e);
        mav.setViewName("redirect:../static/error");

        return mav;
      }

      mav.setViewName("redirect:../search/searchDataHome");
    }

    asyncResourceLength(aDataset, user.isAdmin());

    return mav;
  }