Package com.itstherules.mediacentre.controller

Source Code of com.itstherules.mediacentre.controller.Mp3Controller

package com.itstherules.mediacentre.controller;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import com.itstherules.mediacentre.Extension;
import com.itstherules.mediacentre.model.FileMp3Converter;
import com.itstherules.mediacentre.model.RecursiveItemsList;
import com.itstherules.stream.model.DirectoriesModel;
import com.itstherules.stream.model.Mp3Genres;
import com.itstherules.stream.model.Mp3;
import com.itstherules.stream.model.ParameterBasedMp3;

public class Mp3Controller extends BaseController {

  @Override
  public void list(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
    List<File> values = new RecursiveItemsList("music", Extension.mp3.toString()).values();
    parameters.put("items", new FileMp3Converter().convert(values));
    merge("mp3/list.freemarker", parameters, response.getWriter());
  }
 
  @Override
  public void show(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
    String fileName = (String) parameters.get("fileName");
    parameters.put("mp3", new Mp3(new File(new DirectoriesModel("music").getDirectoryPath() + fileName)));
    merge("mp3/show.freemarker", parameters, response.getWriter());
  }
 
  @Override
  public void edit(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
    String fileName = (String) parameters.get("fileName");
    parameters.put("mp3", new Mp3(new File(new DirectoriesModel("music").getDirectoryPath()+fileName)));
    parameters.put("genres", new Mp3Genres().asList());
    merge("mp3/edit.freemarker", parameters, response.getWriter());
  }
 
  @Override
  public void update(Map<String, Object> parameters, HttpServletResponse response) throws IOException {
    ParameterBasedMp3 parameterBasedMp3 = new ParameterBasedMp3(parameters);
    parameterBasedMp3.persist(new DirectoriesModel("music").getDirectoryPath());
    response.sendRedirect("../show/index.html?fileName="+parameters.get("full"));
  }
 
}
TOP

Related Classes of com.itstherules.mediacentre.controller.Mp3Controller

TOP
Copyright © 2018 www.massapi.com. 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.