// Path: sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/manager/SQSInfo.java
// public interface SQSInfo {
//     @Nullable
//     String getUrl();
// 
//     boolean isTokenLoginUsed();
// 
//     @Nullable
//     String getToken();
// 
//      @Nullable
//     String getLogin();
// 
//      @Nullable
//     String getPassword();
// 
//     @Nullable
//     String getJDBCUrl();
// 
//     @Nullable
//     String getJDBCUsername();
// 
//     @Nullable
//     String getJDBCPassword();
// 
//     @NotNull
//     String getId();
// 
//     @Nullable
//     String getName();
// 
//     @Nullable
//     String getDescription();
// 
//     @NotNull
//     Map<String, String> getParameters();
// }
// 
// Path: sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/manager/SQSManager.java
// public interface SQSManager {
//     @NotNull
//     List<SQSInfo> getAvailableServers(@NotNull final SProject project);
// 
//     @NotNull
//     List<SQSInfo> getOwnAvailableServers(@NotNull final SProject project);
// 
//     @Nullable
//     SQSInfo getServer(@NotNull final SProject project, @NotNull String serverId);
// 
//     @Nullable
//     SQSInfo getOwnServer(@NotNull final SProject project, @NotNull String serverId);
// 
//     @NotNull
//     SQSActionResult editServer(@NotNull final SProject project, @NotNull final SQSInfo sqsInfo);
// 
//     @NotNull
//     SQSActionResult addServer(@NotNull final SProject project, @NotNull final SQSInfo sqsInfo);
// 
//     @NotNull
//     SQSActionResult removeServer(@NotNull final SProject project, @NotNull final String serverId);
// 
//     @NotNull
//     String getDescription();
// 
//     class SQSActionResult {
//         final SQSInfo myBeforeAction;
//         final SQSInfo myAfterAction;
//         final String myReason;
//         final boolean myIsError;
// 
//         public SQSActionResult(@Nullable final SQSInfo beforeAction, @Nullable final SQSInfo afterAction, @NotNull final String reason) {
//             this(beforeAction, afterAction, reason, false);
//         }
// 
//         public SQSActionResult(@Nullable final SQSInfo beforeAction, @Nullable final SQSInfo afterAction, @NotNull final String reason, final boolean isError) {
//             myBeforeAction = beforeAction;
//             myAfterAction = afterAction;
//             myReason = reason;
//             myIsError = isError;
//         }
// 
//         public SQSInfo getBeforeAction() {
//             return myBeforeAction;
//         }
// 
//         public SQSInfo getAfterAction() {
//             return myAfterAction;
//         }
// 
//         public String getReason() {
//             return myReason;
//         }
// 
//         public boolean isError() {
//             return myIsError;
//         }
//     }
// }


import jetbrains.buildServer.controllers.admin.projects.EditProjectTab;
import jetbrains.buildServer.serverSide.SProject;
import jetbrains.buildServer.serverSide.auth.AuthUtil;
import jetbrains.buildServer.serverSide.auth.SecurityContext;
import jetbrains.buildServer.web.openapi.PagePlaces;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildserver.sonarplugin.manager.SQSInfo;
import jetbrains.buildserver.sonarplugin.manager.SQSManager;
import org.jetbrains.annotations.NotNull;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
    }

    @NotNull
    @Override
    public String getTabTitle(@NotNull final HttpServletRequest request) {
        final SProject currentProject = getProject(request);
        if (currentProject == null) {
            return TAB_TITLE;
        }
        final List<SQSInfo> availableServers = mySqsManager.getOwnAvailableServers(currentProject);
        if (availableServers.isEmpty()) {
            return TAB_TITLE;
        }
        return TAB_TITLE + " (" + availableServers.size() + ")";
    }

    @Override
    public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
        final SProject currentProject = getProject(request);
        if (currentProject == null) {
            return;
        }
        Map<SProject, List<SQSInfo>> infoMap = getServersMap(currentProject);
        model.put("availableServersMap", infoMap);
        model.put("projectId", currentProject.getExternalId());
        model.put("userHasPermissionManagement", AuthUtil.hasPermissionToManageProject(securityContext.getAuthorityHolder(), currentProject.getProjectId()));
    }

    private Map<SProject, List<SQSInfo>> getServersMap(@NotNull final SProject currentProject) {
        SProject project = currentProject;
// Path: sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/manager/SQSInfo.java
// public interface SQSInfo {
//     @Nullable
//     String getUrl();
// 
//     boolean isTokenLoginUsed();
// 
//     @Nullable
//     String getToken();
// 
//      @Nullable
//     String getLogin();
// 
//      @Nullable
//     String getPassword();
// 
//     @Nullable
//     String getJDBCUrl();
// 
//     @Nullable
//     String getJDBCUsername();
// 
//     @Nullable
//     String getJDBCPassword();
// 
//     @NotNull
//     String getId();
// 
//     @Nullable
//     String getName();
// 
//     @Nullable
//     String getDescription();
// 
//     @NotNull
//     Map<String, String> getParameters();
// }
// 
// Path: sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/manager/SQSManager.java
// public interface SQSManager {
//     @NotNull
//     List<SQSInfo> getAvailableServers(@NotNull final SProject project);
// 
//     @NotNull
//     List<SQSInfo> getOwnAvailableServers(@NotNull final SProject project);
// 
//     @Nullable
//     SQSInfo getServer(@NotNull final SProject project, @NotNull String serverId);
// 
//     @Nullable
//     SQSInfo getOwnServer(@NotNull final SProject project, @NotNull String serverId);
// 
//     @NotNull
//     SQSActionResult editServer(@NotNull final SProject project, @NotNull final SQSInfo sqsInfo);
// 
//     @NotNull
//     SQSActionResult addServer(@NotNull final SProject project, @NotNull final SQSInfo sqsInfo);
// 
//     @NotNull
//     SQSActionResult removeServer(@NotNull final SProject project, @NotNull final String serverId);
// 
//     @NotNull
//     String getDescription();
// 
//     class SQSActionResult {
//         final SQSInfo myBeforeAction;
//         final SQSInfo myAfterAction;
//         final String myReason;
//         final boolean myIsError;
// 
//         public SQSActionResult(@Nullable final SQSInfo beforeAction, @Nullable final SQSInfo afterAction, @NotNull final String reason) {
//             this(beforeAction, afterAction, reason, false);
//         }
// 
//         public SQSActionResult(@Nullable final SQSInfo beforeAction, @Nullable final SQSInfo afterAction, @NotNull final String reason, final boolean isError) {
//             myBeforeAction = beforeAction;
//             myAfterAction = afterAction;
//             myReason = reason;
//             myIsError = isError;
//         }
// 
//         public SQSInfo getBeforeAction() {
//             return myBeforeAction;
//         }
// 
//         public SQSInfo getAfterAction() {
//             return myAfterAction;
//         }
// 
//         public String getReason() {
//             return myReason;
//         }
// 
//         public boolean isError() {
//             return myIsError;
//         }
//     }
// }


// Path: sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/manager/ServerManagementProjectTab.java
import jetbrains.buildServer.controllers.admin.projects.EditProjectTab;
import jetbrains.buildServer.serverSide.SProject;
import jetbrains.buildServer.serverSide.auth.AuthUtil;
import jetbrains.buildServer.serverSide.auth.SecurityContext;
import jetbrains.buildServer.web.openapi.PagePlaces;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildserver.sonarplugin.manager.SQSInfo;
import jetbrains.buildserver.sonarplugin.manager.SQSManager;
import org.jetbrains.annotations.NotNull;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

    }

    @NotNull
    @Override
    public String getTabTitle(@NotNull final HttpServletRequest request) {
        final SProject currentProject = getProject(request);
        if (currentProject == null) {
            return TAB_TITLE;
        }
        final List<SQSInfo> availableServers = mySqsManager.getOwnAvailableServers(currentProject);
        if (availableServers.isEmpty()) {
            return TAB_TITLE;
        }
        return TAB_TITLE + " (" + availableServers.size() + ")";
    }

    @Override
    public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
        final SProject currentProject = getProject(request);
        if (currentProject == null) {
            return;
        }
        Map<SProject, List<SQSInfo>> infoMap = getServersMap(currentProject);
        model.put("availableServersMap", infoMap);
        model.put("projectId", currentProject.getExternalId());
        model.put("userHasPermissionManagement", AuthUtil.hasPermissionToManageProject(securityContext.getAuthorityHolder(), currentProject.getProjectId()));
    }

    private Map<SProject, List<SQSInfo>> getServersMap(@NotNull final SProject currentProject) {
        SProject project = currentProject;
        Map<SProject, List<SQSInfo>> infoMap = new HashMap<SProject, List<SQSInfo>>();