1616import com .intellij .openapi .actionSystem .AnAction ;
1717import com .intellij .openapi .actionSystem .PlatformDataKeys ;
1818import com .intellij .openapi .actionSystem .CommonDataKeys ;
19+ import com .intellij .openapi .components .ServiceManager ;
1920import com .intellij .openapi .diagnostic .Logger ;
2021import com .intellij .openapi .fileEditor .FileEditorManager ;
2122import com .intellij .openapi .ui .Messages ;
2223import com .intellij .openapi .vfs .VirtualFile ;
2324import com .intellij .psi .PsiFile ;
2425
26+ import org .jboss .tools .intellij .crda .ApiService ;
27+ import com .redhat .crda .tools .Ecosystem ;
2528import org .jboss .tools .intellij .analytics .Platform ;
2629import org .jetbrains .annotations .NotNull ;
2730
28-
2931public class SaAction extends AnAction {
3032 private static final Logger logger = Logger .getInstance (SaAction .class );
3133
34+ private final ApiService apiService ;
35+
36+ public SaAction () {
37+ apiService = ServiceManager .getService (ApiService .class );
38+ }
39+
3240 /**
3341 * <p>Intellij Plugin Action implementation for triggering SA.</p>
3442 *
@@ -43,15 +51,24 @@ public void actionPerformed(@NotNull AnActionEvent event) {
4351 VirtualFile manifestFile = event .getData (PlatformDataKeys .VIRTUAL_FILE );
4452
4553 // Get SA report for given manifest file.
46- JsonObject saReportJson = saUtils .getReport (manifestFile .getPath ());
54+ String reportLink ;
55+ if ("pom.xml" .equals (manifestFile .getName ())) {
56+ reportLink = apiService .getStackAnalysis (
57+ Ecosystem .PackageManager .MAVEN ,
58+ manifestFile .getName (),
59+ manifestFile .getPath ()
60+ ).toUri ().toString ();
61+ } else {
62+ reportLink = saUtils .getReport (manifestFile .getPath ()).get ("report_link" ).getAsString ();
63+ }
4764
4865 // Manifest file details to be saved in temp file which will be used while opening Report tab
4966 JsonObject manifestDetails = new JsonObject ();
5067 manifestDetails .addProperty ("showParent" , false );
5168 manifestDetails .addProperty ("manifestName" , manifestFile .getName ());
5269 manifestDetails .addProperty ("manifestPath" , manifestFile .getPath ());
5370 manifestDetails .addProperty ("manifestFileParent" , manifestFile .getParent ().getName ());
54- manifestDetails .addProperty ("report_link" , saReportJson . get ( "report_link" ). getAsString () );
71+ manifestDetails .addProperty ("report_link" , reportLink );
5572 manifestDetails .addProperty ("manifestNameWithoutExtension" , manifestFile .getNameWithoutExtension ());
5673
5774 // Open custom editor window which will load SA Report in browser attached to it.
0 commit comments