// validate request
if (request == null) {
throw new MissingRequest(LOAD_KAM_REQUEST);
}
Kam kam = request.getKam();
if (kam == null) {
throw new RequestException(KAM_REQUEST_NO_KAM);
}
if (kam.getName() == null) {
throw new RequestException(KAM_REQUEST_NO_NAME);
}
KamInfo kamInfo = null;
List<KamInfo> catalog;
try {
catalog = kamCatalogDao.getCatalog();
} catch (SQLException e) {
String msg = getFirstMessage(e);
LoadKamResponse resp = OBJECT_FACTORY.createLoadKamResponse();
resp.setLoadStatus(FAILED);
resp.setMessage(msg);
return resp;
}
for (final KamInfo ki : catalog) {
if (ki.getName().equals(kam.getName())) {
kamInfo = ki;
break;
}
}
if (kamInfo == null) {
String errorMsg = KAM_REQUEST_NO_KAM_FOR_NAME;
String msg = format(errorMsg, kam.getName());
LoadKamResponse resp = OBJECT_FACTORY.createLoadKamResponse();
resp.setLoadStatus(FAILED);
resp.setMessage(msg);
return resp;
}