<commit_before>package com.imcode.imcms.controller.core;

import com.imcode.imcms.domain.service.VersionService;
import com.imcode.imcms.persistence.entity.Version;
import com.imcode.imcms.servlet.DocumentHistory;
import imcode.util.Utility;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/editDoc")
public class EditDocumentController {

    private static final String PARAMETER__META_ID = "meta_id";

    private final VersionService versionService;

    EditDocumentController(final VersionService versionService) {
        this.versionService = versionService;
    }

    @RequestMapping({"", "/"})
    public void editDocument(HttpServletRequest request, HttpServletResponse response) throws Exception {
        final int metaId = Integer.parseInt(request.getParameter(PARAMETER__META_ID));

        final Version documentWorkingVersion = versionService.findWorking(metaId);

        if (documentWorkingVersion == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        Utility.setDefaultHtmlContentType(response);
        DocumentHistory.from(request.getSession()).pushIfNotYet(metaId);

        request.setAttribute("isEditMode", "true");

        request.getRequestDispatcher("/api/viewDoc/" + metaId).forward(request, response);
    }
}<commit_msg>IMCMS-316: Page /servlet/ListDocuments doesn't work properly: - Handled file and url types in ListDocuments.<commit_after>package com.imcode.imcms.controller.core;

import com.imcode.imcms.domain.service.DelegatingByTypeDocumentService;
import com.imcode.imcms.domain.service.VersionService;
import com.imcode.imcms.model.Document;
import com.imcode.imcms.servlet.DocumentHistory;
import imcode.util.Utility;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/editDoc")
public class EditDocumentController {

    private static final String PARAMETER__META_ID = "meta_id";

    private final VersionService versionService;
    private final DelegatingByTypeDocumentService documentService;

    EditDocumentController(final VersionService versionService,
                           final DelegatingByTypeDocumentService documentService) {

        this.versionService = versionService;
        this.documentService = documentService;
    }

    @RequestMapping({"", "/"})
    public void editDocument(HttpServletRequest request, HttpServletResponse response) throws Exception {

        final int metaId = Integer.parseInt(request.getParameter(PARAMETER__META_ID));

        if (versionService.findWorking(metaId) == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        Utility.setDefaultHtmlContentType(response);                        // not sure it's still needed
        DocumentHistory.from(request.getSession()).pushIfNotYet(metaId);    // not sure it's still needed

        final Document document = documentService.get(metaId);

        switch (document.getType()) {
            case TEXT: {
                request.setAttribute("isEditMode", "true");
                request.getRequestDispatcher("/api/viewDoc/" + metaId).forward(request, response);
                return;
            }
            case URL:
            case FILE:
                response.sendRedirect(request.getContextPath() + "/api/admin/page-info?meta-id=" + metaId);
        }
    }
}
{'fraction_non_alphanumeric': 0.09352324643912927, 'fraction_numerical': 0.0008062348830959419, 'mean_word_length': 3.681761006289308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '681357', 'n_tokens_mistral': 979, 'n_tokens_neox': 951, 'n_words': 179}