Skip to content

Commit 7bfd8fb

Browse files
author
rathnapandi
committed
Code clean up
1 parent ed2c806 commit 7bfd8fb

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

modules/settings/src/main/java/com/axway/apim/setup/adapter/APIManagerConfigAdapter.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,42 @@
1919
public class APIManagerConfigAdapter {
2020

2121
private static final Logger LOG = LoggerFactory.getLogger(APIManagerConfigAdapter.class);
22-
private APIManagerConfig managerConfig;
2322
private final StandardImportParams importParams;
2423

2524
public APIManagerConfigAdapter(StandardImportParams params) {
2625
this.importParams = params;
2726
}
2827

29-
private void readConfig() throws AppException {
28+
29+
public APIManagerConfig getManagerConfig() throws AppException {
3030
ObjectMapper mapper;
3131
String config = importParams.getConfig();
3232
String stage = importParams.getStage();
3333
File configFile = Utils.locateConfigFile(config);
34-
if (!configFile.exists()) return;
34+
if (!configFile.exists()) return null;
3535
File stageConfig = Utils.getStageConfig(stage, importParams.getStageConfig(), configFile);
3636
APIManagerConfig baseConfig;
3737
try {
3838
mapper = Utils.createObjectMapper(configFile);
3939
mapper.configOverride(Map.class).setMergeable(true);
4040
baseConfig = mapper.reader()
41-
.withAttribute(UserDeserializer.Params.USE_LOGIN_NAME, true)
42-
.withAttribute(RemotehostDeserializer.Params.validateRemoteHost, true)
43-
.forType(APIManagerConfig.class)
44-
.readValue(Utils.substituteVariables(configFile));
41+
.withAttribute(UserDeserializer.Params.USE_LOGIN_NAME, true)
42+
.withAttribute(RemotehostDeserializer.Params.validateRemoteHost, true)
43+
.forType(APIManagerConfig.class)
44+
.readValue(Utils.substituteVariables(configFile));
4545
} catch (Exception e) {
4646
throw new AppException("Cannot read API-Manager configuration from config file: " + config, ErrorCode.CANT_READ_CONFIG_FILE, e);
4747
}
4848
if (stageConfig != null) {
4949
try {
5050
ObjectReader updater = mapper.readerForUpdating(baseConfig);
51-
this.managerConfig = updater.readValue(Utils.substituteVariables(stageConfig));
51+
APIManagerConfig managerConfig = updater.readValue(Utils.substituteVariables(stageConfig));
5252
LOG.info("Successfully read stage configuration file: {}", stageConfig);
53+
return managerConfig;
5354
} catch (IOException e) {
5455
LOG.warn("No config file found for stage: {}", stage);
5556
}
56-
} else {
57-
this.managerConfig = baseConfig;
5857
}
59-
}
60-
61-
public APIManagerConfig getManagerConfig() throws AppException {
62-
if (this.managerConfig == null) readConfig();
63-
return this.managerConfig;
58+
return baseConfig;
6459
}
6560
}

0 commit comments

Comments
 (0)