updated send notification checks

This commit is contained in:
Francesco Mangiacrapa 2024-03-22 16:22:22 +01:00
parent bab16ad14d
commit 3913019df3
1 changed files with 59 additions and 41 deletions

View File

@ -24,6 +24,8 @@ import org.gcube.application.geoportal.common.model.configuration.Configuration;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.access.Access; import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo; import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation.Status;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.QueryRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest; import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
@ -115,6 +117,9 @@ public class ProfiledDocuments {
} }
}.execute().getResult(); }.execute().getResult();
Status status = theNewProject.getLifecycleInformation().getLastOperationStatus();
// IF last operation status is not ERROR, notify PROJECT_CREATED event
if (status != null && !status.equals(LifecycleInformation.Status.ERROR)) {
// notifying the Event.PROJECT_CREATED; // notifying the Event.PROJECT_CREATED;
ItemObserved<Project> item = new ItemObserved<Project>(); ItemObserved<Project> item = new ItemObserved<Project>();
EventManager.Event event = Event.PROJECT_CREATED; EventManager.Event event = Event.PROJECT_CREATED;
@ -125,6 +130,7 @@ public class ProfiledDocuments {
item.setProject(theNewProject); item.setProject(theNewProject);
log.info("By notifying event ({}, ID {})", event, item.getProjectId()); log.info("By notifying event ({}, ID {})", event, item.getProjectId());
eventManager.notify(event, item); eventManager.notify(event, item);
}
return theNewProject; return theNewProject;
} }
@ -149,6 +155,10 @@ public class ProfiledDocuments {
} }
}.execute().getResult(); }.execute().getResult();
Status status = theUpdatedProject.getLifecycleInformation().getLastOperationStatus();
// IF last operation status is not ERROR, notify PROJECT_UPDATED event
if (status != null && !status.equals(LifecycleInformation.Status.ERROR)) {
ItemObserved<Project> item = new ItemObserved<Project>(); ItemObserved<Project> item = new ItemObserved<Project>();
EventManager.Event event = Event.PROJECT_UPDATED; EventManager.Event event = Event.PROJECT_UPDATED;
AccountingInfo user = UserUtils.getCurrent().asInfo(); AccountingInfo user = UserUtils.getCurrent().asInfo();
@ -158,6 +168,7 @@ public class ProfiledDocuments {
item.setProject(theUpdatedProject); item.setProject(theUpdatedProject);
log.info("By notifying event ({}, ID {})", event, item.getProjectId()); log.info("By notifying event ({}, ID {})", event, item.getProjectId());
eventManager.notify(event, item); eventManager.notify(event, item);
}
return theUpdatedProject; return theUpdatedProject;
} }
@ -206,6 +217,8 @@ public class ProfiledDocuments {
} }
}.execute().getResult(); }.execute().getResult();
// IF deleted, notify PROJECT_DELETED event
if (deleted) {
ItemObserved<Project> item = new ItemObserved<Project>(); ItemObserved<Project> item = new ItemObserved<Project>();
EventManager.Event event = Event.PROJECT_DELETED; EventManager.Event event = Event.PROJECT_DELETED;
AccountingInfo user = UserUtils.getCurrent().asInfo(); AccountingInfo user = UserUtils.getCurrent().asInfo();
@ -219,6 +232,7 @@ public class ProfiledDocuments {
item.setProject(deletedProject); item.setProject(deletedProject);
log.info("By notifying event ({}, ID {})", event, item.getProjectId()); log.info("By notifying event ({}, ID {})", event, item.getProjectId());
eventManager.notify(event, item); eventManager.notify(event, item);
}
return deleted; return deleted;
} }
@ -298,6 +312,9 @@ public class ProfiledDocuments {
} }
}.execute().getResult(); }.execute().getResult();
Status status = theProject.getLifecycleInformation().getLastOperationStatus();
// IF last operation status is not ERROR, notify LIFECYCLE_STEP_PERFORMED event
if (status != null && !status.equals(LifecycleInformation.Status.ERROR)) {
ItemObserved<Project> item = new ItemObserved<Project>(); ItemObserved<Project> item = new ItemObserved<Project>();
EventManager.Event event = Event.LIFECYCLE_STEP_PERFORMED; EventManager.Event event = Event.LIFECYCLE_STEP_PERFORMED;
AccountingInfo user = UserUtils.getCurrent().asInfo(); AccountingInfo user = UserUtils.getCurrent().asInfo();
@ -307,6 +324,7 @@ public class ProfiledDocuments {
item.setProject(theProject); item.setProject(theProject);
log.info("By notifying event ({}, ID {})", event, item.getProjectId()); log.info("By notifying event ({}, ID {})", event, item.getProjectId());
eventManager.notify(event, item); eventManager.notify(event, item);
}
return theProject; return theProject;
} }