package <%=packageName%>.web.rest;

import <%=packageName%>.config.DefaultProfileUtil;

import io.github.jhipster.config.JHipsterProperties;

import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Resource to return information about the currently running Spring profiles.
 */
@RestController
@RequestMapping("/api")
public class ProfileInfoResource {

    private final Environment env;

    private final JHipsterProperties jHipsterProperties;

    public ProfileInfoResource(Environment env, JHipsterProperties jHipsterProperties) {
        this.env = env;
        this.jHipsterProperties = jHipsterProperties;
    }

    @GetMapping("/profile-info")
    public ProfileInfoResponse getActiveProfiles() {
        String[] activeProfiles = DefaultProfileUtil.getActiveProfiles(env);
        return new ProfileInfoResponse(activeProfiles, getRibbonEnv(activeProfiles));
    }

    private String getRibbonEnv(String[] activeProfiles) {
        String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();

        if (displayOnActiveProfiles == null) {
            return null;
        }

        List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
        List<String> springBootProfiles = Arrays.asList(activeProfiles);
        ribbonProfiles.retainAll(springBootProfiles);

        if (ribbonProfiles.size() > 0) {
            return ribbonProfiles.get(0);
        }
        return null;
    }

    class ProfileInfoResponse {

        public String[] activeProfiles;
        public String ribbonEnv;

        ProfileInfoResponse(String[] activeProfiles, String ribbonEnv) {
            this.activeProfiles = activeProfiles;
            this.ribbonEnv = ribbonEnv;
        }
    }
}

@@ -798,24 +798,18 @@
 fileInfo
-Response
+VM
  getActi
@@ -930,24 +930,18 @@
 fileInfo
-Response
+VM
 (activeP
@@ -1603,43 +1603,155 @@
 Info
-Response %7B%0A%0A        public String%5B%5D
+VM %7B%0A%0A        private String%5B%5D activeProfiles;%0A%0A        private String ribbonEnv;%0A%0A        public String%5B%5D getActiveProfiles() %7B%0A            return
  act
@@ -1755,32 +1755,43 @@
 activeProfiles;%0A
+        %7D%0A%0A
         public S
@@ -1788,32 +1788,68 @@
   public String 
+getRibbonEnv() %7B%0A            return 
 ribbonEnv;%0A%0A    
@@ -1834,32 +1834,42 @@
 eturn ribbonEnv;
+%0A        %7D
 %0A%0A        Profil
@@ -1877,16 +1877,10 @@
 Info
-Response
+VM
 (Str

Fix Sonar 6.2 vulnerability warning