use of com.microsoft.applicationinsights.preference.ApplicationInsightsResource in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsResourceRegistryEclipse method keeepManuallyAddedList.
public static void keeepManuallyAddedList() {
List<ApplicationInsightsResource> addedList = ApplicationInsightsResourceRegistry.getAddedResources();
List<String> addedKeyList = new ArrayList<String>();
for (ApplicationInsightsResource res : addedList) {
addedKeyList.add(res.getInstrumentationKey());
}
List<String> inUsekeyList = getInUseInstrumentationKeys();
for (String inUsekey : inUsekeyList) {
if (!addedKeyList.contains(inUsekey)) {
ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(inUsekey, inUsekey, Messages.unknown, Messages.unknown, Messages.unknown, Messages.unknown, false);
addedList.add(resourceToAdd);
}
}
ApplicationInsightsResourceRegistry.setAppInsightsResrcList(addedList);
ApplicationInsightsPreferences.save();
ApplicationInsightsPreferences.setLoaded(true);
}
use of com.microsoft.applicationinsights.preference.ApplicationInsightsResource in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPreferences method loadPreferences.
/**
* Read and load preference file data.
* Converts byte array format data to list of application insights resources.
*/
private void loadPreferences() {
Preferences prefs = PluginUtil.getPrefs(PREF_FILE);
try {
byte[] data = prefs.getByteArray(PREF_KEY, null);
if (data != null) {
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
ObjectInput input = new ObjectInputStream(buffer);
try {
ApplicationInsightsResource[] resources = (ApplicationInsightsResource[]) input.readObject();
for (ApplicationInsightsResource resource : resources) {
if (!ApplicationInsightsResourceRegistry.getAppInsightsResrcList().contains(resource)) {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resource);
}
}
} finally {
input.close();
}
}
} catch (IOException e) {
Activator.getDefault().log(e.getMessage(), e);
} catch (ClassNotFoundException e) {
Activator.getDefault().log(e.getMessage(), e);
}
}
use of com.microsoft.applicationinsights.preference.ApplicationInsightsResource in project azure-tools-for-java by Microsoft.
the class AppInsightsMngmtPanel method getTableContent.
private List<ApplicationInsightsPageTableElement> getTableContent() {
AzureSettings.getSafeInstance(myProject).loadAppInsights();
List<ApplicationInsightsResource> resourceList = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
List<ApplicationInsightsPageTableElement> tableRowElements = new ArrayList<ApplicationInsightsPageTableElement>();
for (ApplicationInsightsResource resource : resourceList) {
if (resource != null) {
ApplicationInsightsPageTableElement ele = new ApplicationInsightsPageTableElement();
ele.setResourceName(resource.getResourceName());
ele.setInstrumentationKey(resource.getInstrumentationKey());
tableRowElements.add(ele);
}
}
ApplicationInsightsPageTableElements elements = new ApplicationInsightsPageTableElements();
elements.setElements(tableRowElements);
return elements.getElements();
}
use of com.microsoft.applicationinsights.preference.ApplicationInsightsResource in project azure-tools-for-java by Microsoft.
the class AzureSettings method loadAppInsights.
public void loadAppInsights() {
try {
if (myState.appInsights != null) {
byte[] data = Base64.decode(myState.appInsights.getBytes());
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
ObjectInput input = new ObjectInputStream(buffer);
try {
ApplicationInsightsResource[] resources = (ApplicationInsightsResource[]) input.readObject();
for (ApplicationInsightsResource resource : resources) {
if (!ApplicationInsightsResourceRegistry.getAppInsightsResrcList().contains(resource)) {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resource);
}
}
} finally {
input.close();
}
}
} catch (ClassNotFoundException ex) {
// ignore - this happens because class package changed and settings were not updated
} catch (Exception e) {
log(message("err"), e);
}
}
use of com.microsoft.applicationinsights.preference.ApplicationInsightsResource 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