use of com.microsoft.intellij.ui.libraries.AILibraryHandler in project azure-tools-for-java by Microsoft.
the class AzurePlugin method initializeAIRegistry.
private void initializeAIRegistry() {
try {
AzureSettings.getSafeInstance(myProject).loadAppInsights();
Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
if (module != null && module.isLoaded() && ModuleTypeId.JAVA_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE))) {
String aiXMLPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator, message("aiXMLPath"));
if (new File(aiXMLPath).exists()) {
AILibraryHandler handler = new AILibraryHandler();
handler.parseAIConfXmlPath(aiXMLPath);
String key = handler.getAIInstrumentationKey();
if (key != null && !key.isEmpty()) {
String unknown = message("unknown");
List<ApplicationInsightsResource> list = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(key, key, unknown, unknown, unknown, unknown, false);
if (!list.contains(resourceToAdd)) {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resourceToAdd);
}
}
}
}
}
AzureSettings.getSafeInstance(myProject).saveAppInsights();
} catch (Exception ex) {
AzurePlugin.log(ex.getMessage(), ex);
}
}
use of com.microsoft.intellij.ui.libraries.AILibraryHandler in project azure-tools-for-java by Microsoft.
the class MethodUtils method getModuleNameAsPerKey.
/**
* Method scans all open Maven or Dynamic web projects form workspace
* and returns name of project who is using specific key.
* @return
*/
public static String getModuleNameAsPerKey(Project project, String keyToRemove) {
String name = "";
try {
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
if (module != null && module.isLoaded() && ModuleTypeId.JAVA_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE))) {
String aiXMLPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator, message("aiXMLPath"));
String webXMLPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator, message("xmlPath"));
AILibraryHandler handler = new AILibraryHandler();
if (new File(aiXMLPath).exists() && new File(webXMLPath).exists()) {
handler.parseWebXmlPath(webXMLPath);
handler.parseAIConfXmlPath(aiXMLPath);
// if application insights configuration is enabled.
if (handler.isAIWebFilterConfigured()) {
String key = handler.getAIInstrumentationKey();
if (key != null && !key.isEmpty() && key.equals(keyToRemove)) {
return module.getName();
}
}
}
}
}
} catch (Exception ex) {
AzurePlugin.log(ex.getMessage(), ex);
}
return name;
}
use of com.microsoft.intellij.ui.libraries.AILibraryHandler in project azure-tools-for-java by Microsoft.
the class AzurePlugin method initializeAIRegistry.
private void initializeAIRegistry(Project myProject) {
try {
AzureSettings.getSafeInstance(myProject).loadAppInsights();
Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
if (module != null && module.isLoaded() && ModuleTypeId.JAVA_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE))) {
String aiXMLPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator, message("aiXMLPath"));
if (new File(aiXMLPath).exists()) {
AILibraryHandler handler = new AILibraryHandler();
handler.parseAIConfXmlPath(aiXMLPath);
String key = handler.getAIInstrumentationKey();
if (key != null && !key.isEmpty()) {
String unknown = message("unknown");
List<ApplicationInsightsResource> list = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(key, key, unknown, unknown, unknown, unknown, false);
if (!list.contains(resourceToAdd)) {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resourceToAdd);
}
}
}
}
}
AzureSettings.getSafeInstance(myProject).saveAppInsights();
} catch (Exception ex) {
// should ignore ProcessCanceledException
if (Objects.isNull(ExceptionUtil.findCause(ex, ProcessCanceledException.class))) {
AzurePlugin.log(ex.getMessage(), ex);
}
}
}
Aggregations