|
|
|
@ -40,9 +40,8 @@ import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
|
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
|
import org.gcube.application.framework.core.session.SessionManager;
|
|
|
|
|
import org.gcube.application.reporting.reader.ModelReader;
|
|
|
|
|
import org.gcube.application.rsg.client.RsgClient;
|
|
|
|
|
import org.gcube.application.rsg.client.*;
|
|
|
|
|
import org.gcube.application.rsg.client.support.ClientException;
|
|
|
|
|
import org.gcube.application.rsg.service.RsgService;
|
|
|
|
|
import org.gcube.application.rsg.service.dto.ReportEntry;
|
|
|
|
|
import org.gcube.application.rsg.service.dto.ReportType;
|
|
|
|
|
import org.gcube.application.rsg.service.dto.response.ServiceResponse;
|
|
|
|
@ -74,7 +73,6 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries;
|
|
|
|
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|
|
|
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
|
|
|
|
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
|
|
|
|
import org.gcube.common.resources.gcore.utils.Group;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
|
|
|
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
|
|
@ -110,9 +108,6 @@ import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
|
|
|
|
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|
|
|
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayRoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
@ -166,9 +161,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
* the WF DB Store
|
|
|
|
|
*/
|
|
|
|
|
private Store store;
|
|
|
|
|
//the client for the VME-DB case
|
|
|
|
|
private RsgReadClient rsgReadClient;
|
|
|
|
|
private RsgWriteClient rsgWriteClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//set to true if wanna test workflow menu mode
|
|
|
|
|
//set to true if want to test workflow menu mode
|
|
|
|
|
boolean testWorkflow = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1640,20 +1637,28 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
_log.info("HTTP Session renewed" + new Date(session.getLastAccessedTime()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RsgClient getRsgSecureClient() {
|
|
|
|
|
private RsgReadClient getRsgClient() {
|
|
|
|
|
RSGAccessPoint rsgWsAddr = getRSGWSAddress();
|
|
|
|
|
if (rsgReadClient == null) {
|
|
|
|
|
rsgReadClient = new RsgReadClient(rsgWsAddr.getRestUrl());
|
|
|
|
|
System.out.println("rsgReadClient = new RsgReadClient(rsgWsAddr.getRestUrl()"+rsgWsAddr.getRestUrl());
|
|
|
|
|
}
|
|
|
|
|
return rsgReadClient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RsgWriteClient getRsgSecureClient() {
|
|
|
|
|
RSGAccessPoint rsgWsAddr = getRSGWSAddress();
|
|
|
|
|
if (rsgWriteClient == null) {
|
|
|
|
|
rsgWriteClient = new RsgWriteClient(rsgWsAddr.getRestUrl()+"/write");
|
|
|
|
|
|
|
|
|
|
RsgClient rsgClient = new RsgClient(rsgWsAddr.getRestUrl());
|
|
|
|
|
try {
|
|
|
|
|
rsgClient.securedWithEncryptedToken(
|
|
|
|
|
rsgWsAddr.getTokenUrl(),
|
|
|
|
|
rsgWsAddr.getiMarineKeyRingLocation(),
|
|
|
|
|
rsgWsAddr.getPassword(),
|
|
|
|
|
rsgWsAddr.getVmeKeyRingLocation());
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
try {
|
|
|
|
|
rsgWriteClient.secureWithPlainTokenSecurity(rsgWsAddr.getTokenUrl());
|
|
|
|
|
System.out.println("rsgWriteClient.secureWithPlainTokenSecurity(rsgWsAddr.getTokenUrl())"+rsgWsAddr.getTokenUrl());
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rsgClient;
|
|
|
|
|
return rsgWriteClient;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* the list of Regional Fishery Management Organizations (RFMO) associated to the current user is constructed by looking at the roles
|
|
|
|
@ -1714,16 +1719,18 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
ReportType type = new ReportType();
|
|
|
|
|
type.setTypeIdentifier("Vme");
|
|
|
|
|
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
_log.debug("listVMEReports() securedWithEncryptedToken completed");
|
|
|
|
|
_log.info("listVMEReports() instantiating secure rsgClient ...");
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
_log.info("listVMEReports() securedWithEncryptedToken completed");
|
|
|
|
|
|
|
|
|
|
ReportEntry[] reports = null;
|
|
|
|
|
try {
|
|
|
|
|
reports = rsgClient.listReports(type);
|
|
|
|
|
_log.info("calling rsgClient#listReports... ");
|
|
|
|
|
reports = rsgReadClient.listReports(type);
|
|
|
|
|
_log.info("got the reports list");
|
|
|
|
|
} catch (ClientException e) {
|
|
|
|
|
_log.error("failed to get the list of VME Reports: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isVREManager()) {
|
|
|
|
|
for (ReportEntry re : reports) {
|
|
|
|
|
String rfmo = re.getOwner();
|
|
|
|
@ -1744,6 +1751,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1758,17 +1766,17 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
ArrayList<VMEReportBean> toReturn = new ArrayList<VMEReportBean>();
|
|
|
|
|
ReportType type = new ReportType();
|
|
|
|
|
type.setTypeIdentifier(refType.toString());
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
|
|
|
|
|
if (isVREManager()) {
|
|
|
|
|
for (ReportEntry re :rsgClient.listReports(new ReportType(refType.getId()))) {
|
|
|
|
|
for (ReportEntry re :rsgReadClient.listReports(new ReportType(refType.getId()))) {
|
|
|
|
|
String rfmo = re.getOwner();
|
|
|
|
|
String name = re.getIdentifier();
|
|
|
|
|
toReturn.add(new VMEReportBean(""+re.getId(), rfmo, name));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ArrayList<String> allowedRFMOs = getUserRFMOs();
|
|
|
|
|
for (ReportEntry re :rsgClient.listReports(new ReportType(refType.getId()))) {
|
|
|
|
|
for (ReportEntry re :rsgReadClient.listReports(new ReportType(refType.getId()))) {
|
|
|
|
|
String rfmo = re.getOwner();
|
|
|
|
|
String name = re.getIdentifier();
|
|
|
|
|
if (rfmo == null) { //when getting a RFMO refType the Owner is null
|
|
|
|
@ -1790,17 +1798,17 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Model importVMEReport(String id, String name, VMETypeIdentifier refType) {
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompiledReport cr = null;
|
|
|
|
|
if (refType == VMETypeIdentifier.Vme) {
|
|
|
|
|
_log.info("Importing VME id=" + id + " name=" + name);
|
|
|
|
|
cr = rsgClient.getReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
cr = rsgReadClient.getReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_log.info("Importing Ref type= " + refType.getId() + " id=" + id + " name=" + name);
|
|
|
|
|
cr = rsgClient.getReferenceReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
cr = rsgReadClient.getReferenceReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Model model = null;
|
|
|
|
@ -1820,11 +1828,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Model getVMEReportRef2Associate(String id, VMETypeIdentifier refType) {
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_log.info("Importing Ref type= " + refType.getId() + " id=" + id);
|
|
|
|
|
CompiledReport cr = rsgClient.getReferenceReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
CompiledReport cr = rsgReadClient.getReferenceReportById(new ReportType(refType.getId()), id);
|
|
|
|
|
Model model = null;
|
|
|
|
|
try {
|
|
|
|
|
model = new ReportManagerReportBuilder().buildReferenceReport(cr);
|
|
|
|
@ -1838,16 +1846,16 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Model importVMETemplate(VMETypeIdentifier refType) {
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
|
|
|
|
|
CompiledReport cr = null;
|
|
|
|
|
if (refType == VMETypeIdentifier.Vme) {
|
|
|
|
|
_log.info("Importing VME Template");
|
|
|
|
|
cr = rsgClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
cr = rsgReadClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_log.info("Importing Ref type= " + refType.getId());
|
|
|
|
|
cr = rsgClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
cr = rsgReadClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Model model = null;
|
|
|
|
@ -1866,7 +1874,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
public VmeExportResponse exportReportToRSG(VMETypeIdentifier refType, Model model) {
|
|
|
|
|
System.out.println(new ModelReader(model).toString());
|
|
|
|
|
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
rsgReadClient = getRsgClient();
|
|
|
|
|
rsgWriteClient = getRsgSecureClient();
|
|
|
|
|
|
|
|
|
|
//Use the RSG client to get a template for the report whose type is the last token (i.e. the corresponding class' 'simple name')
|
|
|
|
|
//appearing in the VME model class name as stored in the 'type' metadata
|
|
|
|
@ -1874,11 +1883,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
CompiledReport template = null;
|
|
|
|
|
if (refType == VMETypeIdentifier.Vme) {
|
|
|
|
|
_log.info("getTemplate for VME Report");
|
|
|
|
|
template = rsgClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
template = rsgReadClient.getTemplate(new ReportType(refType.getId()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_log.info("getTemplate for Ref Report");
|
|
|
|
|
template = rsgClient.getRefTemplate(new ReportType(refType.getId()));
|
|
|
|
|
template = rsgReadClient.getRefTemplate(new ReportType(refType.getId()));
|
|
|
|
|
}
|
|
|
|
|
CompiledReport toSend = null;
|
|
|
|
|
try {
|
|
|
|
@ -1891,11 +1900,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
ServiceResponse res = null;
|
|
|
|
|
if (refType == VMETypeIdentifier.Vme) {
|
|
|
|
|
_log.info("Exporting VME Report");
|
|
|
|
|
res = rsgClient.update(toSend);
|
|
|
|
|
res = rsgWriteClient.update(toSend);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_log.info("Exporting Ref type= " + refType.getId());
|
|
|
|
|
res = rsgClient.updateRef(toSend);
|
|
|
|
|
res = rsgWriteClient.updateRef(toSend);
|
|
|
|
|
}
|
|
|
|
|
return getClientResponse(res);
|
|
|
|
|
} catch (RuntimeException ex) {
|
|
|
|
@ -1906,7 +1915,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public VmeExportResponse deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete) {
|
|
|
|
|
RsgClient rsgClient = getRsgSecureClient();
|
|
|
|
|
RsgWriteClient rsgClient = getRsgSecureClient();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ServiceResponse res = null;
|
|
|
|
|