diff --git a/.classpath b/.classpath
index cc87779..9450698 100644
--- a/.classpath
+++ b/.classpath
@@ -6,12 +6,6 @@
-
-
-
-
-
-
diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java
index bc15c69..bd2c262 100644
--- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java
+++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java
@@ -373,6 +373,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
private void prepareMetadataList(final List profiles) {
if(profiles != null && !profiles.isEmpty()){
+ GWT.log("Building form/s for profile/s: "+profiles);
if(profiles.size()>1)
showChooseProfileForm(true);
diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/FileUtil.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/FileUtil.java
new file mode 100644
index 0000000..5c653bc
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/FileUtil.java
@@ -0,0 +1,45 @@
+package org.gcube.portlets.widgets.mpformbuilder.server;
+
+import java.io.File;
+import java.nio.file.Files;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The Class FileUtil.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
+ *
+ * Oct 21, 2020
+ */
+public class FileUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);
+
+ /**
+ * Delete file.
+ *
+ * @param path the path
+ * @return true, if successful
+ */
+ public static boolean deleteFile(String path) {
+ LOG.info("called deleteFile for path: "+path);
+ boolean deleted = false;
+ if(path!=null) {
+ try {
+ File file = new File(path);
+ deleted = Files.deleteIfExists(file.toPath());
+ LOG.info("File "+path+" deleted? "+deleted);
+ }catch (Exception e) {
+ LOG.warn("Error on deleting file: "+path, e);
+ }
+ }else {
+ LOG.warn("I cannot delete the file. NullPointer parameter 'path'");
+ }
+
+ return deleted;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java
index 6c90f49..53968d3 100644
--- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java
+++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java
@@ -100,7 +100,8 @@ public class MetadataDiscovery {
MetadataProfileReader reader = new MetadataProfileReader(gRSecondaryType);
List profiles = reader.getListOfMetadataProfiles();
- LOG.debug("Profiles are " + profiles);
+ prettyPrintProfiles(profiles);
+ LOG.info("Profiles are " + profiles.size());
List categories = reader.getListOfNamespaceCategories();
if (categories == null)
@@ -109,17 +110,14 @@ public class MetadataDiscovery {
LOG.debug("All Categories are " + categories);
for (MetadataProfile profile : profiles) {
-
- LOG.debug(
- "Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType());
-
+ LOG.debug("Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType());
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
-
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
beans.add(bean);
}
- LOG.debug("List of beans is " + beans);
+ prettyPrintList(beans);
+ LOG.info("Returning " + beans.size() + " profile/s");
} catch (Exception e) {
LOG.error("Error while retrieving metadata beans ", e);
@@ -131,6 +129,27 @@ public class MetadataDiscovery {
return beans;
}
+ private static void prettyPrintProfiles(List profiles) {
+
+ if(LOG.isDebugEnabled() && profiles!=null) {
+ LOG.debug("Pretty print list of profiles: ");
+ for (MetadataProfile profile : profiles) {
+ LOG.debug(profile.toString());
+ }
+ }
+ }
+
+
+ private static void prettyPrintList(List beans) {
+
+ if(LOG.isDebugEnabled() && beans!=null) {
+ LOG.debug("Pretty print list of beans: ");
+ for (MetaDataProfileBean metaDataProfileBean : beans) {
+ LOG.debug(metaDataProfileBean.toString());
+ }
+ }
+ }
+
/**
@@ -196,6 +215,7 @@ public class MetadataDiscovery {
wrapperObj.setMandatory(metadataField.getMandatory());
wrapperObj.setNote(metadataField.getNote());
MetadataValidator validator = metadataField.getValidator();
+ LOG.debug(metadataField.getFieldName() +" validator is: "+validator);
if (validator != null)
wrapperObj.setValidator(validator.getRegularExpression());
diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java
index 49f8648..e609aee 100644
--- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java
+++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java
@@ -1,7 +1,5 @@
package org.gcube.portlets.widgets.mpformbuilder.server;
-import java.io.File;
-import java.nio.file.Files;
import java.util.List;
import javax.servlet.annotation.WebListener;
@@ -21,20 +19,17 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener {
@Override
public void sessionDestroyed(HttpSessionEvent event) {
- LOG.info("sessionDestroyed called. Session id is: "+event.getSession().getId());
+ LOG.info("sessionDestroyed called");
try {
HttpSession httpSession = event.getSession();
- List listFileUploaded = (List) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR);
- if(listFileUploaded!=null) {
- LOG.info("found file uploded in session, removin it");
- for (FileUploaded fileUploaded : listFileUploaded) {
- try {
- File file = new File(fileUploaded.getTempSystemPath());
- boolean result = Files.deleteIfExists(file.toPath());
- LOG.info("File "+fileUploaded.getTempSystemPath() +" deleted? "+result);
- }catch (Exception e) {
- LOG.warn("Error on deleting file: "+fileUploaded, e);
+ if(httpSession!=null) {
+ LOG.info("Sesson id is: "+httpSession.getId());
+ List listFileUploaded = (List) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR);
+ if(listFileUploaded!=null) {
+ LOG.info("found file uploded in session, removing it");
+ for (FileUploaded fileUploaded : listFileUploaded) {
+ FileUtil.deleteFile(fileUploaded.getTempSystemPath());
}
}
}
@@ -47,8 +42,5 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent arg0) {
LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId());
-
- //session.setMaxInactiveInterval(5);//in seconds
-
}
}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index f997444..c39a766 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -5,10 +5,6 @@
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
-
- org.gcube.portlets.widgets.mpformbuilder.server.UploadedFileHttpSessionListener
-
-
mpformbuilderServlet
@@ -36,4 +32,9 @@
MetadataProfileFormBuilder.html
+
+ org.gcube.portlets.widgets.mpformbuilder.server.UploadedFileHttpSessionListener
+
+
+