From c4b9d79e6878548f793772b7ff8b39dceb2c2f80 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 11 Oct 2024 17:17:05 +0200 Subject: [PATCH 1/5] Init new feature --- .settings/org.eclipse.wst.common.component | 41 ++++++--- CHANGELOG.md | 4 + pom.xml | 2 +- .../client/GeoPortalDataEntryApp.java | 38 +++++++- .../client/GeoportalDataEntryService.java | 16 +++- .../GeoportalDataEntryServiceAsync.java | 6 +- .../client/ui/utils/UUIDUtil.java | 16 ++++ .../server/GeoportalDataEntryServiceImpl.java | 83 +++++++++++++++-- .../server/SessionUtil.java | 22 ++++- .../shared/monitoring/MonitorActions.java | 66 ++++++++++++++ .../shared/monitoring/MonitoringAction.java | 89 +++++++++++++++++++ 11 files changed, 359 insertions(+), 24 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UUIDUtil.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringAction.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index bd0903c..311279f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -175,7 +177,9 @@ - + + + @@ -351,7 +355,9 @@ - + + + @@ -527,7 +533,9 @@ - + + + @@ -703,7 +711,9 @@ - + + + @@ -834,16 +844,15 @@ uses - - uses - uses - + uses - + + + @@ -1019,7 +1028,9 @@ - + + + @@ -1195,7 +1206,9 @@ - + + + @@ -1371,7 +1384,9 @@ - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 278fe2a..37f7fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v3.4.0-SNAPSHOT] + +- Added the logic for monitoring the operations on saving project + ## [v3.3.0] - 2024-06-28 - Implemented the init facility to resolve a public link on an item [#27120] diff --git a/pom.xml b/pom.xml index 6845762..1026dd6 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 3.3.0 + 3.4.0-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 452088b..15e1546 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -72,6 +72,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ModalConfirm; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.UUIDUtil; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -79,6 +80,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundException; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget; import org.gcube.portlets.widgets.gdvw.client.project.ProjectViewer; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; @@ -728,9 +730,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.setWidth(800); modal.setMaxHeigth("650px"); final VerticalPanel modalContainerPanel = new VerticalPanel(); + final VerticalPanel modalContainerMonitor = new VerticalPanel(); final LoaderIcon loader = new LoaderIcon(); loader.setText("Trying to save the data, please wait..."); modalContainerPanel.add(loader); + modalContainerPanel.add(modalContainerMonitor); modal.add(modalContainerPanel); String[] listPostActionOnSave = mainTabPanel @@ -745,7 +749,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { GWT.log("Calling saveGeonaDataForms, stepsOnPostCreation are " + stepsOnPostCreation); - GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms( + final String uuid = UUIDUtil.generateUUID(); + GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(uuid, saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getTreeNode(), stepsOnPostCreation, new AsyncCallback() { @@ -806,6 +811,37 @@ public class GeoPortalDataEntryApp implements EntryPoint { }); modal.show(); + String uuidString = uuid.toString(); + new Timer() { + + @Override + public void run() { + GeoportalDataEntryServiceAsync.Util.getInstance().getSavingProjectMonitorStatus(uuidString, new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub + + } + + @Override + public void onSuccess(LinkedHashMap monitorActions) { + modalContainerMonitor.clear(); + if(monitorActions!=null) { + if(monitorActions.size()>0) { + for (Integer key : monitorActions.keySet()) { + MonitoringAction action = monitorActions.get(key); + modalContainerMonitor.add(new Label(action.getMsg() + " --- "+action.getStatus().getLabel())); + } + } + } + + } + }); + + } + }.scheduleRepeating(2000); + } else geoNaMainForm.enableButtonSave(true); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index c52839b..c7f2a17 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataentry.client; +import java.util.LinkedHashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; @@ -22,6 +23,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedCon import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -39,13 +41,14 @@ public interface GeoportalDataEntryService extends RemoteService { /** * Save geona data forms. * + * @param uuid the uuid * @param profileID the profile ID * @param tree_Node the tree node * @param stepsOnPostCreation the steps on post creation * @return the commit report * @throws Exception the exception */ - CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node, + CommitReport saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, List stepsOnPostCreation) throws Exception; /** @@ -146,6 +149,7 @@ public interface GeoportalDataEntryService extends RemoteService { * @param optionalMessage the optional message * @param action the action * @return the project DV + * @throws Exception the exception */ StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action) throws Exception; @@ -248,4 +252,14 @@ public interface GeoportalDataEntryService extends RemoteService { */ ProjectView getProjectView(String profileID, String projectID) throws Exception; + + /** + * Gets the saving project monitor status. + * + * @param savingProjectUUID the saving project UUID + * @return the saving project monitor status + * @throws Exception the exception + */ + LinkedHashMap getSavingProjectMonitorStatus(String savingProjectUUID) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index 20b337c..b1b6588 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataentry.client; +import java.util.LinkedHashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; @@ -22,6 +23,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedCon import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -53,7 +55,7 @@ public interface GeoportalDataEntryServiceAsync { } } - void saveGeonaDataForms(String profileID, Tree_Node tree_Node, + void saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, List stepsOnPostCreation, AsyncCallback callback); void updateGeportalDataForm(String profileID, String projectID, GeoNaFormDataObject section, @@ -101,4 +103,6 @@ public interface GeoportalDataEntryServiceAsync { void getProjectView(String profileID, String projectID, AsyncCallback callback); + void getSavingProjectMonitorStatus(String savingProjectUUID, AsyncCallback> callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UUIDUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UUIDUtil.java new file mode 100644 index 0000000..a0334e0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UUIDUtil.java @@ -0,0 +1,16 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +public class UUIDUtil { + + public static String generateUUID() { + return nativeGenerateUUID(); + } + + // Usa una funzione JavaScript per generare un UUID + private static native String nativeGenerateUUID() /*-{ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + }-*/; +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index fb3a868..ef23b5b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -76,6 +76,9 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundException; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitorActions; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction.STATUS; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote; @@ -137,27 +140,41 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Save geona data forms. * + * @param uuid the uuid * @param profileID the profile ID - * @param optionalMessage the optional message * @param tree_Node the tree node * @param stepsOnPostCreation the steps on post creation * @return the commit report * @throws Exception the exception */ @Override - public CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node, + public CommitReport saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, List stepsOnPostCreation) throws Exception { LOG.info("saveGeonaDataForms called for profileID {}", profileID); long startTime = System.currentTimeMillis(); LOG.info("Procedure starting at: " + startTime); + final String uuidAsString = uuid.toString(); + + final MonitorActions monitorActions = new MonitorActions(this.getThreadLocalRequest(), uuidAsString); MongoServiceUtil mongoService = new MongoServiceUtil(); String theDocumentString = null; try { + // 1. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Converting prject metadata to Geoportal data model"); + int actionId = monitorActions.pushAction(action); + action.setActionId(actionId); FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); JSONObject theDocument = metadataConverter.convert(tree_Node, null); + + //1. Action completed + action.setMsg("Converted prject metadata to Geoportal data model"); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); + theDocumentString = theDocument.toString(); LOG.info("Got Document: " + theDocumentString); } catch (Exception e) { @@ -171,7 +188,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); LOG.debug("Going to create the project..."); + // 2. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Creating project on Geoportal Storage service"); + int actionId = monitorActions.pushAction(action); + action.setActionId(actionId); + theProject = mongoService.createNew(profileID, theDocumentString); + + //2. Action completed + action.setMsg("Created project on Geoportal Storage service"); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); + LOG.info("Project created with id: " + theProject.getId() + " and profileID: " + theProject.getProfileID()); } catch (Exception e) { @@ -186,7 +215,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // Uploading files into tempDirs in order to avoid clashing of names LOG.debug("Going to upload the files"); - listTempDirs = recursiveUploadFileset(mongoService, profileID, theProject, tree_Node, null, listTempDirs); + + // 3. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Going to upload the file/s..."); + int actionId = monitorActions.pushAction(action); + action.setActionId(actionId); + + listTempDirs = recursiveUploadFileset(monitorActions, mongoService, profileID, theProject, tree_Node, null, listTempDirs); } catch (Exception e) { LOG.error("Error on uploading files: ", e); @@ -201,7 +237,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("stepsOnPostCreation are {}", stepsOnPostCreation); for (String stepID : stepsOnPostCreation) { LOG.info("calling step OnPostCreation are {}", stepID); + + // 4. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Performing step: "+stepID); + int actionId = monitorActions.pushAction(action); + action.setActionId(actionId); + theProject = client.performStep(theProject.getProfileID(), theProject.getId(), stepID, null, null); + + //5. Action completed + action.setMsg("Performed step: "+stepID); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); } } catch (Exception e) { @@ -240,11 +288,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen long endDiffMillis = System.currentTimeMillis() - startTime; long minutes = TimeUnit.MILLISECONDS.toMinutes(endDiffMillis); LOG.info("Procedure terminated in ms: " + endDiffMillis + ", minutes: " + minutes); + monitorActions.destroyMonitor(); } catch (Exception e) { // silent } } } + + @Override + public LinkedHashMap getSavingProjectMonitorStatus(final String savingProjectUUID) throws Exception { + MonitorActions ma = SessionUtil.getMonitorStatus(getThreadLocalRequest(), savingProjectUUID); + return ma.getMonitor(); + } /** * Update geportal data form. @@ -430,6 +485,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Recursive upload fileset. * + * @param monitorActions the monitor actions * @param mongoService the mongo service * @param profileID the profile ID * @param theProject the the project @@ -439,7 +495,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @return the list * @throws Exception the exception */ - public List recursiveUploadFileset(MongoServiceUtil mongoService, String profileID, Project theProject, + public List recursiveUploadFileset(final MonitorActions monitorActions, MongoServiceUtil mongoService, String profileID, Project theProject, Tree_Node tree_Node, Map sectionJSONPathIndexer, List tempDirs) throws Exception { LOG.debug("recursiveUploadFileset called [tree_Node: " + tree_Node + "], [jsonPathIndexer: " @@ -500,6 +556,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen String formFieldName = file.getFilePath().getFormFieldLabel(); LOG.debug( "Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName); + FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile); LOG.info("Found {} for the form fieldName {}", filePath, formFieldName); if (filePath == null) { @@ -570,13 +627,29 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.debug("registering the fileset in the section: " + sectionJSONPath); access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, sectionJSONPath); + + + List fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList()); + + //1..N Monitoring Uploading Fileset + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Uploading fileset: "+fileNames ); + int actionId = monitorActions.pushAction(action); + action.setActionId(actionId); + + mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); + + //1..N Monitoring Fileset uploaded action completed + action.setMsg("Fileset "+fileNames+" uploaded correclty"); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); } } - tempDirs = recursiveUploadFileset(mongoService, profileID, theProject, treeNodeChild_GNA_DO, + tempDirs = recursiveUploadFileset(monitorActions, mongoService, profileID, theProject, treeNodeChild_GNA_DO, sectionJSONPathIndexer, tempDirs); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index a08c3b0..14a738e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -19,6 +19,7 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetSorted; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitorActions; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; @@ -41,7 +42,8 @@ public class SessionUtil { private static final String GNA_DATAENTRY_CONFIG_PROFILE = "GNA_DATAENTRY_CONFIG_PROFILE"; private static final String LATEST_RESULT_SET_SORTED = "LATEST_RESULT_SET_SORTED"; - //private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE"; + // private static final String GEONA_DATAVIEWER_PROFILE = + // "GEONA_DATAVIEWER_PROFILE"; private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI"; private static final String LIST_OF_RELATIONSHIP_DEFINITION = "LIST_OF_RELATIONSHIP_DEFINITION"; @@ -325,7 +327,7 @@ public class SessionUtil { HttpSession session = threadLocalRequest.getSession(); session.setAttribute(LIST_OF_RELATIONSHIP_DEFINITION + profileID, listRelationshipNames); } - + /** * Gets the JSON timeline template. * @@ -351,5 +353,21 @@ public class SessionUtil { session.setAttribute(TIMELINE_JSON_TEMPLATE + profileID, jsonTimelineTemplate); } + public static void setMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString, + MonitorActions monitorActions) { + HttpSession session = httpServletRequest.getSession(); + String monitorID = getUniqueMonitorID(uuidAsString); + session.setAttribute(monitorID, monitorActions); + } + + public static MonitorActions getMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString) { + HttpSession session = httpServletRequest.getSession(); + String monitorID = getUniqueMonitorID(uuidAsString); + return (MonitorActions) session.getAttribute(monitorID); + } + + public static final String getUniqueMonitorID(String uuid) { + return uuid + "_MONITOR"; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java new file mode 100644 index 0000000..a356401 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java @@ -0,0 +1,66 @@ +package org.gcube.portlets.user.geoportaldataentry.shared.monitoring; + +import java.io.Serializable; +import java.util.LinkedHashMap; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.portlets.user.geoportaldataentry.server.SessionUtil; + +public class MonitorActions implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -2370892426311458184L; + + private LinkedHashMap monitor = new LinkedHashMap(); + + private HttpServletRequest request; + + private String monitorUUID; + + public MonitorActions(HttpServletRequest httpServletRequest, String monitorUUID) { + this.request = httpServletRequest; + this.monitorUUID = monitorUUID; + } + + /** + * Push action. + * + * @param action the action + * @return the action Id + */ + public synchronized int pushAction(MonitoringAction action) { + final int current = monitor.size(); + monitor.put(current + 1, action); + updateMonitorInSession(); + return current; + } + + public synchronized void overrideAction(MonitoringAction action) { + monitor.put(action.getActionId(), action); + updateMonitorInSession(); + } + + public MonitoringAction getAction(Integer index) { + if (index == null || index < 0) + return null; + + return monitor.get(index); + + } + + public LinkedHashMap getMonitor() { + return monitor; + } + + private void updateMonitorInSession() { + SessionUtil.setMonitorStatus(request, monitorUUID, this); + } + + public void destroyMonitor() { + SessionUtil.setMonitorStatus(request, monitorUUID, null); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringAction.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringAction.java new file mode 100644 index 0000000..973507f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringAction.java @@ -0,0 +1,89 @@ +package org.gcube.portlets.user.geoportaldataentry.shared.monitoring; + +import java.io.Serializable; + +public class MonitoringAction implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7129157692965636149L; + private Integer actionId; + private STATUS status; + private String msg; + + public static enum STATUS { + IN_PENDING("Pending", "Operation in Pending"), + IN_PROGESS("Progress", "Operation in Progress"), + FAILED("Failed", "Operation Failed"), + DONE("Done", "Operation Done"); + + String id; + String label; + + STATUS(String id, String label) { + this.id = id; + this.label = label; + } + + public String getId() { + return id; + } + + public String getLabel() { + return label; + } + } + + public MonitoringAction() { + + } + + public MonitoringAction(STATUS status, String msg) { + this.status = status; + this.msg = msg; + } + + public MonitoringAction(Integer actionId, STATUS status, String msg) { + this(status, msg); + this.actionId = actionId; + } + + public STATUS getStatus() { + return status; + } + + public String getMsg() { + return msg; + } + + public void setStatus(STATUS status) { + this.status = status; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Integer getActionId() { + return actionId; + } + + public void setActionId(Integer actionId) { + this.actionId = actionId; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("MonitoringAction [actionId="); + builder.append(actionId); + builder.append(", status="); + builder.append(status); + builder.append(", msg="); + builder.append(msg); + builder.append("]"); + return builder.toString(); + } + +} From 39efa4b27ce1f09d76a98523a2cf74ca82b4995a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 14 Oct 2024 17:21:14 +0200 Subject: [PATCH 2/5] In progress task [#28268] --- .settings/org.eclipse.wst.common.component | 30 +- CHANGELOG.md | 2 +- .../client/GeoPortalDataEntryApp.java | 403 ++++++++++++------ .../client/GeoportalDataEntryService.java | 13 +- .../GeoportalDataEntryServiceAsync.java | 8 +- .../client/ui/utils/ExtModal.java | 132 ++++++ .../server/GeoportalDataEntryServiceImpl.java | 342 +++++++++------ .../server/MonitoringActionsOnServer.java | 106 +++++ .../server/SessionUtil.java | 20 +- .../server/test/MockData.java | 79 ++++ .../shared/monitoring/MonitorActions.java | 66 --- .../monitoring/MonitoringActionsOnClient.java | 87 ++++ 12 files changed, 933 insertions(+), 355 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExtModal.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MonitoringActionsOnServer.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/server/test/MockData.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringActionsOnClient.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 311279f..26d873c 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -177,7 +178,8 @@ - + + @@ -355,7 +357,8 @@ - + + @@ -533,7 +536,8 @@ - + + @@ -711,7 +715,8 @@ - + + @@ -841,16 +846,14 @@ - - uses - uses uses - + + @@ -1028,7 +1031,8 @@ - + + @@ -1206,7 +1210,8 @@ - + + @@ -1384,7 +1389,8 @@ - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f7fcb..5620a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [v3.4.0-SNAPSHOT] -- Added the logic for monitoring the operations on saving project +- The save operation is now monitored asynchronously [#28268] ## [v3.3.0] - 2024-06-28 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 15e1546..ceaa9cd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -81,6 +81,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundExceptio import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringActionsOnClient; import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget; import org.gcube.portlets.widgets.gdvw.client.project.ProjectViewer; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; @@ -95,9 +96,13 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Icon; +import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.IconSize; +import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; @@ -119,7 +124,6 @@ import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; -import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TreeItem; import com.google.gwt.user.client.ui.VerticalPanel; @@ -180,6 +184,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { private GNADataEntryExtendedConfigProfile gNADataEntryPresentationConfig = null; + private MonitoringActionsOnClient monitorActionsClientInstance = null; + /** * This is the entry point method. */ @@ -443,6 +449,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { mainTabPanel.setTabActive(1); } else mainTabPanel.setTabActive(0); + } }); } @@ -458,9 +465,19 @@ public class GeoPortalDataEntryApp implements EntryPoint { initExecutor.putCommand(commandInitOnItem); } initExecutor.execute(); + + // Uncomment this to test the monitor +// try { +// new Timer() { +// public void run() { +// appManagerBus.fireEvent(new SaveGeonaDataFormsEvent("the id", null)); +// } +// }.schedule(7000); +// } catch (Exception e) { +// } } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Window.alert( + "Error during application initialization. Please refresh and try again. If the problem persists please contact the support"); } } @@ -719,132 +736,268 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) { + GWT.log("SaveGeonaDataFormsEvent fired"); + + // resetting last monitor + monitorActionsClientInstance = null; + geoNaMainForm.enableButtonSave(false); - if (saveGeonaDataFormsEvent.getTreeNode() != null) { - - final Modal modal = new Modal(true); - modal.setCloseVisible(false); - modal.setTitle("Saving project..."); - modal.hide(false); - modal.setWidth(800); - modal.setMaxHeigth("650px"); - final VerticalPanel modalContainerPanel = new VerticalPanel(); - final VerticalPanel modalContainerMonitor = new VerticalPanel(); - final LoaderIcon loader = new LoaderIcon(); - loader.setText("Trying to save the data, please wait..."); - modalContainerPanel.add(loader); - modalContainerPanel.add(modalContainerMonitor); - modal.add(modalContainerPanel); - - String[] listPostActionOnSave = mainTabPanel - .getPostCreationActionOnSave(saveGeonaDataFormsEvent.getProfileID()); - - List stepsOnPostCreation = new ArrayList(); - if (listPostActionOnSave != null) { - for (String step : listPostActionOnSave) { - stepsOnPostCreation.add(step); - } - } - - GWT.log("Calling saveGeonaDataForms, stepsOnPostCreation are " + stepsOnPostCreation); - - final String uuid = UUIDUtil.generateUUID(); - GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(uuid, - saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getTreeNode(), - stepsOnPostCreation, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - modalContainerPanel.clear(); - modal.setCloseVisible(true); - try { - modal.remove(loader); - } catch (Exception e) { - } - Alert alert = new Alert(caught.getMessage()); - alert.setType(AlertType.ERROR); - alert.setClose(false); - modal.add(alert); - // resetUI(); - geoNaMainForm.enableButtonSave(true); - } - - @Override - public void onSuccess(CommitReport result) { - modalContainerPanel.clear(); - modal.setCloseVisible(true); - modal.setTitle("Project Saved!"); - - LifecycleInformationDV lcDV = result.getLifecycleInformation(); - - switch (lcDV.getLastOperationStatus()) { - case OK: { - String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, - "SUCCESS"); - String msg = lcDV.getLastInvokedStep() + "terminated with: " + success; - projectSavedWithSuccess = true; - geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); - purgeFileUploaded(); - break; - } - case WARNING: { - geoNaMainForm.enableButtonSave(true); - break; - } - case ERROR: { - geoNaMainForm.enableButtonSave(true); - break; - } - default: - break; - } - - savedMap.put(result.getProjectID(), saveGeonaDataFormsEvent.getTreeNode()); - - LifecycleInformationPanel lip = new LifecycleInformationPanel(result.getProjectID(), - result.getProfileID(), result.getProjectAsJSON(), lcDV, false); - - modalContainerPanel.add(lip); - - } - }); - - modal.show(); - String uuidString = uuid.toString(); - new Timer() { - - @Override - public void run() { - GeoportalDataEntryServiceAsync.Util.getInstance().getSavingProjectMonitorStatus(uuidString, new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub - - } - - @Override - public void onSuccess(LinkedHashMap monitorActions) { - modalContainerMonitor.clear(); - if(monitorActions!=null) { - if(monitorActions.size()>0) { - for (Integer key : monitorActions.keySet()) { - MonitoringAction action = monitorActions.get(key); - modalContainerMonitor.add(new Label(action.getMsg() + " --- "+action.getStatus().getLabel())); - } - } - } - - } - }); - - } - }.scheduleRepeating(2000); - - } else + // TODO REMOVE THIS + if (saveGeonaDataFormsEvent.getTreeNode() == null) { + Window.alert("I cannot save the project. Incorrect data. Please, refresh and try again"); geoNaMainForm.enableButtonSave(true); + return; + } + final Modal modal = new Modal(true); + modal.setCloseVisible(false); + modal.setTitle("Saving project..."); + modal.hide(false); + modal.setWidth(800); + modal.setMaxHeigth("650px"); + final VerticalPanel modalContainerPanel = new VerticalPanel(); + final VerticalPanel modalContainerMonitor = new VerticalPanel(); + final LoaderIcon loader = new LoaderIcon(); + loader.setText("Trying to save the project, please wait..."); + modalContainerPanel.add(loader); + modalContainerPanel.add(modalContainerMonitor); + modal.add(modalContainerPanel); + + String[] listPostActionOnSave = mainTabPanel + .getPostCreationActionOnSave(saveGeonaDataFormsEvent.getProfileID()); + + List stepsOnPostCreation = new ArrayList(); + if (listPostActionOnSave != null) { + for (String step : listPostActionOnSave) { + stepsOnPostCreation.add(step); + } + } + + GWT.log("Calling saveGeonaDataForms, stepsOnPostCreation are " + stepsOnPostCreation); + + final String uuid = UUIDUtil.generateUUID(); + GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(uuid, + saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getTreeNode(), + stepsOnPostCreation, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + try { + modal.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert(caught.getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + modal.add(alert); + // resetUI(); + geoNaMainForm.enableButtonSave(true); + } + + @Override + public void onSuccess(Void result) { + // null + } + }); + + modal.show(); + + // Monitoring the save actions calling the timer (polling) + String uuidString = uuid.toString(); + final Timer pollingMonitor = new Timer() { + + @Override + public void run() { + + if (!GWT.isProdMode()) { + GWT.log("New polling starts..."); + if (monitorActionsClientInstance != null) { + GWT.log("New polling for: " + monitorActionsClientInstance.getMonitorUUID()); + } + } + + // Check if the last action on monitor has been consumed on client side + boolean monitorConsumedByClient = false; + + if (monitorActionsClientInstance != null) { + + // In case of exception or terminated monitor on server side, I'm going to + // cancel the monitor on client side (last monitor has been consumed) + if (monitorActionsClientInstance.getException() != null + || monitorActionsClientInstance.isMonitoringTerminatedOnServer()) { + monitorConsumedByClient = true; + // cancel the monitor client side + GWT.log("Cancelled the monitor polling for: " + + monitorActionsClientInstance.getMonitorUUID()); + cancel(); + modal.setCloseVisible(true); + } + + } + + final boolean isMonitorConsumedByClient = monitorConsumedByClient; + + GeoportalDataEntryServiceAsync.Util.getInstance().getSavingProjectMonitorStatus(uuidString, + monitorConsumedByClient, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + + if (isMonitorConsumedByClient) { + return; + } + + modalContainerPanel.clear(); + modal.setCloseVisible(true); + try { + modal.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert(caught.getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + modal.add(alert); + // resetUI(); + geoNaMainForm.enableButtonSave(true); + + } + + @Override + public void onSuccess(MonitoringActionsOnClient monitoringActions) { + + // The monitor is consumed here reporting the actions + monitorActionsClientInstance = monitoringActions; + + if (isMonitorConsumedByClient) { + return; + } + + if (monitoringActions != null && monitoringActions.getMonitor() != null) { + modalContainerMonitor.clear(); + modalContainerMonitor.getElement().getStyle().setMarginTop(15, Unit.PX); + LinkedHashMap monitor = monitoringActions + .getMonitor(); + if (monitor.size() > 0) { + for (Integer key : monitor.keySet()) { + MonitoringAction action = monitor.get(key); + Icon icon = null; + if (action.getStatus() != null) { + switch (action.getStatus()) { + case IN_PENDING: + icon = new Icon(IconType.HEADPHONES); + icon.setTitle(action.getStatus().getLabel()); + icon.setSize(IconSize.TWO_TIMES); + break; + case IN_PROGESS: + icon = new Icon(IconType.GEAR); + icon.setSpin(true); + icon.setSize(IconSize.TWO_TIMES); + icon.setTitle(action.getStatus().getLabel()); + break; + case DONE: + icon = new Icon(IconType.OK); + icon.getElement().getStyle().setColor("#008000"); + icon.setSize(IconSize.TWO_TIMES); + icon.setTitle(action.getStatus().getLabel()); + break; + case FAILED: + icon = new Icon(IconType.WARNING_SIGN); + icon.getElement().getStyle().setColor("#800000"); + icon.setSize(IconSize.TWO_TIMES); + icon.setTitle(action.getStatus().getLabel()); + break; + + default: + break; + } + } + + HorizontalPanel hp = new HorizontalPanel(); + hp.getElement().getStyle().setMargin(10, Unit.PX); + hp.getElement().getStyle().setMarginLeft(32, Unit.PX); + com.google.gwt.user.client.ui.Label label = new com.google.gwt.user.client.ui.Label( + action.getMsg()); + icon.getElement().getStyle().setMarginRight(10, Unit.PX); + + if (icon != null) + hp.add(icon); + + hp.add(label); + + modalContainerMonitor.add(hp); + } + } + + if (monitoringActions.getException() != null) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + try { + modal.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert(monitoringActions.getException().getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + modal.add(alert); + // resetUI(); + geoNaMainForm.enableButtonSave(true); + return; + } + + CommitReport commitReport = monitoringActions.getCommitReport(); + if (commitReport != null) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + modal.setTitle("Project Saved!"); + + LifecycleInformationDV lcDV = commitReport.getLifecycleInformation(); + + switch (lcDV.getLastOperationStatus()) { + case OK: { + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, + "32CD32", null, "SUCCESS"); + String msg = lcDV.getLastInvokedStep() + "terminated with: " + + success; + projectSavedWithSuccess = true; + geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); + purgeFileUploaded(); + break; + } + case WARNING: { + geoNaMainForm.enableButtonSave(true); + break; + } + case ERROR: { + geoNaMainForm.enableButtonSave(true); + break; + } + default: + break; + } + + savedMap.put(commitReport.getProjectID(), + saveGeonaDataFormsEvent.getTreeNode()); + + LifecycleInformationPanel lip = new LifecycleInformationPanel( + commitReport.getProjectID(), commitReport.getProfileID(), + commitReport.getProjectAsJSON(), lcDV, false); + + modalContainerPanel.add(lip); + } + + } + + } + + }); + + } + }; + + pollingMonitor.scheduleRepeating(1500); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index c7f2a17..398b830 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -1,6 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client; -import java.util.LinkedHashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; @@ -23,7 +22,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedCon import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; -import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringActionsOnClient; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -48,7 +47,7 @@ public interface GeoportalDataEntryService extends RemoteService { * @return the commit report * @throws Exception the exception */ - CommitReport saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, + void saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, List stepsOnPostCreation) throws Exception; /** @@ -252,14 +251,16 @@ public interface GeoportalDataEntryService extends RemoteService { */ ProjectView getProjectView(String profileID, String projectID) throws Exception; - + /** * Gets the saving project monitor status. * - * @param savingProjectUUID the saving project UUID + * @param monitorUUID the monitor UUID + * @param isMonitoringTerminatedClientConsumed the is monitoring terminated client consumed * @return the saving project monitor status * @throws Exception the exception */ - LinkedHashMap getSavingProjectMonitorStatus(String savingProjectUUID) throws Exception; + MonitoringActionsOnClient getSavingProjectMonitorStatus(String monitorUUID, + boolean isMonitoringTerminatedClientConsumed) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index b1b6588..8861148 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -1,6 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client; -import java.util.LinkedHashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; @@ -23,7 +22,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedCon import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; -import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringActionsOnClient; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -56,7 +55,7 @@ public interface GeoportalDataEntryServiceAsync { } void saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, - List stepsOnPostCreation, AsyncCallback callback); + List stepsOnPostCreation, AsyncCallback callback); void updateGeportalDataForm(String profileID, String projectID, GeoNaFormDataObject section, String sectionPath, List listFilePaths, AsyncCallback callback); @@ -103,6 +102,7 @@ public interface GeoportalDataEntryServiceAsync { void getProjectView(String profileID, String projectID, AsyncCallback callback); - void getSavingProjectMonitorStatus(String savingProjectUUID, AsyncCallback> callback); + void getSavingProjectMonitorStatus(String monitorUUID, boolean isMonitoringTerminatedClientConsumed, + AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExtModal.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExtModal.java new file mode 100644 index 0000000..df80899 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExtModal.java @@ -0,0 +1,132 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +import com.github.gwtbootstrap.client.ui.Modal; +import com.github.gwtbootstrap.client.ui.event.HideEvent; +import com.github.gwtbootstrap.client.ui.event.HideHandler; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Element; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.EventListener; +import com.google.gwt.user.client.Random; + +/** + * The Class ExtModal. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Apr 29, 2021 + * + * This Class extends the {{@link Modal} preventing the default close of + * the Modal Bootstrap when clicking outside of the modal Window + */ +public class ExtModal extends Modal { + + private String elementId; + private String closeElementId; + private Boolean closeButtoClicked = false; + final private ExtModal INSTANCE = this; + + /** + * Instantiates a new ext modal. + */ + public ExtModal() { + super(); + setElementIds(); + addDeferredCommandToPreventModalClose(); + } + + /** + * Creates an empty, hidden widget with specified show behavior. + * + * @param animated true if the widget should be animated. + */ + public ExtModal(boolean animated) { + super(animated, false); + setElementIds(); + addDeferredCommandToPreventModalClose(); + } + + /** + * Creates an empty, hidden widget with specified show behavior. + * + * @param animated true if the widget should be animated. + * @param dynamicSafe true removes from RootPanel when hidden + */ + public ExtModal(boolean animated, boolean dynamicSafe) { + super(animated, dynamicSafe); + setElementIds(); + addDeferredCommandToPreventModalClose(); + } + + private void addDeferredCommandToPreventModalClose() { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + ((Element) INSTANCE.getElement().getChildNodes().getItem(0)).getFirstChildElement() + .setId(closeElementId); + preventModalCloseWhenClickingOutside(); + + } + }); + + } + + /** + * Sets the element id. + */ + private void setElementIds() { + this.elementId = "my-modal-publish-meta" + Random.nextInt(); + this.getElement().setId(elementId); + + this.closeElementId = "my-modal-close-button" + Random.nextInt(); + } + + /** + * Prevent modal close when clicking outside. + */ + private void preventModalCloseWhenClickingOutside() { + + com.google.gwt.user.client.Element buttonCloseElement = DOM.getElementById(this.closeElementId); + + if (buttonCloseElement != null) { + + Event.sinkEvents(buttonCloseElement, Event.ONCLICK); + Event.setEventListener(buttonCloseElement, new EventListener() { + + @Override + public void onBrowserEvent(Event event) { + if (Event.ONCLICK == event.getTypeInt()) { + GWT.log("close event clicked"); + closeButtoClicked = true; + } + + } + }); + } else { + GWT.log("button close element not found"); + closeButtoClicked = true; + } + + // hide any popup panel opened + this.addHideHandler(new HideHandler() { + + @Override + public void onHide(HideEvent hideEvent) { + GWT.log("HideEvent on modal fired"); + GWT.log(hideEvent.toDebugString()); + GWT.log("CloseButtonClicked is: " + closeButtoClicked); + + if (!closeButtoClicked) { + hideEvent.preventDefault(); + hideEvent.stopPropagation(); + } + } + }); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index ef23b5b..dd04ac9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -18,6 +18,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -76,9 +77,9 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundException; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; -import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitorActions; import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction.STATUS; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringActionsOnClient; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote; @@ -92,6 +93,7 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.allen_sauer.gwt.log.client.Log; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gwt.user.client.Random; @@ -140,7 +142,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Save geona data forms. * - * @param uuid the uuid + * @param uuid the uuid * @param profileID the profile ID * @param tree_Node the tree node * @param stepsOnPostCreation the steps on post creation @@ -148,125 +150,131 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public CommitReport saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, + public void saveGeonaDataForms(String uuid, String profileID, Tree_Node tree_Node, List stepsOnPostCreation) throws Exception { LOG.info("saveGeonaDataForms called for profileID {}", profileID); long startTime = System.currentTimeMillis(); LOG.info("Procedure starting at: " + startTime); final String uuidAsString = uuid.toString(); + + //Uncomment this to test the monitor +// if(!SessionUtil.isIntoPortal()) { +// MockData.mockMonitor(uuidAsString, getThreadLocalRequest()); +// return; +// } - final MonitorActions monitorActions = new MonitorActions(this.getThreadLocalRequest(), uuidAsString); - - MongoServiceUtil mongoService = new MongoServiceUtil(); - String theDocumentString = null; - try { - // 1. Action to Monitoring - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Converting prject metadata to Geoportal data model"); - int actionId = monitorActions.pushAction(action); - action.setActionId(actionId); - - FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); - JSONObject theDocument = metadataConverter.convert(tree_Node, null); - - //1. Action completed - action.setMsg("Converted prject metadata to Geoportal data model"); - action.setStatus(STATUS.DONE); - monitorActions.overrideAction(action); - - theDocumentString = theDocument.toString(); - LOG.info("Got Document: " + theDocumentString); - } catch (Exception e) { - LOG.error("Error on converting form data: ", e); - throw new Exception( - "Error occurred on converting data, try again or contact the support. Error: " + e.getMessage()); - } - + final MonitoringActionsOnServer monitoringActionsOnServer = new MonitoringActionsOnServer( + this.getThreadLocalRequest(), uuidAsString); + List listTempDirs = new ArrayList(); Project theProject = null; try { - - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - LOG.debug("Going to create the project..."); - // 2. Action to Monitoring - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Creating project on Geoportal Storage service"); - int actionId = monitorActions.pushAction(action); - action.setActionId(actionId); - - theProject = mongoService.createNew(profileID, theDocumentString); - - //2. Action completed - action.setMsg("Created project on Geoportal Storage service"); - action.setStatus(STATUS.DONE); - monitorActions.overrideAction(action); - - LOG.info("Project created with id: " + theProject.getId() + " and profileID: " + theProject.getProfileID()); - - } catch (Exception e) { - LOG.error("Error on creating the project: ", e); - throw new Exception("Error occurred on creating new project, try again or contact the support. Error: " - + e.getMessage()); - } - - List listTempDirs = new ArrayList(); - - try { - - // Uploading files into tempDirs in order to avoid clashing of names - LOG.debug("Going to upload the files"); - - // 3. Action to Monitoring - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Going to upload the file/s..."); - int actionId = monitorActions.pushAction(action); - action.setActionId(actionId); - - listTempDirs = recursiveUploadFileset(monitorActions, mongoService, profileID, theProject, tree_Node, null, listTempDirs); - - } catch (Exception e) { - LOG.error("Error on uploading files: ", e); - throw new Exception( - "Error occurred on uploading files, try again or contact the support. Error: " + e.getMessage()); - } - - try { - - ProjectsCaller client = GeoportalClientCaller.projects(); - SessionUtil.getCurrentContext(getThreadLocalRequest(), true); - LOG.info("stepsOnPostCreation are {}", stepsOnPostCreation); - for (String stepID : stepsOnPostCreation) { - LOG.info("calling step OnPostCreation are {}", stepID); - - // 4. Action to Monitoring + MongoServiceUtil mongoService = new MongoServiceUtil(); + String theDocumentString = null; + try { + // 1. Action to Monitoring MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Performing step: "+stepID); - int actionId = monitorActions.pushAction(action); - action.setActionId(actionId); - - theProject = client.performStep(theProject.getProfileID(), theProject.getId(), stepID, null, null); - - //5. Action completed - action.setMsg("Performed step: "+stepID); + "Converting project metadata to Geoportal data model"); + action = monitoringActionsOnServer.pushAction(action); + + FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); + JSONObject theDocument = metadataConverter.convert(tree_Node, null); + + // 1. Action completed + action.setMsg("Converted project metadata to Geoportal data model"); action.setStatus(STATUS.DONE); - monitorActions.overrideAction(action); + monitoringActionsOnServer.overrideAction(action); + + theDocumentString = theDocument.toString(); + LOG.info("Got Document: " + theDocumentString); + } catch (Exception e) { + LOG.error("Error on converting form data: ", e); + throw new Exception("Error occurred on converting data, try again or contact the support. Error: " + + e.getMessage()); + } + + try { + + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + LOG.debug("Going to create the project..."); + // 2. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Creating project on Geoportal Storage service"); + action = monitoringActionsOnServer.pushAction(action); + + theProject = mongoService.createNew(profileID, theDocumentString); + + // 2. Action completed + action.setMsg("Created project on Geoportal Storage service"); + action.setStatus(STATUS.DONE); + monitoringActionsOnServer.overrideAction(action); + + LOG.info("Project created with id: " + theProject.getId() + " and profileID: " + + theProject.getProfileID()); + + } catch (Exception e) { + LOG.error("Error on creating the project: ", e); + throw new Exception("Error occurred on creating new project, try again or contact the support. Error: " + + e.getMessage()); + } + + try { + + // Uploading files into tempDirs in order to avoid clashing of names + LOG.debug("Going to upload the files"); + listTempDirs = recursiveUploadFileset(monitoringActionsOnServer, mongoService, profileID, theProject, + tree_Node, null, listTempDirs); + + } catch (Exception e) { + LOG.error("Error on uploading files: ", e); + throw new Exception("Error occurred on uploading files, try again or contact the support. Error: " + + e.getMessage()); + } + + try { + + ProjectsCaller client = GeoportalClientCaller.projects(); + SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + LOG.info("stepsOnPostCreation are {}", stepsOnPostCreation); + for (String stepID : stepsOnPostCreation) { + LOG.info("calling step OnPostCreation are {}", stepID); + + // 4. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, "Performing step: " + stepID); + action = monitoringActionsOnServer.pushAction(action); + + theProject = client.performStep(theProject.getProfileID(), theProject.getId(), stepID, null, null); + + // 4. Action completed + action.setMsg("Performed step: " + stepID); + action.setStatus(STATUS.DONE); + monitoringActionsOnServer.overrideAction(action); + } + + } catch (Exception e) { + throw new Exception("Error occurred on performing steps " + stepsOnPostCreation + " on the project: " + + theProject.getId() + ". Error: " + e.getMessage()); + } + + try { + + LifecycleInformation lifecycleInfo = theProject.getLifecycleInformation(); + LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lifecycleInfo); + + monitoringActionsOnServer.setCommitReport(new CommitReport(theProject.getId(), + theProject.getProfileID(), theProject.getTheDocument().toJson(), liDV)); + monitoringActionsOnServer.setMonitoringTerminated(true); + } catch (Exception e) { + throw new Exception("Error occurred on loading LifecycleInformation for the project: " + + theProject.getId() + ". Error: " + e.getMessage()); } } catch (Exception e) { - throw new Exception("Error occurred on performing steps " + stepsOnPostCreation + " on the project: " - + theProject.getId() + ". Error: " + e.getMessage()); - } + // general catch + Log.error("General Error: ", e.getMessage()); + monitoringActionsOnServer.setException(e); + monitoringActionsOnServer.setMonitoringTerminated(true); - try { - - LifecycleInformation lifecycleInfo = theProject.getLifecycleInformation(); - LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lifecycleInfo); - - return new CommitReport(theProject.getId(), theProject.getProfileID(), theProject.getTheDocument().toJson(), - liDV); - } catch (Exception e) { - throw new Exception("Error occurred on loading LifecycleInformation for the project: " + theProject.getId() - + ". Error: " + e.getMessage()); } finally { LOG.debug("List listTempDirs is: " + listTempDirs); @@ -288,19 +296,52 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen long endDiffMillis = System.currentTimeMillis() - startTime; long minutes = TimeUnit.MILLISECONDS.toMinutes(endDiffMillis); LOG.info("Procedure terminated in ms: " + endDiffMillis + ", minutes: " + minutes); - monitorActions.destroyMonitor(); + // monitorActions.destroyMonitor(); } catch (Exception e) { // silent } } } - + @Override - public LinkedHashMap getSavingProjectMonitorStatus(final String savingProjectUUID) throws Exception { - MonitorActions ma = SessionUtil.getMonitorStatus(getThreadLocalRequest(), savingProjectUUID); - return ma.getMonitor(); + public MonitoringActionsOnClient getSavingProjectMonitorStatus(String monitorUUID, + boolean isMonitoringTerminatedClientConsumed) throws Exception { + LOG.info("getSavingProjectMonitorStatus called for: " + monitorUUID); + + MonitoringActionsOnServer mas = SessionUtil.getMonitorStatus(getThreadLocalRequest(), monitorUUID); + + // destroying the monitor + if (isMonitoringTerminatedClientConsumed) { + LOG.info("monitor for " + monitorUUID + " consumed on client side, destroying it"); + mas.destroyMonitor(); + return null; + } + + // converting the monitor to the client version + MonitoringActionsOnClient macU = clientMonitor.apply(mas); + + if (LOG.isDebugEnabled()) { + LOG.debug("returning monitor on client: " + macU); + } + LOG.info("returning monitor for " + monitorUUID); + return macU; + } + private static Function clientMonitor = new Function() { + + public MonitoringActionsOnClient apply(MonitoringActionsOnServer ms) { + MonitoringActionsOnClient mac = new MonitoringActionsOnClient(); + mac.setCommitReport(ms.getCommitReport()); + mac.setMonitor(ms.getMonitor()); + mac.setException(ms.getException()); + mac.setMonitorUUID(ms.getMonitorUUID()); + mac.setMonitoringTerminatedOnServer(ms.isMonitoringTerminatedOnServer()); + + return mac; + } + }; + /** * Update geportal data form. * @@ -485,7 +526,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Recursive upload fileset. * - * @param monitorActions the monitor actions + * @param monitorActions the monitor actions * @param mongoService the mongo service * @param profileID the profile ID * @param theProject the the project @@ -495,7 +536,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @return the list * @throws Exception the exception */ - public List recursiveUploadFileset(final MonitorActions monitorActions, MongoServiceUtil mongoService, String profileID, Project theProject, + public List recursiveUploadFileset(final MonitoringActionsOnServer monitorActions, + MongoServiceUtil mongoService, String profileID, Project theProject, Tree_Node tree_Node, Map sectionJSONPathIndexer, List tempDirs) throws Exception { LOG.debug("recursiveUploadFileset called [tree_Node: " + tree_Node + "], [jsonPathIndexer: " @@ -549,6 +591,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Map collectFilesetPerFieldDef = new HashMap(); List files = gdb.getFilesUploaded(); if (files.size() > 0) { + List fileNames = files.stream().map(fl -> fl.getFileName()).collect(Collectors.toList()); + // 1..N Monitoring Copying files +// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, +// "Copying file/s: " + fileNames); +// action = monitorActions.pushAction(action); // Iterating on the files upload for the section for (int i = 0; i < files.size(); i++) { FileUploaded file = files.get(i); @@ -556,7 +603,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen String formFieldName = file.getFilePath().getFormFieldLabel(); LOG.debug( "Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName); - + FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile); LOG.info("Found {} for the form fieldName {}", filePath, formFieldName); if (filePath == null) { @@ -598,6 +645,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen + ". Please upload it/them again and retry"); } } + + // 1..N Monitoring Fileset copied action completed +// action.setMsg("File/s " + fileNames + " copied correclty"); +// action.setStatus(STATUS.DONE); +// monitorActions.overrideAction(action); } @@ -609,6 +661,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen File[] fileset = uploadedFileset.getFileset(); FilePathDV filePath = uploadedFileset.getFilePathDV(); + + //Getting fileNames for the monitoring + List fileNames = new ArrayList(); + if(fileset!=null) + fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()) + .collect(Collectors.toList()); Access access; // If the maxOccurs is not 1 @@ -618,39 +676,47 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen String arraySectionJSONPAth = String.format("%s[%d]", sectionJSONPath, jpcV); LOG.debug("registering the fileset in the array section: " + sectionJSONPath); + access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, arraySectionJSONPAth); + + // 1..N Monitoring Registering Fileset + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Registering and indexing the fileset: " + fileNames); + monitorActions.pushAction(action); + mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth, filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); + + // 1..N Monitoring Fileset uploaded action completed + action.setMsg("Fileset " + fileNames + " registered correclty"); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); + } else { LOG.info("The gCube Profile with the section " + sectionJSONPath + " has maxOccurs = 1"); LOG.debug("registering the fileset in the section: " + sectionJSONPath); access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, sectionJSONPath); - - - List fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList()); - - //1..N Monitoring Uploading Fileset + + // 1..N Monitoring Registering Fileset MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Uploading fileset: "+fileNames ); - int actionId = monitorActions.pushAction(action); - action.setActionId(actionId); - - + "Registering and indexing the fileset: " + fileNames); + monitorActions.pushAction(action); + mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); - - //1..N Monitoring Fileset uploaded action completed - action.setMsg("Fileset "+fileNames+" uploaded correclty"); + + // 1..N Monitoring Fileset uploaded action completed + action.setMsg("Fileset " + fileNames + " registered correclty"); action.setStatus(STATUS.DONE); monitorActions.overrideAction(action); } } - tempDirs = recursiveUploadFileset(monitorActions, mongoService, profileID, theProject, treeNodeChild_GNA_DO, - sectionJSONPathIndexer, tempDirs); + tempDirs = recursiveUploadFileset(monitorActions, mongoService, profileID, theProject, + treeNodeChild_GNA_DO, sectionJSONPathIndexer, tempDirs); } } @@ -1103,16 +1169,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen client.deleteProject(profileID, projectID, true); + //To be sure project deleted + Project deletedP = null; try { - Project deletedP = client.getProjectByID(profileID, projectID); - if (deletedP != null) { - String error = "The project with id " + projectID + " still exists"; - LOG.error(error + ". Sending exception.."); - throw new Exception(error); - } + deletedP = client.getProjectByID(profileID, projectID); } catch (Exception e) { - throw e; + //silent } + + if (deletedP != null) { + String error = "The project with id " + projectID + " still exists"; + LOG.error(error + ". Sending exception.."); + throw new Exception(error); + } + // Updating count of Documents in session per profileID Integer totalProjectForProfile = client.getTotalDocument(profileID); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MonitoringActionsOnServer.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MonitoringActionsOnServer.java new file mode 100644 index 0000000..845b71f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MonitoringActionsOnServer.java @@ -0,0 +1,106 @@ +package org.gcube.portlets.user.geoportaldataentry.server; + +import java.io.Serializable; +import java.util.LinkedHashMap; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; + +public class MonitoringActionsOnServer implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -2370892426311458184L; + + private LinkedHashMap monitor = new LinkedHashMap(); + + private Exception exception; + + private HttpServletRequest request; + + private String monitorUUID; + + private CommitReport commitReport; + + private boolean monitoringTerminatedOnServer; + + private boolean monitoringTerminatedClientConsumed; + + public MonitoringActionsOnServer(HttpServletRequest httpServletRequest, String monitorUUID) { + this.request = httpServletRequest; + this.monitorUUID = monitorUUID; + } + + /** + * Push action. + * + * @param action the action + * @return the action Id + */ + public synchronized MonitoringAction pushAction(MonitoringAction action) { + final int current = monitor.size(); + int actionId = current + 1; + action.setActionId(actionId); + monitor.put(actionId, action); + updateMonitorInSession(); + return action; + } + + public synchronized void overrideAction(MonitoringAction action) { + monitor.put(action.getActionId(), action); + updateMonitorInSession(); + } + + public MonitoringAction getAction(Integer index) { + if (index == null || index < 0) + return null; + + return monitor.get(index); + + } + + public LinkedHashMap getMonitor() { + return monitor; + } + + private void updateMonitorInSession() { + SessionUtil.setMonitorStatus(request, monitorUUID, this); + } + + public void setMonitoringTerminated(boolean bool) { + this.monitoringTerminatedOnServer = bool; + updateMonitorInSession(); + } + + public boolean isMonitoringTerminatedOnServer() { + return monitoringTerminatedOnServer; + } + + public void destroyMonitor() { + SessionUtil.removeMonitorStatus(request, monitorUUID); + } + + public Exception getException() { + return exception; + } + + public void setException(Exception exception) { + this.exception = exception; + } + + public void setCommitReport(CommitReport commitReport) { + this.commitReport = commitReport; + } + + public CommitReport getCommitReport() { + return commitReport; + } + + public String getMonitorUUID() { + return monitorUUID; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 14a738e..f5d8943 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -19,7 +19,6 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetSorted; -import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitorActions; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; @@ -354,16 +353,27 @@ public class SessionUtil { } public static void setMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString, - MonitorActions monitorActions) { + MonitoringActionsOnServer monitorActions) { HttpSession session = httpServletRequest.getSession(); String monitorID = getUniqueMonitorID(uuidAsString); session.setAttribute(monitorID, monitorActions); } - - public static MonitorActions getMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString) { + + public static void removeMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString) { HttpSession session = httpServletRequest.getSession(); String monitorID = getUniqueMonitorID(uuidAsString); - return (MonitorActions) session.getAttribute(monitorID); + session.removeAttribute(monitorID); + } + + public static MonitoringActionsOnServer getMonitorStatus(HttpServletRequest httpServletRequest, String uuidAsString) { + HttpSession session = httpServletRequest.getSession(); + String monitorID = getUniqueMonitorID(uuidAsString); + try { + return (MonitoringActionsOnServer) session.getAttribute(monitorID); + }catch (Exception e) { + LOG.warn("No monitor in session for id: "+monitorID); + return null; + } } public static final String getUniqueMonitorID(String uuid) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/test/MockData.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/test/MockData.java new file mode 100644 index 0000000..5f5d555 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/test/MockData.java @@ -0,0 +1,79 @@ +package org.gcube.portlets.user.geoportaldataentry.server.test; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.portlets.user.geoportaldataentry.server.MonitoringActionsOnServer; +import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction; +import org.gcube.portlets.user.geoportaldataentry.shared.monitoring.MonitoringAction.STATUS; + +/** + * The Class MockData. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Oct 14, 2024 + */ +public class MockData { + + /** + * Mock monitor. + * + * @param uuidAsString the uuid as string + * @param request the request + * @throws InterruptedException the interrupted exception + */ + public static final void mockMonitor(String uuidAsString, HttpServletRequest request) throws InterruptedException { + + final MonitoringActionsOnServer monitoringActionsOnServer = new MonitoringActionsOnServer(request, + uuidAsString); + + // 1. Action to Monitoring + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Converting prject metadata to Geoportal data model"); + action = monitoringActionsOnServer.pushAction(action); + + // 1. Action completed + action.setMsg("Converted prject metadata to Geoportal data model"); + action.setStatus(STATUS.DONE); + monitoringActionsOnServer.overrideAction(action); + + // 2. Action to Monitoring + MonitoringAction action2 = new MonitoringAction(STATUS.IN_PROGESS, + "Creating project on Geoportal Storage service"); + action2 = monitoringActionsOnServer.pushAction(action2); + + Thread.sleep(5000); + + // 2. Action completed + action2.setMsg("Created project on Geoportal Storage service"); + action2.setStatus(STATUS.DONE); + monitoringActionsOnServer.overrideAction(action2); + + // 3. Action to Monitoring + MonitoringAction action3 = new MonitoringAction(STATUS.IN_PENDING, "Going to register the file/s..."); + action3 = monitoringActionsOnServer.pushAction(action3); + + for (int i = 0; i < 5; i++) { + + String fileName = "File " + i; + // 1..N Monitoring Uploading Fileset + MonitoringAction actionI = new MonitoringAction(STATUS.IN_PROGESS, "Registering the fileset: " + fileName); + actionI = monitoringActionsOnServer.pushAction(actionI); + + Thread.sleep(5000); + // 1..N Monitoring Fileset uploaded action completed + actionI.setMsg("Fileset " + fileName + " registered correclty"); + actionI.setStatus(STATUS.DONE); + monitoringActionsOnServer.overrideAction(actionI); + + } + + monitoringActionsOnServer.setMonitoringTerminated(true); + Thread.sleep(5000); + + CommitReport commitReport = new CommitReport("Mock projectId", "Mock profileId", null, null); + monitoringActionsOnServer.setCommitReport(commitReport); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java deleted file mode 100644 index a356401..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitorActions.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.gcube.portlets.user.geoportaldataentry.shared.monitoring; - -import java.io.Serializable; -import java.util.LinkedHashMap; - -import javax.servlet.http.HttpServletRequest; - -import org.gcube.portlets.user.geoportaldataentry.server.SessionUtil; - -public class MonitorActions implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -2370892426311458184L; - - private LinkedHashMap monitor = new LinkedHashMap(); - - private HttpServletRequest request; - - private String monitorUUID; - - public MonitorActions(HttpServletRequest httpServletRequest, String monitorUUID) { - this.request = httpServletRequest; - this.monitorUUID = monitorUUID; - } - - /** - * Push action. - * - * @param action the action - * @return the action Id - */ - public synchronized int pushAction(MonitoringAction action) { - final int current = monitor.size(); - monitor.put(current + 1, action); - updateMonitorInSession(); - return current; - } - - public synchronized void overrideAction(MonitoringAction action) { - monitor.put(action.getActionId(), action); - updateMonitorInSession(); - } - - public MonitoringAction getAction(Integer index) { - if (index == null || index < 0) - return null; - - return monitor.get(index); - - } - - public LinkedHashMap getMonitor() { - return monitor; - } - - private void updateMonitorInSession() { - SessionUtil.setMonitorStatus(request, monitorUUID, this); - } - - public void destroyMonitor() { - SessionUtil.setMonitorStatus(request, monitorUUID, null); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringActionsOnClient.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringActionsOnClient.java new file mode 100644 index 0000000..86980d6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/monitoring/MonitoringActionsOnClient.java @@ -0,0 +1,87 @@ +package org.gcube.portlets.user.geoportaldataentry.shared.monitoring; + +import java.io.Serializable; +import java.util.LinkedHashMap; + +import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; + +public class MonitoringActionsOnClient implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8517260295153833253L; + + private LinkedHashMap monitor = new LinkedHashMap(); + + private Exception exception; + + private String monitorUUID; + + private CommitReport commitReport; + + private boolean monitoringTerminatedOnServer; + + public MonitoringActionsOnClient() { + } + + public LinkedHashMap getMonitor() { + return monitor; + } + + public Exception getException() { + return exception; + } + + public String getMonitorUUID() { + return monitorUUID; + } + + public CommitReport getCommitReport() { + return commitReport; + } + + public boolean isMonitoringTerminatedOnServer() { + return monitoringTerminatedOnServer; + } + + public void setMonitor(LinkedHashMap monitor) { + this.monitor = monitor; + } + + public void setException(Exception exception) { + this.exception = exception; + } + + public void setMonitorUUID(String monitorUUID) { + this.monitorUUID = monitorUUID; + } + + public void setCommitReport(CommitReport commitReport) { + this.commitReport = commitReport; + } + + public void setMonitoringTerminatedOnServer(boolean monitoringTerminatedOnServer) { + this.monitoringTerminatedOnServer = monitoringTerminatedOnServer; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("MonitoringActionsOnClient [monitor="); + builder.append(monitor); + builder.append(", exception="); + builder.append(exception); + builder.append(", monitorUUID="); + builder.append(monitorUUID); + builder.append(", commitReport="); + builder.append(commitReport); + builder.append(", monitoringTerminatedOnServer="); + builder.append(monitoringTerminatedOnServer); + builder.append("]"); + return builder.toString(); + } + + + +} From 6617655492983582d923658514036b307c8fce87 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 12:41:11 +0200 Subject: [PATCH 3/5] improved the monitoring.. --- .../client/GeoPortalDataEntryApp.java | 2 +- .../server/GeoportalDataEntryServiceImpl.java | 126 +++++++++++------- 2 files changed, 76 insertions(+), 52 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index ceaa9cd..595d772 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -905,7 +905,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; case FAILED: icon = new Icon(IconType.WARNING_SIGN); - icon.getElement().getStyle().setColor("#800000"); + icon.getElement().getStyle().setColor("#FF0000"); icon.setSize(IconSize.TWO_TIMES); icon.setTitle(action.getStatus().getLabel()); break; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index dd04ac9..612a9f4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -157,8 +157,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen long startTime = System.currentTimeMillis(); LOG.info("Procedure starting at: " + startTime); final String uuidAsString = uuid.toString(); - - //Uncomment this to test the monitor + + // Uncomment this to test the monitor // if(!SessionUtil.isIntoPortal()) { // MockData.mockMonitor(uuidAsString, getThreadLocalRequest()); // return; @@ -172,18 +172,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen MongoServiceUtil mongoService = new MongoServiceUtil(); String theDocumentString = null; try { - // 1. Action to Monitoring - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Converting project metadata to Geoportal data model"); - action = monitoringActionsOnServer.pushAction(action); +// // 1. Action to Monitoring +// MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, +// "Converting project metadata to Geoportal data model"); +// action = monitoringActionsOnServer.pushAction(action); FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); JSONObject theDocument = metadataConverter.convert(tree_Node, null); - // 1. Action completed - action.setMsg("Converted project metadata to Geoportal data model"); - action.setStatus(STATUS.DONE); - monitoringActionsOnServer.overrideAction(action); +// // 1. Action completed +// action.setMsg("Converted project metadata to Geoportal data model"); +// action.setStatus(STATUS.DONE); +// monitoringActionsOnServer.overrideAction(action); theDocumentString = theDocument.toString(); LOG.info("Got Document: " + theDocumentString); @@ -199,13 +199,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.debug("Going to create the project..."); // 2. Action to Monitoring MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Creating project on Geoportal Storage service"); + "Creating the project on the Geoportal storage service"); action = monitoringActionsOnServer.pushAction(action); theProject = mongoService.createNew(profileID, theDocumentString); // 2. Action completed - action.setMsg("Created project on Geoportal Storage service"); + action.setMsg("Created the project on the Geoportal storage service"); action.setStatus(STATUS.DONE); monitoringActionsOnServer.overrideAction(action); @@ -494,7 +494,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } - LOG.info("Project with id " + currentProject.getId() + " updated correclty"); + LOG.info("Project with id " + currentProject.getId() + " updated correctly"); ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); // Reading again the project to be sure updatedProject = client.getProjectByID(profileID, projectID); @@ -591,7 +591,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Map collectFilesetPerFieldDef = new HashMap(); List files = gdb.getFilesUploaded(); if (files.size() > 0) { - List fileNames = files.stream().map(fl -> fl.getFileName()).collect(Collectors.toList()); + // List fileNames = files.stream().map(fl -> + // fl.getFileName()).collect(Collectors.toList()); // 1..N Monitoring Copying files // MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, // "Copying file/s: " + fileNames); @@ -645,9 +646,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen + ". Please upload it/them again and retry"); } } - + // 1..N Monitoring Fileset copied action completed -// action.setMsg("File/s " + fileNames + " copied correclty"); +// action.setMsg("File/s " + fileNames + " copied correctly"); // action.setStatus(STATUS.DONE); // monitorActions.overrideAction(action); @@ -661,12 +662,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen File[] fileset = uploadedFileset.getFileset(); FilePathDV filePath = uploadedFileset.getFilePathDV(); - - //Getting fileNames for the monitoring + + // Getting fileNames for the monitoring List fileNames = new ArrayList(); - if(fileset!=null) - fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()) - .collect(Collectors.toList()); + if (fileset != null) + fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList()); Access access; // If the maxOccurs is not 1 @@ -674,43 +674,30 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("The gCube Profile with the section " + sectionJSONPath + " has maxOccurs > 1 need to manage it as array, going to add the array index"); String arraySectionJSONPAth = String.format("%s[%d]", sectionJSONPath, jpcV); - LOG.debug("registering the fileset in the array section: " + sectionJSONPath); - + LOG.debug("registering the fileset in the array section: " + arraySectionJSONPAth); access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, arraySectionJSONPAth); + + monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject, + arraySectionJSONPAth, filePath.getFieldName(), filePath.getFieldDefinition(), access, + fileset); - // 1..N Monitoring Registering Fileset - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Registering and indexing the fileset: " + fileNames); - monitorActions.pushAction(action); - - mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth, - filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); - - // 1..N Monitoring Fileset uploaded action completed - action.setMsg("Fileset " + fileNames + " registered correclty"); - action.setStatus(STATUS.DONE); - monitorActions.overrideAction(action); - +// mongoService.registerFileSet(profileID, theProject, arraySectionJSONPAth, +// filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); + } else { LOG.info("The gCube Profile with the section " + sectionJSONPath + " has maxOccurs = 1"); LOG.debug("registering the fileset in the section: " + sectionJSONPath); access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, sectionJSONPath); - // 1..N Monitoring Registering Fileset - MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, - "Registering and indexing the fileset: " + fileNames); - monitorActions.pushAction(action); + monitoredRegisteredFileset(mongoService, monitorActions, profileID, theProject, sectionJSONPath, + filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); - mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(), - filePath.getFieldDefinition(), access, fileset); +// mongoService.registerFileSet(profileID, theProject, sectionJSONPath, filePath.getFieldName(), +// filePath.getFieldDefinition(), access, fileset); - // 1..N Monitoring Fileset uploaded action completed - action.setMsg("Fileset " + fileNames + " registered correclty"); - action.setStatus(STATUS.DONE); - monitorActions.overrideAction(action); } } @@ -725,6 +712,44 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } + private void monitoredRegisteredFileset(final MongoServiceUtil mongoService, + final MonitoringActionsOnServer monitorActions, String profileID, Project theProject, + String sectionJSONPath, String fieldName, String fieldDefinition, Access access, File... fileset) { + + // Getting fileNames for the monitoring + List fileNames = new ArrayList(); + if (fileset != null) + fileNames = Arrays.asList(fileset).stream().map(f -> f.getName()).collect(Collectors.toList()); + + // 1..N Monitoring Registering Fileset + MonitoringAction action = new MonitoringAction(STATUS.IN_PROGESS, + "Registering and indexing the fileset: " + fileNames); + monitorActions.pushAction(action); + + boolean error = false; + try { + + mongoService.registerFileSet(profileID, theProject, sectionJSONPath, fieldName, fieldDefinition, access, + fileset); + + } catch (Exception e) { + error = true; + LOG.error("Error on registering fileset: ", e); + // 1..N Monitoring Fileset not registered + action.setMsg("Fileset " + fileNames + " not registered. Error: "+e.getMessage()); + action.setStatus(STATUS.FAILED); + monitorActions.overrideAction(action); + } finally { + if (!error) { + // 1..N Monitoring Fileset registered correctly completed + action.setMsg("Fileset " + fileNames + " registered correctly"); + action.setStatus(STATUS.DONE); + monitorActions.overrideAction(action); + } + } + + } + /** * Collect files. * @@ -1169,21 +1194,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen client.deleteProject(profileID, projectID, true); - //To be sure project deleted + // To be sure project deleted Project deletedP = null; try { deletedP = client.getProjectByID(profileID, projectID); } catch (Exception e) { - //silent + // silent } - + if (deletedP != null) { String error = "The project with id " + projectID + " still exists"; LOG.error(error + ". Sending exception.."); throw new Exception(error); } - // Updating count of Documents in session per profileID Integer totalProjectForProfile = client.getTotalDocument(profileID); SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), profileID, totalProjectForProfile); @@ -1218,7 +1242,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Document updatedDocument = Serialization.read(jsonUpdate, Document.class); LOG.info("updatedDocument is {}", updatedDocument); Project project = client.updateProject(profileID, projectID, updatedDocument); - LOG.info("Project with id " + project.getId() + " updated correclty"); + LOG.info("Project with id " + project.getId() + " updated correctly"); ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); return ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); } catch (Exception e) { From d8f5d0ba53cc812cb1af5ca7faf9be39ff776daf Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 13:59:45 +0200 Subject: [PATCH 4/5] fixed log import --- .../server/GeoportalDataEntryServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 612a9f4..f92ad58 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -93,7 +93,6 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.allen_sauer.gwt.log.client.Log; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gwt.user.client.Random; @@ -271,7 +270,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } catch (Exception e) { // general catch - Log.error("General Error: ", e.getMessage()); + LOG.error("General Error: ", e.getMessage()); monitoringActionsOnServer.setException(e); monitoringActionsOnServer.setMonitoringTerminated(true); From 3bccd516a34091cc0b3c82db4bd136c23a580628 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 14:12:01 +0200 Subject: [PATCH 5/5] Declared as geoportal-data-entry-app.v3.3.0-SNAPSHOT --- CHANGELOG.md | 7 ++----- pom.xml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5620a16..8a7cf76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,17 +4,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v3.4.0-SNAPSHOT] - -- The save operation is now monitored asynchronously [#28268] - -## [v3.3.0] - 2024-06-28 +## [v3.3.0-SNAPSHOT] - 2024-06-28 - Implemented the init facility to resolve a public link on an item [#27120] - Integrated new Uri-Resolver-Manager [#27160] - Added Get Shareable Link facility [#27120] - Added optional message when performing lifecycle step [#27192] - Enforced deleteProject method/UX +- The save operation is now monitored asynchronously [#28268] ## [v3.2.2] - 2024-01-11 diff --git a/pom.xml b/pom.xml index 1026dd6..62460d1 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 3.4.0-SNAPSHOT + 3.3.0-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service