001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * mcedica 018 */ 019package org.nuxeo.ecm.webengine.management; 020 021import javax.ws.rs.GET; 022import javax.ws.rs.Path; 023import javax.ws.rs.Produces; 024import javax.ws.rs.WebApplicationException; 025import javax.ws.rs.core.Response; 026 027import org.apache.commons.logging.Log; 028import org.apache.commons.logging.LogFactory; 029import org.nuxeo.ecm.webengine.management.statuses.StatusesObject; 030import org.nuxeo.ecm.webengine.model.WebObject; 031import org.nuxeo.ecm.webengine.model.exceptions.WebSecurityException; 032import org.nuxeo.ecm.webengine.model.impl.ModuleRoot; 033 034/** 035 * Web object implementation corresponding to the root module for management (module used for administrative purpose). 036 * 037 * @author mcedica 038 */ 039@Path("/mgmt") 040@WebObject(type = "Management") 041@Produces("text/html; charset=UTF-8") 042public class ManagementModule extends ModuleRoot { 043 044 @SuppressWarnings("unused") 045 private static final Log log = LogFactory.getLog(ManagementModule.class); 046 047 @GET 048 public Object doGet() { 049 return getView("index"); 050 } 051 052 @Path("statuses") 053 public Object dispatchStatuses() { 054 return StatusesObject.newObject(this); 055 } 056 057 @Override 058 public Object handleError(WebApplicationException e) { 059 if (e instanceof WebSecurityException) { 060 return Response.status(401).entity(getTemplate("error_401.ftl")).type("text/html").build(); 061 } 062 return super.handleError(e); 063 } 064 065}