2013-02-06 23:25:43 +01:00
package org.gcube.portlets.user.reportgenerator.server.servlet ;
2013-12-17 19:19:51 +01:00
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor ;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor ;
2013-02-06 23:25:43 +01:00
import java.io.ByteArrayOutputStream ;
import java.io.File ;
import java.io.FileInputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.ObjectInputStream ;
2014-05-15 15:27:25 +02:00
import java.net.MalformedURLException ;
2013-02-06 23:25:43 +01:00
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import java.util.Vector ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpSession ;
import org.apache.commons.io.IOUtils ;
2014-04-28 18:26:53 +02:00
import org.apache.tika.config.TikaConfig ;
import org.apache.tika.detect.Detector ;
import org.apache.tika.io.TikaInputStream ;
import org.apache.tika.metadata.Metadata ;
import org.apache.tika.mime.MediaType ;
2013-02-06 23:25:43 +01:00
import org.gcube.application.framework.core.session.ASLSession ;
import org.gcube.application.framework.core.session.SessionManager ;
2014-01-22 18:31:02 +01:00
import org.gcube.application.reporting.reader.ModelReader ;
2015-09-29 16:37:06 +02:00
import org.gcube.application.rsg.client.RsgReadClient ;
import org.gcube.application.rsg.client.RsgWriteClient ;
2014-07-02 15:12:44 +02:00
import org.gcube.application.rsg.client.support.ClientException ;
2013-11-13 18:56:13 +01:00
import org.gcube.application.rsg.service.dto.ReportEntry ;
import org.gcube.application.rsg.service.dto.ReportType ;
2014-05-15 15:27:25 +02:00
import org.gcube.application.rsg.service.dto.response.ServiceResponse ;
import org.gcube.application.rsg.service.dto.response.ServiceResponseMessage ;
2013-12-04 23:21:12 +01:00
import org.gcube.application.rsg.support.builder.exceptions.ReportBuilderException ;
import org.gcube.application.rsg.support.builder.impl.ReportManagerReportBuilder ;
import org.gcube.application.rsg.support.model.components.impl.CompiledReport ;
2021-10-28 11:47:57 +02:00
import org.gcube.common.encryption.encrypter.StringEncrypter ;
2018-06-26 17:58:23 +02:00
import org.gcube.common.portal.PortalContext ;
2013-12-17 19:19:51 +01:00
import org.gcube.common.resources.gcore.ServiceEndpoint ;
2014-05-15 15:27:25 +02:00
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint ;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property ;
2013-12-17 19:19:51 +01:00
import org.gcube.common.scope.api.ScopeProvider ;
2013-02-06 23:25:43 +01:00
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper ;
import org.gcube.portlets.d4sreporting.common.server.ServiceUtil ;
2013-03-05 15:26:22 +01:00
import org.gcube.portlets.d4sreporting.common.shared.Model ;
2013-03-01 19:42:50 +01:00
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries ;
2013-03-05 15:26:22 +01:00
import org.gcube.portlets.d4sreporting.common.shared.Table ;
2013-02-06 23:25:43 +01:00
import org.gcube.portlets.d4sreporting.common.shared.TableCell ;
import org.gcube.portlets.user.reportgenerator.client.ReportConstants ;
import org.gcube.portlets.user.reportgenerator.client.ReportService ;
2014-05-15 15:27:25 +02:00
import org.gcube.portlets.user.reportgenerator.shared.RSGAccessPoint ;
2014-04-28 18:26:53 +02:00
import org.gcube.portlets.user.reportgenerator.shared.ReportImage ;
2013-02-06 23:25:43 +01:00
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo ;
2013-03-05 15:26:22 +01:00
import org.gcube.portlets.user.reportgenerator.shared.UserBean ;
2013-11-25 17:12:01 +01:00
import org.gcube.portlets.user.reportgenerator.shared.VMEReportBean ;
2013-11-13 18:56:13 +01:00
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier ;
2014-01-28 17:31:13 +01:00
import org.gcube.portlets.user.reportgenerator.shared.VmeExportResponse ;
import org.gcube.portlets.user.reportgenerator.shared.VmeResponseEntry ;
2013-12-17 19:19:51 +01:00
import org.gcube.resources.discovery.client.api.DiscoveryClient ;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery ;
2014-06-27 15:24:57 +02:00
import org.gcube.vomanagement.usermanagement.RoleManager ;
2016-06-29 12:09:29 +02:00
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager ;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager ;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager ;
import org.gcube.vomanagement.usermanagement.model.GCubeRole ;
import org.gcube.vomanagement.usermanagement.model.GCubeTeam ;
import org.gcube.vomanagement.usermanagement.model.GCubeUser ;
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames ;
2013-10-09 14:21:50 +02:00
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
2013-02-06 23:25:43 +01:00
import com.google.gwt.user.server.rpc.RemoteServiceServlet ;
2013-03-05 15:26:22 +01:00
import com.liferay.portal.service.UserLocalServiceUtil ;
2013-02-06 23:25:43 +01:00
2017-02-08 11:52:16 +01:00
import net.sf.csv4j.CSVFileProcessor ;
import net.sf.csv4j.CSVLineProcessor ;
import net.sf.csv4j.ParseException ;
import net.sf.csv4j.ProcessingException ;
2013-02-06 23:25:43 +01:00
2014-04-28 18:26:53 +02:00
2013-02-06 23:25:43 +01:00
/ * *
*
* class implementing services
* @author Massimiliano Assante , ISTI - CNR - massimiliano . assante @isti.cnr.it
* /
@SuppressWarnings ( " serial " )
public class ReportServiceImpl extends RemoteServiceServlet implements ReportService {
2013-10-09 14:21:50 +02:00
private static final Logger _log = LoggerFactory . getLogger ( ReportServiceImpl . class ) ;
2013-02-06 23:25:43 +01:00
2014-04-28 18:26:53 +02:00
protected static final String IMAGE_SERVICE_URL = " reports/DownloadService " ;
2013-02-06 23:25:43 +01:00
/ * *
*
* /
public static final String CURRENT_REPORT_ID_ATTRIBUTE = " CURRENT_REPORT_ID_ATTRIBUTE " ;
/ * *
*
* /
public static final String CURRENT_REPORT_INSTANCE = " myReport " ;
/ * *
*
* /
public static final String PREVIOUS_REPORT_INSTANCE = " myPreviousReport " ;
2013-12-17 19:19:51 +01:00
/ * *
*
* /
2014-10-21 12:15:09 +02:00
public static final String RSG_WS_ADDRESS = " RSG-WS-ENDPOINT " ;
2014-05-15 15:27:25 +02:00
2014-04-28 18:26:53 +02:00
private static final String REPORT_IMAGES_FOLDER = " Report Images " ;
2015-12-17 17:05:40 +01:00
public static final String TEST_USER = " test.user " ;
public static final String TEST_SCOPE = " /gcube/devsec/devVRE " ;
2013-02-06 23:25:43 +01:00
2016-06-29 12:09:29 +02:00
2014-09-16 17:40:52 +02:00
//the client for the VME-DB case
private RsgReadClient rsgReadClient ;
private RsgWriteClient rsgWriteClient ;
2013-02-06 23:25:43 +01:00
2013-03-08 15:49:26 +01:00
2013-02-06 23:25:43 +01:00
/ * *
* the current ASLSession
* @return .
* /
private ASLSession getASLSession ( ) {
String sessionID = this . getThreadLocalRequest ( ) . getSession ( ) . getId ( ) ;
2013-03-16 02:53:00 +01:00
2013-02-06 23:25:43 +01:00
String user = ( String ) this . getThreadLocalRequest ( ) . getSession ( ) . getAttribute ( ScopeHelper . USERNAME_ATTRIBUTE ) ;
if ( user = = null ) {
2015-12-17 17:05:40 +01:00
user = getDevelopmentUser ( ) ;
if ( user . compareTo ( TEST_USER ) ! = 0 ) {
SessionManager . getInstance ( ) . getASLSession ( sessionID , user ) . setScope ( TEST_SCOPE ) ;
this . getThreadLocalRequest ( ) . getSession ( ) . setAttribute ( ScopeHelper . USERNAME_ATTRIBUTE , user ) ;
String email = user + " @isti.cnr.it " ;
String fullName = " Andrea Rossi " ;
String thumbnailURL = " images/Avatar_default.png " ;
SessionManager . getInstance ( ) . getASLSession ( sessionID , user ) . setUserEmailAddress ( email ) ;
SessionManager . getInstance ( ) . getASLSession ( sessionID , user ) . setUserAvatarId ( thumbnailURL ) ;
SessionManager . getInstance ( ) . getASLSession ( sessionID , user ) . setUserFullName ( fullName ) ;
}
2013-03-16 02:53:00 +01:00
2013-02-06 23:25:43 +01:00
}
return SessionManager . getInstance ( ) . getASLSession ( sessionID , user ) ;
2013-03-08 15:49:26 +01:00
2013-02-06 23:25:43 +01:00
}
2015-12-17 17:05:40 +01:00
public String getDevelopmentUser ( ) {
String user = TEST_USER ;
return user ;
2014-04-28 18:26:53 +02:00
}
2014-06-27 15:24:57 +02:00
/ * *
*
* @return true if you ' re running into the portal , false if in development
* /
private boolean isWithinPortal ( ) {
try {
UserLocalServiceUtil . getService ( ) ;
return true ;
}
catch ( com . liferay . portal . kernel . bean . BeanLocatorException ex ) {
_log . trace ( " Development Mode ON " ) ;
return false ;
}
}
2013-02-06 23:25:43 +01:00
/ * *
* Retrieve the user saved template names
*
* @return a String [ ] containing the template names
* /
public String [ ] getUserTemplateNames ( ) {
ServiceUtil myUtil = new ServiceUtil ( getASLSession ( ) ) ;
Vector < String > tmp = new Vector < String > ( ) ;
String userDir = myUtil . getTemplateFolder ( getVreName ( ) , getUsername ( ) ) ;
2013-03-05 15:26:22 +01:00
_log . debug ( " userDir: " + userDir ) ;
2013-02-06 23:25:43 +01:00
File f = new File ( userDir ) ;
//checking if dir exists
if ( ! f . exists ( ) ) {
try {
f . mkdirs ( ) ;
return new String [ 0 ] ;
} catch ( SecurityException ex ) {
return new String [ 0 ] ;
}
}
else {
File [ ] f2 = f . listFiles ( ) ;
for ( int i = 0 ; i < f2 . length ; i + + ) {
if ( f2 [ i ] . isDirectory ( ) ) {
tmp . add ( f2 [ i ] . getName ( ) ) ;
}
}
return tmp . toArray ( new String [ 0 ] ) ;
}
}
/ * *
* @return a SerializableModel instance of the imported fimes xml
* /
2013-03-01 19:42:50 +01:00
public Model readImportedModel ( String tempPath ) {
Model toConvert = null ;
2013-02-06 23:25:43 +01:00
FileInputStream fis = null ;
ObjectInputStream in = null ;
try {
fis = new FileInputStream ( tempPath ) ;
in = new ObjectInputStream ( fis ) ;
2013-03-01 19:42:50 +01:00
toConvert = ( Model ) in . readObject ( ) ;
2013-02-06 23:25:43 +01:00
in . close ( ) ;
} catch ( IOException ex ) {
ex . printStackTrace ( ) ;
} catch ( ClassNotFoundException ex ) {
ex . printStackTrace ( ) ;
}
2013-10-29 17:08:14 +01:00
_log . debug ( " Converting Imported Fimes to Serializable object, num sections: " + toConvert . getSections ( ) . size ( ) ) ;
2013-02-06 23:25:43 +01:00
return ( toConvert ) ;
}
/ * *
* @return a SerializableModel instance of the templatename passed as parameter
* @param templateName : the template to read from disk
* @param templateObjectID the id in the basket
* @param isTemplate says if you ' re opening a template or a report
* @param isImporting says if your importing or youre loading a template in the UI
*
* /
2013-03-01 19:42:50 +01:00
public Model readModel ( String templateName , String templateObjectID , boolean isTemplate , boolean isImporting ) {
2013-10-29 17:08:14 +01:00
return new Model ( ) ;
2013-02-06 23:25:43 +01:00
}
2014-05-15 15:27:25 +02:00
2014-04-28 18:26:53 +02:00
/ * *
* used when an image is uploaded
* /
@Override
public ReportImage getUploadedImageUrlById ( String fileName , String absolutePathOnServer ) {
return null ;
}
/ * *
*
* @param is
* @return
* @throws IOException
* @throws MagicParseException
* @throws MagicMatchNotFoundException
* @throws MagicException
* /
protected static String getMimeType ( InputStream is , String filenameWithExtension ) throws IOException {
TikaConfig config = TikaConfig . getDefaultConfig ( ) ;
Detector detector = config . getDetector ( ) ;
TikaInputStream stream = TikaInputStream . get ( is ) ;
Metadata metadata = new Metadata ( ) ;
metadata . add ( Metadata . RESOURCE_NAME_KEY , filenameWithExtension ) ;
MediaType mediaType = detector . detect ( stream , metadata ) ;
return mediaType . getBaseType ( ) . toString ( ) ;
}
/ * *
* used to actually display images in reports ( when reading reports )
* /
@Override
public ReportImage getImageUrlById ( String identifier ) {
return null ;
}
2013-02-06 23:25:43 +01:00
2014-09-22 17:48:16 +02:00
/ * *
*
* @param id
* @return
* /
2014-04-28 18:26:53 +02:00
protected String buildImageServiceUrl ( String id ) {
StringBuilder sb = new StringBuilder ( ) ;
2014-09-22 17:48:16 +02:00
sb . append ( this . getServletContext ( ) . getContextPath ( ) ) . append ( " / " ) ;
2014-04-28 18:26:53 +02:00
sb . append ( IMAGE_SERVICE_URL ) . append ( " ?id= " ) . append ( id ) . append ( " &type=IMAGE " ) ;
return sb . toString ( ) ;
}
2013-02-06 23:25:43 +01:00
2021-10-28 11:47:57 +02:00
2013-02-06 23:25:43 +01:00
2013-03-16 02:53:00 +01:00
2013-02-06 23:25:43 +01:00
/ * *
*
* @return the shared session
* /
public String getUsername ( ) {
if ( ! ReportConstants . isDeployed ) {
return " massimiliano.assante " ;
} else {
HttpServletRequest httpServletRequest = this . getThreadLocalRequest ( ) ;
HttpSession session = httpServletRequest . getSession ( ) ;
String user = ( String ) session . getAttribute ( ScopeHelper . USERNAME_ATTRIBUTE ) ;
if ( session . getAttribute ( ScopeHelper . USERNAME_ATTRIBUTE ) = = null )
{
user = " massimiliano.assante " ;
2013-03-05 15:26:22 +01:00
_log . warn ( " D4ScienceSession user NULL set to: " + user ) ;
2013-02-06 23:25:43 +01:00
}
2013-03-05 15:26:22 +01:00
_log . warn ( " ASLSession user: " + user ) ;
2013-02-06 23:25:43 +01:00
ASLSession d4session = SessionManager . getInstance ( ) . getASLSession ( session . getId ( ) , user ) ;
d4session . setAttribute ( ScopeHelper . USERNAME_ATTRIBUTE , user ) ;
return user ;
}
}
/ * *
*
* @return the current scope
* /
public String getVreName ( ) {
if ( ! ReportConstants . isDeployed ) {
2013-03-15 14:19:27 +01:00
return TEST_SCOPE ;
2013-02-06 23:25:43 +01:00
} else {
HttpServletRequest httpServletRequest = this . getThreadLocalRequest ( ) ;
HttpSession session = httpServletRequest . getSession ( ) ;
ASLSession d4session = SessionManager . getInstance ( ) . getASLSession ( session . getId ( ) , getUsername ( ) ) ;
String scope = d4session . getScopeName ( ) ;
if ( scope = = null ) {
2013-03-15 14:19:27 +01:00
scope = TEST_SCOPE ;
2013-03-05 15:26:22 +01:00
_log . warn ( " ASL Session scope NULL set to: " + scope ) ;
2013-02-06 23:25:43 +01:00
}
//need to remove the initial / of the scope
if ( scope . charAt ( 0 ) = = '/' )
scope = scope . substring ( 1 , scope . length ( ) ) ;
2013-03-05 15:26:22 +01:00
_log . info ( " SCOPE: " + scope ) ;
2013-02-06 23:25:43 +01:00
return scope ;
}
}
2014-01-23 19:11:55 +01:00
2014-05-15 15:27:25 +02:00
private RSGAccessPoint getRSGWSAddress ( ) {
2014-10-21 12:15:09 +02:00
RSGAccessPoint rsgAp = ( RSGAccessPoint ) this . getThreadLocalRequest ( ) . getSession ( ) . getAttribute ( RSG_WS_ADDRESS ) ;
2015-12-17 17:05:40 +01:00
if ( rsgAp ! = null )
_log . trace ( " getRSGWSAddress: " + rsgAp . getRestUrl ( ) ) ;
2014-05-15 15:27:25 +02:00
return rsgAp ;
2013-12-17 19:19:51 +01:00
}
2014-05-15 15:27:25 +02:00
private void setRSGWSAddress ( RSGAccessPoint rsgAp ) {
2014-10-21 12:15:09 +02:00
this . getThreadLocalRequest ( ) . getSession ( ) . setAttribute ( RSG_WS_ADDRESS , rsgAp ) ;
2015-12-17 17:05:40 +01:00
if ( rsgAp ! = null )
_log . trace ( " setting RSG WS address to " + rsgAp . getRestUrl ( ) ) ;
2013-12-17 19:19:51 +01:00
}
2013-02-06 23:25:43 +01:00
/ * *
*
* @return the model previously stored in the session
* /
2013-03-01 19:42:50 +01:00
public Model readTemplateFromSession ( ) {
2013-02-06 23:25:43 +01:00
return null ;
}
/ * *
* recurdively delete the templates folder of the dir dir
* @param dir the dir to delete
* /
public void delTemplateDir ( File dir ) {
try {
File [ ] files = dir . listFiles ( ) ;
for ( int i = 0 ; i < files . length ; i + + ) {
if ( files [ i ] . isDirectory ( ) )
delTemplateDir ( files [ i ] ) ;
files [ i ] . delete ( ) ;
}
} catch ( Exception e ) {
System . out . println ( " WARNING: Could not cleaning temp dir: reason unknown " ) ;
}
}
/ * *
* @param model to store in the session
* /
2013-03-01 19:42:50 +01:00
public void storeTemplateInSession ( Model model ) {
2013-02-06 23:25:43 +01:00
ASLSession d4Session = getASLSession ( ) ;
d4Session . setAttribute ( CURRENT_REPORT_INSTANCE , model ) ;
2013-05-06 17:38:24 +02:00
_log . trace ( " Saved in Session " ) ;
2013-02-06 23:25:43 +01:00
}
/ * *
* @param reportItemid the report itemd id in basket to store in the session
* /
public void storeReportItemIDInSession ( String reportItemid ) {
ASLSession d4Session = getASLSession ( ) ;
d4Session . setAttribute ( CURRENT_REPORT_ID_ATTRIBUTE , reportItemid ) ;
2013-03-05 15:26:22 +01:00
_log . debug ( " WROTE REPORT ID IN SESSION: " + reportItemid ) ;
2013-02-06 23:25:43 +01:00
}
/ * *
* @return the report item id in basket , or " " if doesn ' t exist
* /
public String getReportItemIDFromSession ( ) {
ASLSession d4Session = getASLSession ( ) ;
if ( d4Session . getAttribute ( CURRENT_REPORT_ID_ATTRIBUTE ) = = null )
return " " ;
else
return d4Session . getAttribute ( CURRENT_REPORT_ID_ATTRIBUTE ) . toString ( ) ;
}
/ * *
2013-10-29 19:17:47 +01:00
* used to save the report in the same folder
2013-02-06 23:25:43 +01:00
* /
2013-05-06 17:38:24 +02:00
public void saveReport ( Model toSave ) {
2021-10-28 11:47:57 +02:00
_log . warn ( " saveReport Not supported anymore " ) ;
2013-02-06 23:25:43 +01:00
}
2014-01-23 19:11:55 +01:00
2013-02-06 23:25:43 +01:00
/ * *
2013-02-15 16:54:13 +01:00
* @param save a report in another folder .
2013-02-06 23:25:43 +01:00
*
* /
2013-05-06 17:38:24 +02:00
public void saveReport ( Model toSave , String folderid , String newname ) {
2021-10-28 11:47:57 +02:00
_log . warn ( " saveReport Not supported anymore " ) ;
2013-02-06 23:25:43 +01:00
}
2021-10-28 11:47:57 +02:00
/ *
2016-06-29 12:09:29 +02:00
2013-02-06 23:25:43 +01:00
/ * *
* return a sample of the given TS to the client
* @param sTS .
* @return .
* /
2013-03-01 19:42:50 +01:00
public Table getSampleTimeSeries ( RepTimeSeries sTS ) {
2021-10-28 11:47:57 +02:00
return null ;
2013-02-06 23:25:43 +01:00
}
2021-10-28 11:47:57 +02:00
2013-02-06 23:25:43 +01:00
/ * *
*
* @param toParse the csv to parse
* @throws ProcessingException .
* @throws IOException .
* @throws ParseException .
* /
2013-03-01 19:42:50 +01:00
private Table parseCSV ( File toParse , final RepTimeSeries sTS ) throws ParseException , IOException , ProcessingException {
2013-02-06 23:25:43 +01:00
2013-03-01 19:42:50 +01:00
final Table toReturn ;
2013-02-06 23:25:43 +01:00
final boolean isFiltered ;
final int fromLine ;
final int toLine ;
//if there is no filter
if ( sTS . getFilter ( ) = = null ) {
2013-03-01 19:42:50 +01:00
toReturn = new Table ( sTS . getTsMetadata ( ) . getHeaderLabels ( ) . size ( ) ) ;
2013-02-06 23:25:43 +01:00
isFiltered = false ;
fromLine = 1 ;
toLine = 10 ;
}
else {
int headers = sTS . getFilter ( ) . getColsNumberToShow ( ) . size ( ) ;
2013-03-01 19:42:50 +01:00
toReturn = new Table ( headers ) ;
2013-02-06 23:25:43 +01:00
isFiltered = true ;
fromLine = sTS . getFilter ( ) . getFrom ( ) ;
toLine = fromLine + 10 ;
}
final CSVFileProcessor fp = new CSVFileProcessor ( ) ;
fp . processFile ( toParse . getAbsolutePath ( ) , new CSVLineProcessor ( ) {
boolean keepGoing = true ;
public void processHeaderLine ( final int linenumber , final List < String > fieldNames ) {
ArrayList < TableCell > toInsert = new ArrayList < TableCell > ( ) ;
for ( String field : fieldNames ) {
toInsert . add ( new TableCell ( field ) ) ;
}
if ( ! isFiltered )
toReturn . addRow ( ( ArrayList < TableCell > ) toInsert ) ;
else {
ArrayList < String > filteredHeaders = new ArrayList < String > ( ) ;
for ( Integer colNo : sTS . getFilter ( ) . getColsNumberToShow ( ) ) {
String toAdd = sTS . getTsMetadata ( ) . getHeaderLabels ( ) . get ( colNo ) ;
filteredHeaders . add ( toAdd ) ;
toInsert = new ArrayList < TableCell > ( ) ;
for ( String field : filteredHeaders ) {
toInsert . add ( new TableCell ( field ) ) ;
}
}
toReturn . addRow ( toInsert ) ;
}
}
public void processDataLine ( final int linenumber , final List < String > fieldValues ) {
if ( linenumber > toLine )
keepGoing = false ;
if ( linenumber > = fromLine & & linenumber < = toLine ) {
ArrayList < TableCell > toInsert = new ArrayList < TableCell > ( ) ;
for ( String field : fieldValues ) {
toInsert . add ( new TableCell ( field ) ) ;
}
if ( ! isFiltered )
toReturn . addRow ( toInsert ) ;
else {
ArrayList < String > filteredFields = new ArrayList < String > ( ) ;
for ( Integer colNo : sTS . getFilter ( ) . getColsNumberToShow ( ) ) {
String toAdd = fieldValues . get ( colNo ) ;
filteredFields . add ( toAdd ) ;
toInsert = new ArrayList < TableCell > ( ) ;
for ( String field : filteredFields ) {
toInsert . add ( new TableCell ( field ) ) ;
}
}
toReturn . addRow ( toInsert ) ;
}
}
}
public boolean continueProcessing ( ) {
return keepGoing ;
}
} ) ;
return toReturn ;
}
2021-10-28 11:47:57 +02:00
2013-02-06 23:25:43 +01:00
/ * *
* each portlet instance runs in a scope
* each portlet instance is used by a unique username from within the portal
* @param currentHost .
* @return a SessionInfo bean containing the username the scope andis opening a workflow document or not
* /
public SessionInfo getSessionInfo ( String currentHost ) {
2013-12-17 19:19:51 +01:00
boolean isVME = isReportsStoreGatewayAvailable ( ) ;
2016-06-29 12:09:29 +02:00
String rsgEndpoint = " " ;
if ( getRSGWSAddress ( ) ! = null )
rsgEndpoint = ( ( RSGAccessPoint ) getRSGWSAddress ( ) ) . getRestUrl ( ) ;
return new SessionInfo ( getUserBean ( ) , getVreName ( ) , false , false , isVME , rsgEndpoint ) ;
2014-01-23 19:11:55 +01:00
2013-02-06 23:25:43 +01:00
2016-06-29 12:09:29 +02:00
}
2013-03-05 15:26:22 +01:00
/ * *
*
* @return the info about the current user
* /
private UserBean getUserBean ( ) {
try {
String username = getASLSession ( ) . getUsername ( ) ;
String email = username + " @isti.cnr.it " ;
String fullName = username + " FULL " ;
String thumbnailURL = " images/Avatar_default.png " ;
2014-06-27 15:24:57 +02:00
if ( isWithinPortal ( ) ) {
2013-03-05 15:26:22 +01:00
2016-06-29 12:09:29 +02:00
GCubeUser user = new LiferayUserManager ( ) . getUserByUsername ( username ) ;
thumbnailURL = user . getUserAvatarURL ( ) ;
fullName = user . getFullname ( ) ;
email = user . getEmail ( ) ;
UserBean toReturn = new UserBean ( username , fullName , thumbnailURL , email ) ;
_log . debug ( " Returning USER: " + toReturn ) ;
2013-03-05 15:26:22 +01:00
return toReturn ;
}
else {
UserBean toReturn = new UserBean ( getASLSession ( ) . getUsername ( ) , fullName , thumbnailURL , email ) ;
2016-06-29 12:09:29 +02:00
_log . debug ( " Returning test USER: " + toReturn ) ;
2013-03-05 15:26:22 +01:00
return toReturn ;
}
2013-02-06 23:25:43 +01:00
2013-03-05 15:26:22 +01:00
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
return new UserBean ( ) ;
}
2013-02-06 23:25:43 +01:00
/ * *
* /
byte [ ] getBytesFromInputStream ( InputStream is ) {
ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ;
try {
IOUtils . copy ( is , os ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
return os . toByteArray ( ) ;
}
2016-06-29 12:09:29 +02:00
2018-06-26 17:58:23 +02:00
2013-03-15 19:06:43 +01:00
2013-04-30 16:16:20 +02:00
@Override
public void renewHTTPSession ( ) {
HttpSession session = this . getThreadLocalRequest ( ) . getSession ( ) ;
_log . info ( " HTTP Session renewed " + new Date ( session . getLastAccessedTime ( ) ) ) ;
}
2013-11-13 18:56:13 +01:00
2014-09-16 17:40:52 +02:00
private RsgReadClient getRsgClient ( ) {
RSGAccessPoint rsgWsAddr = getRSGWSAddress ( ) ;
if ( rsgReadClient = = null ) {
rsgReadClient = new RsgReadClient ( rsgWsAddr . getRestUrl ( ) ) ;
2016-06-29 12:09:29 +02:00
_log . info ( " rsgReadClient = new RsgReadClient(rsgWsAddr.getRestUrl() " + rsgWsAddr . getRestUrl ( ) ) ;
2014-09-16 17:40:52 +02:00
}
return rsgReadClient ;
}
2015-12-17 17:05:40 +01:00
2014-09-16 17:40:52 +02:00
private RsgWriteClient getRsgSecureClient ( ) {
2014-05-15 15:27:25 +02:00
RSGAccessPoint rsgWsAddr = getRSGWSAddress ( ) ;
2014-09-16 17:40:52 +02:00
if ( rsgWriteClient = = null ) {
rsgWriteClient = new RsgWriteClient ( rsgWsAddr . getRestUrl ( ) + " /write " ) ;
2014-05-15 15:27:25 +02:00
2014-09-16 17:40:52 +02:00
try {
rsgWriteClient . secureWithPlainTokenSecurity ( rsgWsAddr . getTokenUrl ( ) ) ;
2016-06-29 12:09:29 +02:00
_log . info ( " rsgWriteClient.secureWithPlainTokenSecurity(rsgWsAddr.getTokenUrl()) " + rsgWsAddr . getTokenUrl ( ) ) ;
2014-09-16 17:40:52 +02:00
} catch ( MalformedURLException e ) {
e . printStackTrace ( ) ;
}
2014-05-15 15:27:25 +02:00
}
2014-09-16 17:40:52 +02:00
return rsgWriteClient ;
2014-05-15 15:27:25 +02:00
}
2014-06-27 15:24:57 +02:00
/ * *
* the list of Regional Fishery Management Organizations ( RFMO ) associated to the current user is constructed by looking at the roles
* of the current user .
*
* @returnt the list of Regional Fishery Management Organizations ( RFMO ) associated to the current user .
* /
private ArrayList < String > getUserRFMOs ( ) {
if ( ! isWithinPortal ( ) )
return new ArrayList < String > ( ) ;
ArrayList < String > toReturn = new ArrayList < String > ( ) ;
RoleManager rm = new LiferayRoleManager ( ) ;
ASLSession session = getASLSession ( ) ;
try {
2016-06-29 12:09:29 +02:00
GCubeUser theUser = new LiferayUserManager ( ) . getUserByUsername ( session . getUsername ( ) ) ;
long groupId = new LiferayGroupManager ( ) . getGroupIdFromInfrastructureScope ( session . getScope ( ) ) ;
List < GCubeTeam > roles = rm . listTeamsByUserAndGroup ( theUser . getUserId ( ) , groupId ) ;
for ( GCubeTeam team : roles ) {
_log . info ( " VRE Group " + team . getTeamName ( ) + " Adding RFMO " ) ;
if ( team . getTeamName ( ) . endsWith ( " -Editor " ) ) {
String [ ] splits = team . getTeamName ( ) . split ( " - " ) ;
2014-06-27 15:24:57 +02:00
toReturn . add ( splits [ 0 ] ) ;
_log . info ( " Added grant for RFMO= " + splits [ 0 ] ) ;
}
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
return toReturn ;
}
/ * *
*
* @return whether the user is a VRE Manager for this VRE or not .
* /
private boolean isVREManager ( ) {
if ( isWithinPortal ( ) ) {
RoleManager rm = new LiferayRoleManager ( ) ;
ASLSession session = getASLSession ( ) ;
try {
2016-06-29 12:09:29 +02:00
long groupId = new LiferayGroupManager ( ) . getGroupIdFromInfrastructureScope ( session . getScope ( ) ) ;
GCubeUser theUser = new LiferayUserManager ( ) . getUserByUsername ( session . getUsername ( ) ) ;
List < GCubeRole > roles = rm . listRolesByUserAndGroup ( theUser . getUserId ( ) , groupId ) ;
for ( GCubeRole role : roles )
if ( role . getRoleName ( ) . equals ( GatewayRolesNames . VRE_MANAGER . getRoleName ( ) ) ) return true ;
2014-06-27 15:24:57 +02:00
}
catch ( Exception e ) {
e . printStackTrace ( ) ;
}
return false ;
} else {
_log . warn ( " Working in Eclipse, returning all rights " ) ;
return true ;
}
}
2014-05-15 15:27:25 +02:00
2013-11-13 18:56:13 +01:00
@Override
2013-11-25 17:12:01 +01:00
public ArrayList < VMEReportBean > listVMEReports ( ) {
ArrayList < VMEReportBean > toReturn = new ArrayList < VMEReportBean > ( ) ;
2013-11-13 18:56:13 +01:00
ReportType type = new ReportType ( ) ;
type . setTypeIdentifier ( " Vme " ) ;
2014-09-16 17:40:52 +02:00
_log . info ( " listVMEReports() instantiating secure rsgClient ... " ) ;
rsgReadClient = getRsgClient ( ) ;
_log . info ( " listVMEReports() securedWithEncryptedToken completed " ) ;
2013-12-04 23:21:12 +01:00
2014-07-02 15:12:44 +02:00
ReportEntry [ ] reports = null ;
try {
2014-09-16 17:40:52 +02:00
_log . info ( " calling rsgClient#listReports... " ) ;
reports = rsgReadClient . listReports ( type ) ;
_log . info ( " got the reports list " ) ;
2014-07-02 15:12:44 +02:00
} catch ( ClientException e ) {
_log . error ( " failed to get the list of VME Reports: " + e . getMessage ( ) ) ;
}
2014-06-27 15:24:57 +02:00
if ( isVREManager ( ) ) {
2014-07-02 15:12:44 +02:00
for ( ReportEntry re : reports ) {
2014-06-27 15:24:57 +02:00
String rfmo = re . getOwner ( ) ;
String name = re . getIdentifier ( ) ;
toReturn . add ( new VMEReportBean ( " " + re . getId ( ) , rfmo , name ) ) ;
}
} else {
ArrayList < String > allowedRFMOs = getUserRFMOs ( ) ;
2014-07-02 15:12:44 +02:00
for ( ReportEntry re : reports ) {
2014-06-27 15:24:57 +02:00
String rfmo = re . getOwner ( ) . trim ( ) ;
String name = re . getIdentifier ( ) ;
for ( String allowedRFMO : allowedRFMOs ) {
if ( allowedRFMO . compareTo ( rfmo ) = = 0 ) {
toReturn . add ( new VMEReportBean ( " " + re . getId ( ) , rfmo , name ) ) ;
_log . debug ( " Added " + rfmo + " - " + name ) ;
}
}
}
2013-11-13 18:56:13 +01:00
}
2014-09-16 17:40:52 +02:00
2013-11-13 18:56:13 +01:00
return toReturn ;
}
@Override
2013-11-25 19:11:03 +01:00
public ArrayList < VMEReportBean > listVMEReportRefByType ( VMETypeIdentifier refType ) {
2013-11-13 18:56:13 +01:00
if ( refType = = VMETypeIdentifier . Vme )
throw new IllegalArgumentException ( " VME Type is not a reference " ) ;
try {
Thread . sleep ( 1000 ) ;
} catch ( InterruptedException e ) {
}
2013-11-25 19:11:03 +01:00
ArrayList < VMEReportBean > toReturn = new ArrayList < VMEReportBean > ( ) ;
2013-11-13 18:56:13 +01:00
ReportType type = new ReportType ( ) ;
type . setTypeIdentifier ( refType . toString ( ) ) ;
2014-09-16 17:40:52 +02:00
rsgReadClient = getRsgClient ( ) ;
2014-05-15 15:27:25 +02:00
2014-06-30 18:55:27 +02:00
if ( isVREManager ( ) ) {
2014-09-16 17:40:52 +02:00
for ( ReportEntry re : rsgReadClient . listReports ( new ReportType ( refType . getId ( ) ) ) ) {
2014-06-30 18:55:27 +02:00
String rfmo = re . getOwner ( ) ;
String name = re . getIdentifier ( ) ;
toReturn . add ( new VMEReportBean ( " " + re . getId ( ) , rfmo , name ) ) ;
}
} else {
ArrayList < String > allowedRFMOs = getUserRFMOs ( ) ;
2014-09-16 17:40:52 +02:00
for ( ReportEntry re : rsgReadClient . listReports ( new ReportType ( refType . getId ( ) ) ) ) {
2014-06-30 18:55:27 +02:00
String rfmo = re . getOwner ( ) ;
String name = re . getIdentifier ( ) ;
if ( rfmo = = null ) { //when getting a RFMO refType the Owner is null
rfmo = name ;
}
for ( String allowedRFMO : allowedRFMOs ) {
if ( allowedRFMO . compareTo ( rfmo ) = = 0 ) {
toReturn . add ( new VMEReportBean ( " " + re . getId ( ) , rfmo , name ) ) ;
_log . debug ( " Added ref report " + rfmo + " - " + name ) ;
}
}
}
}
2013-12-06 18:23:49 +01:00
2013-11-13 18:56:13 +01:00
return toReturn ;
}
2013-11-26 18:37:13 +01:00
2013-11-13 18:56:13 +01:00
@Override
2013-12-04 23:21:12 +01:00
public Model importVMEReport ( String id , String name , VMETypeIdentifier refType ) {
2014-09-16 17:40:52 +02:00
rsgReadClient = getRsgClient ( ) ;
2014-05-15 15:27:25 +02:00
2013-12-06 18:23:49 +01:00
2013-12-04 23:21:12 +01:00
CompiledReport cr = null ;
2013-11-26 18:37:13 +01:00
if ( refType = = VMETypeIdentifier . Vme ) {
2013-12-04 23:21:12 +01:00
_log . info ( " Importing VME id= " + id + " name= " + name ) ;
2014-09-16 17:40:52 +02:00
cr = rsgReadClient . getReportById ( new ReportType ( refType . getId ( ) ) , id ) ;
2013-12-04 23:21:12 +01:00
}
2013-11-26 18:37:13 +01:00
else {
2013-12-04 23:21:12 +01:00
_log . info ( " Importing Ref type= " + refType . getId ( ) + " id= " + id + " name= " + name ) ;
2014-09-16 17:40:52 +02:00
cr = rsgReadClient . getReferenceReportById ( new ReportType ( refType . getId ( ) ) , id ) ;
2013-12-06 18:23:49 +01:00
2013-11-26 18:37:13 +01:00
}
2013-12-04 23:21:12 +01:00
Model model = null ;
2013-11-13 18:56:13 +01:00
try {
2013-12-12 16:39:48 +01:00
model = new ReportManagerReportBuilder ( ) . buildReport ( cr ) ;
model . setTemplateName ( name ) ;
2013-12-18 16:30:32 +01:00
//ReportsReader.readReportStructure(model);
2013-12-04 23:21:12 +01:00
} catch ( ReportBuilderException e ) {
e . printStackTrace ( ) ;
2013-11-13 18:56:13 +01:00
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
2014-01-22 18:31:02 +01:00
ModelReader reader = new ModelReader ( model ) ;
System . out . println ( reader ) ;
2013-12-04 23:21:12 +01:00
return model ;
2013-11-13 18:56:13 +01:00
}
2013-12-06 18:23:49 +01:00
2013-11-26 18:37:13 +01:00
@Override
public Model getVMEReportRef2Associate ( String id , VMETypeIdentifier refType ) {
2014-09-16 17:40:52 +02:00
rsgReadClient = getRsgClient ( ) ;
2014-05-15 15:27:25 +02:00
2013-12-04 23:21:12 +01:00
_log . info ( " Importing Ref type= " + refType . getId ( ) + " id= " + id ) ;
2014-09-16 17:40:52 +02:00
CompiledReport cr = rsgReadClient . getReferenceReportById ( new ReportType ( refType . getId ( ) ) , id ) ;
2013-12-04 23:21:12 +01:00
Model model = null ;
2013-11-14 16:26:26 +01:00
try {
2013-12-12 16:39:48 +01:00
model = new ReportManagerReportBuilder ( ) . buildReferenceReport ( cr ) ;
2013-12-04 23:21:12 +01:00
} catch ( ReportBuilderException e ) {
e . printStackTrace ( ) ;
2013-11-14 16:26:26 +01:00
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
2013-12-04 23:21:12 +01:00
return model ;
2013-11-14 16:26:26 +01:00
}
2014-01-23 19:11:55 +01:00
2013-12-18 16:30:32 +01:00
@Override
public Model importVMETemplate ( VMETypeIdentifier refType ) {
2014-09-16 17:40:52 +02:00
rsgReadClient = getRsgClient ( ) ;
2013-12-18 16:30:32 +01:00
CompiledReport cr = null ;
if ( refType = = VMETypeIdentifier . Vme ) {
_log . info ( " Importing VME Template " ) ;
2014-09-16 17:40:52 +02:00
cr = rsgReadClient . getTemplate ( new ReportType ( refType . getId ( ) ) ) ;
2013-12-18 16:30:32 +01:00
}
else {
_log . info ( " Importing Ref type= " + refType . getId ( ) ) ;
2014-09-16 17:40:52 +02:00
cr = rsgReadClient . getTemplate ( new ReportType ( refType . getId ( ) ) ) ;
2013-12-18 16:30:32 +01:00
}
Model model = null ;
try {
model = new ReportManagerReportBuilder ( ) . buildReport ( cr ) ;
model . setTemplateName ( " New " + refType . getDisplayName ( ) ) ;
} catch ( ReportBuilderException e ) {
e . printStackTrace ( ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
return model ;
}
2014-01-23 19:11:55 +01:00
@Override
2014-01-28 17:31:13 +01:00
public VmeExportResponse exportReportToRSG ( VMETypeIdentifier refType , Model model ) {
2014-01-24 12:50:50 +01:00
System . out . println ( new ModelReader ( model ) . toString ( ) ) ;
2014-01-28 17:31:13 +01:00
2014-09-16 17:40:52 +02:00
rsgReadClient = getRsgClient ( ) ;
rsgWriteClient = getRsgSecureClient ( ) ;
2014-01-23 19:11:55 +01:00
//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
2014-01-29 17:34:57 +01:00
CompiledReport template = null ;
if ( refType = = VMETypeIdentifier . Vme ) {
_log . info ( " getTemplate for VME Report " ) ;
2014-09-16 17:40:52 +02:00
template = rsgReadClient . getTemplate ( new ReportType ( refType . getId ( ) ) ) ;
2014-01-29 17:34:57 +01:00
}
else {
_log . info ( " getTemplate for Ref Report " ) ;
2014-09-16 17:40:52 +02:00
template = rsgReadClient . getRefTemplate ( new ReportType ( refType . getId ( ) ) ) ;
2014-01-29 17:34:57 +01:00
}
2014-01-23 19:11:55 +01:00
CompiledReport toSend = null ;
try {
2014-01-24 16:25:54 +01:00
toSend = new ReportManagerReportBuilder ( ) . extract ( template , model ) ;
} catch ( Exception e ) {
2014-01-23 19:11:55 +01:00
e . printStackTrace ( ) ;
}
2014-01-28 17:31:13 +01:00
try {
//Actual RSG client interface exposes different methods (publish / publishDelta etc.) that need to be updated
2014-05-15 15:27:25 +02:00
ServiceResponse res = null ;
2014-01-28 17:31:13 +01:00
if ( refType = = VMETypeIdentifier . Vme ) {
_log . info ( " Exporting VME Report " ) ;
2014-09-16 17:40:52 +02:00
res = rsgWriteClient . update ( toSend ) ;
2014-01-28 17:31:13 +01:00
}
else {
_log . info ( " Exporting Ref type= " + refType . getId ( ) ) ;
2014-09-16 17:40:52 +02:00
res = rsgWriteClient . updateRef ( toSend ) ;
2014-01-28 17:31:13 +01:00
}
return getClientResponse ( res ) ;
} catch ( RuntimeException ex ) {
ex . printStackTrace ( ) ;
return new VmeExportResponse ( new VmeResponseEntry ( " RUNTIME_EXCEPTION " , " Sorry, there was an error on the Server, please try again in few minutes or report an Issue. " ) ) ;
}
2014-01-23 19:11:55 +01:00
}
2014-04-28 18:26:53 +02:00
2014-01-28 17:31:13 +01:00
@Override
public VmeExportResponse deleteReportFromRSG ( VMETypeIdentifier refType , String idToDelete ) {
2014-09-16 17:40:52 +02:00
RsgWriteClient rsgClient = getRsgSecureClient ( ) ;
2014-04-28 18:26:53 +02:00
2014-01-28 17:31:13 +01:00
try {
2014-05-15 15:27:25 +02:00
ServiceResponse res = null ;
2014-01-28 17:31:13 +01:00
if ( refType = = VMETypeIdentifier . Vme ) {
_log . info ( " Deleting VME Report id = " + idToDelete ) ;
res = rsgClient . deleteById ( new ReportType ( refType . getId ( ) ) , idToDelete ) ;
}
else {
_log . info ( " Deleting VME Reference Report of Type " + refType + " having id = " + idToDelete ) ;
res = rsgClient . deleteReferenceById ( new ReportType ( refType . getId ( ) ) , idToDelete ) ;
}
return getClientResponse ( res ) ;
} catch ( RuntimeException ex ) {
ex . printStackTrace ( ) ;
return new VmeExportResponse ( new VmeResponseEntry ( " RUNTIME_EXCEPTION " , " Sorry, there was an error on the Server, we could not delete. Please try again in few minutes or report an Issue. " ) ) ;
}
}
2014-04-28 18:26:53 +02:00
2013-12-17 19:19:51 +01:00
/ * *
2013-12-18 16:30:32 +01:00
* this method look for a ReportsStoreGateway WS available in the infrastructure
2013-12-17 19:19:51 +01:00
* @return true if an instance of the ReportsStoreGateway is available in the infrastructure
2014-05-15 15:27:25 +02:00
* @throws Exception
2013-12-17 19:19:51 +01:00
* /
2014-05-15 15:27:25 +02:00
private boolean isReportsStoreGatewayAvailable ( ) {
2018-06-26 17:58:23 +02:00
String user = PortalContext . getConfiguration ( ) . getCurrentUser ( getThreadLocalRequest ( ) ) . getUsername ( ) ;
2015-12-15 19:31:47 +01:00
if ( user = = null & & isWithinPortal ( ) ) {
_log . warn ( " Session expired, returning ReportsStoreGateway not available " ) ;
return false ;
}
2018-06-26 17:58:23 +02:00
String scope = PortalContext . getConfiguration ( ) . getCurrentScope ( getThreadLocalRequest ( ) ) ;
_log . info ( " Looking for a running ReportsStoreGateway WS in " + scope ) ;
2013-12-17 19:19:51 +01:00
ScopeProvider . instance . set ( scope ) ;
SimpleQuery query = queryFor ( ServiceEndpoint . class ) ;
query . addCondition ( " $resource/Profile/Category/string() eq 'Service' " ) ;
query . addCondition ( " $resource/Profile/Name/string() eq 'ReportsStoreGateway' " ) ;
DiscoveryClient < ServiceEndpoint > client = clientFor ( ServiceEndpoint . class ) ;
List < ServiceEndpoint > list = client . submit ( query ) ;
2018-06-26 17:58:23 +02:00
2013-12-17 19:19:51 +01:00
if ( list . size ( ) > 1 ) {
_log . warn ( " Multiple ReportsStoreGateway Service Endpoints available in the scope, should be only one. " ) ;
return false ;
}
else if ( list . size ( ) = = 1 ) {
ServiceEndpoint se = list . get ( 0 ) ;
String host = se . profile ( ) . runtime ( ) . hostedOn ( ) ;
2014-05-15 15:27:25 +02:00
AccessPoint ap = se . profile ( ) . accessPoints ( ) . iterator ( ) . next ( ) ;
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 ) ;
2016-06-29 12:09:29 +02:00
new RsgReadClient ( rsgAp . getRestUrl ( ) ) ;
2013-12-17 19:19:51 +01:00
return true ;
}
else return false ;
}
2014-01-23 19:11:55 +01:00
2014-05-15 15:27:25 +02:00
private VmeExportResponse getClientResponse ( ServiceResponse rsgResponse ) {
2014-01-28 17:31:13 +01:00
VmeExportResponse toReturn = new VmeExportResponse ( ) ;
2014-05-15 15:27:25 +02:00
for ( ServiceResponseMessage entry : rsgResponse . getResponseMessageList ( ) ) {
2014-01-28 17:31:13 +01:00
String entryCode = entry . getResponseCode ( ) = = null ? " no-code " : entry . getResponseCode ( ) . toString ( ) ;
String entryMessage = entry . getResponseMessage ( ) = = null ? " no response message " : entry . getResponseMessage ( ) ;
toReturn . getResponseMessageList ( ) . add ( new VmeResponseEntry ( entryCode , entryMessage ) ) ;
}
toReturn . setGloballySucceded ( rsgResponse . isGloballySucceeded ( ) ) ;
return toReturn ;
}
2014-04-28 18:26:53 +02:00
2014-01-23 19:11:55 +01:00
2013-02-06 23:25:43 +01:00
}