Commit d243a51b authored by Matija Obreza's avatar Matija Obreza

Admin actions

parent 8c1da1ea
package org.crophub.rest.servlet.controller;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.crophub.rest.common.service.GeoService;
import org.crophub.rest.common.service.InstituteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/admin")
public class AdminController {
public static final Log LOG = LogFactory.getLog(AdminController.class);
@Autowired
InstituteService instituteService;
@Autowired
GeoService geoService;
@RequestMapping("/")
public String root() {
return "/admin/index";
}
@RequestMapping("/refreshWiews")
public String refreshWiews() {
try {
instituteService.updateFaoInstitutes();
} catch (IOException e) {
LOG.error(e);
}
return "redirect:/admin/";
}
@RequestMapping("/refreshCountries")
public String refreshCountries() {
try {
geoService.updateCountryData();
} catch (final IOException e) {
LOG.error(e.getMessage(), e);
}
return "redirect:/admin/";
}
}
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<head>
<title><spring:message code="sample.message.index.title" /></title>
</head>
<body>
<sec:authorize access="hasRole('ADMINISTRATOR')">
<form method="post" action="<c:url value="/admin/refreshWiews" />">
<input type="submit" value="Refresh WIEWS data" />
</form>
<form method="post" action="<c:url value="/admin/refreshCountries" />">
<input type="submit" value="Refresh country data" />
</form>
</sec:authorize>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment