package com.atlassian.stash.internal.web.mirror;

import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

@Controller
@RequestMapping("/mirror")
public class MirrorController {
    private static final Logger log = getLogger(MirrorController.class);

    private static final String PATH_PLACEHOLDER_PAGE = "/plugins/servlet/mirror-placeholder";

    @RequestMapping(method = GET)
    public String view() {
        // this should never get executed - the MirrorInterceptionFilter in the mirroring plugin should redirect to
        // PATH_PLACEHOLDER_PAGE first - this is here as a safeguard
        log.warn("Mirror interception filter did not forward to the placeholder page");
        return "forward:" + PATH_PLACEHOLDER_PAGE;
    }
}
