Package net.pterodactylus.sone.data

Examples of net.pterodactylus.sone.data.Album


   */
  @Override
  public Object get(TemplateContext templateContext, Object object, String member) {
    Image image = (Image) object;
    if ("next".equals(member)) {
      Album album = image.getAlbum();
      int imagePosition = album.getImages().indexOf(image);
      if (imagePosition < album.getImages().size() - 1) {
        return album.getImages().get(imagePosition + 1);
      }
      return null;
    } else if ("previous".equals(member)) {
      Album album = image.getAlbum();
      int imagePosition = album.getImages().indexOf(image);
      if (imagePosition > 0) {
        return album.getImages().get(imagePosition - 1);
      }
      return null;
    }
    return super.get(templateContext, object, member);
  }
View Full Code Here


  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      String albumId = request.getHttpRequest().getPartAsStringFailsafe("album", 36);
      Album album = webInterface.getCore().getAlbum(albumId, false);
      if (album == null) {
        throw new RedirectException("invalid.html");
      }
      if (!album.getSone().isLocal()) {
        throw new RedirectException("noPermission.html");
      }
      if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveLeft", 4))) {
        album.getParent().moveAlbumUp(album);
        webInterface.getCore().touchConfiguration();
        throw new RedirectException("imageBrowser.html?album=" + album.getParent().getId());
      } else if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveRight", 4))) {
        album.getParent().moveAlbumDown(album);
        webInterface.getCore().touchConfiguration();
        throw new RedirectException("imageBrowser.html?album=" + album.getParent().getId());
      }
      String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36);
      if (webInterface.getCore().getImage(albumImageId, false) == null) {
        albumImageId = null;
      }
      album.modify().setAlbumImage(albumImageId).update();
      String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim();
      if (title.length() == 0) {
        templateContext.set("titleMissing", true);
        return;
      }
      String description = request.getHttpRequest().getPartAsStringFailsafe("description", 1000).trim();
      album.modify().setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).update();
      webInterface.getCore().touchConfiguration();
      throw new RedirectException("imageBrowser.html?album=" + album.getId());
    }
  }
View Full Code Here

  private final MemoryDatabase memoryDatabase = new MemoryDatabase(null, null);

  @Test
  public void testBasicAlbumFunctionality() {
    Album newAlbum = new AlbumImpl();
    assertThat(memoryDatabase.getAlbum(newAlbum.getId()), is(Optional.<Album>absent()));
    memoryDatabase.storeAlbum(newAlbum);
    assertThat(memoryDatabase.getAlbum(newAlbum.getId()), is(of(newAlbum)));
    memoryDatabase.removeAlbum(newAlbum);
    assertThat(memoryDatabase.getAlbum(newAlbum.getId()), is(Optional.<Album>absent()));
  }
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.data.Album

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.