/**
* PODD is an OWL ontology database used for scientific project management
*
* Copyright (C) 2009-2013 The University Of Queensland
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.podd.resources;
import java.util.Map;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
import org.restlet.security.User;
import com.github.podd.restlet.RestletUtils;
import com.github.podd.utils.PoddWebConstants;
/**
*
* Attempt at serving a simple non-authenticated page
*
* @author kutila
*
*/
public class IndexResourceImpl extends AbstractPoddResourceImpl
{
@Get
public Representation getIndexPageHtml(final Representation entity) throws ResourceException
{
// Enable either of the following to test authenticated access
// this.getPoddApplication().authenticate(PoddAction.ROLE_EDIT,
// getRequest(),
// getResponse());
// this.checkAuthentication(PoddAction.ROLE_EDIT);
this.log.info("getIndexPageHtml");
final User user = this.getRequest().getClientInfo().getUser();
this.log.info("authenticated user: {}", user);
final Map<String, Object> dataModel = RestletUtils.getBaseDataModel(this.getRequest());
dataModel.put("contentTemplate", "index.html.ftl");
dataModel.put("pageTitle", "PODD Index Page");
// Output the base template, with contentTemplate from the dataModel
// defining the
// template to use for the content in the body of the page
return RestletUtils.getHtmlRepresentation(
this.getPoddApplication().getPropertyUtil()
.get(PoddWebConstants.PROPERTY_TEMPLATE_BASE, PoddWebConstants.DEFAULT_TEMPLATE_BASE),
dataModel, MediaType.TEXT_HTML, this.getPoddApplication().getTemplateConfiguration());
}
}