HomeController.java

  1. /*
  2.  * Copyright (C) 2011-2014 eXo Platform SAS.
  3.  *
  4.  * This file is part of eXo Acceptance Webapp.
  5.  *
  6.  * eXo Acceptance Webapp is free software; you can redistribute it and/or modify it
  7.  * under the terms of the GNU Lesser General Public License as
  8.  * published by the Free Software Foundation; either version 3 of
  9.  * the License, or (at your option) any later version.
  10.  *
  11.  * eXo Acceptance Webapp software is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with eXo Acceptance Webapp; if not, write to the Free
  18.  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19.  * 02110-1301 USA, or see <http://www.gnu.org/licenses/>.
  20.  */
  21. package org.exoplatform.acceptance.ui.controllers;


  22. import static org.apache.http.HttpStatus.SC_FORBIDDEN;

  23. import com.google.common.base.Strings;
  24. import javax.inject.Inject;
  25. import juzu.Action;
  26. import juzu.Path;
  27. import juzu.Response;
  28. import juzu.Route;
  29. import juzu.View;
  30. import juzu.plugin.asset.Assets;

  31. /**
  32.  * <p>HomeController class.</p>
  33.  *
  34.  * @author Arnaud Héritier ( aheritier@exoplatform.com )
  35.  * @since 2.0.0
  36.  */
  37. public class HomeController extends BaseController {

  38.   /**
  39.    * Application homepage
  40.    */
  41.   @Inject
  42.   @Path("index.gtmpl")
  43.   private org.exoplatform.acceptance.ui.templates.index index;

  44.   /**
  45.    * Sources list page
  46.    */
  47.   @Inject
  48.   @Path("sources.gtmpl")
  49.   private org.exoplatform.acceptance.ui.templates.sources sources;

  50.   /**
  51.    * Build jobs list page
  52.    */
  53.   @Inject
  54.   @Path("buildjobs.gtmpl")
  55.   private org.exoplatform.acceptance.ui.templates.buildjobs buildjobs;

  56.   /**
  57.    * Deployments list page
  58.    */
  59.   @Inject
  60.   @Path("deployments.gtmpl")
  61.   private org.exoplatform.acceptance.ui.templates.deployments deployments;

  62.   /**
  63.    * Forbidden access page (403)
  64.    */
  65.   @Inject
  66.   @Path("error403.gtmpl")
  67.   private org.exoplatform.acceptance.ui.templates.error403 error403;

  68.   /**
  69.    * Application homepage route
  70.    *
  71.    * @param error a {@link java.lang.String} object.
  72.    * @return a {@link juzu.Response.Content} object.
  73.    */
  74.   @View
  75.   @Route("/")
  76.   public Response.Content index(String error) {
  77.     if (!Strings.isNullOrEmpty(error)) {
  78.       getFlash().setError("Erroneous username or password !");
  79.     }
  80.     return makeResponse(index);
  81.   }

  82.   /**
  83.    * Sources list page
  84.    *
  85.    * @return a {@link juzu.Response.Content} object.
  86.    */
  87.   @View
  88.   @Route("/sources")
  89.   @Assets({"sources.js"})
  90.   public Response.Content sources() {
  91.     return makeResponse(sources);
  92.   }

  93.   /**
  94.    * Build jobs list page
  95.    *
  96.    * @return a {@link juzu.Response.Content} object.
  97.    */
  98.   @View
  99.   @Route("/buildjobs")
  100.   public Response.Content buildjobs() {
  101.     return makeResponse(buildjobs);
  102.   }

  103.   /**
  104.    * Deployments list route
  105.    *
  106.    * @return a {@link juzu.Response.Content} object.
  107.    */
  108.   @View
  109.   @Route("/deployments")
  110.   public Response.Content deployments() {
  111.     return makeResponse(deployments);
  112.   }

  113.   /**
  114.    * Login page
  115.    * fake method for juzu template compilation (ex: @{HomeController.login()}
  116.    * this url is catch up by the spring security filter and the action method is never call
  117.    */
  118.   @Action
  119.   @Route("/login")
  120.   public void login() {
  121.   }

  122.   /**
  123.    * Logout page
  124.    * fake method for juzu template compilation (ex: @{HomeController.logout()}
  125.    * this url is catch up by the spring security filter and the action method is never call
  126.    */
  127.   @Action
  128.   @Route("/logout")
  129.   public void logout() {
  130.   }

  131.   /**
  132.    * Forbidden access route
  133.    *
  134.    * @return a {@link juzu.Response.Content} object.
  135.    */
  136.   @View
  137.   @Route("/403")
  138.   public Response.Content error403() {
  139.     return makeResponse(error403.with().status(SC_FORBIDDEN));
  140.   }

  141. }