Moved to doPost method

This commit is contained in:
Francesco Mangiacrapa 2024-05-03 17:03:26 +02:00
parent ee4524139e
commit 0224f787c1
2 changed files with 73 additions and 25 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
@ -37,8 +38,14 @@ import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
@ -227,21 +234,55 @@ public class ProjectViewer extends Composite {
String currentContextId = GCubeClientContext.getCurrentContextId();
String currentUserId = GCubeClientContext.getCurrentUserId();
StringBuilder builder = new StringBuilder();
builder.append(GeoportalDataViewerConstants.GEOPORTAL_EXPORT_ACTION_SERVLET + "?");
builder.append(GeoportalDataViewerConstants.UCD_ID_PARAMETER + "="
+ projectView.getTheProjectDV().getProfileID());
builder.append("&");
builder.append(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER + "="
+ projectView.getTheProjectDV().getId());
builder.append("&");
builder.append(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER + "=" + currentContextId);
builder.append("&");
builder.append(GeoportalDataViewerConstants.USER_ID_PARAMETER + "=" + currentUserId);
/*
* USE TO GET REQUEST StringBuilder builder = new StringBuilder();
* builder.append(GeoportalDataViewerConstants.GEOPORTAL_EXPORT_ACTION_SERVLET +
* "?"); builder.append(GeoportalDataViewerConstants.UCD_ID_PARAMETER + "=" +
* projectView.getTheProjectDV().getProfileID()); builder.append("&");
* builder.append(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER + "=" +
* projectView.getTheProjectDV().getId()); builder.append("&");
* builder.append(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER + "=" +
* currentContextId); builder.append("&");
* builder.append(GeoportalDataViewerConstants.USER_ID_PARAMETER + "=" +
* currentUserId);
*
* String geoportalExportActionServlet = builder.toString();
*
* NewBrowserWindow.open(geoportalExportActionServlet, "_blank", "");
*/
ProjectDV thePDV = projectView.getTheProjectDV();
final String targetWindow = "target_window_" + Random.nextInt() + "_" + Random.nextInt();
final FormPanel form = new FormPanel(targetWindow);
RootPanel.get().add(form);
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
form.setAction(GeoportalDataViewerConstants.GEOPORTAL_EXPORT_ACTION_SERVLET);
form.setEncoding(FormPanel.ENCODING_URLENCODED);
form.setMethod(FormPanel.METHOD_POST);
panel.add(new Hidden(GeoportalDataViewerConstants.UCD_ID_PARAMETER, thePDV.getProfileID()));
panel.add(new Hidden(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER, thePDV.getId()));
panel.add(new Hidden(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER, currentContextId));
panel.add(new Hidden(GeoportalDataViewerConstants.USER_ID_PARAMETER, currentUserId));
// Add an event handler to the form.
form.addSubmitHandler(new FormPanel.SubmitHandler() {
public void onSubmit(SubmitEvent event) {
GWT.log("onSubmit done");
NewBrowserWindow.open("", targetWindow, null);
}
});
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
GWT.log("onSubmitComplete done");
}
});
form.submit();
String geoportalExportActionServlet = builder.toString();
NewBrowserWindow.open(geoportalExportActionServlet, "_blank", "");
}
});

View File

@ -47,19 +47,26 @@ public class GeoportalExporterActionServlet extends HttpServlet {
super.init();
logger.trace(GeoportalExporterActionServlet.class.getSimpleName() + " ready.");
}
/**
* Do get.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
* @throws ServletException the servlet exception
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.info("doPost Called");
serveRequest(req, resp);
}
// /**
// * Do get.
// *
// * @param req the req
// * @param resp the resp
// * @throws IOException Signals that an I/O exception has occurred.
// * @throws ServletException the servlet exception
// */
// public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
// logger.info("doGet Called");
// serveRequest(req, resp);
// }
/**
* Serve request.
*
@ -73,7 +80,7 @@ public class GeoportalExporterActionServlet extends HttpServlet {
String ucdID = req.getParameter(GeoportalDataViewerConstants.UCD_ID_PARAMETER);
String contextID = req.getParameter(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER);
String userID = req.getParameter(GeoportalDataViewerConstants.USER_ID_PARAMETER);
logger.info("doGet called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: " + contextID
logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: " + contextID
+ ", userID: " + userID + "]");
if (contextID == null || contextID.isEmpty())