integrated security for rsg

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@95719 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-05-15 13:27:25 +00:00
parent fd610b29bc
commit 5c32d373f8
10 changed files with 1323 additions and 1162 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/reports-4.8.1-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/reports-4.8.2-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/reports-4.8.1-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/reports-4.8.2-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -2,6 +2,6 @@
<<<<<<<=.mine <<<<<<<=.mine
>>>>>>>=.r71295 >>>>>>>=.r71295
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.8.1-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.8.2-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

19
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>reports</artifactId> <artifactId>reports</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>4.8.1-SNAPSHOT</version> <version>4.8.3-SNAPSHOT</version>
<name>gCube Reports Manager</name> <name>gCube Reports Manager</name>
<description> <description>
gCube Reports Portlet. gCube Reports Portlet.
@ -60,7 +60,8 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>LATEST</version> <!-- <version>LATEST</version> -->
<version>1.4.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -110,6 +111,12 @@
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<scope>${setScope}</scope> <scope>${setScope}</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>${setScope}</scope>
</dependency>
<dependency> <dependency>
<groupId>com.sencha.gxt</groupId> <groupId>com.sencha.gxt</groupId>
<artifactId>gxt</artifactId> <artifactId>gxt</artifactId>
@ -128,7 +135,13 @@
<dependency> <dependency>
<groupId>org.gcube.application.rsg</groupId> <groupId>org.gcube.application.rsg</groupId>
<artifactId>reports-store-gateway-client</artifactId> <artifactId>reports-store-gateway-client</artifactId>
<version>[0.0.3-SNAPSHOT, 1.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<artifactId>el-api</artifactId>
<groupId>javax.el</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jboss.weld</groupId> <groupId>org.jboss.weld</groupId>

View File

@ -60,9 +60,6 @@ public class ClientImage extends Composite {
private String idInBasket; private String idInBasket;
private String currentUser;
private String currentScope;
public static final int DEFAULT_HEIGHT = 100; public static final int DEFAULT_HEIGHT = 100;
public static final int DEFAULT_WIDTH = 700; public static final int DEFAULT_WIDTH = 700;
@ -111,6 +108,7 @@ public class ClientImage extends Composite {
else { else {
GWT.log("Found ImageUrl="+imageURL); GWT.log("Found ImageUrl="+imageURL);
showImage(new Image(imageURL), width, height); showImage(new Image(imageURL), width, height);
enableUpload(false);
} }
//set style for buttons //set style for buttons
@ -161,6 +159,7 @@ public class ClientImage extends Composite {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
resetImage(); resetImage();
enableUpload(true);
} }
}); });
@ -189,7 +188,7 @@ public class ClientImage extends Composite {
} }
private void showUploadPopup() { private void showUploadPopup() {
presenter.showUploadFilePopup(this); presenter.showUploadImagePopup(this);
} }
private VerticalPanel getAttributesPanel(BasicComponent co) { private VerticalPanel getAttributesPanel(BasicComponent co) {
@ -287,6 +286,8 @@ public class ClientImage extends Composite {
GWT.log("URL:" + url, null); GWT.log("URL:" + url, null);
idInBasket = id; idInBasket = id;
showImage(new Image(url), width, height); showImage(new Image(url), width, height);
enableUpload(false);
} }
public void fetchImage(String identifier, final boolean isInteralImage, boolean fullDetails) { public void fetchImage(String identifier, final boolean isInteralImage, boolean fullDetails) {
@ -399,4 +400,9 @@ public class ClientImage extends Composite {
owner.removeFromParent(this); owner.removeFromParent(this);
removeFromParent(); removeFromParent();
} }
private void enableUpload(boolean enabled) {
addImageB.setVisible(enabled);
uploadImageB.setVisible(enabled);
}
} }

View File

@ -10,6 +10,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
@ -52,10 +53,10 @@ public class OpenOptions extends Composite {
doAction(OpenMode.OPEN_TEMPLATE); doAction(OpenMode.OPEN_TEMPLATE);
} }
@UiHandler("uploadReport") // @UiHandler("uploadReport")
void unUploadClick(ClickEvent e) { // void unUploadClick(ClickEvent e) {
doAction(OpenMode.UPLOAD); // doAction(OpenMode.UPLOAD);
} // }
private void doAction(OpenMode mode) { private void doAction(OpenMode mode) {
CommonCommands cmd = new CommonCommands(p); CommonCommands cmd = new CommonCommands(p);
@ -67,7 +68,7 @@ public class OpenOptions extends Composite {
cmd.openTemplate.execute(); cmd.openTemplate.execute();
break; break;
case UPLOAD: case UPLOAD:
p.showUploadFilePopup(null); //TODO: fix this //nothing to do, reminded to workspace
break; break;
default: default:
break; break;

View File

@ -11,7 +11,10 @@
<g:HTML ui:field="openReport" styleName="openOption optionOpenReport">Open/Edit Report</g:HTML> <g:HTML ui:field="openReport" styleName="openOption optionOpenReport">Open/Edit Report</g:HTML>
</td> </td>
<td> <td>
<g:HTML ui:field="uploadReport" styleName="openOption optionUpload">Upload from Desktop</g:HTML> <a href="/group/data-e-infrastructure-gateway/workspace" target="_blank" style="text-decoration: none;">
<g:HTML ui:field="uploadReport" styleName="openOption optionUpload">Upload from
Desktop</g:HTML>
</a>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -38,8 +38,8 @@ public class NotificationsThread implements Runnable {
public void run() { public void run() {
for (String userId : userIdsToBeNotified) { for (String userId : userIdsToBeNotified) {
try { try {
boolean notifResult = nm.notifyUpdatedItem(userId, subjectItem, sharedFolder); // boolean notifResult = nm.notifyUpdatedItem(userId, subjectItem, sharedFolder);
_log.trace("Update Notification sent to " + userId + " result="+notifResult); //_log.trace("Update Notification sent to " + userId + " result="+notifResult);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -13,6 +13,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -43,13 +44,14 @@ import org.gcube.application.rsg.client.RsgClient;
import org.gcube.application.rsg.service.RsgService; import org.gcube.application.rsg.service.RsgService;
import org.gcube.application.rsg.service.dto.ReportEntry; import org.gcube.application.rsg.service.dto.ReportEntry;
import org.gcube.application.rsg.service.dto.ReportType; import org.gcube.application.rsg.service.dto.ReportType;
import org.gcube.application.rsg.service.dto.response.Response; import org.gcube.application.rsg.service.dto.response.ServiceResponse;
import org.gcube.application.rsg.service.dto.response.ResponseEntry; import org.gcube.application.rsg.service.dto.response.ServiceResponseMessage;
import org.gcube.application.rsg.support.builder.exceptions.ReportBuilderException; import org.gcube.application.rsg.support.builder.exceptions.ReportBuilderException;
import org.gcube.application.rsg.support.builder.impl.ReportManagerReportBuilder; import org.gcube.application.rsg.support.builder.impl.ReportManagerReportBuilder;
import org.gcube.application.rsg.support.model.components.impl.CompiledReport; import org.gcube.application.rsg.support.model.components.impl.CompiledReport;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
@ -69,6 +71,9 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.ImageDocument; import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.ImageDocument;
import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries; 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;
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.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
@ -90,6 +95,7 @@ import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.CreateRepo
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenReportLogEntry; import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenReportLogEntry;
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenWorkflowLogEntry; import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.OpenWorkflowLogEntry;
import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.SaveWorkflowLogEntry; import org.gcube.portlets.user.reportgenerator.server.servlet.loggers.SaveWorkflowLogEntry;
import org.gcube.portlets.user.reportgenerator.shared.RSGAccessPoint;
import org.gcube.portlets.user.reportgenerator.shared.ReportImage; import org.gcube.portlets.user.reportgenerator.shared.ReportImage;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo; import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean; import org.gcube.portlets.user.reportgenerator.shared.UserBean;
@ -128,8 +134,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/ */
private boolean withinPortal = true; private boolean withinPortal = true;
//private static final String TEST_SCOPE = "/gcube/devsec/devVRE"; public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
public static final String TEST_SCOPE = "/gcube/devNext/NextNext"; //public static final String TEST_SCOPE = "/gcube/devNext/NextNext";
protected static final String IMAGE_SERVICE_URL = "reports/DownloadService"; protected static final String IMAGE_SERVICE_URL = "reports/DownloadService";
/** /**
@ -424,10 +430,20 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
try { try {
_log.trace("trying read: "+absolutePathOnServer); _log.trace("trying read: "+absolutePathOnServer);
WorkspaceFolder imagesFolder = getImagesFolder(); WorkspaceFolder imagesFolder = getImagesFolder();
// Read from an input stream // Read from an input stream
InputStream imageData = new BufferedInputStream(new FileInputStream(absolutePathOnServer)); InputStream imageData = new BufferedInputStream(new FileInputStream(absolutePathOnServer));
ExternalImage image = imagesFolder.createExternalImageItem(fileName, "automatically uploaded by Reports Manager", getMimeType(imageData, fileName), imageData); String itemName = fileName;
int i = 1;
while (imagesFolder.exists(itemName)) {
String[] splitted = fileName.split("\\.");
itemName = splitted[0]+"_"+i+"."+splitted[splitted.length-1];
i++;
}
ExternalImage image = imagesFolder.createExternalImageItem(itemName, "automatically uploaded by Reports Manager", getMimeType(imageData, fileName), imageData);
_log.trace("Created external image with name " + image.getName()); _log.trace("Created external image with name " + image.getName());
//delete the temp file
File toDelete = new File(absolutePathOnServer);
toDelete.delete();
return new ReportImage(image.getId(), buildImageServiceUrl(image.getId()), image.getWidth(), image.getHeight()); return new ReportImage(image.getId(), buildImageServiceUrl(image.getId()), image.getWidth(), image.getHeight());
} catch (Exception e) { } catch (Exception e) {
_log.error("Error in server get image by id", e); _log.error("Error in server get image by id", e);
@ -435,6 +451,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} }
return null; return null;
} }
/**
* @return the images folder of the workspace, create it if not exist.
*/
private WorkspaceFolder getImagesFolder() { private WorkspaceFolder getImagesFolder() {
Workspace ws = null; Workspace ws = null;
WorkspaceFolder reportFolder = null; WorkspaceFolder reportFolder = null;
@ -669,14 +688,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} }
private String getRSGWSAddress() { private RSGAccessPoint getRSGWSAddress() {
String addr = (String) getASLSession().getAttribute(RSG_WS_ADDRESS); RSGAccessPoint rsgAp = (RSGAccessPoint) getASLSession().getAttribute(RSG_WS_ADDRESS);
_log.trace("getRSGWSAddress: " + addr); _log.trace("getRSGWSAddress: " + rsgAp.getRestUrl());
return addr; return rsgAp;
} }
private void setRSGWSAddress(String addr) {
getASLSession().setAttribute(RSG_WS_ADDRESS, addr); private void setRSGWSAddress(RSGAccessPoint rsgAp) {
_log.trace("setting RSG WS address to " + addr); getASLSession().setAttribute(RSG_WS_ADDRESS, rsgAp);
_log.trace("setting RSG WS address to " + rsgAp.getRestUrl());
} }
/** /**
* *
@ -1606,6 +1626,22 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
_log.info("HTTP Session renewed" + new Date(session.getLastAccessedTime())); _log.info("HTTP Session renewed" + new Date(session.getLastAccessedTime()));
} }
private RsgClient getRsgSecureClient() {
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();
}
return rsgClient;
}
@Override @Override
public ArrayList<VMEReportBean> listVMEReports() { public ArrayList<VMEReportBean> listVMEReports() {
try { try {
@ -1616,7 +1652,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
ReportType type = new ReportType(); ReportType type = new ReportType();
type.setTypeIdentifier("Vme"); type.setTypeIdentifier("Vme");
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
_log.debug("listVMEReports() securedWithEncryptedToken completed");
for (ReportEntry re : rsgClient.listReports(type)) { for (ReportEntry re : rsgClient.listReports(type)) {
String rfmo = re.getOwner(); String rfmo = re.getOwner();
@ -1638,7 +1675,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
ArrayList<VMEReportBean> toReturn = new ArrayList<VMEReportBean>(); ArrayList<VMEReportBean> toReturn = new ArrayList<VMEReportBean>();
ReportType type = new ReportType(); ReportType type = new ReportType();
type.setTypeIdentifier(refType.toString()); type.setTypeIdentifier(refType.toString());
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
for (ReportEntry re :rsgClient.listReports(new ReportType(refType.getId()))) { for (ReportEntry re :rsgClient.listReports(new ReportType(refType.getId()))) {
String rfmo = re.getOwner(); String rfmo = re.getOwner();
@ -1651,7 +1689,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
@Override @Override
public Model importVMEReport(String id, String name, VMETypeIdentifier refType) { public Model importVMEReport(String id, String name, VMETypeIdentifier refType) {
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
CompiledReport cr = null; CompiledReport cr = null;
if (refType == VMETypeIdentifier.Vme) { if (refType == VMETypeIdentifier.Vme) {
@ -1680,7 +1719,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
@Override @Override
public Model getVMEReportRef2Associate(String id, VMETypeIdentifier refType) { public Model getVMEReportRef2Associate(String id, VMETypeIdentifier refType) {
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
_log.info("Importing Ref type= " + refType.getId() + " id=" + id); _log.info("Importing Ref type= " + refType.getId() + " id=" + id);
CompiledReport cr = rsgClient.getReferenceReportById(new ReportType(refType.getId()), id); CompiledReport cr = rsgClient.getReferenceReportById(new ReportType(refType.getId()), id);
Model model = null; Model model = null;
@ -1696,7 +1737,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
@Override @Override
public Model importVMETemplate(VMETypeIdentifier refType) { public Model importVMETemplate(VMETypeIdentifier refType) {
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
CompiledReport cr = null; CompiledReport cr = null;
if (refType == VMETypeIdentifier.Vme) { if (refType == VMETypeIdentifier.Vme) {
@ -1724,7 +1765,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
public VmeExportResponse exportReportToRSG(VMETypeIdentifier refType, Model model) { public VmeExportResponse exportReportToRSG(VMETypeIdentifier refType, Model model) {
System.out.println(new ModelReader(model).toString()); System.out.println(new ModelReader(model).toString());
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = 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') //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 //appearing in the VME model class name as stored in the 'type' metadata
@ -1746,7 +1787,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} }
try { try {
//Actual RSG client interface exposes different methods (publish / publishDelta etc.) that need to be updated //Actual RSG client interface exposes different methods (publish / publishDelta etc.) that need to be updated
Response res = null; ServiceResponse res = null;
if (refType == VMETypeIdentifier.Vme) { if (refType == VMETypeIdentifier.Vme) {
_log.info("Exporting VME Report"); _log.info("Exporting VME Report");
res = rsgClient.update(toSend); res = rsgClient.update(toSend);
@ -1764,10 +1805,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
@Override @Override
public VmeExportResponse deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete) { public VmeExportResponse deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete) {
RsgService rsgClient = new RsgClient(getRSGWSAddress()); RsgClient rsgClient = getRsgSecureClient();
try { try {
Response res = null; ServiceResponse res = null;
if (refType == VMETypeIdentifier.Vme) { if (refType == VMETypeIdentifier.Vme) {
_log.info("Deleting VME Report id = " + idToDelete); _log.info("Deleting VME Report id = " + idToDelete);
res = rsgClient.deleteById(new ReportType(refType.getId()), idToDelete); res = rsgClient.deleteById(new ReportType(refType.getId()), idToDelete);
@ -1786,8 +1827,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
/** /**
* this method look for a ReportsStoreGateway WS available in the infrastructure * this method look for a ReportsStoreGateway WS available in the infrastructure
* @return true if an instance of the ReportsStoreGateway is available in the infrastructure * @return true if an instance of the ReportsStoreGateway is available in the infrastructure
* @throws Exception
*/ */
private boolean isReportsStoreGatewayAvailable() { private boolean isReportsStoreGatewayAvailable(){
String scope = getASLSession().getScope(); String scope = getASLSession().getScope();
_log.info("Looking for a running ReportsStoreGateway WS in " + scope); _log.info("Looking for a running ReportsStoreGateway WS in " + scope);
String previousScope = ScopeProvider.instance.get(); String previousScope = ScopeProvider.instance.get();
@ -1807,17 +1849,33 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
else if (list.size() == 1) { else if (list.size() == 1) {
ServiceEndpoint se = list.get(0); ServiceEndpoint se = list.get(0);
String host = se.profile().runtime().hostedOn(); String host = se.profile().runtime().hostedOn();
String accessPoint = se.profile().accessPoints().iterator().next().address(); AccessPoint ap = se.profile().accessPoints().iterator().next();
setRSGWSAddress(host+accessPoint); String address = ap.address();
String password = "";
String iMarineSkrURL = "";
String vmeSkrURL = "";
try {
password = StringEncrypter.getEncrypter().decrypt(ap.password());
for (Property property : ap.properties()) {
if (property.name().compareTo(RSGAccessPoint.IMARINE_SECURE_KEYRING_NAME) == 0)
iMarineSkrURL = StringEncrypter.getEncrypter().decrypt(property.value());
if (property.name().compareTo(RSGAccessPoint.VME_SECURE_KEYRING_NAME) == 0)
vmeSkrURL = StringEncrypter.getEncrypter().decrypt(property.value());
}
} catch (Exception e) {
e.printStackTrace();
}
RSGAccessPoint rsgAp = new RSGAccessPoint(host+address, iMarineSkrURL, vmeSkrURL, password);
setRSGWSAddress(rsgAp);
return true; return true;
} }
else return false; else return false;
} }
private VmeExportResponse getClientResponse(Response rsgResponse) { private VmeExportResponse getClientResponse(ServiceResponse rsgResponse) {
VmeExportResponse toReturn = new VmeExportResponse(); VmeExportResponse toReturn = new VmeExportResponse();
for (ResponseEntry entry : rsgResponse.getResponseMessageList()) { for (ServiceResponseMessage entry : rsgResponse.getResponseMessageList()) {
String entryCode = entry.getResponseCode() == null ? "no-code" : entry.getResponseCode().toString(); String entryCode = entry.getResponseCode() == null ? "no-code" : entry.getResponseCode().toString();
String entryMessage = entry.getResponseMessage() == null ? "no response message" : entry.getResponseMessage(); String entryMessage = entry.getResponseMessage() == null ? "no response message" : entry.getResponseMessage();
toReturn.getResponseMessageList().add(new VmeResponseEntry(entryCode, entryMessage)); toReturn.getResponseMessageList().add(new VmeResponseEntry(entryCode, entryMessage));

View File

@ -0,0 +1,49 @@
package org.gcube.portlets.user.reportgenerator.shared;
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 String url;
private String iMarineKeyRing;
private String vmeKeyRing;
private String password;
public RSGAccessPoint(String url, String iMarineKeyRing, String vmeKeyRing, String password) {
super();
this.url = url;
this.iMarineKeyRing = iMarineKeyRing;
this.vmeKeyRing = vmeKeyRing;
this.password = password;
}
public String getRestUrl() {
return url+REST_ENDPOINT;
}
public String getTokenUrl() {
return url+TOKEN_ENDPOINT;
}
public String getiMarineKeyRingLocation() {
return iMarineKeyRing;
}
public String getVmeKeyRingLocation() {
return vmeKeyRing;
}
public String getPassword() {
return password;
}
@Override
public String toString() {
return "RSGAccessPoint [getRestUrl()=" + getRestUrl()
+ ", getTokenUrl()=" + getTokenUrl()
+ ", getiMarineKeyRingLocation()="
+ getiMarineKeyRingLocation() + ", getVmeKeyRingLocation()="
+ getVmeKeyRingLocation() + ", getPassword()=" + getPassword()
+ "]";
}
}