From 4a08b1e610121d242ecd3b9eccc2fbc3e1bf9e0a Mon Sep 17 00:00:00 2001 From: ashitsalesforce Date: Sun, 13 Oct 2024 22:06:50 -0700 Subject: [PATCH] prefix all property names with "PROP_" for code maintainability prefix all property names with "PROP_" for code maintainability --- .../action/visitor/DAOLoadVisitor.java | 2 +- .../action/visitor/bulk/BulkLoadVisitor.java | 8 +- .../dataloader/config/AppConfig.java | 93 ++++++++++++------- ...perty.java => ConfigPropertyMetadata.java} | 48 ++++++---- .../dataloader/dao/DAORowCache.java | 2 +- .../dataloader/dao/csv/CSVFileReader.java | 2 +- .../dao/database/DatabaseReader.java | 2 +- .../dataloader/ui/AdvancedSettingsDialog.java | 20 ++-- .../salesforce/dataloader/ui/BaseWizard.java | 2 +- .../salesforce/dataloader/ui/FinishPage.java | 2 +- .../dataloader/ui/OperationPage.java | 8 +- .../com/salesforce/dataloader/ui/UIUtils.java | 8 +- .../dataloader/ui/WizardDialog.java | 4 +- .../com/salesforce/dataloader/TestBase.java | 2 +- .../salesforce/dataloader/TestSetting.java | 2 +- .../dataloader/process/CsvProcessTest.java | 24 ++--- .../dataloader/process/ProcessTestBase.java | 2 +- 17 files changed, 132 insertions(+), 99 deletions(-) rename src/main/java/com/salesforce/dataloader/config/{ConfigProperty.java => ConfigPropertyMetadata.java} (73%) diff --git a/src/main/java/com/salesforce/dataloader/action/visitor/DAOLoadVisitor.java b/src/main/java/com/salesforce/dataloader/action/visitor/DAOLoadVisitor.java index ed5aae30..d8c958fb 100644 --- a/src/main/java/com/salesforce/dataloader/action/visitor/DAOLoadVisitor.java +++ b/src/main/java/com/salesforce/dataloader/action/visitor/DAOLoadVisitor.java @@ -145,7 +145,7 @@ protected boolean isRowConversionSuccessful() { public boolean visit(Row row) throws OperationException, DataAccessObjectException, ConnectionException { AppConfig appConfig = controller.getAppConfig(); - if (appConfig.getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + if (appConfig.getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || (!appConfig.isBulkAPIEnabled() && !appConfig.isBulkV2APIEnabled())) { // either bulk mode or cache bulk data uploaded from DAO this.daoRowList.add(row); diff --git a/src/main/java/com/salesforce/dataloader/action/visitor/bulk/BulkLoadVisitor.java b/src/main/java/com/salesforce/dataloader/action/visitor/bulk/BulkLoadVisitor.java index 1de2b958..88e56931 100644 --- a/src/main/java/com/salesforce/dataloader/action/visitor/bulk/BulkLoadVisitor.java +++ b/src/main/java/com/salesforce/dataloader/action/visitor/bulk/BulkLoadVisitor.java @@ -393,7 +393,7 @@ private String generateBatchCSVFilename(String prefix, int batchNum) { private void createBatch(ByteArrayOutputStream os, int numRecords) throws AsyncApiException { if (numRecords <= 0) return; final byte[] request = os.toByteArray(); - if (controller.getAppConfig().getBoolean(AppConfig.SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV)) { + if (controller.getAppConfig().getBoolean(AppConfig.PROP_SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV)) { this.batchCountForJob++; writeServerLoadBatchDataToCSV(os); } @@ -449,7 +449,7 @@ private void getResults() throws AsyncApiException, OperationException, DataAcce return; } DataReader dataReader = null; - if (!controller.getAppConfig().getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO)) { + if (!controller.getAppConfig().getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO)) { dataReader = resetDAO(); } // create a map of batch infos by batch id. Each batchinfo has the final processing state of the batch @@ -490,7 +490,7 @@ private void processResults(final DataReader dataReader, final BatchInfo batch, final int totalRowsInDAOInCurrentBatch = lastDAORowForCurrentBatch - this.firstDAORowForCurrentBatch + 1; List rows; - if (controller.getAppConfig().getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO)) { + if (controller.getAppConfig().getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO)) { rows = new ArrayList(); for (int i=0; i configPropsMap = ConfigProperty.getPropertiesMap(); + private Map configPropsMetadataMap = ConfigPropertyMetadata.getPropertiesMap(); private Map parameterOverridesMap; @@ -429,16 +429,16 @@ public class AppConfig { public static final String RUN_MODE_INSTALL_VAL = "install"; public static final String RUN_MODE_ENCRYPT_VAL = "encrypt"; - public static final String SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV = "process.bulk.saveServerLoadAndRawResultsInCSV"; - public static final String PROCESS_BULK_CACHE_DATA_FROM_DAO = "process.bulk.cacheDataFromDao"; - public static final String READ_ONLY_CONFIG_PROPERTIES = "config.properties.readonly"; - public static final String WIZARD_WIDTH = "sfdc.ui.wizard.width"; - public static final String WIZARD_HEIGHT = "sfdc.ui.wizard.height"; - public static final String WIZARD_X_OFFSET = "sfdc.ui.wizard.xoffset"; - public static final String WIZARD_Y_OFFSET = "sfdc.ui.wizard.yoffset"; - public static final String ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG = "sfdc.ui.wizard.enforceWidthHeight"; - public static final String WIZARD_CLOSE_ON_FINISH = "sfdc.ui.wizard.closeOnFinish"; - public static final String WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER = "sfdc.ui.wizard.finishStep.prepopulateWithPreviousOpResultsFolder"; + public static final String PROP_SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV = "process.bulk.saveServerLoadAndRawResultsInCSV"; + public static final String PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO = "process.bulk.cacheDataFromDao"; + public static final String PROP_READ_ONLY_CONFIG_PROPERTIES = "config.properties.readonly"; + public static final String PROP_WIZARD_WIDTH = "sfdc.ui.wizard.width"; + public static final String PROP_WIZARD_HEIGHT = "sfdc.ui.wizard.height"; + public static final String PROP_WIZARD_X_OFFSET = "sfdc.ui.wizard.xoffset"; + public static final String PROP_WIZARD_Y_OFFSET = "sfdc.ui.wizard.yoffset"; + public static final String PROP_ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG = "sfdc.ui.wizard.enforceWidthHeight"; + public static final String PROP_WIZARD_CLOSE_ON_FINISH = "sfdc.ui.wizard.closeOnFinish"; + public static final String PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER = "sfdc.ui.wizard.finishStep.prepopulateWithPreviousOpResultsFolder"; public static final String DIALOG_BOUNDS_PREFIX = "sfdc.ui.dialog."; public static final String DIALOG_WIDTH_SUFFIX = ".width"; public static final String DIALOG_HEIGHT_SUFFIX = ".height"; @@ -453,7 +453,7 @@ public class AppConfig { // Following properties are read-only, i.e. they are not overridden during save() to config.properties // - These properties are not set in Advanced Settings dialog. // - Make sure to list all sensitive properties such as password because these properties are not saved. - private static final String[] READ_ONLY_PROPERTY_NAMES = { + static final String[] READ_ONLY_PROPERTY_NAMES = { PROP_PASSWORD, PROP_IDLOOKUP_FIELD, PROP_MAPPING_FILE, @@ -468,16 +468,16 @@ public class AppConfig { PROP_DEBUG_MESSAGES_FILE, PROP_WIRE_OUTPUT, PROP_PROCESS_THREAD_NAME, - PROCESS_BULK_CACHE_DATA_FROM_DAO, + PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO, PROP_PROCESS_EXIT_WITH_ERROR_ON_FAILED_ROWS_BATCH_MODE, - SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV, + PROP_SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV, PROP_API_VERSION, PROP_READ_CHARSET, - READ_ONLY_CONFIG_PROPERTIES, + PROP_READ_ONLY_CONFIG_PROPERTIES, PROP_RICH_TEXT_FIELD_REGEX, PROP_DAO_READ_PREPROCESSOR_SCRIPT, PROP_DAO_WRITE_POSTPROCESSOR_SCRIPT, - ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, + PROP_ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, PROP_DELETE_WITH_EXTERNALID, PROP_OAUTH_ACCESSTOKEN, PROP_OAUTH_REFRESHTOKEN, @@ -497,7 +497,7 @@ public class AppConfig { PROP_USE_SYSTEM_PROPS_FOR_HTTP_CLIENT, }; - private static final String[] ENCRYPTED_PROPERTY_NAMES = { + static final String[] ENCRYPTED_PROPERTY_NAMES = { PROP_PASSWORD, PROP_PROXY_PASSWORD, PROP_OAUTH_ACCESSTOKEN, @@ -657,19 +657,19 @@ private void setDefaults(Map cliOptionsMap) { setDefaultValue(PROP_OAUTH_LOGIN_FROM_BROWSER, true); setDefaultValue(PROP_LOAD_PRESERVE_WHITESPACE_IN_RICH_TEXT, true); setDefaultValue(AppConfig.CLI_OPTION_RUN_MODE, AppConfig.RUN_MODE_UI_VAL); - setDefaultValue(SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV, false); - setDefaultValue(PROCESS_BULK_CACHE_DATA_FROM_DAO, true); + setDefaultValue(PROP_SAVE_BULK_SERVER_LOAD_AND_RAW_RESULTS_IN_CSV, false); + setDefaultValue(PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO, true); setDefaultValue(PROP_PROCESS_KEEP_ACCOUNT_TEAM, false); - setDefaultValue(WIZARD_WIDTH, DEFAULT_WIZARD_WIDTH); - setDefaultValue(WIZARD_HEIGHT, DEFAULT_WIZARD_HEIGHT); - setDefaultValue(ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, true); + setDefaultValue(PROP_WIZARD_WIDTH, DEFAULT_WIZARD_WIDTH); + setDefaultValue(PROP_WIZARD_HEIGHT, DEFAULT_WIZARD_HEIGHT); + setDefaultValue(PROP_ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, true); setDefaultValue(PROP_DAO_READ_PREPROCESSOR_SCRIPT, ""); setDefaultValue(PROP_DAO_WRITE_POSTPROCESSOR_SCRIPT, ""); setDefaultValue(PROP_LIMIT_OUTPUT_TO_QUERY_FIELDS, true); - setDefaultValue(WIZARD_CLOSE_ON_FINISH, true); - setDefaultValue(WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, true); - setDefaultValue(WIZARD_X_OFFSET, DEFAULT_WIZARD_X_OFFSET); - setDefaultValue(WIZARD_Y_OFFSET, DEFAULT_WIZARD_Y_OFFSET); + setDefaultValue(PROP_WIZARD_CLOSE_ON_FINISH, true); + setDefaultValue(PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, true); + setDefaultValue(PROP_WIZARD_X_OFFSET, DEFAULT_WIZARD_X_OFFSET); + setDefaultValue(PROP_WIZARD_Y_OFFSET, DEFAULT_WIZARD_Y_OFFSET); setDefaultValue(PROP_CACHE_DESCRIBE_GLOBAL_RESULTS, true); setDefaultValue(PROP_PROCESS_EXIT_WITH_ERROR_ON_FAILED_ROWS_BATCH_MODE, false); setDefaultValue(PROP_INCLUDE_RICH_TEXT_FIELD_DATA_IN_QUERY_RESULTS, false); @@ -1008,7 +1008,30 @@ private void load(InputStream in) throws ConfigInitializationException, IOExcept dirty = false; } - + + public static boolean isReadOnlyProperty(String propertyName) { + if (propertyName == null) { + return false; + } + for (String roProp : AppConfig.READ_ONLY_PROPERTY_NAMES) { + if (roProp.equals(propertyName)) { + return true; + } + } + return false; + } + + public static boolean isEncryptedProperty(String propertyName) { + if (propertyName == null) { + return false; + } + for (String encryptedProp : AppConfig.ENCRYPTED_PROPERTY_NAMES) { + if (encryptedProp.equals(propertyName)) { + return true; + } + } + return false; + } /** * Post process parameters. Right now, only decrypts encrypted values in the map * @@ -1194,7 +1217,7 @@ public void putValue(String name, String value) { */ public void save() throws IOException, GeneralSecurityException { if (getString(AppConfig.CLI_OPTION_RUN_MODE).equalsIgnoreCase(AppConfig.RUN_MODE_BATCH_VAL) - || getBoolean(READ_ONLY_CONFIG_PROPERTIES)) { + || getBoolean(PROP_READ_ONLY_CONFIG_PROPERTIES)) { return; // do not save any updates to config.properties file } if (filename == null) { @@ -1472,15 +1495,13 @@ private void setValue(String name, T value, boolean skipIfAlreadySet) { } } - private void setConfigProperty(String propName, String propVal, boolean isDefault) { - ConfigProperty configProp = configPropsMap.get(propName); - if (configProp == null) { - configProp = new ConfigProperty(propName); - configPropsMap.put(propName, configProp); + private void setConfigPropertyMetadata(String propName, String propVal, boolean isDefault) { + ConfigPropertyMetadata configPropMD = configPropsMetadataMap.get(propName); + if (configPropMD == null) { + return; // did not find the property metadata in the registry of properties } - configProp.setValue(propVal); if (isDefault) { - configProp.setDefaultValue(propVal); + configPropMD.setDefaultValue(propVal); } } @@ -1489,7 +1510,7 @@ private void setConfigProperty(String propName, String propVal, boolean isDefaul * @param newValue */ private void setProperty(String name, String newValue, boolean skipIfAlreadySet) { - setConfigProperty(name, newValue, skipIfAlreadySet); + setConfigPropertyMetadata(name, newValue, skipIfAlreadySet); final String oldValue = getString(name); if (skipIfAlreadySet && oldValue != null && !oldValue.isBlank()) { // do not override the old value diff --git a/src/main/java/com/salesforce/dataloader/config/ConfigProperty.java b/src/main/java/com/salesforce/dataloader/config/ConfigPropertyMetadata.java similarity index 73% rename from src/main/java/com/salesforce/dataloader/config/ConfigProperty.java rename to src/main/java/com/salesforce/dataloader/config/ConfigPropertyMetadata.java index 0e697704..e6a5f464 100644 --- a/src/main/java/com/salesforce/dataloader/config/ConfigProperty.java +++ b/src/main/java/com/salesforce/dataloader/config/ConfigPropertyMetadata.java @@ -25,6 +25,7 @@ */ package com.salesforce.dataloader.config; +import java.lang.reflect.Field; import java.util.HashMap; import com.salesforce.dataloader.ui.Labels; @@ -32,19 +33,36 @@ /* * Data class capturing information about configuration property (aka Setting). */ -public class ConfigProperty { - private static final HashMap propertiesMap = new HashMap(); +public class ConfigPropertyMetadata { + private static final HashMap propertiesMap = new HashMap(); private final String name; private String defaultValue = ""; - private String value = ""; - private boolean readonly; - private boolean encrypted; - private boolean commandLineOption; + private boolean readOnly = false; + private boolean encrypted = false; + private boolean commandLineOption = false; private final String uiLabelTemplate; private final String uiTooltipTemplate; + + static { + Field[] appConfigFields = AppConfig.class.getDeclaredFields(); + for (Field configField : appConfigFields) { + if (configField.getName().startsWith("PROP_")) { + String propName; + try { + propName = configField.get(null).toString(); + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { + continue; + } + ConfigPropertyMetadata configProp = new ConfigPropertyMetadata(configField.getName()); + configProp.setEncrypted(AppConfig.isEncryptedProperty(propName)); + configProp.setReadOnly(AppConfig.isReadOnlyProperty(propName)); + propertiesMap.put(propName, configProp); + } + } + } - public ConfigProperty(String name) { + public ConfigPropertyMetadata(String name) { this.name = name; this.uiLabelTemplate = Labels.getString("AdvancedSettingsDialog.uiLabel." + name); String tooltipText = null; @@ -73,7 +91,7 @@ public ConfigProperty(String name) { }; } - public static HashMap getPropertiesMap() { + public static HashMap getPropertiesMap() { return propertiesMap; } public String getDefaultValue() { @@ -82,17 +100,11 @@ public String getDefaultValue() { public void setDefaultValue(String defaultValue) { this.defaultValue = defaultValue; } - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - } - public boolean isReadonly() { - return readonly; + public boolean isReadOnly() { + return readOnly; } - public void setReadonly(boolean readonly) { - this.readonly = readonly; + public void setReadOnly(boolean readonly) { + this.readOnly = readonly; } public boolean isEncrypted() { return encrypted; diff --git a/src/main/java/com/salesforce/dataloader/dao/DAORowCache.java b/src/main/java/com/salesforce/dataloader/dao/DAORowCache.java index e7bf6c33..3a178441 100644 --- a/src/main/java/com/salesforce/dataloader/dao/DAORowCache.java +++ b/src/main/java/com/salesforce/dataloader/dao/DAORowCache.java @@ -45,7 +45,7 @@ public void resetCurrentRowIndex() { public Row getCurrentRow() { AppConfig appConfig = AppConfig.getCurrentConfig(); if (currentRowIndex >= totalRows - || !appConfig.getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO)) { + || !appConfig.getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO)) { return null; } return rowList.get(currentRowIndex++); diff --git a/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileReader.java b/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileReader.java index dfe764b4..66f8f349 100644 --- a/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileReader.java +++ b/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileReader.java @@ -178,7 +178,7 @@ public Row readRow() throws DataAccessObjectException { return row; } - if (appConfig.getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + if (appConfig.getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) && endOfFileReached) { return null; } diff --git a/src/main/java/com/salesforce/dataloader/dao/database/DatabaseReader.java b/src/main/java/com/salesforce/dataloader/dao/database/DatabaseReader.java index 976afed1..2fd1565e 100644 --- a/src/main/java/com/salesforce/dataloader/dao/database/DatabaseReader.java +++ b/src/main/java/com/salesforce/dataloader/dao/database/DatabaseReader.java @@ -187,7 +187,7 @@ public Row readRow() throws DataAccessObjectException { currentRowNumber++; return row; } - if (appConfig.getBoolean(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + if (appConfig.getBoolean(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) && endOfDBReached) { return null; } diff --git a/src/main/java/com/salesforce/dataloader/ui/AdvancedSettingsDialog.java b/src/main/java/com/salesforce/dataloader/ui/AdvancedSettingsDialog.java index 38a88f16..7eafc824 100644 --- a/src/main/java/com/salesforce/dataloader/ui/AdvancedSettingsDialog.java +++ b/src/main/java/com/salesforce/dataloader/ui/AdvancedSettingsDialog.java @@ -840,8 +840,8 @@ public void verifyText(VerifyEvent event) { data.horizontalSpan = 2; blankAgain.setLayoutData(data); - createLabel(restComp, null, null, AppConfig.WIZARD_CLOSE_ON_FINISH); - boolean closeWizardOnFinish = appConfig.getBoolean(AppConfig.WIZARD_CLOSE_ON_FINISH); + createLabel(restComp, null, null, AppConfig.PROP_WIZARD_CLOSE_ON_FINISH); + boolean closeWizardOnFinish = appConfig.getBoolean(AppConfig.PROP_WIZARD_CLOSE_ON_FINISH); buttonCloseWizardOnFinish = new Button(restComp, SWT.CHECK); buttonCloseWizardOnFinish.setSelection(closeWizardOnFinish); @@ -852,7 +852,7 @@ public void verifyText(VerifyEvent event) { layout = new GridLayout(3, false); widthAndHeightComp.setLayout(layout); textWizardWidth = new Text(widthAndHeightComp, SWT.BORDER); - textWizardWidth.setText(appConfig.getString(AppConfig.WIZARD_WIDTH)); + textWizardWidth.setText(appConfig.getString(AppConfig.PROP_WIZARD_WIDTH)); data = new GridData(); textWizardWidth.setTextLimit(4); data.widthHint = 4 * textSize.x; @@ -869,7 +869,7 @@ public void verifyText(VerifyEvent event) { labelMultiplySymbol.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); textWizardHeight = new Text(widthAndHeightComp, SWT.BORDER); - textWizardHeight.setText(appConfig.getString(AppConfig.WIZARD_HEIGHT)); + textWizardHeight.setText(appConfig.getString(AppConfig.PROP_WIZARD_HEIGHT)); textWizardHeight.setTextLimit(4); data.widthHint = 4 * textSize.x; textWizardHeight.setLayoutData(data); @@ -880,8 +880,8 @@ public void verifyText(VerifyEvent event) { } }); - createLabel(restComp, null, null, AppConfig.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER); - boolean populateResultsFolderOnFinishStep = appConfig.getBoolean(AppConfig.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER); + createLabel(restComp, null, null, AppConfig.PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER); + boolean populateResultsFolderOnFinishStep = appConfig.getBoolean(AppConfig.PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER); buttonPopulateResultsFolderOnWizardFinishStep = new Button(restComp, SWT.CHECK); buttonPopulateResultsFolderOnWizardFinishStep.setSelection(populateResultsFolderOnFinishStep); @@ -1036,11 +1036,11 @@ public void widgetSelected(SelectionEvent event) { appConfig.setValue(AppConfig.PROP_BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection()); appConfig.setValue(AppConfig.PROP_BULKV2_API_ENABLED, buttonUseBulkV2Api.getSelection()); appConfig.setValue(AppConfig.PROP_OAUTH_LOGIN_FROM_BROWSER, buttonLoginFromBrowser.getSelection()); - appConfig.setValue(AppConfig.WIZARD_CLOSE_ON_FINISH, buttonCloseWizardOnFinish.getSelection()); - appConfig.setValue(AppConfig.WIZARD_WIDTH, textWizardWidth.getText()); - appConfig.setValue(AppConfig.WIZARD_HEIGHT, textWizardHeight.getText()); + appConfig.setValue(AppConfig.PROP_WIZARD_CLOSE_ON_FINISH, buttonCloseWizardOnFinish.getSelection()); + appConfig.setValue(AppConfig.PROP_WIZARD_WIDTH, textWizardWidth.getText()); + appConfig.setValue(AppConfig.PROP_WIZARD_HEIGHT, textWizardHeight.getText()); - appConfig.setValue(AppConfig.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, buttonPopulateResultsFolderOnWizardFinishStep.getSelection()); + appConfig.setValue(AppConfig.PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, buttonPopulateResultsFolderOnWizardFinishStep.getSelection()); LoggingUtil.setLoggingLevel(LOGGING_LEVEL[comboLoggingLevelDropdown.getSelectionIndex()]); String clientIdVal = textProductionPartnerClientID.getText(); if (clientIdVal != null && !clientIdVal.strip().isEmpty()) { diff --git a/src/main/java/com/salesforce/dataloader/ui/BaseWizard.java b/src/main/java/com/salesforce/dataloader/ui/BaseWizard.java index 5d05360d..607b95d3 100644 --- a/src/main/java/com/salesforce/dataloader/ui/BaseWizard.java +++ b/src/main/java/com/salesforce/dataloader/ui/BaseWizard.java @@ -78,7 +78,7 @@ protected WizardPage getFinishPage() { } protected boolean closeWizardPagePostSuccessfulFinish() { - return getConfig().getBoolean(AppConfig.WIZARD_CLOSE_ON_FINISH); + return getConfig().getBoolean(AppConfig.PROP_WIZARD_CLOSE_ON_FINISH); } } diff --git a/src/main/java/com/salesforce/dataloader/ui/FinishPage.java b/src/main/java/com/salesforce/dataloader/ui/FinishPage.java index 118af2e2..dbef8d10 100644 --- a/src/main/java/com/salesforce/dataloader/ui/FinishPage.java +++ b/src/main/java/com/salesforce/dataloader/ui/FinishPage.java @@ -116,7 +116,7 @@ public boolean canFlipToNextPage() { protected boolean setupPagePostLogin() { try { verifySettings(); - if (!controller.getAppConfig().getBoolean(AppConfig.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER)) { + if (!controller.getAppConfig().getBoolean(AppConfig.PROP_WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER)) { dirFE.setStringValue(null); // clear previous selection } } catch (final MappingInitializationException e) { diff --git a/src/main/java/com/salesforce/dataloader/ui/OperationPage.java b/src/main/java/com/salesforce/dataloader/ui/OperationPage.java index 6bdbca17..e8416000 100644 --- a/src/main/java/com/salesforce/dataloader/ui/OperationPage.java +++ b/src/main/java/com/salesforce/dataloader/ui/OperationPage.java @@ -168,10 +168,10 @@ private void persistedWizardShellBoundsChanged(Event event) { } AppConfig appConfig = controller.getAppConfig(); Rectangle shellBounds = this.getShell().getBounds(); - appConfig.setValue(AppConfig.WIZARD_X_OFFSET, shellBounds.x); - appConfig.setValue(AppConfig.WIZARD_Y_OFFSET, shellBounds.y); - appConfig.setValue(AppConfig.WIZARD_WIDTH, shellBounds.width); - appConfig.setValue(AppConfig.WIZARD_HEIGHT, shellBounds.height); + appConfig.setValue(AppConfig.PROP_WIZARD_X_OFFSET, shellBounds.x); + appConfig.setValue(AppConfig.PROP_WIZARD_Y_OFFSET, shellBounds.y); + appConfig.setValue(AppConfig.PROP_WIZARD_WIDTH, shellBounds.width); + appConfig.setValue(AppConfig.PROP_WIZARD_HEIGHT, shellBounds.height); try { appConfig.save(); } catch (GeneralSecurityException | IOException e) { diff --git a/src/main/java/com/salesforce/dataloader/ui/UIUtils.java b/src/main/java/com/salesforce/dataloader/ui/UIUtils.java index e6457a19..b70b34bd 100644 --- a/src/main/java/com/salesforce/dataloader/ui/UIUtils.java +++ b/src/main/java/com/salesforce/dataloader/ui/UIUtils.java @@ -139,10 +139,10 @@ public static Rectangle getPersistedWizardBounds(AppConfig appConfig) { int height = AppConfig.DEFAULT_WIZARD_HEIGHT; if (appConfig != null) { try { - xOffset = appConfig.getInt(AppConfig.WIZARD_X_OFFSET); - yOffset = appConfig.getInt(AppConfig.WIZARD_Y_OFFSET); - width = appConfig.getInt(AppConfig.WIZARD_WIDTH); - height = appConfig.getInt(AppConfig.WIZARD_HEIGHT); + xOffset = appConfig.getInt(AppConfig.PROP_WIZARD_X_OFFSET); + yOffset = appConfig.getInt(AppConfig.PROP_WIZARD_Y_OFFSET); + width = appConfig.getInt(AppConfig.PROP_WIZARD_WIDTH); + height = appConfig.getInt(AppConfig.PROP_WIZARD_HEIGHT); } catch (Exception ex) { // no op } diff --git a/src/main/java/com/salesforce/dataloader/ui/WizardDialog.java b/src/main/java/com/salesforce/dataloader/ui/WizardDialog.java index 1253fe9f..fd5b84ab 100644 --- a/src/main/java/com/salesforce/dataloader/ui/WizardDialog.java +++ b/src/main/java/com/salesforce/dataloader/ui/WizardDialog.java @@ -60,8 +60,8 @@ protected Rectangle getPersistedDialogBounds() { int height = wizardBounds.height; if (appConfig != null) { try { - xOffset = appConfig.getInt(AppConfig.WIZARD_X_OFFSET) + AppConfig.DIALOG_X_OFFSET; - yOffset = appConfig.getInt(AppConfig.WIZARD_Y_OFFSET) + AppConfig.DIALOG_Y_OFFSET; + xOffset = appConfig.getInt(AppConfig.PROP_WIZARD_X_OFFSET) + AppConfig.DIALOG_X_OFFSET; + yOffset = appConfig.getInt(AppConfig.PROP_WIZARD_Y_OFFSET) + AppConfig.DIALOG_Y_OFFSET; width = appConfig.getInt(AppConfig.DIALOG_BOUNDS_PREFIX + getClass().getSimpleName() + AppConfig.DIALOG_WIDTH_SUFFIX); height = appConfig.getInt(AppConfig.DIALOG_BOUNDS_PREFIX + getClass().getSimpleName() + AppConfig.DIALOG_HEIGHT_SUFFIX); } catch (Exception ex) { diff --git a/src/test/java/com/salesforce/dataloader/TestBase.java b/src/test/java/com/salesforce/dataloader/TestBase.java index 58f61aad..e4efc9c2 100644 --- a/src/test/java/com/salesforce/dataloader/TestBase.java +++ b/src/test/java/com/salesforce/dataloader/TestBase.java @@ -195,7 +195,7 @@ private void setupTestName() { protected void setupController(Map configOverrideMap) { // configure the Controller to point to our testing config - configOverrideMap.put(AppConfig.READ_ONLY_CONFIG_PROPERTIES, Boolean.TRUE.toString()); + configOverrideMap.put(AppConfig.PROP_READ_ONLY_CONFIG_PROPERTIES, Boolean.TRUE.toString()); if (!System.getProperties().contains(AppUtil.CLI_OPTION_CONFIG_DIR_PROP)) System.setProperty(AppUtil.CLI_OPTION_CONFIG_DIR_PROP, getTestConfDir()); diff --git a/src/test/java/com/salesforce/dataloader/TestSetting.java b/src/test/java/com/salesforce/dataloader/TestSetting.java index 897b26f0..b1014851 100644 --- a/src/test/java/com/salesforce/dataloader/TestSetting.java +++ b/src/test/java/com/salesforce/dataloader/TestSetting.java @@ -39,7 +39,7 @@ public enum TestSetting { BULK_API_DISABLED(AppConfig.PROP_BULK_API_ENABLED, Boolean.FALSE), BULK_API_ZIP_CONTENT_ENABLED(AppConfig.PROP_BULK_API_ZIP_CONTENT, Boolean.TRUE), BULK_API_SERIAL_MODE_ENABLED(AppConfig.PROP_BULK_API_SERIAL_MODE, Boolean.TRUE), - BULK_API_CACHE_DAO_UPLOAD_ENABLED(AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO, Boolean.TRUE), + BULK_API_CACHE_DAO_UPLOAD_ENABLED(AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO, Boolean.TRUE), BULK_V2_API_ENABLED(AppConfig.PROP_BULKV2_API_ENABLED, Boolean.TRUE), BULK_V2_API_DISABLED(AppConfig.PROP_BULKV2_API_ENABLED, Boolean.FALSE), COMPOSITE_REST_API_DISABLED(AppConfig.PROP_UPDATE_WITH_EXTERNALID, Boolean.FALSE), diff --git a/src/test/java/com/salesforce/dataloader/process/CsvProcessTest.java b/src/test/java/com/salesforce/dataloader/process/CsvProcessTest.java index 07eb6eb4..5073871b 100644 --- a/src/test/java/com/salesforce/dataloader/process/CsvProcessTest.java +++ b/src/test/java/com/salesforce/dataloader/process/CsvProcessTest.java @@ -95,7 +95,7 @@ public static Collection getParameters() { public void testInsertAccountCsv() throws Exception { Map configMap = getTestConfig(OperationInfo.insert, false); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -139,7 +139,7 @@ public void testInsertTaskWithContactAsWhoCsv() throws Exception { Map configMap = getTestConfig(OperationInfo.insert, false); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) || isSettingEnabled(configMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -172,7 +172,7 @@ public void testInsertTaskWithContactAsWhoCsv() throws Exception { public void testUpdateAccountCsv() throws Exception { Map configMap = getUpdateTestConfig(false, null, 100); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) || isSettingEnabled(configMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) @@ -199,7 +199,7 @@ public void testUpsertAccountCsv() throws Exception { Map configMap = getUpdateTestConfig(true, DEFAULT_ACCOUNT_EXT_ID_FIELD, 50); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) || isSettingEnabled(configMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -224,7 +224,7 @@ public void testUpsertAccountCsv() throws Exception { public void testConstantMappingInCsv() throws Exception { Map configMap = getTestConfig(OperationInfo.insert, false); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -263,7 +263,7 @@ public void testDescriptionAsConstantMappingInCsv() throws Exception { Map configMap = getTestConfig(OperationInfo.insert, getTestDataDir() + "/constantMappingInCsv.csv", false); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -298,7 +298,7 @@ public void testFieldAndConstantFieldClash() throws Exception { Map configMap = getTestConfig(OperationInfo.insert, getTestDataDir() + "/constantMappingInCsvClashing.csv", false); if (isSettingEnabled(configMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(configMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(configMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(configMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(configMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -466,7 +466,7 @@ public void testCreateAttachment() throws Exception { if (isSettingEnabled(argMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID)) { return; } - if (isSettingEnabled(argMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO)) { + if (isSettingEnabled(argMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO)) { return; } @@ -541,7 +541,7 @@ private void _doTestHtmlFormattingInInsert(boolean preserveWhitespaceInRichText) return; } if (isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(argumentMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(argumentMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(argumentMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -636,7 +636,7 @@ public void testTimezoneNotTruncated() throws Exception { getTestDataDir() + "/timeZoneFormatTesting.csv", false); if (isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) || isSettingEnabled(argumentMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) - || isSettingEnabled(argumentMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(argumentMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(argumentMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -692,7 +692,7 @@ public void testOneToManySforceFieldsMappingInCsv() throws Exception { + "/oneToManySforceFieldsMappingInCsv.csv", false); if (isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) || isSettingEnabled(argumentMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) - || isSettingEnabled(argumentMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(argumentMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(argumentMap, AppConfig.PROP_NO_COMPRESSION) ) { @@ -735,7 +735,7 @@ public void testOneToManySforceFieldsMappingInCsv() throws Exception { public void testEmptyFirstRowFieldValueInCsv() throws Exception { Map argumentMap = getUpdateTestConfig(false, null, 2); if (isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_ZIP_CONTENT) - || isSettingEnabled(argumentMap, AppConfig.PROCESS_BULK_CACHE_DATA_FROM_DAO) + || isSettingEnabled(argumentMap, AppConfig.PROP_PROCESS_BULK_CACHE_DATA_FROM_DAO) || isSettingEnabled(argumentMap, AppConfig.PROP_BULK_API_SERIAL_MODE) || isSettingEnabled(argumentMap, AppConfig.PROP_NO_COMPRESSION) || isSettingEnabled(argumentMap, AppConfig.PROP_UPDATE_WITH_EXTERNALID) diff --git a/src/test/java/com/salesforce/dataloader/process/ProcessTestBase.java b/src/test/java/com/salesforce/dataloader/process/ProcessTestBase.java index 4ec198af..8374daa7 100644 --- a/src/test/java/com/salesforce/dataloader/process/ProcessTestBase.java +++ b/src/test/java/com/salesforce/dataloader/process/ProcessTestBase.java @@ -717,7 +717,7 @@ protected Controller runProcessNegative(Map args, String failure protected IProcess runBatchProcess(Map argMap) { if (argMap == null) argMap = getTestConfig(); argMap.put(AppConfig.PROP_PROCESS_THREAD_NAME, this.baseName); - argMap.put(AppConfig.READ_ONLY_CONFIG_PROPERTIES, Boolean.TRUE.toString()); + argMap.put(AppConfig.PROP_READ_ONLY_CONFIG_PROPERTIES, Boolean.TRUE.toString()); argMap.put(AppConfig.CLI_OPTION_RUN_MODE, AppConfig.RUN_MODE_BATCH_VAL); // emulate invocation through process.bat script