RequestContainer reqCont = getRequestContainer();
SessionContainer sessCont = reqCont.getSessionContainer();
SessionContainer permSess = sessCont.getPermanentContainer();
IEngUserProfile profile = (IEngUserProfile)permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
IDistributionListDAO dao=DAOFactory.getDistributionListDAO();
dao.setUserProfile(profile);
DistributionList dlNew = recoverDistributionListDetails(serviceRequest);
EMFErrorHandler errorHandler = getErrorHandler();
// if there are some validation errors into the errorHandler it does not write into DB
Collection errors = errorHandler.getErrors();
if (errors != null && errors.size() > 0) {
Iterator iterator = errors.iterator();
while (iterator.hasNext()) {
Object error = iterator.next();
if (error instanceof EMFValidationError) {
serviceResponse.setAttribute("dlObj", dlNew);
serviceResponse.setAttribute("modality", mod);
return;
}
}
}
if (mod.equalsIgnoreCase(SpagoBIConstants.DETAIL_INS)) {
//if a dl with the same name does not exist in the db ok, else error
if (dao.loadDistributionListByName(dlNew.getName()) != null){
HashMap params = new HashMap();
params.put(AdmintoolsConstants.PAGE, ListDistributionListModule.MODULE_PAGE);
EMFUserError error = new EMFUserError(EMFErrorSeverity.ERROR, 9100, new Vector(), params );
getErrorHandler().addError(error);
return;
}
dao.insertDistributionList(dlNew);
//gets the new setted Id from the DL just inserted and puts it into dlNew
DistributionList tmpDL = dao.loadDistributionListByName(dlNew.getName());
dlNew.setId(tmpDL.getId());
mod = SpagoBIConstants.DETAIL_MOD;
} else {
//updates dl
dao.modifyDistributionList(dlNew);
}
IDomainDAO domaindao = DAOFactory.getDomainDAO();
List dialects = domaindao.loadListDomainsByType("DIALECT_HIB");
serviceResponse.setAttribute(NAME_ATTR_LIST_DIALECTS, dialects);