/*
 * Copyright (C) 2018 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.frontend.web.base.logic.view;

import org.jbb.system.api.install.InstallationService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

import lombok.RequiredArgsConstructor;

@Component
@Order(2)
@RequiredArgsConstructor
public class PreInstallationViewStrategy extends ReplacingViewStrategy {

    private final InstallationService installationService;

    @Override
    boolean canHandle(ModelAndView modelAndView) {
        return !installationService.isInstalled() && !"install".equals(modelAndView.getViewName())
                && !"swagger".equals(modelAndView.getViewName());
    }

    @Override
    void performHandle(ModelAndView modelAndView) {
        boolean requestUrlExists = modelAndView.getModel().containsKey("requestURL");
        if (requestUrlExists) {
            String requestUrl = (String) modelAndView.getModel().get("requestURL");
            if (requestUrl.endsWith("/install")) {
                modelAndView.setViewName("install");
                return;
            }
        }
        modelAndView.setViewName("redirect:/install");

    }
}

@@ -318,24 +318,61 @@
 ogic.view;%0A%0A
+import org.jbb.lib.mvc.PathResolver;%0A
 import org.j
@@ -414,16 +414,16 @@
 ervice;%0A
-
 import o
@@ -785,16 +785,61 @@
 Service;
+%0A    private final PathResolver pathResolver;
 %0A%0A    @O
@@ -1147,237 +1147,65 @@
     
-boolean requestUrlExists = modelAndView.getModel().containsKey(%22requestURL%22);%0A        if (requestUrlExists) %7B%0A            String requestUrl = (String) modelAndView.getModel().get(%22requestURL%22);%0A            if (requestUrl.endsWith
+if (pathResolver.getRequestPathWithinApplication().equals
 (%22/i
@@ -1212,28 +1212,24 @@
 nstall%22)) %7B%0A
-    
             
@@ -1277,48 +1277,21 @@
     
-        return;%0A            %7D%0A        %7D%0A
+%7D else %7B%0A    
     
@@ -1341,16 +1341,25 @@
 tall%22);%0A
+        %7D
 %0A    %7D%0A%7D

Use path resolver in PreInstallationViewStrategy