From 574adc3a0cf0cd5f6cec3085d4b72e303fa2844d Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Thu, 3 Feb 2011 09:08:02 +0000 Subject: [PATCH] Check a logging property in configuration and if missing get it from default settings. --- .../loggingutils/LoggingConfigForm.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java index 153bd3bfa..5de52bbc8 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java @@ -37,6 +37,12 @@ public class LoggingConfigForm private static final Logger logger = Logger.getLogger(LoggingConfigForm.class); + /** + * Upload location property. + */ + private static final String UPLOAD_LOCATION_PROPETY = + "plugin.loggingutils.uploadlocation"; + /** * The enable packet logging check box. */ @@ -223,11 +229,7 @@ private void init() c.gridy = 4; mainPanel.add(archiveButton, c); - String uploadLocation = - LoggingUtilsActivator.getResourceService() - .getSettingsString("plugin.loggingutils.uploadlocation"); - - if(!StringUtils.isNullOrEmpty(uploadLocation)) + if(!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton( resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); @@ -239,6 +241,28 @@ private void init() } } + /** + * Checks the property in configuration service and if missing there get it + * from default settings. + * @return the upload location. + */ + private String getUploadLocation() + { + // check first in configuration it can be manually set + // or by provisioning + String uploadLocation = + LoggingUtilsActivator.getConfigurationService() + .getString(UPLOAD_LOCATION_PROPETY); + // if missing check default settings + if(uploadLocation == null || uploadLocation.length() == 0) + { + uploadLocation = LoggingUtilsActivator.getResourceService() + .getSettingsString(UPLOAD_LOCATION_PROPETY); + } + + return uploadLocation; + } + /** * Loading the values stored into configuration form */ @@ -660,9 +684,7 @@ private void uploadLogs(String[] params, String[] values) if(optionalFile != null) optionalFile.delete(); - String uploadLocation = - LoggingUtilsActivator.getResourceService() - .getSettingsString("plugin.loggingutils.uploadlocation"); + String uploadLocation = getUploadLocation(); if(uploadLocation == null) return;