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;
}
KAMCatalogDao.KamFilter filter;
try {
filter = convert(request.getFilter(), kamInfo);
} catch (InvalidIdException ex) {
LoadKamResponse resp = OBJECT_FACTORY.createLoadKamResponse();
resp.setLoadStatus(FAILED);
resp.setMessage(ex.getMessage());
return resp;
}
LoadKAMResult rslt;
try {
rslt = kamCacheService.loadKamWithResult(kamInfo, filter);
} catch (KamCacheServiceException e) {
String msg = getFirstMessage(e);
LoadKamResponse resp = OBJECT_FACTORY.createLoadKamResponse();
resp.setLoadStatus(FAILED);
resp.setMessage(msg);
return resp;
}
LoadKamResponse resp = OBJECT_FACTORY.createLoadKamResponse();
if (rslt.getStatus() == LOADING) {
resp.setLoadStatus(KAMLoadStatus.IN_PROCESS);
return resp;
}
KamHandle kamHandle = OBJECT_FACTORY.createKamHandle();
kamHandle.setHandle(rslt.getHandle());
resp.setHandle(kamHandle);
resp.setLoadStatus(KAMLoadStatus.COMPLETE);
return resp;
}