From 54657a4696faa6dd39ab27232ecc8c6b57105597 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 16 Sep 2014 15:40:52 +0000 Subject: [PATCH] gCube 3.4 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@99952 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 +- .settings/com.google.gdt.eclipse.core.prefs | 2 +- pom.xml | 10 +- .../server/servlet/ReportServiceImpl.java | 91 ++++++++++--------- .../shared/RSGAccessPoint.java | 2 +- src/main/webapp/ReportGenerator.css | 5 +- 6 files changed, 58 insertions(+), 56 deletions(-) diff --git a/.classpath b/.classpath index 06357ed..5495a9d 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index 757f76e..15b2d83 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -2,6 +2,6 @@ <<<<<<<=.mine >>>>>>>=.r71295 eclipse.preferences.version=1 -lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.10.0-SNAPSHOT +lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.11.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/pom.xml b/pom.xml index 2735dea..1702552 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.user reports war - 4.10.0-SNAPSHOT + 4.11.0-SNAPSHOT gCube Reports Manager gCube Reports Portlet. @@ -67,14 +67,6 @@ - - - xerces - xercesImpl - 2.9.1 - ${setScope} - com.google.gwt gwt-user diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java b/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java index 1011091..f0a3cf5 100644 --- a/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/reportgenerator/server/servlet/ReportServiceImpl.java @@ -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(); - - RsgClient rsgClient = new RsgClient(rsgWsAddr.getRestUrl()); - try { - rsgClient.securedWithEncryptedToken( - rsgWsAddr.getTokenUrl(), - rsgWsAddr.getiMarineKeyRingLocation(), - rsgWsAddr.getPassword(), - rsgWsAddr.getVmeKeyRingLocation()); - } catch (MalformedURLException e) { - e.printStackTrace(); + if (rsgReadClient == null) { + rsgReadClient = new RsgReadClient(rsgWsAddr.getRestUrl()); + System.out.println("rsgReadClient = new RsgReadClient(rsgWsAddr.getRestUrl()"+rsgWsAddr.getRestUrl()); } - return rsgClient; + return rsgReadClient; + } + + private RsgWriteClient getRsgSecureClient() { + RSGAccessPoint rsgWsAddr = getRSGWSAddress(); + if (rsgWriteClient == null) { + rsgWriteClient = new RsgWriteClient(rsgWsAddr.getRestUrl()+"/write"); + + try { + rsgWriteClient.secureWithPlainTokenSecurity(rsgWsAddr.getTokenUrl()); + System.out.println("rsgWriteClient.secureWithPlainTokenSecurity(rsgWsAddr.getTokenUrl())"+rsgWsAddr.getTokenUrl()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + 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 toReturn = new ArrayList(); 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 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; diff --git a/src/main/java/org/gcube/portlets/user/reportgenerator/shared/RSGAccessPoint.java b/src/main/java/org/gcube/portlets/user/reportgenerator/shared/RSGAccessPoint.java index 05aafbd..7f1a2f1 100644 --- a/src/main/java/org/gcube/portlets/user/reportgenerator/shared/RSGAccessPoint.java +++ b/src/main/java/org/gcube/portlets/user/reportgenerator/shared/RSGAccessPoint.java @@ -5,7 +5,7 @@ public class RSGAccessPoint { public static final String VME_SECURE_KEYRING_NAME = "vme.pkr"; public static final String IMARINE_SECURE_KEYRING_NAME = "imarine.skr"; private static final String REST_ENDPOINT = "/rest"; - private static final String TOKEN_ENDPOINT = "/security/token/encrypted/request"; + private static final String TOKEN_ENDPOINT = "/security/token/plain/request"; private String url; private String iMarineKeyRing; diff --git a/src/main/webapp/ReportGenerator.css b/src/main/webapp/ReportGenerator.css index 3bec5e9..20ea1d9 100644 --- a/src/main/webapp/ReportGenerator.css +++ b/src/main/webapp/ReportGenerator.css @@ -157,8 +157,9 @@ .deleteEntryButton { background-image: none !important; background-repeat: none !important; - background-color: #D62222 !important; - color: #FFF !important; + background-color: #F2DEDE !important; + border-color: #EBCCD1 !important; + color: #A94440 !important; } .deleteEntryButton:hover {