/*
 * Copyright 2000-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package jetbrains.buildServer.nuget.server.feed.server.tab;

import jetbrains.buildServer.RootUrlHolder;
import jetbrains.buildServer.controllers.AuthorizationInterceptor;
import jetbrains.buildServer.controllers.BaseController;
import jetbrains.buildServer.controllers.RequestPermissionsChecker;
import jetbrains.buildServer.nuget.server.feed.server.NuGetServerSettings;
import jetbrains.buildServer.nuget.server.toolRegistry.tab.PermissionChecker;
import jetbrains.buildServer.serverSide.ServerSettings;
import jetbrains.buildServer.serverSide.auth.AccessDeniedException;
import jetbrains.buildServer.serverSide.auth.AuthorityHolder;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.ModelAndView;

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

/**
 * @author Eugene Petrenko (eugene.petrenko@gmail.com)
 *         Date: 26.10.11 19:21
 */
public class FeedServerController extends BaseController {
  @NotNull private final FeedServerSettingsSection mySection;
  @NotNull private final PluginDescriptor myDescriptor;
  @NotNull private final NuGetServerSettings mySettings;
  @NotNull private final ServerSettings myServerSettings;
  @NotNull private final RootUrlHolder myRootUrlHolder;

  public FeedServerController(@NotNull final AuthorizationInterceptor auth,
                              @NotNull final PermissionChecker checker,
                              @NotNull final FeedServerSettingsSection section,
                              @NotNull final WebControllerManager web,
                              @NotNull final PluginDescriptor descriptor,
                              @NotNull final ServerSettings serverSettings,
                              @NotNull final NuGetServerSettings settings,
                              @NotNull final RootUrlHolder rootUrlHolder) {
    mySection = section;
    myDescriptor = descriptor;
    mySettings = settings;
    myServerSettings = serverSettings;
    myRootUrlHolder = rootUrlHolder;
    final String myPath = section.getIncludePath();

    auth.addPathBasedPermissionsChecker(myPath, new RequestPermissionsChecker() {
      public void checkPermissions(@NotNull AuthorityHolder authorityHolder, @NotNull HttpServletRequest request) throws AccessDeniedException {
        checker.assertAccess(authorityHolder);
      }
    });
    web.registerController(myPath, this);
  }

  @Override
  protected ModelAndView doHandle(@NotNull final HttpServletRequest request,
                                  @NotNull final HttpServletResponse response) throws Exception {
    final ModelAndView mv = new ModelAndView(myDescriptor.getPluginResourcesPath("server/feedServerSettingsWindows.jsp"));

    mv.getModel().put("actualServerUrl", myRootUrlHolder.getRootUrl());
    mv.getModel().put("nugetStatusRefreshUrl", mySection.getIncludePath());
    mv.getModel().put("nugetSettingsPostUrl", mySection.getSettingsPath());
    mv.getModel().put("privateFeedUrl", mySettings.getNuGetHttpAuthFeedControllerPath());
    mv.getModel().put("publicFeedUrl", mySettings.getNuGetGuestAuthFeedControllerPath());
    mv.getModel().put("serverEnabled", mySettings.isNuGetServerEnabled());
    mv.getModel().put("isGuestEnabled", myServerSettings.isGuestLoginAllowed());

    return mv;
  }
}

@@ -1073,65 +1073,8 @@
 r;%0D%0A
-import jetbrains.buildServer.serverSide.ServerSettings;%0D%0A
 impo
@@ -1193,32 +1193,98 @@
 thorityHolder;%0D%0A
+import jetbrains.buildServer.serverSide.auth.LoginConfiguration;%0D%0A
 import jetbrains
@@ -1953,39 +1953,47 @@
 nal 
-ServerSettings myServerSettings
+LoginConfiguration myLoginConfiguration
 ;%0D%0A 
@@ -2477,37 +2477,45 @@
 nal 
-ServerSettings serverSettings
+LoginConfiguration loginConfiguration
 ,%0D%0A 
@@ -2762,39 +2762,47 @@
   my
-ServerSettings = serverSettings
+LoginConfiguration = loginConfiguration
 ;%0D%0A 
@@ -4081,30 +4081,34 @@
 led%22, my
-ServerSettings
+LoginConfiguration
 .isGuest

fix compilation