avoid that an order is submitted more than once by blocking it.

This commit is contained in:
Massimiliano Assante 2021-10-18 12:45:13 +02:00
parent dffa8fb6ce
commit af432c083f
3 changed files with 11 additions and 9 deletions

View File

@ -52,9 +52,6 @@ import net.spy.memcached.MemcachedClient;
*/
public class DdasVreIntegration extends MVCPortlet {
private static com.liferay.portal.kernel.log.Log log = LogFactoryUtil.getLog(DdasVreIntegration.class);
//The Blue-Cloud DD&AS Service endpoint for feedback about downloads
public static final String BROKERf_FEEDBACK_ENDPOINT = "https://data.blue-cloud.org/api/vre/download-ready";
private static final String BC_BROKER_RESOURCE_NAME = "Blue-Cloud-DataDownloadAndAccess";
private static final String CATEGORY_NAME = "Service";
@ -78,7 +75,7 @@ public class DdasVreIntegration extends MVCPortlet {
boolean result = false;
if (params != null && params.length > 0) {
String otp = params[0];
System.out.println("Read OTP="+otp);
log.debug("Read Blue-Cloud cache OTP="+otp);
if (otp != null && !otp.equals("")) {
JsonElement brokerRequest = checkRequest(otp);
if (brokerRequest == null) {//the token is expired or there was no request, return to the JSP token expired page
@ -259,6 +256,9 @@ public class DdasVreIntegration extends MVCPortlet {
JsonElement jelement = new JsonParser().parse(brokerRequest);
JsonObject jobject = jelement.getAsJsonObject();
log.debug("Found tempCode into memcached, broker request="+jobject.toString());
log.debug("Invalidating tempCode into memcached with key="+code);
entries.delete(code);
log.debug("Invalidated key "+ code + " with success.");
return jelement;
} catch(Exception e){
log.error("Failed to check the correctness of the broker request", e);

View File

@ -33,5 +33,7 @@ pageContext.setAttribute("responseResultSuccess", responseResultSuccess);
<p class="lead">Your order <c:out value="${orderData}"></c:out>, is being retrieved and the dataset are being saved to your
workspace area, you will receive an e-email when the
download process is completed. You may close this Tab now.</p>
<a class="btn btn-large btn-primary" href="javascript:window.close();"><i
class="icon icon-times"></i>&nbsp;Close</a>
</c:otherwise>
</c:choose>

View File

@ -10,16 +10,16 @@
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%String orderData = (String) renderRequest.getAttribute("orderData");%>
<portlet:renderURL var="normalState"
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
<p class="lead">
We're sorry, it seems that too much time is passed since your order on Blue-Cloud Data Discovery &amp; Access Service. <br>
Please close this page and trigger the move to VRE again from Blue-Cloud Data Discovery &amp; Access Service application.
We're sorry, your order <c:out value="${orderData}"></c:out> has either expired or was already submitted.<br>
Please close this page and click the Push to VRE button from Blue-Cloud Data Discovery &amp; Access Service again.
</p>
<a class="btn btn-large btn-primary" href="https://blue-cloud.d4science.org/"><i
class="icon icon-angle-left"></i>&nbsp;Close</a>
<a class="btn btn-large btn-primary" href="javascript:window.close();"><i
class="icon icon-times"></i>&nbsp;Close</a>