gt:       List allHosts = cmfEM.findAllHosts();
context: package com.cloudera.server.web.cmf;
  
  import com.cloudera.cmf.model.DbBase;
  import com.cloudera.cmf.model.DbCluster;
  import com.cloudera.cmf.model.DbExternalAccount;
  import com.cloudera.cmf.model.DbHost;
  import com.cloudera.cmf.model.DbRole;
  import com.cloudera.cmf.model.DbRoleConfigGroup;
  import com.cloudera.cmf.model.DbService;
  import com.cloudera.cmf.model.DbUser;
  import com.cloudera.cmf.persist.CmfEntityManager;
  import com.cloudera.cmf.persist.DbUserSettingDao;
  import com.cloudera.cmf.service.HostHandler;
  import com.cloudera.cmf.service.RoleHandler;
  import com.cloudera.cmf.service.ServiceDataProvider;
  import com.cloudera.cmf.service.ServiceHandler;
  import com.cloudera.cmf.service.ServiceHandlerRegistry;
  import com.cloudera.cmf.service.config.ConfigSpec;
  import com.cloudera.cmf.service.scm.ScmHandler;
  import com.cloudera.server.cmf.OperationsManager;
  import com.cloudera.server.web.cmf.aggregator.AggregatorConfigPage;
  import com.cloudera.server.web.cmf.config.CommonConfigOperation;
  import com.cloudera.server.web.cmf.config.ConfigFilterStrategy;
  import com.cloudera.server.web.cmf.config.DisplayGroupKeyFilterStrategy;
  import com.cloudera.server.web.cmf.config.GenericConfigResponse;
  import com.cloudera.server.web.cmf.config.ParamSpecProperty;
  import com.cloudera.server.web.cmf.config.SearchByLabelsStrategy;
  import com.cloudera.server.web.cmf.config.SearchConfigFilterStrategy;
  import com.cloudera.server.web.cmf.config.ServiceDependentFilterStrategy;
  import com.cloudera.server.web.cmf.config.TemplateNameFilterStrategy;
  import com.cloudera.server.web.cmf.config.components.GenericConfigHelper;
  import com.cloudera.server.web.cmf.config.components.GenericConfigHelper.OverridingOptions;
  import com.cloudera.server.web.cmf.include.ParamSpecPropertiesDialog;
  import com.cloudera.server.web.common.I18n;
  import com.cloudera.server.web.common.JamonModelAndView;
  import com.cloudera.server.web.common.TimeControlModel;
  import com.cloudera.server.web.common.TimeControlModel.Mode;
  import com.google.common.base.Preconditions;
  import com.google.common.collect.ImmutableList;
  import com.google.common.collect.Iterables;
  import com.google.common.collect.Lists;
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  @RequestMapping({"/*"})
  public class GenericConfigController extends WebController
  {
  
    @Autowired
    private GenericConfigHelper genericConfigHelper;
  
    @RequestMapping(value={"services/{serviceId}/config2"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public ModelAndView serviceConfigPage(@PathVariable long serviceId, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpSession session)
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        DbService service = validateService(cmfEM, serviceId);
        ServiceHandler sh = getServiceHandler(service);
  
        String metadataJsonUrl = CmfPath.GenericConfig.buildMetadataUrlForOperation(service, operation);
  
        String allClustersJsonUrl = CmfPath.GenericConfig.buildAllClustersJsonForOperation(service, operation != CommonConfigOperation.ALL ? operation : null);
  
        ServiceConfig2 page = new ServiceConfig2();
        page.setTimeControlModel(getTimeControlModel(session, TimeControlModel.Mode.TIMEONLY, Boolean.valueOf(true)));
  
        page.setRequiredAuthorities(sh.getAuthoritiesForConfigs());
  
        boolean multiClusterService = cmfEM.findServicesByType(service.getServiceType()).size() > 1;
  
        List otherClustersWithService = Lists.newLinkedList();
  
        for (Iterator i$ = cmfEM.findServicesByType(service.getServiceType()).iterator(); i$.hasNext(); ) { otherService = (DbService)i$.next();
  
          if (!service.getId().equals(otherService.getId())) {
            otherClustersWithService.add(otherService.getCluster());
          }
        }
  
        Map userSettings = getUserSettings(cmfEM);
        DbService otherService = JamonModelAndView.of(page.makeRenderer(service, sh, metadataJsonUrl, allClustersJsonUrl, multiClusterService, otherClustersWithService, userSettings));
        return otherService; } finally { cmfEM.close(); } throw localObject;
    }
  
    @RequestMapping(value={"services/{serviceId}/config2/metadata.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void serviceConfigPageMetadata(@PathVariable long serviceId, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        DbService service = validateService(cmfEM, serviceId);
        searchConfigMetadataForDbBase(cmfEM, operation, service, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"accounts/{accountName}/config2/metadata.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void externalAccountConfigPageMetadata(@PathVariable String accountName, @RequestParam(value="labels", required=false, defaultValue="") String labels, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        DbExternalAccount account = validateExternalAccount(cmfEM, accountName);
        ConfigFilterStrategy filterStrategy = null;
        if (labels.isEmpty())
          filterStrategy = operation;
        else {
          filterStrategy = getSearchLabelStrategy(labels);
        }
        searchConfigMetadataForDbBase(cmfEM, filterStrategy, account, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"services/{serviceId}/config2/allClusters.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void serviceAllClustersConfigPageMetadata(@PathVariable long serviceId, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, @RequestParam(value="diffClusterId", required=false) Long diffClusterId, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        DbService service = validateService(cmfEM, serviceId);
  
        List services = Lists.newLinkedList();
        List otherServices = cmfEM.findServicesByType(service.getServiceType());
  
        if (diffClusterId != null) {
          for (DbService otherService : otherServices)
            if ((diffClusterId.equals(otherService.getCluster().getId())) || (otherService.getId().equals(Long.valueOf(serviceId))))
            {
              services.add(otherService);
            }
        }
        else {
          services = otherServices;
        }
  
        GenericConfigResponse configResponse = this.genericConfigHelper.getConfigForServices(cmfEM, services, operation);
  
        writeJackson2JsonToHttpResponse(configResponse, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"services/{serviceId}/instances/{roleId}/config2"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public ModelAndView roleConfigPage(@PathVariable long serviceId, @PathVariable long roleId, @RequestParam(value="q", required=false) String searchQuery, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpSession session)
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
  
        DbRole role = validateRole(cmfEM, roleId);
        DbService service = role.getService();
        Preconditions.checkState(service.getId().longValue() == serviceId);
        RoleHandler rh = getRoleHandler(role);
  
        String metadataJsonUrl = CmfPath.GenericConfig.buildMetadataUrlForOperation(role, operation);
  
        RoleInstanceConfig2 page = new RoleInstanceConfig2();
  
        page.setTimeControlModel(getTimeControlModel(session, TimeControlModel.Mode.TIMEONLY, Boolean.valueOf(true)));
  
        ServiceHandler sh = getServiceHandler(service);
        page.setRequiredAuthorities(sh.getAuthoritiesForConfigs());
  
        page.setPeerless(service.getRolesWithType(role.getRoleType()).size() == 1);
        page.setSearchQuery(searchQuery);
  
        Map userSettings = getUserSettings(cmfEM);
        ModelAndView localModelAndView = JamonModelAndView.of(page.makeRenderer(role, rh, metadataJsonUrl, userSettings));
        return localModelAndView; } finally { cmfEM.close(); } throw localObject;
    }
  
    @RequestMapping(value={"services/{serviceId}/instances/{roleId}/config2/metadata.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void roleConfigPageMetadata(@PathVariable long serviceId, @PathVariable long roleId, @RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        DbRole role = validateRole(cmfEM, roleId);
  
        DbService service = role.getService();
        Preconditions.checkState(service.getId().longValue() == serviceId);
  
        searchConfigMetadataForDbBase(cmfEM, operation, role, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"settings2"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public ModelAndView settingsPage(@RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation)
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        GenericConfig2 page = new GenericConfig2();
        page.setDefaultUpdateMessage(I18n.t("message.configRevision.scm"));
        page.setRequiredAuthorities(this.serviceProvider.getServiceHandlerRegistry().getScmHandler().getConfigSpec().getAuthorities());
  
        String metadataJsonUrl = CmfPath.GenericConfig.buildMetaDataUrlForSettings(operation);
  
        Map userSettings = getUserSettings(cmfEM);
        ModelAndView localModelAndView = JamonModelAndView.of(page.makeRenderer(metadataJsonUrl, userSettings));
        return localModelAndView; } finally { cmfEM.close(); } throw localObject;
    }
  
    @RequestMapping(value={"settings2/metadata.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void settingsPageMetadata(@RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        searchConfigMetadataForSettings(cmfEM, operation, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"hardware/hosts/config2"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public ModelAndView hostsConfigPage(@RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation)
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
  
        String metadataJsonUrl = CmfPath.GenericConfig.buildMetaDataUrlForAllHosts(operation);
  
        HostsConfig2 page = new HostsConfig2();
  
        Set requiredAuthorities = this.serviceProvider.getServiceHandlerRegistry().getHostHandler().getConfigSpec().getAuthorities();
  
        page.setRequiredAuthorities(requiredAuthorities);
  
        Map userSettings = getUserSettings(cmfEM);
        ModelAndView localModelAndView = JamonModelAndView.of(page.makeRenderer(metadataJsonUrl, userSettings));
        return localModelAndView; } finally { cmfEM.close(); } throw localObject;
    }
  
    @RequestMapping(value={"hardware/hosts/config2/metadata.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void hostsConfigPageMetadata(@RequestParam(value="task", required=false, defaultValue="ALL") CommonConfigOperation operation, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
        List allHosts = cmfEM.findAllHosts();
        searchConfigMetadataForAllHosts(cmfEM, operation, allHosts, response);
      } finally {
        cmfEM.close();
      }
    }
  
    @RequestMapping(value={"hardware/hosts/config2/allHostValues.json"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
    public void allValuesForHostProperty(@RequestParam("templateName") String templateName, HttpServletResponse response)
      throws IOException
    {
      CmfEntityManager cmfEM = createCmfEntityManager();
      try {
        cmfEM.beginForRollbackAndReadonly();
  