Skip to content
Snippets Groups Projects
Commit 4383fe3b authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

Don't throw error when id is not found: just return null InsetionModes

parent c48110d6
Branches
Tags
No related merge requests found
......@@ -62,7 +62,6 @@ public class TTSArchivingManagerApi implements IArchivingManagerApi {
private static final String DOUBLE_SLASH = "//";
private static final String GROUP_NAME = "Check-Exported-TTS-Archivers";
private static final String FAILED_TO_GET_ARCHIVER_LIST = "Failed to get archiver list: ";
private static final String NO_ID_FOUND_FOR = "no id found for ";
private static final Logger LOGGER = LoggerFactory.getLogger(TTSArchivingManagerApi.class);
......@@ -89,7 +88,8 @@ public class TTSArchivingManagerApi implements IArchivingManagerApi {
config.setUser(params.getUser());
config.setPassword(params.getPassword());
// TANGOARCH-833: possibility to connect to another port
config.setPort(ApiUtils.getProperty(ApiConstants.TTS_PORT_PROPERTY, ApiConstants.TTS_PORT_ENV, config.getPort()));
config.setPort(
ApiUtils.getProperty(ApiConstants.TTS_PORT_PROPERTY, ApiConstants.TTS_PORT_ENV, config.getPort()));
config.setIdleTimeout(params.getInactivityTimeout());
config.setMaxPoolSize(params.getMaxPoolSize());
if (params.getHealthRegistry() != null) {
......@@ -347,22 +347,27 @@ public class TTSArchivingManagerApi implements IArchivingManagerApi {
public InsertionModes getInsertionModes(String attributeName) throws ArchivingException {
OptionalInt id;
Optional<InsertionModes> modes;
if (configService == null) {
id = null;
} else {
id = configService.getAttributeID(attributeName);
}
if (id == null || !id.isPresent()) {
throw new ArchivingException(NO_ID_FOUND_FOR + attributeName);
// No InsertionModes if id is not found
modes = null;
} else {
modes = configService.getCurrentInsertionModes(id.getAsInt());
}
Optional<InsertionModes> modes = configService.getCurrentInsertionModes(id.getAsInt());
return modes == null || !modes.isPresent() ? null : modes.get();
}
@Override
public String[] getArchivingMode(String attributeName) throws ArchivingException {
InsertionModes modes = getInsertionModes(attributeName);
return ApiUtils.cleanToStringArray(ArchivingUtils.insertionModesToStringArray(new ArrayList<>(), modes));
// Return empty array if modes is null
return modes == null ? ApiConstants.EMPTY
: ApiUtils.cleanToStringArray(ArchivingUtils.insertionModesToStringArray(new ArrayList<>(), modes));
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment