Added try catches to manage errors on publishing

This commit is contained in:
Francesco Mangiacrapa 2020-10-21 16:16:53 +02:00
parent b5512eb7c0
commit e54ba3b0b6
3 changed files with 138 additions and 109 deletions

View File

@ -194,6 +194,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onSave(SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) {
geoNaMainForm.enableButtonSave(false);
if(saveGeonaDataFormsEvent.getListGeonaDataForms()!=null) {
final Modal modal = new Modal(true);
@ -206,29 +208,32 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
modal.remove(loader);
modal.clear();
Alert alert = new Alert(caught.getMessage());
alert.setType(AlertType.ERROR);
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
//resetUI();
geoNaMainForm.enableButtonSave(true);
}
@Override
public void onSuccess(String result) {
modal.remove(loader);
modal.clear();
Alert alert = new Alert(result);
alert.setType(AlertType.INFO);
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
//resetUI();
geoNaMainForm.enableButtonSave(true);
}
});
modal.show();
}
}else
geoNaMainForm.enableButtonSave(true);
}
});

View File

@ -12,6 +12,7 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
@ -44,6 +45,9 @@ public class GeonaDataEntryMainForm extends Composite {
@UiField
AlertBlock alertFormAction;
@UiField
Button buttonSave;
private LinkedHashMap<String,MetadataFormCard> mapForms = new LinkedHashMap<String,MetadataFormCard>();
private List<Tab> listTabs = new ArrayList<Tab>();
@ -152,6 +156,10 @@ public class GeonaDataEntryMainForm extends Composite {
}
}
public void enableButtonSave(boolean enabled) {
buttonSave.setEnabled(enabled);
}
/**
* Sets the ative after.

View File

@ -61,6 +61,9 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
ConcessioneManager manager;
try {
//Saving Data
//Informazioni di Progetto
List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
@ -74,7 +77,7 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
Concessione concessione = ConvertToServiceModel.toConcessione(idp, user);
LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione);
//saving into back-end
ConcessioneManager manager = ManagerFactory.registerNew(concessione);
manager = ManagerFactory.registerNew(concessione);
//RELAZIONE_DI_SCAVO
list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
@ -153,6 +156,12 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
//saving into back-end
manager.addPiantaFineScavo(layerPfs, isd);
}
}catch (Exception e) {
LOG.error("Error on converting form data: ",e);
throw new Exception("Error occurred on saving data, try again or contact the support");
}
try {
//If true -> data are published into the SDI
Boolean publish=false;
@ -177,6 +186,13 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
return "Project saved successfully";
else
return "Project saved with errors";
}catch (Exception e) {
LOG.error("Error on commiting data: ",e);
throw new Exception("Error occurred on saving data, try again or contact the support");
}
}
@Override