fixed the issue related to the incompatibility between HL an storagHub, fixed bug on form validation and on from publishing

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/branches/portlets/user/PerformFISH-Apps/1.3@178472 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-03-05 11:03:54 +00:00
parent e757949b6d
commit 7c0128fe82
6 changed files with 54 additions and 69 deletions

View File

@ -13,7 +13,7 @@
<artifactId>PerformFISH-Apps-portlet</artifactId>
<packaging>war</packaging>
<name>PerformFISH-Apps Portlet</name>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<description>
PerformFISH Apps is a set of portlet for the implementation of the Form Submission useful to calculate KPIs
</description>

View File

@ -1,8 +1,5 @@
package org.gcube.portlets.user.performfish;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -34,14 +31,10 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.performfish.util.PFISHConstants;
import org.gcube.portlets.user.performfish.util.Utils;
import org.gcube.portlets.user.performfish.util.ValidationResult;
import org.gcube.portlets.user.performfish.util.db.DBUtil;
import org.gcube.portlets.user.performfish.util.db.DatabaseConnection;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
import org.w3c.dom.Node;
@ -73,7 +66,8 @@ public class SubmittedFormValidation extends MVCPortlet {
GCubeTeam theCompany;
try {
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request));
long[] farmIds = ParamUtil.getLongValues(httpReq, "farmId");
String[] farmIds = ParamUtil.getParameterValues(httpReq, Utils.ENCODED_FARM_PARAM);
GCubeTeam theFarm = null;
theCompany = Utils.checkBelongingToOneCompanyOnly(request, response, this);
if (farmIds == null || farmIds.length == 0) {
@ -84,7 +78,8 @@ public class SubmittedFormValidation extends MVCPortlet {
}
}
else { //the farmId is passed via param on the query string
theFarm = new LiferayRoleManager().getTeam(farmIds[0]);
long selectedFarmId = Utils.unmaskId(farmIds[0]);
theFarm = new LiferayRoleManager().getTeam(selectedFarmId);
if (Utils.checkBelongsToTeam(PortalUtil.getUserId(request), theFarm.getTeamId(), PortalUtil.getScopeGroupId(request)) ) {//check that the user belong ot the farm
request.setAttribute("theFarm", theFarm); //pass to the JSP
}
@ -97,6 +92,9 @@ public class SubmittedFormValidation extends MVCPortlet {
request.setAttribute("theCompany", TeamLocalServiceUtil.getTeam(theCompany.getTeamId()));
request.setAttribute("theFarm", theFarm);
super.render(request, response);
} else {
_log.warn("theFarm is null");
super.render(request, response);
}
} catch (Exception e) {
e.printStackTrace();
@ -107,9 +105,9 @@ public class SubmittedFormValidation extends MVCPortlet {
e1.printStackTrace();
}
}
}
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {
long companyId = ParamUtil.getLong(resourceRequest, "companyId");
long farmId = ParamUtil.getLong(resourceRequest, "farmId");
@ -229,7 +227,7 @@ public class SubmittedFormValidation extends MVCPortlet {
e.printStackTrace();
return new ValidationResult(false, "There was a problem contacting the DataMiner cluster in this VRE ("
+ context+ ")"
+ "), please report this issue at www.d4science.org/contact-us");
+ "), please report this issue at http://support.d4science.org");
}
return toReturn;
}

View File

@ -1,10 +1,2 @@
<?xml version="1.0"?>
<web-app
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"/>

View File

@ -77,8 +77,7 @@
<%
ExternalFile item = (ExternalFile) pageContext.getAttribute("file");
String iconHTML = IconsManager.getMDIconTextualName(item.getName()).getHtml();
String fullName = Utils.getUserByUsername(item.getCurrentVersion().getUser())
.getFullname();
String fullName = Utils.getUserByUsername(item.getLastUpdatedBy()).getFullname();
String userProfileLink = Utils.getUserProfileLink(item.getLastUpdatedBy());
Date lastUpdated = new Date(item.getLastModificationTime().getTimeInMillis());
pageContext.setAttribute("lastUpdated", lastUpdated);

View File

@ -1,8 +1,7 @@
<%@include file="../init.jsp"%>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />
<%
List<SubmittedForm> submittedFormsWithPublishStatus = (List<SubmittedForm>) renderRequest.getAttribute("submittedFormsWithPublishStatus");
pageContext.setAttribute("submittedFormsWithPublishStatus", submittedFormsWithPublishStatus);
@ -22,8 +21,13 @@
String currentURL = PortalUtil.getCurrentURL(request);
pageContext.setAttribute("AnalyticalToolkitPortletEndpoint", Utils.ANALYTICAL_TOOLKIT_PORTLET_ENDPOINT);
%>
<script>
function closeAndReload() {
$("#modalSuccess").hide();
location.reload();
}
</script>
<portlet:resourceURL var="publishAndAnonymiseURL"></portlet:resourceURL>
<portlet:renderURL var="maximizedState"
windowState="<%=LiferayWindowState.MAXIMIZED.toString()%>" />
<portlet:renderURL var="normalState"
@ -72,7 +76,7 @@
SubmittedForm submittedForm = (SubmittedForm) pageContext.getAttribute("form");
ExternalFile item = submittedForm.getFormFile();
String iconHTML = IconsManager.getMDIconTextualName(item.getName()).getHtml();
String fullName = Utils.getUserByUsername(item.getCurrentVersion().getUser()).getFullname();
String fullName = Utils.getUserByUsername(item.getLastUpdatedBy()).getFullname();
String userProfileLink = Utils.getUserProfileLink(item.getLastUpdatedBy());
Date lastUpdated = new Date(item.getLastModificationTime().getTimeInMillis());
pageContext.setAttribute("lastUpdated", lastUpdated);
@ -154,16 +158,16 @@
</c:otherwise>
</c:choose>
</div>
<div id="modalSuccess" class="modal">
<div id="modalSuccess" class="modal" style="display: none;">
<div class="logo-circular"
style="background-image: url('${logoURL}');
background-size: cover; "></div>
<p class="lead">
The publishing and anonymising process started correctly.<br>
Please <a href="#" rel="modal:close" onClick="location.reload();">click here</a> to monitor the progress.
Please <a href="#" onClick="closeAndReload();">click here</a> to monitor the progress.
</p>
</div>
<div id="modalFailed" class="modal">
<div id="modalFailed" class="modal" style="display: none;">
<div class="logo-circular"
style="background-image: url('${logoURL}');
background-size: cover; "></div>
@ -171,7 +175,7 @@
We're sorry. An error occurred in the server. <br>
The publishing and anonymising process could not start, please report this issue.
</p>
<a href="#" rel="modal:close">Close</a>
<a href="#" onClick="closeAndReload();">Close</a>
</div>
</c:if>

View File

@ -40,43 +40,7 @@ function showFileNameWarningFromDOM(show) {
document.getElementById('fileNamesExplain').style.display = "none";
}
/* in view_farm_repository */
function publishAndAnonymise(endpoint, farmId, fileId) {
console.log("publishAndAnonymise:" + endpoint);
$('#publishAndAnonymise-Button').html('<i class="icon-refresh icon-white">in progress ...please wait');
$.ajax({
url : endpoint,
type : 'POST',
datatype : 'json',
data : {
farmId : farmId,
userId : Liferay.ThemeDisplay.getUserId(),
fileToPublishId : fileId,
groupId : Liferay.ThemeDisplay.getScopeGroupId()
},
success : function(data) {
var content = JSON.parse(data);
if (content.success == "OK") {
$("#modalSuccess").modal({
fadeDuration: 250,
escapeClose: false,
clickClose: false,
showClose: false
});
}
else {
$("#modalFailed").modal({
fadeDuration: 250,
escapeClose: false,
clickClose: false,
showClose: false
});
}
$('#publishAndAnonymise-Button').html('Anonymise and Publish');
}
});
}
function validateFile(companyId, farmId, endpoint, encodedURI, fileName, phase) {
console.log("validateFile:" + endpoint);
@ -112,6 +76,34 @@ function validateFile(companyId, farmId, endpoint, encodedURI, fileName, phase)
});
}
/* in view_farm_repository */
function publishAndAnonymise(endpoint, farmId, fileId) {
console.log("publishAndAnonymise:" + endpoint);
$('#publishAndAnonymise-Button').html('<i class="icon-refresh icon-white">in progress ...please wait');
$.ajax({
url : endpoint,
type : 'POST',
datatype : 'json',
data : {
farmId : farmId,
userId : Liferay.ThemeDisplay.getUserId(),
fileToPublishId : fileId,
groupId : Liferay.ThemeDisplay.getScopeGroupId()
},
success : function(data) {
var content = JSON.parse(data);
if (content.success == "OK") {
$("#modalSuccess").show();
}
else {
$("#modalFailed").show();
}
$('#publishAndAnonymise-Button').html('Anonymise and Publish');
}
});
}
function showInsertFarm(show) {
if (show) {
$('#formNewFarmButton').hide();