package no.dusken.aranea.web.control;
import no.dusken.aranea.model.Person;
import no.dusken.aranea.model.Role;
import no.dusken.aranea.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author Benjamin Bj�rnseth <benjamin@underdusken.no>
*/
@Controller
public class FooterController {
private RoleService roleService;
private final String footerViewLocation = "no/dusken/aranea/base/common/footer";
@RequestMapping("/footer.do")
public String getFooterView(Model model) {
Role editor = roleService.getRolesByName("Ansvarlig redakt\u00f8r");
Role netEditor = roleService.getRolesByName("Nettredakt\u00f8r");
if (!(editor == null || editor.getPersons() == null || editor.getPersons().isEmpty())) {
model.addAttribute("ansred", editor.getPersons().iterator().next());
}
if (!(netEditor == null || netEditor.getPersons() == null || netEditor.getPersons().isEmpty())) {
model.addAttribute("netred", netEditor.getPersons().iterator().next());
}
return footerViewLocation;
}
@Autowired
public void setRoleService(RoleService roleService) {
this.roleService = roleService;
}
}