private void addOrUpdateDataset() throws RestServiceException {
      String accountName = null;
      String containerName = null;
      String datasetName = null;
      try {
        // version schema and expiration time has to be provided during dataset creation.
        if (!RestUtils.isDatasetUpdate(restRequest.getArgs())) {
          if (datasetToUpdate.getVersionSchema() == null) {
            throw new RestServiceException("Version schema can't be null for dataset creation",
                RestServiceErrorCode.BadRequest);
          }
        }
        datasetName = datasetToUpdate.getDatasetName();
        accountName = datasetToUpdate.getAccountName();
        containerName = datasetToUpdate.getContainerName();
        if (RestUtils.isDatasetUpdate(restRequest.getArgs())) {
          accountService.updateDataset(datasetToUpdate);
        } else {
          accountService.addDataset(datasetToUpdate);
        }
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_ACCOUNT_NAME, accountName);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_CONTAINER_NAME, containerName);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_DATASET_NAME, datasetName);
      } catch (AccountServiceException ex) {
        logger.error(
            "Dataset update failed for accountName " + accountName + " containerName " + containerName + " datasetName "
                + datasetName);
        throw new RestServiceException(ex.getMessage(),
            RestServiceErrorCode.getRestServiceErrorCode(ex.getErrorCode()));
      }
    }
Process the request json and call {@link AccountService#addDataset} or {@link AccountService#updateDataset}
to add or update the dataset.
@throws RestServiceException
ambry-frontend/src/main/java/com/github/ambry/frontend/PostDatasetsHandler.java