public String getCourses(Principal currentUser, Model model, Locale locale,
@RequestParam(defaultValue="1", required=false) Integer page,
@RequestParam(defaultValue="", required=false) String order) {
try {
String ordering = order != null && !("").equals(order) ? order : "title";
Provider provider =
this.serviceLocator.getTransversalService().getProviderByUserName(currentUser.getName(), locale);
model.addAttribute("provider", provider);
PageManager<Course> paginator = new PageManager<Course>();
paginator.setOffset(this.getPageSize());
paginator.setUrlBase("/" + locale.getLanguage() +
"/dashboard/mediator/catalog/courses");
paginator.setStart((page-1)*paginator.getOffset());
paginator.setSize(this.serviceLocator.getCourseService().countCoursesByProvider(provider.getId()));
paginator.setCollection(this.serviceLocator.getCourseService().getCoursesByProvider(provider.getId(),
ordering, locale, paginator.getStart(), paginator.getEnd()));
model.addAttribute("paginator", paginator);
model.addAttribute("order", ordering);
} catch(Exception e) {
LOGGER.severe(StackTraceUtil.getStackTrace(e));