Package su.mauser

Source Code of su.mauser.Moview

package su.mauser;

import java.io.IOException;
import java.net.UnknownHostException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import spark.Spark;
import su.mauser.interfaces.IDBStatus.DBStatus;
import su.mauser.router.Router;

import com.mongodb.DB;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;

/**
* The home movie collection DB program
*
*/
public class Moview
{

  public static void main(String[] args) throws UnknownHostException
  {
    Logger logger = LoggerFactory.getLogger(Moview.class);

    DBStatus connectionStatus = DBStatus.UNKNOWN;

    // checking the DB connection
    Mongo mongo = new Mongo();
    try
    {
      mongo.getConnector().getDBPortPool(mongo.getAddress()).get().ensureOpen();
      connectionStatus = DBStatus.CONNECTED;

    }
    catch (IOException e)
    {
      logger.error("No database connection!");
      connectionStatus = DBStatus.DISCONNECTED;
    }

    Router router = new Router(connectionStatus);

    MongoClient client = new MongoClient(new ServerAddress("localhost", 27017));

    DB db = client.getDB("moview");

    Spark.get(router.getStartPage());

    // Добавление нового фильма. Только название фильма.
    Spark.post(router.getInsertFilmPage(db));

    Spark.get(router.getSelectPage(db));
    Spark.post(router.getSelectPage(db));

    // Редактирование данных фильма
    Spark.post(router.getEditFilmPage(db));

    Spark.post(router.getEditActorPage(db));

    Spark.post(router.getRemovePage(db));

    Spark.get(router.getListPage(db));
    Spark.post(router.getListPage(db));

    // Получение информации по фильму через AJAX.
    Spark.post(router.getFilmInfo(db));

    Spark.get(router.getActorsPage(db));

    // Получение короткого списка актеров для редактирования фильма по AJAX.
    Spark.post(router.getActorsShortList(db));

    Spark.get(router.getInsertActorsPage(db));
    Spark.post(router.getInsertActorsPage(db));
    Spark.post(router.getRemoveActor(db));

    Spark.get(router.getMissingPage());

    Spark.get(router.getDBConnectionErrorPage());
  }
}
TOP

Related Classes of su.mauser.Moview

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.