*/
private void modifyDataSource(SourceBean serviceRequest, String mod, SourceBean serviceResponse)
throws EMFUserError, SourceBeanException {
try {
IDataSourceDAO dao=DAOFactory.getDataSourceDAO();
dao.setUserProfile(profile);
DataSource dsNew = recoverDataSourceDetails(serviceRequest);
EMFErrorHandler errorHandler = getErrorHandler();
// if there are some validation errors into the errorHandler 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("dsObj", dsNew);
serviceResponse.setAttribute("modality", mod);
return;
}
}
}
if (mod.equalsIgnoreCase(SpagoBIConstants.DETAIL_INS)) {
//if a ds with the same label not exists on db ok else error
if (DAOFactory.getDataSourceDAO().loadDataSourceByLabel(dsNew.getLabel()) != null){
HashMap params = new HashMap();
params.put(AdmintoolsConstants.PAGE, ListDataSourceModule.MODULE_PAGE);
EMFUserError error = new EMFUserError(EMFErrorSeverity.ERROR, 8004, new Vector(), params );
getErrorHandler().addError(error);
return;
}
dao.insertDataSource(dsNew);
IDataSource tmpDS = dao.loadDataSourceByLabel(dsNew.getLabel());
dsNew.setDsId(tmpDS.getDsId());
mod = SpagoBIConstants.DETAIL_MOD;
} else {
//update ds
dao.modifyDataSource(dsNew);
}
IDomainDAO domaindao = DAOFactory.getDomainDAO();
List dialects = domaindao.loadListDomainsByType("DIALECT_HIB");
serviceResponse.setAttribute(NAME_ATTR_LIST_DIALECTS, dialects);