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

import com.imcode.imcms.api.TextDocument;
import com.imcode.imcms.api.TextDocumentViewing;
import imcode.server.ImcmsConstants;
import imcode.server.parser.ParserParameters;
import imcode.util.Utility;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

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

/**
 * Created by <NAME> from Ubrainians for imCode
 * 18.09.17.
 */
@Controller
@RequestMapping("/viewDoc")
public class ViewDocumentController {

    @RequestMapping("/")
    public ModelAndView goToStartPage(HttpServletRequest request, HttpServletResponse response, ModelAndView mav) {
        return processDocView(String.valueOf(ImcmsConstants.DEFAULT_START_DOC_ID), request, response, mav);
    }

    @RequestMapping("/{docIdentifier}")
    public ModelAndView getDocument(@PathVariable("docIdentifier") String docIdentifier, HttpServletRequest request,
                                    HttpServletResponse response, ModelAndView mav) {

        return processDocView(docIdentifier, request, response, mav);
    }

    private ModelAndView processDocView(String docIdentifier, HttpServletRequest request, HttpServletResponse response,
                                        ModelAndView mav) {

        final TextDocument textDocument = Utility.getCMS(request)
                .getDocumentService()
                .getTextDocument(docIdentifier);

        // save doc data

        // this should be done to use tags functionality on page
        ParserParameters parserParameters = new ParserParameters(textDocument.getInternal(), request, response);
        TextDocumentViewing.putInRequest(new TextDocumentViewing(parserParameters));
        ParserParameters.putInRequest(parserParameters);

        // add if edit mode
//        parserParameters.setFlags(PERM_EDIT_DOCUMENT);

        final String viewName = textDocument.getTemplate().getName();
        mav.setViewName(viewName);

        mav.addObject("currentDocId", textDocument.getId());

        return mav;
    }
}<commit_msg>IMCMS-233 - Apply new UI to the admin panel and editors: - Setting current document to model.<commit_after>package com.imcode.imcms.controller;

import com.imcode.imcms.api.TextDocument;
import com.imcode.imcms.api.TextDocumentViewing;
import imcode.server.ImcmsConstants;
import imcode.server.parser.ParserParameters;
import imcode.util.Utility;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

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

/**
 * Created by <NAME> from Ubrainians for imCode
 * 18.09.17.
 */
@Controller
@RequestMapping("/viewDoc")
public class ViewDocumentController {

    @RequestMapping("/")
    public ModelAndView goToStartPage(HttpServletRequest request, HttpServletResponse response, ModelAndView mav) {
        return processDocView(String.valueOf(ImcmsConstants.DEFAULT_START_DOC_ID), request, response, mav);
    }

    @RequestMapping("/{docIdentifier}")
    public ModelAndView getDocument(@PathVariable("docIdentifier") String docIdentifier, HttpServletRequest request,
                                    HttpServletResponse response, ModelAndView mav) {

        return processDocView(docIdentifier, request, response, mav);
    }

    private ModelAndView processDocView(String docIdentifier, HttpServletRequest request, HttpServletResponse response,
                                        ModelAndView mav) {

        final TextDocument textDocument = Utility.getCMS(request)
                .getDocumentService()
                .getTextDocument(docIdentifier);

        // save doc data

        // this should be done to use tags functionality on page
        ParserParameters parserParameters = new ParserParameters(textDocument.getInternal(), request, response);
        TextDocumentViewing.putInRequest(new TextDocumentViewing(parserParameters));
        ParserParameters.putInRequest(parserParameters);

        // add if edit mode
//        parserParameters.setFlags(PERM_EDIT_DOCUMENT);

        final String viewName = textDocument.getTemplate().getName();
        mav.setViewName(viewName);

        mav.addObject("currentDocument", textDocument);

        return mav;
    }
}
{'fraction_non_alphanumeric': 0.08554763447828904, 'fraction_numerical': 0.0032404406999351912, 'mean_word_length': 3.753593429158111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6817333', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1145, 'n_words': 254}