Java tutorial
/* * ==================================================================== * Copyright (c) 2005-2012 sventon project. All rights reserved. * * This software is licensed as described in the file LICENSE, which * you should have received as part of this distribution. The terms * are also available at http://www.sventon.org. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ package org.sventon.web.ctrl.template; import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; import org.sventon.SVNConnection; import org.sventon.model.DirEntry; import org.sventon.model.DirEntrySorter; import org.sventon.web.UserRepositoryContext; import org.sventon.web.command.BaseCommand; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; /** * Controller used when flatting directory structure. * * @author jesper@sventon.org */ public final class FlattenController extends AbstractTemplateController { @Override protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand command, final long headRevision, final UserRepositoryContext userRepositoryContext, final HttpServletRequest request, final HttpServletResponse response, final BindException exception) throws Exception { final List<DirEntry> entries = Collections.checkedList(new ArrayList<DirEntry>(), DirEntry.class); logger.debug("Flattening directories below: " + command.getPath()); entries.addAll(getCache().findDirectories(command.getName(), command.getPath())); logger.debug(entries.size() + " entries found"); final Map<String, Object> model = new HashMap<String, Object>(); logger.debug("Sort params: " + userRepositoryContext.getSortType().name() + ", " + userRepositoryContext.getSortMode()); new DirEntrySorter(userRepositoryContext.getSortType(), userRepositoryContext.getSortMode()).sort(entries); model.put("dirEntries", entries); model.put("isFlatten", true); // Indicates that path should be shown in browser view. return new ModelAndView(getViewName(), model); } }