Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see org.opengeoportal.harvester.api.service.IngestService#save(
   * org.opengeoportal .harvester.api.domain.Ingest, java.lang.Long,
   * org.opengeoportal.harvester.api.domain.InstanceType)
   */
  @Override
  @Transactional(readOnly = false)
  public Ingest save(Ingest ingest, Long customRepositoryId, InstanceType customRepoInstanceType) {
    CustomRepository cRepository = customRepositoryService.findById(customRepositoryId);
    if (cRepository == null || cRepository.getServiceType() != customRepoInstanceType) {
      throw new InstanceNotFoundException(
          "There is not any CustomRepository with id = "
              + customRepositoryId
              + " and serviceType = "
              + customRepoInstanceType.name());
    }

    ingest.setRepository(cRepository);
    Ingest result;
    if (ingest instanceof IngestOGP) {
      result = saveAndUpdateServerQuery(ingest);
    } else {
      result = ingestRepository.save(ingest);
    }

    return result;
  }