| | |
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | |
|
| | | import javax.inject.Inject;
|
| | | import javax.inject.Singleton;
|
| | | import javax.servlet.ServletException;
|
| | | import javax.servlet.http.HttpServlet;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.gitblit.manager.IRuntimeManager;
|
| | | import com.gitblit.utils.FileUtils;
|
| | |
|
| | | /**
|
| | |
| | | * @author James Moger
|
| | | *
|
| | | */
|
| | | @Singleton
|
| | | public class RobotsTxtServlet extends HttpServlet {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public RobotsTxtServlet() {
|
| | | private final IRuntimeManager runtimeManager;
|
| | |
|
| | | @Inject
|
| | | public RobotsTxtServlet(IRuntimeManager runtimeManager) {
|
| | | super();
|
| | | this.runtimeManager = runtimeManager;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | protected void processRequest(javax.servlet.http.HttpServletRequest request,
|
| | | javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,
|
| | | java.io.IOException {
|
| | | File file = GitBlit.getFileOrFolder(Keys.web.robots.txt, null);
|
| | | File file = runtimeManager.getFileOrFolder(Keys.web.robots.txt, null);
|
| | | String content = "";
|
| | | if (file.exists()) {
|
| | | content = FileUtils.readContent(file, "\n");
|