improved the monitoring..
This commit is contained in:
parent
39efa4b27c
commit
6617655492
|
@ -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;
|
||||
|
|
|
@ -158,7 +158,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
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<String, FileSetDataObject> collectFilesetPerFieldDef = new HashMap<String, FileSetDataObject>();
|
||||
List<FileUploaded> files = gdb.getFilesUploaded();
|
||||
if (files.size() > 0) {
|
||||
List<String> fileNames = files.stream().map(fl -> fl.getFileName()).collect(Collectors.toList());
|
||||
// List<String> 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);
|
||||
|
@ -647,7 +648,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -662,11 +663,10 @@ 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<String> fileNames = new ArrayList<String>();
|
||||
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,24 +674,17 @@ 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);
|
||||
|
||||
// 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,
|
||||
arraySectionJSONPAth, filePath.getFieldName(), filePath.getFieldDefinition(), access,
|
||||
fileset);
|
||||
|
||||
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");
|
||||
|
@ -699,18 +692,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
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<String> fileNames = new ArrayList<String>();
|
||||
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,12 +1194,12 @@ 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) {
|
||||
|
@ -1183,7 +1208,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue