@Override
  @Transactional
  public Collection create(CollectionDetailsInfo collectionDetailsInfo, UserAccount user)
      throws Exception {

    String filteredTrack = collectionDetailsInfo.getTrack();

    if (!StringUtils.isEmpty(filteredTrack)) {
      filteredTrack = getFilteredTrack(filteredTrack);

      if (StringUtils.isEmpty(filteredTrack)) {
        return null;
      }
    }

    Collection collection = adaptCollectionDetailsInfoToCollection(collectionDetailsInfo, user);
    collection.setTrack(filteredTrack);
    collection.setUsageType(UsageType.Production);
    try {
      collectionRepository.save(collection);
      collaboratorService.addCollaboratorToCollection(
          collectionDetailsInfo.getCode(), user.getId());
      return collection;
    } catch (Exception e) {

      logger.error("Error in creating collection.", e);
      return null;
    }
  }
  private Collection adaptCollectionDetailsInfoToCollection(
      CollectionDetailsInfo collectionInfo, UserAccount user) {

    Collection collection = new Collection();
    collection.setDurationHours(collectionInfo.getDurationHours());
    collection.setCode(collectionInfo.getCode());
    collection.setName(collectionInfo.getName());
    collection.setClassifierEnabled(false);
    collection.setProvider(CollectionType.valueOf(collectionInfo.getProvider()));
    collection.setOwner(user);
    collection.setStatus(CollectionStatus.NOT_RUNNING);
    collection.setPubliclyListed(true); // TODO: change default behavior to user choice

    collection.setGeoR(collectionInfo.getGeoR());
    collection.setGeo(collectionInfo.getGeo());
    collection.setTrack(collectionInfo.getTrack());
    collection.setCrisisType(crisisTypeService.getById(collectionInfo.getCrisisType()));
    collection.setFollow(collectionInfo.getFollow());
    collection.setLangFilters(collectionInfo.getLangFilters());
    collection.setMicromappersEnabled(Boolean.FALSE);
    collection.setProvider(CollectionType.valueOf(collectionInfo.getProvider()));
    collection.setPurpose(collectionInfo.getPurpose());
    collection.setFetchInterval(collectionInfo.getFetchInterval());
    collection.setFetchFrom(collectionInfo.getFetchFrom());

    if (CollectionType.SMS.equals(collectionInfo.getProvider())) {
      collection.setTrack(null);
      collection.setLangFilters(null);
      collection.setGeo(null);
      collection.setFollow(null);
    }

    Timestamp now = new Timestamp(System.currentTimeMillis());
    collection.setCreatedAt(now);
    collection.setUpdatedAt(now);
    return collection;
  }