StoppingDownMediaServerService.java

  1. /*
  2.  * *********************************************************************************************************************
  3.  *
  4.  * blueMarine II: Semantic Media Centre
  5.  * http://tidalwave.it/projects/bluemarine2
  6.  *
  7.  * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
  8.  *
  9.  * *********************************************************************************************************************
  10.  *
  11.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  12.  * the License. You may obtain a copy of the License at
  13.  *
  14.  *     http://www.apache.org/licenses/LICENSE-2.0
  15.  *
  16.  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  17.  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  18.  * specific language governing permissions and limitations under the License.
  19.  *
  20.  * *********************************************************************************************************************
  21.  *
  22.  * git clone https://bitbucket.org/tidalwave/bluemarine2-src
  23.  * git clone https://github.com/tidalwave-it/bluemarine2-src
  24.  *
  25.  * *********************************************************************************************************************
  26.  */
  27. package it.tidalwave.bluemarine2.service.stoppingdown.impl;

  28. import javax.annotation.Nonnull;
  29. import javax.inject.Inject;
  30. import javax.inject.Named;
  31. import java.util.List;
  32. import java.util.Collection;
  33. import java.nio.file.Path;
  34. import java.nio.file.Paths;
  35. import it.tidalwave.bluemarine2.model.MediaFolder;
  36. import it.tidalwave.bluemarine2.model.VirtualMediaFolder;
  37. import it.tidalwave.bluemarine2.model.spi.PathAwareEntity;
  38. import it.tidalwave.bluemarine2.mediaserver.spi.MediaServerService;

  39. /***********************************************************************************************************************
  40.  *
  41.  * @author  Fabrizio Giudici
  42.  *
  43.  **********************************************************************************************************************/
  44. public class StoppingDownMediaServerService implements MediaServerService
  45.   {
  46.     private static final Path PATH_ROOT = Paths.get("stoppingdown.net");

  47.     private static final Path PATH_DIARY = Paths.get("diary");

  48.     private static final Path PATH_THEMES = Paths.get("themes");

  49.     @Inject @Named("diaryPhotoCollectionProvider")
  50.     private PhotoCollectionProvider diaryProvider;

  51.     @Inject @Named("themesPhotoCollectionProvider")
  52.     private PhotoCollectionProvider themesProvider;

  53.     @Override @Nonnull
  54.     public MediaFolder createRootFolder (@Nonnull final MediaFolder parent)
  55.       {
  56.         return new VirtualMediaFolder(parent, PATH_ROOT, "Stopping Down", this::childrenFactory);
  57.       }

  58.     @Nonnull
  59.     private Collection<PathAwareEntity> childrenFactory (@Nonnull final MediaFolder parent)
  60.       {
  61.         return List.of(new VirtualMediaFolder(parent, PATH_DIARY,  "Diary",  diaryProvider::findPhotos),
  62.                        new VirtualMediaFolder(parent, PATH_THEMES, "Themes", themesProvider::findPhotos));
  63.       }
  64.   }