Fixed Bug #7568
Updated pom version at 3.9.1 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@145006 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
07cde19bbd
commit
e7ccc34245
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="lib" path="/home/francesco-mangiacrapa/libraries/asm-5.0.3/lib/asm-5.0.3.jar"/>
|
||||
<classpathentry kind="src" output="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/species-discovery-3.9.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -32,5 +32,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/species-discovery-3.9.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/species-discovery-TRUNK/target/species-discovery-3.7.2-SNAPSHOT
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/species-discovery-TRUNK-TOTEST/target/species-discovery-3.9.1-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.species-discovery.3-9-1"
|
||||
date="20-03-2017">
|
||||
<Change>[Bug #7568] Managed ASL session expiration during polling on SPD jobs </Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.species-discovery.3-9-0"
|
||||
date="11-01-2016">
|
||||
<Change>[Feature #6313] SPD portlet upgrade: porting to spd-client-library 4.0.0 </Change>
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -19,7 +19,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>species-discovery</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>3.9.0-SNAPSHOT</version>
|
||||
<version>3.9.1-SNAPSHOT</version>
|
||||
<name>gCube Species Discovery</name>
|
||||
<description>
|
||||
gCube Species Discovery Portlet lets the users discovery species information from the Species Service.
|
||||
|
@ -93,6 +93,12 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- USED TO SHOW A LAYER VIA GISVIEWER -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.portlets.user</groupId> -->
|
||||
|
|
|
@ -93,9 +93,11 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
|||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.util.SearchTermValidator;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.WorskpaceExplorerSaveNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.save.WorkspaceExplorerSaveDialog;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
@ -1763,6 +1765,8 @@ public class SearchController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
if(caught instanceof SessionExpired)
|
||||
CheckSession.showLogoutDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1794,6 +1798,8 @@ public class SearchController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
if(caught instanceof SessionExpired)
|
||||
CheckSession.showLogoutDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1826,6 +1832,9 @@ public class SearchController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
if(caught instanceof SessionExpired)
|
||||
CheckSession.showLogoutDialog();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
|||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
|
||||
|
@ -89,7 +90,7 @@ public interface TaxonomySearchService extends RemoteService {
|
|||
|
||||
public SearchResult<ResultRow> getSearchResultRows(int start, int limit,
|
||||
ResultFilter activeFiltersObject, boolean onlySelected)
|
||||
throws SearchServiceException;
|
||||
throws SearchServiceException, SessionExpired;
|
||||
|
||||
public SearchResult<TaxonomyRow> getSearchTaxonomyRow(int start, int limit,
|
||||
ResultFilter activeFiltersObject, boolean showOnlySelected)
|
||||
|
@ -104,7 +105,7 @@ public interface TaxonomySearchService extends RemoteService {
|
|||
public OccurrencesStatus getCountOfOccurrencesBatch()
|
||||
throws SearchServiceException;
|
||||
|
||||
public List<JobTaxonomyModel> getListTaxonomyJobs() throws Exception;
|
||||
public List<JobTaxonomyModel> getListTaxonomyJobs() throws SessionExpired, Exception;
|
||||
|
||||
// public JobTaxonomyModel createTaxonomyJobByChildren(TaxonomyRow taxonomy,
|
||||
// String dataSourceName) throws Exception;
|
||||
|
@ -124,7 +125,7 @@ public interface TaxonomySearchService extends RemoteService {
|
|||
SaveFileFormat saveFileFormat, OccurrencesSaveEnum csvType,
|
||||
boolean isByDataSource, int expectedOccurrence) throws Exception;
|
||||
|
||||
public List<JobOccurrencesModel> getListOccurrencesJob() throws Exception;
|
||||
public List<JobOccurrencesModel> getListOccurrencesJob() throws SessionExpired, Exception;
|
||||
|
||||
public boolean saveOccurrenceJob(JobOccurrencesModel jobModel,
|
||||
String destinationFolderId, String fileName, String scientificName,
|
||||
|
@ -208,8 +209,7 @@ public interface TaxonomySearchService extends RemoteService {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<JobGisLayerModel> getListGisLayerJob()
|
||||
throws Exception;
|
||||
List<JobGisLayerModel> getListGisLayerJob() throws SessionExpired, Exception;
|
||||
|
||||
boolean saveGisLayerAsWsLink(
|
||||
JobGisLayerModel jobGisLayer, String destinationFolderId, String fileName) throws Exception;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
|
|||
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||
|
||||
|
||||
|
@ -190,6 +191,9 @@ public class TaxonomyRowTable extends HttpServlet {
|
|||
|
||||
} catch (Exception e) {
|
||||
|
||||
if(e instanceof SessionExpired)
|
||||
throw new SessionExpired("Sorry, user session is expired, Refresh and Try again");
|
||||
|
||||
logger.error("Error in TaxonomyRowTable servlet ",e);
|
||||
throw new Exception("Error in ResultRowTable servlet ", e);
|
||||
}
|
||||
|
@ -199,7 +203,12 @@ public class TaxonomyRowTable extends HttpServlet {
|
|||
out.close(); //CLOSE STREAM
|
||||
|
||||
}catch (Exception e) {
|
||||
String error = "Sorry an error occurred when creating the table for taxonomy row with id: "+taxonomyServiceRowID;
|
||||
String error;
|
||||
|
||||
if(e instanceof SessionExpired)
|
||||
error = e.getMessage();
|
||||
else
|
||||
error = "Sorry an error occurred when creating the table for taxonomy row with id: "+taxonomyServiceRowID;
|
||||
|
||||
if(out==null){
|
||||
try{
|
||||
|
|
|
@ -93,6 +93,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
|||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyJob;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||
|
@ -128,17 +129,12 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
public static final String BASETAXONOMY = "Kingdom";
|
||||
public static final String UNK = "Unk";
|
||||
|
||||
// static {
|
||||
// Logger root = Logger.getLogger("org.gcube.portlets.user.speciesdiscovery");
|
||||
// root.setLevel(Level.ALL);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the ASL session.
|
||||
*
|
||||
* @return the ASL session
|
||||
*/
|
||||
protected ASLSession getASLSession()
|
||||
* Gets the ASL session.
|
||||
*
|
||||
* @return the ASL session
|
||||
*/
|
||||
protected ASLSession getASLSession()
|
||||
{
|
||||
return SessionUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
}
|
||||
|
@ -334,7 +330,7 @@ protected ASLSession getASLSession()
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public SearchResult<ResultRow> getSearchResultRows(int start, int limit, ResultFilter activeFiltersObject, boolean onlySelected) throws SearchServiceException {
|
||||
public SearchResult<ResultRow> getSearchResultRows(int start, int limit, ResultFilter activeFiltersObject, boolean onlySelected) throws SessionExpired, SearchServiceException {
|
||||
logger.info("getSearchResultRows start: "+start+" limit: "+limit+" onlySelected: "+onlySelected);
|
||||
Long startTime = System.currentTimeMillis();
|
||||
|
||||
|
@ -389,6 +385,10 @@ protected ASLSession getASLSession()
|
|||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||
logger.info("returning "+chunk.size()+" elements in " + time);
|
||||
} catch (Exception e) {
|
||||
|
||||
if(e instanceof SessionExpired)
|
||||
throw new SessionExpired("The session is expired");
|
||||
|
||||
logger.error("Error in getSearchResultRows ", e);
|
||||
throw new SearchServiceException(e.getMessage());
|
||||
}
|
||||
|
@ -1314,7 +1314,7 @@ protected ASLSession getASLSession()
|
|||
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListTaxonomyJobs()
|
||||
*/
|
||||
@Override
|
||||
public List<JobTaxonomyModel> getListTaxonomyJobs() throws Exception {
|
||||
public List<JobTaxonomyModel> getListTaxonomyJobs() throws SessionExpired, Exception {
|
||||
logger.info("getListTaxonomyJobs... ");
|
||||
List<JobTaxonomyModel> listJobs = new ArrayList<JobTaxonomyModel>();
|
||||
|
||||
|
@ -1836,7 +1836,7 @@ protected ASLSession getASLSession()
|
|||
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListOccurrencesJob()
|
||||
*/
|
||||
@Override
|
||||
public List<JobOccurrencesModel> getListOccurrencesJob() throws Exception{
|
||||
public List<JobOccurrencesModel> getListOccurrencesJob() throws SessionExpired, Exception{
|
||||
logger.info("getListOccurencesJob... ");
|
||||
List<JobOccurrencesModel> listJobs = new ArrayList<JobOccurrencesModel>();
|
||||
|
||||
|
@ -1876,6 +1876,13 @@ protected ASLSession getASLSession()
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if(e instanceof SessionExpired){
|
||||
logger.error("Session is expired");
|
||||
throw new SessionExpired(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
logger.error("Error on get iterator "+e, e);
|
||||
}
|
||||
|
||||
|
@ -1888,7 +1895,7 @@ protected ASLSession getASLSession()
|
|||
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListGisLayerJob()
|
||||
*/
|
||||
@Override
|
||||
public List<JobGisLayerModel> getListGisLayerJob() throws Exception{
|
||||
public List<JobGisLayerModel> getListGisLayerJob() throws SessionExpired, Exception{
|
||||
logger.info("getListGisLayerJob... ");
|
||||
List<JobGisLayerModel> listJobs = new ArrayList<JobGisLayerModel>();
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public class SessionUtil {
|
|||
|
||||
//for test only
|
||||
user = "test.user";
|
||||
String scope = "/gcube/devsec"; //Development
|
||||
String scope = "/gcube/preprod/preVRE"; //Development
|
||||
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
|
||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
||||
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
|
|
|
@ -18,13 +18,15 @@ import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonRowP
|
|||
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyJobPersistence;
|
||||
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyRowPersistence;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class DaoSession.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 9, 2017
|
||||
* Mar 17, 2017
|
||||
*/
|
||||
public class DaoSession {
|
||||
|
||||
|
@ -35,14 +37,48 @@ public class DaoSession {
|
|||
private static final String JDBCDRIVER = "jdbc:h2:";
|
||||
|
||||
|
||||
/**
|
||||
* Check asl session.
|
||||
*
|
||||
* @param session the session
|
||||
* @return true, if is valid
|
||||
* @throws SessionExpired the session expired
|
||||
*/
|
||||
public static boolean checkASLSession(ASLSession session) throws SessionExpired{
|
||||
|
||||
if(session==null){
|
||||
String error = "ASL session is null!!!!";
|
||||
logger.error(error);
|
||||
throw new SessionExpired(error);
|
||||
}
|
||||
|
||||
String username = session.getUsername();
|
||||
String scope = session.getScopeName();
|
||||
|
||||
if(username==null || username.isEmpty() ){
|
||||
String error = "Username is null or empty, throwing session expired exception";
|
||||
logger.error(error);
|
||||
throw new SessionExpired(error);
|
||||
}
|
||||
|
||||
if(scope==null || scope.isEmpty() ){
|
||||
String error = "Scope is null or empty, throwing session expired exception";
|
||||
logger.error(error);
|
||||
throw new SessionExpired(error);
|
||||
}
|
||||
logger.trace("Session is valid: [username: "+username+", scope: "+scope+"]");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username scope value.
|
||||
*
|
||||
* @param username the username
|
||||
* @param scope the scope
|
||||
* @return the username scope value
|
||||
* @throws SessionExpired the session expired
|
||||
*/
|
||||
public static String getUsernameScopeValue(String username, String scope){
|
||||
public static String getUsernameScopeValue(String username, String scope) throws SessionExpired{
|
||||
|
||||
scope = scope.replaceAll("/","");
|
||||
username = username.replaceAll("\\.","");
|
||||
|
@ -51,8 +87,6 @@ public class DaoSession {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the tomcat folder.
|
||||
*
|
||||
|
@ -75,12 +109,12 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the connection url
|
||||
* @throws SessionExpired the session expired
|
||||
*/
|
||||
public static String getConnectionUrl(ASLSession session){
|
||||
public static String getConnectionUrl(ASLSession session) throws SessionExpired{
|
||||
|
||||
String username = session.getUsername();
|
||||
String scope = session.getScopeName();
|
||||
return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(username,scope)+";create=true";
|
||||
checkASLSession(session);
|
||||
return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(session.getUsername(),session.getScopeName())+";create=true";
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,8 +146,10 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the entity manager
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static EntityManager newEntityManager(ASLSession session){
|
||||
public static EntityManager newEntityManager(ASLSession session) throws SessionExpired, Exception{
|
||||
|
||||
return getEntityManagerFactory(session).createEntityManager();
|
||||
}
|
||||
|
@ -123,8 +159,10 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the entity manager factory
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static EntityManagerFactory getEntityManagerFactory(ASLSession session){
|
||||
public static EntityManagerFactory getEntityManagerFactory(ASLSession session) throws SessionExpired, Exception{
|
||||
|
||||
|
||||
EntityManagerFactory factory = SessionUtil.getEntityManagerFactory(session);
|
||||
|
@ -142,11 +180,12 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the occurrences job dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static OccurrenceJobPersistence getOccurrencesJobDAO(ASLSession session) throws Exception
|
||||
{
|
||||
public static OccurrenceJobPersistence getOccurrencesJobDAO(ASLSession session) throws SessionExpired, Exception{
|
||||
|
||||
checkASLSession(session);
|
||||
OccurrenceJobPersistence occurrencesJobDao = SessionUtil.getCurrentDaoOccurrencesJob(session);
|
||||
|
||||
if(occurrencesJobDao==null){
|
||||
|
@ -164,10 +203,12 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the gis layers job dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static GisLayerJobPersistence getGisLayersJobDAO(ASLSession session) throws Exception {
|
||||
public static GisLayerJobPersistence getGisLayersJobDAO(ASLSession session) throws SessionExpired, Exception{
|
||||
|
||||
checkASLSession(session);
|
||||
GisLayerJobPersistence gisLayerJobDao = SessionUtil.getCurrentGisLayersJob(session);
|
||||
|
||||
if(gisLayerJobDao==null){
|
||||
|
@ -184,8 +225,10 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the gis layer job persistence
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private static GisLayerJobPersistence initGisLayerJobsDao(ASLSession session) {
|
||||
private static GisLayerJobPersistence initGisLayerJobsDao(ASLSession session) throws SessionExpired, Exception {
|
||||
GisLayerJobPersistence gisLayerJobP = new GisLayerJobPersistence(getEntityManagerFactory(session));
|
||||
SessionUtil.setCurrentEJBGisLayerJob(session, gisLayerJobP);
|
||||
return gisLayerJobP;
|
||||
|
@ -196,11 +239,11 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the taxonomy job dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static TaxonomyJobPersistence getTaxonomyJobDAO(ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
public static TaxonomyJobPersistence getTaxonomyJobDAO(ASLSession session) throws SessionExpired, Exception {
|
||||
checkASLSession(session);
|
||||
TaxonomyJobPersistence taxonomyJobPeristence = SessionUtil.getCurrentDAOTaxonomyJob(session);
|
||||
|
||||
if(taxonomyJobPeristence==null){
|
||||
|
@ -216,9 +259,12 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the entity manager factory
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static EntityManagerFactory createEntityManagerFactory(ASLSession session){
|
||||
public static EntityManagerFactory createEntityManagerFactory(ASLSession session) throws SessionExpired, Exception {
|
||||
|
||||
checkASLSession(session);
|
||||
Map<String,String> properties = new HashMap<String, String>();
|
||||
// properties.put("javax.persistence.jdbc.driver", jdbcDriverH2);
|
||||
try{
|
||||
|
@ -226,9 +272,8 @@ public class DaoSession {
|
|||
}
|
||||
catch (Exception e) {
|
||||
logger.error("error on get connection url "+e, e);
|
||||
String username = session.getUsername();
|
||||
String scope = session.getScopeName();
|
||||
properties.put("javax.persistence.jdbc.url", JDBCDRIVER+getTomcatFolder()+"/temp/h2dbspecies/h2"+getUsernameScopeValue(username,scope)+";create=true");
|
||||
checkASLSession(session);
|
||||
properties.put("javax.persistence.jdbc.url", JDBCDRIVER+getTomcatFolder()+"/temp/h2dbspecies/h2"+getUsernameScopeValue(session.getUsername(),session.getScopeName())+";create=true");
|
||||
}
|
||||
//emf = Persistence.createEntityManagerFactory("jpablogPUnit");
|
||||
return Persistence.createEntityManagerFactory("SPD_PERSISTENCE_FACTORY",properties);
|
||||
|
@ -241,14 +286,11 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the occurrence job persistence
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static OccurrenceJobPersistence initOccurrencesJobsDao(ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
String username = session.getUsername();
|
||||
String scope = session.getScopeName();
|
||||
return createOccurrencesJobDao(username, scope, session);
|
||||
public static OccurrenceJobPersistence initOccurrencesJobsDao(ASLSession session) throws SessionExpired, Exception {
|
||||
return createOccurrencesJobDao(session.getUsername(), session.getScopeName(), session);
|
||||
|
||||
}
|
||||
|
||||
|
@ -274,9 +316,10 @@ public class DaoSession {
|
|||
* @param scope the scope
|
||||
* @param session the session
|
||||
* @return the occurrence job persistence
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static OccurrenceJobPersistence createOccurrencesJobDao(String username, String scope, ASLSession session) throws Exception{
|
||||
public static OccurrenceJobPersistence createOccurrencesJobDao(String username, String scope, ASLSession session) throws SessionExpired, Exception{
|
||||
|
||||
OccurrenceJobPersistence occurrenceJobPersistence = new OccurrenceJobPersistence(getEntityManagerFactory(session));
|
||||
SessionUtil.setCurrentEJBOccurrencesJob(session, occurrenceJobPersistence);
|
||||
|
@ -310,11 +353,11 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the occurrence dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static OccurrenceRowPersistence getOccurrenceDAO(ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
public static OccurrenceRowPersistence getOccurrenceDAO(ASLSession session) throws SessionExpired, Exception {
|
||||
checkASLSession(session);
|
||||
OccurrenceRowPersistence occurrenceEJB = SessionUtil.getCurrentEJBOccurrence(session);
|
||||
|
||||
if(occurrenceEJB==null){
|
||||
|
@ -330,10 +373,10 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the taxon row persistence
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static TaxonRowPersistence initTaxonDao(ASLSession session) throws Exception
|
||||
{
|
||||
public static TaxonRowPersistence initTaxonDao(ASLSession session) throws SessionExpired, Exception {
|
||||
|
||||
TaxonRowPersistence taxonRowPersistence = new TaxonRowPersistence(getEntityManagerFactory(session));
|
||||
SessionUtil.setCurrentEJBTaxonRow(session, taxonRowPersistence);
|
||||
|
@ -367,11 +410,11 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the taxon dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static TaxonRowPersistence getTaxonDAO(ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
public static TaxonRowPersistence getTaxonDAO(ASLSession session) throws SessionExpired, Exception{
|
||||
checkASLSession(session);
|
||||
TaxonRowPersistence taxonDao = SessionUtil.getCurrentEJBTaxonRow(session);
|
||||
|
||||
if(taxonDao==null){
|
||||
|
@ -390,10 +433,11 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the taxonomy dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static TaxonomyRowPersistence getTaxonomyDAO(ASLSession session) throws Exception
|
||||
{
|
||||
public static TaxonomyRowPersistence getTaxonomyDAO(ASLSession session) throws SessionExpired, Exception{
|
||||
checkASLSession(session);
|
||||
logger.trace("In getTaxonomyDAO...");
|
||||
|
||||
TaxonomyRowPersistence taxonItemDAO = SessionUtil.getCurrentEJBTaxonomyItem(session);
|
||||
|
@ -430,27 +474,19 @@ public class DaoSession {
|
|||
*
|
||||
* @param session the session
|
||||
* @return the result row dao
|
||||
* @throws SessionExpired the session expired
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static ResultRowPersistence getResultRowDAO(ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
public static ResultRowPersistence getResultRowDAO(ASLSession session) throws SessionExpired, Exception {
|
||||
checkASLSession(session);
|
||||
logger.trace("In getResultRowDAO...");
|
||||
|
||||
ResultRowPersistence resultRowEJB = SessionUtil.getCurrentEJBResultRow(session);
|
||||
|
||||
if(resultRowEJB==null){
|
||||
resultRowEJB = initResultRowDao(session);
|
||||
SessionUtil.setCurrentEJBResultRow(session, resultRowEJB);
|
||||
}
|
||||
|
||||
// logger.trace("Return result row Dao : " + resultRowEJB + " table name: " + resultRowDAO.getTableConfig().getTableName());
|
||||
// logger.trace("session id: " + session.getExternalSessionID() + " sessione username: " +session.getUsername() + " session scope: "+session.getScopeName());
|
||||
|
||||
return resultRowEJB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.speciesdiscovery.shared;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 17, 2017
|
||||
*/
|
||||
public class SessionExpired extends Exception {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4412298198084979081L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public SessionExpired() {
|
||||
|
||||
}
|
||||
|
||||
public SessionExpired(String arg0){
|
||||
super(arg0);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name="com.extjs.gxt.ui.GXT" />
|
||||
<!-- Used to show a layer via GisViewer -->
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.application.framework.core.session.SessionManager;
|
|||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.portlets.user.speciesdiscovery.server.persistence.DaoSession;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||
|
||||
/**
|
||||
|
@ -241,7 +242,7 @@ public class H2TestResultItemRetrievingAndConverting {
|
|||
|
||||
}
|
||||
|
||||
protected static void storeRR(TaxonomyRow row){
|
||||
protected static void storeRR(TaxonomyRow row) throws SessionExpired, Exception{
|
||||
EntityManagerFactory factory = DaoSession.getEntityManagerFactory(session);
|
||||
|
||||
EntityManager em = factory.createEntityManager();
|
||||
|
|
Loading…
Reference in New Issue