removed ScopeProvider.set everywhere

fixed occurrencescall

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@141544 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-01-13 10:00:53 +00:00
parent f82797b6f1
commit 2b71b38a8b
15 changed files with 261 additions and 282 deletions

View File

@ -1,20 +1,21 @@
<?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.8.2-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry excluding="log4j/" kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry including="*.properties" kind="src" path="src/test/java/log4j"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
@ -31,5 +32,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/species-discovery-3.8.2-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -3,6 +3,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java/log4j"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="species-discovery"/>
</wb-module>

View File

@ -41,19 +41,8 @@ import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
*/
public class TaxonomyRowTable extends HttpServlet {
/**
*
*/
protected static final String UTF_8 = "UTF-8";
/**
*
*/
private static final long serialVersionUID = 9157876104914505028L;
/**
*
*/
public static final String TEXT_HTML = "text/html; charset=UTF-8";
public static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.portlets.user.speciesdiscovery.server.asl;
@ -27,12 +27,12 @@ import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonName
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForTaxonomyRow;
/**
*
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class SessionUtil {
public static final String SPECIES_SERVICE = "SPECIES_SERVICE";
public static final String SEARCH_SESSION = "SEARCH_SESSION";
public static final String TAXONOMY_OCCURRENCE = "TAXONOMY_OCCURRENCE";
@ -51,10 +51,10 @@ public class SessionUtil {
private static final String CACHE_HASH_MAP_CHILDREN_TAXONOMY = "CACHE_HASH_MAP_CHILDREN_TAXONOMY";
private static final String CACHE_HASH_MAP_SYNONYMS_TAXONOMY = "CACHE_HASH_MAP_SYNONYMS_TAXONOMY";
private static final String CACHE_HASH_MAP_TAXONOMYID_TAXONOMY = "CACHE_HASH_MAP_TAXONOMYID_TAXONOMY";
protected static Logger logger = Logger.getLogger(SessionUtil.class);
public static EntityManagerFactory getEntityManagerFactory(ASLSession session) {
return (EntityManagerFactory) session.getAttribute(ENTITY_FACTORY);
}
@ -62,41 +62,40 @@ public class SessionUtil {
public static void setEntityManagerFactory(ASLSession session, EntityManagerFactory factory) {
session.setAttribute(ENTITY_FACTORY, factory);
}
public static SpeciesService getService(ASLSession session) throws Exception
{
SpeciesService service = (SpeciesService) session.getAttribute(SPECIES_SERVICE);
if (service==null) {
logger.trace("Service not found, creating it");
String scope = session.getScope();
service = new SpeciesService(scope, session);
service = new SpeciesService();
session.setAttribute(SPECIES_SERVICE, service);
}
return service;
}
@SuppressWarnings("unchecked")
public static FetchingSession<? extends FetchingElement> getCurrentSearchSession(ASLSession session)
{
return (FetchingSession<? extends FetchingElement>) session.getAttribute(SEARCH_SESSION);
}
public static void setCurrentSearchSession(ASLSession session, FetchingSession<? extends FetchingElement> searchSession){
session.setAttribute(SEARCH_SESSION, searchSession);
}
@SuppressWarnings("unchecked")
public static FetchingSession<Occurrence> getCurrentOccurrenceSession(ASLSession session){
return (FetchingSession<Occurrence>) session.getAttribute(TAXONOMY_OCCURRENCE);
}
public static void setCurrentOccurrenceSession(ASLSession session, FetchingSession<Occurrence> searchSession){
session.setAttribute(TAXONOMY_OCCURRENCE, searchSession);
}
// public static void setCurrentTaxonomyChildrenSession(ASLSession session, FetchingSession<TaxonomyRow> searchSession)
// {
// session.setAttribute(TAXONOMY_CHILD, searchSession);
@ -114,10 +113,10 @@ public class SessionUtil {
// user = "lucio.lelii";
// user = "pasquale.pagano";
// user = "francesco.mangiacrapa";
String scope = "/gcube/devsec"; //Development
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setScope(scope);
@ -125,7 +124,7 @@ public class SessionUtil {
logger.warn("TaxonomySearchServiceImpl STARTING IN TEST MODE - NO USER FOUND");
logger.warn("Created fake Asl session for user "+user + " with scope "+scope);
// session.setScope("/gcube/devsec");
return session;
}
@ -133,12 +132,12 @@ public class SessionUtil {
}
//MODIFIED******************************************************************************************
public static void setCurrentEJBResultRow(ASLSession session, ResultRowPersistence resultRowPersistence) {
session.setAttribute(EJB_RESULT_ROW, resultRowPersistence);
}
public static ResultRowPersistence getCurrentEJBResultRow(ASLSession session) {
return (ResultRowPersistence) session.getAttribute(EJB_RESULT_ROW);
}
@ -146,39 +145,39 @@ public class SessionUtil {
public static void setCurrentEJBTaxonRow(ASLSession session,TaxonRowPersistence taxonRowPersistence) {
session.setAttribute(EJB_TAXON_ROW, taxonRowPersistence);
}
public static TaxonRowPersistence getCurrentEJBTaxonRow(ASLSession session) {
return (TaxonRowPersistence) session.getAttribute(EJB_TAXON_ROW);
}
public static void setCurrentEJBOccurrence(ASLSession session, OccurrenceRowPersistence occurrenceRowPersistence) {
session.setAttribute(EJB_OCCURENCE, occurrenceRowPersistence);
}
public static OccurrenceRowPersistence getCurrentEJBOccurrence(ASLSession session) {
return (OccurrenceRowPersistence) session.getAttribute(EJB_OCCURENCE);
}
@SuppressWarnings("unchecked")
public static TaxonomyRowPersistence getCurrentEJBTaxonomyItem(ASLSession session) {
return (TaxonomyRowPersistence) session.getAttribute(EJB_TAXONOMY);
}
public static void setCurrentEJBTaxonomyItem(ASLSession session, TaxonomyRowPersistence taxonomyItemDAO) {
session.setAttribute(EJB_TAXONOMY, taxonomyItemDAO);
}
public static void setCurrentEJBOccurrencesJob(ASLSession session, OccurrenceJobPersistence occurrenceJobPersistence) {
session.setAttribute(EJB_OCCURRENCES_JOB, occurrenceJobPersistence);
}
@SuppressWarnings("unchecked")
public static OccurrenceJobPersistence getCurrentDaoOccurrencesJob(ASLSession session) {
return (OccurrenceJobPersistence) session.getAttribute(EJB_OCCURRENCES_JOB);
}
@SuppressWarnings("unchecked")
public static TaxonomyJobPersistence getCurrentDAOTaxonomyJob(ASLSession session) {
return (TaxonomyJobPersistence) session.getAttribute(EJB_TAXONOMY_JOB);
@ -195,17 +194,17 @@ public class SessionUtil {
public static void setCurrentQuery(ASLSession aslSession, String lastQuery) {
logger.trace("Last query in session: "+lastQuery);
aslSession.setAttribute(CURRENT_SPD_QUERY, lastQuery);
}
/**
*
*
* @param aslSession
*/
public static String getCurrentQuery(ASLSession aslSession) {
return (String) aslSession.getAttribute(CURRENT_SPD_QUERY);
}
/**
@ -213,89 +212,89 @@ public class SessionUtil {
*/
public static void setCurrentClusterCommonNameForResultRow(ASLSession session, HashMap<String, ClusterCommonNameDataSourceForResultRow> hashClusterCommonNameDataSource) {
session.setAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW, hashClusterCommonNameDataSource);
}
/**
* @param hashClusterCommonNameDataSource
* @return
* @return
*/
public static HashMap<String, ClusterCommonNameDataSourceForResultRow> getCurrentClusterCommonNameForResultRow(ASLSession session) {
return (HashMap<String, ClusterCommonNameDataSourceForResultRow>) session.getAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW);
}
/**
* @param hashClusterCommonNameDataSource
*/
public static void setCurrentClusterCommonNameForTaxonomyRow(ASLSession session, HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> hashClusterCommonNameDataSource) {
session.setAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW, hashClusterCommonNameDataSource);
}
/**
* @param hashClusterCommonNameDataSource
* @return
*/
public static HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> getCurrentClusterCommonNameForTaxonomyRow(ASLSession session) {
return (HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow>) session.getAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW);
}
/**
* @return
*
* @param hashClusterCommonNameDataSource
* @return
*/
public static HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> getCurrentClusterCommonNameForTaxonomyRow(ASLSession session) {
return (HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow>) session.getAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW);
}
/**
* @return
*
*/
public static HashMap<String, TaxonomyRow> getHashMapChildrenTaxonomyCache(ASLSession session) {
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY);
}
/**
* @return
*
* @return
*
*/
public static void setHashMapChildrenTaxonomyCache(ASLSession session, Map<String, TaxonomyRow> list) {
session.setAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY, list);
}
/**
* @return
*
* @return
*
*/
public static HashMap<String, TaxonomyRow> getHashMapSynonymsTaxonomyCache(ASLSession session) {
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY);
}
/**
* @return
*
* @return
*
*/
public static void setHashMapSynonymsTaxonomyCache(ASLSession session, Map<String, TaxonomyRow> list) {
session.setAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY, list);
}
/**
* @return
*
* @return
*
*/
public static HashMap<String, TaxonomyRow> getHashMapTaxonomyByIdsCache(ASLSession session) {
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY);
}
/**
* @return
*
* @return
*
*/
public static void setHashMapTaxonomyByIdsCache(ASLSession session, Map<String, TaxonomyRow> list) {
session.setAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY, list);
}
}

View File

@ -23,44 +23,44 @@ import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException;
*
*/
public class DaoSession {
protected static final String PROPERTY_CATALINA_HOME = "catalina.home";
protected static final String CATALINA_HOME = "CATALINA_HOME";
protected static final String PERSISTENCE_H2DBSPECIES_H2 = "persistence/h2dbspecies/h2";
public static Logger logger = Logger.getLogger(DaoSession.class);
private static final String JDBCDRIVER = "jdbc:h2:";
public static String getUsernameScopeValue(String username, String scope){
scope = scope.replaceAll("/","");
username = username.replaceAll("\\.","");
return username+scope;
}
/**
*
*
* @return $CATALINA_HOME
* @throws Exception
* @throws Exception
*/
public static String getTomcatFolder(){
String catalinaHome = System.getenv(CATALINA_HOME) != null ? System.getenv(CATALINA_HOME) : System.getProperty(PROPERTY_CATALINA_HOME);
if(catalinaHome == null || catalinaHome.isEmpty())
logger.error("CATALINA_HOME ENVIROMENT NOT FOUND - RETURNED / PATH");
return catalinaHome.endsWith("/") ? catalinaHome : catalinaHome+"/";
}
public static String getConnectionUrl(ASLSession session){
String username = session.getUsername();
String scope = session.getScopeName();
return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(username,scope)+";create=true";
@ -82,26 +82,26 @@ public class DaoSession {
}
}
//MODIFIED**************************************************************************************+
public static EntityManager newEntityManager(ASLSession session){
return getEntityManagerFactory(session).createEntityManager();
}
public static EntityManagerFactory getEntityManagerFactory(ASLSession session){
EntityManagerFactory factory = SessionUtil.getEntityManagerFactory(session);
if(factory==null){
factory = createEntityManagerFactory(session);
SessionUtil.setEntityManagerFactory(session, factory);
}
return factory;
}
@ -109,22 +109,22 @@ public class DaoSession {
{
OccurrenceJobPersistence occurrencesJobDao = SessionUtil.getCurrentDaoOccurrencesJob(session);
if(occurrencesJobDao==null){
occurrencesJobDao = initOccurrencesJobsDao(session);
SessionUtil.setCurrentEJBOccurrencesJob(session, occurrencesJobDao);
}
return occurrencesJobDao;
}
public static TaxonomyJobPersistence getTaxonomyJobDAO(ASLSession session) throws Exception
{
TaxonomyJobPersistence taxonomyJobPeristence = SessionUtil.getCurrentDAOTaxonomyJob(session);
if(taxonomyJobPeristence==null){
taxonomyJobPeristence = initTaxonomyJobsDao(session);
SessionUtil.setCurrentDAOTaxonomyJob(session, taxonomyJobPeristence);
@ -132,12 +132,11 @@ public class DaoSession {
return taxonomyJobPeristence;
}
public static EntityManagerFactory createEntityManagerFactory(ASLSession session){
Map<String,String> properties = new HashMap<String, String>();
// properties.put("javax.persistence.jdbc.driver", jdbcDriverH2);
try{
properties.put("javax.persistence.jdbc.url", getConnectionUrl(session));
}
@ -149,19 +148,19 @@ public class DaoSession {
}
//emf = Persistence.createEntityManagerFactory("jpablogPUnit");
return Persistence.createEntityManagerFactory("SPD_PERSISTENCE_FACTORY",properties);
}
public static OccurrenceJobPersistence initOccurrencesJobsDao(ASLSession session) throws Exception
{
String username = session.getUsername();
String scope = session.getScopeName();
return createOccurrencesJobDao(username, scope, session);
}
public static TaxonomyJobPersistence initTaxonomyJobsDao(ASLSession session) throws Exception{
TaxonomyJobPersistence occurrenceJobPersistence = new TaxonomyJobPersistence(getEntityManagerFactory(session));
@ -169,34 +168,34 @@ public class DaoSession {
return occurrenceJobPersistence;
}
public static OccurrenceJobPersistence createOccurrencesJobDao(String username, String scope, ASLSession session) throws Exception{
OccurrenceJobPersistence occurrenceJobPersistence = new OccurrenceJobPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBOccurrencesJob(session, occurrenceJobPersistence);
// logger.trace("ResultRow Dao IS READY AT CONNECTION URL: " + jdbcDriver + " table name "+ resultRowDAO.getTableInfo().getTableName());
return occurrenceJobPersistence;
}
public static ResultRowPersistence initResultRowDao(ASLSession session) throws Exception
{
ResultRowPersistence resultRowPersistence = new ResultRowPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBResultRow(session, resultRowPersistence);
// logger.trace("ResultRow Dao IS READY AT CONNECTION URL: " + jdbcDriver + " table name "+ resultRowDAO.getTableInfo().getTableName());
return resultRowPersistence;
}
public static OccurrenceRowPersistence getOccurrenceDAO(ASLSession session) throws Exception
{
OccurrenceRowPersistence occurrenceEJB = SessionUtil.getCurrentEJBOccurrence(session);
if(occurrenceEJB==null){
occurrenceEJB = initOccurrenceDao(session);
SessionUtil.setCurrentEJBOccurrence(session, occurrenceEJB);
@ -207,60 +206,60 @@ public class DaoSession {
public static TaxonRowPersistence initTaxonDao(ASLSession session) throws Exception
{
TaxonRowPersistence taxonRowPersistence = new TaxonRowPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBTaxonRow(session, taxonRowPersistence);
// logger.trace("ResultRow Dao IS READY AT CONNECTION URL: " + jdbcDriver + " table name "+ resultRowDAO.getTableInfo().getTableName());
return taxonRowPersistence;
}
private static OccurrenceRowPersistence initOccurrenceDao(ASLSession session) throws Exception {
OccurrenceRowPersistence occurrenceRowPersistence = new OccurrenceRowPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBOccurrence(session, occurrenceRowPersistence);
// logger.trace("ResultRow Dao IS READY AT CONNECTION URL: " + jdbcDriver + " table name "+ resultRowDAO.getTableInfo().getTableName());
return occurrenceRowPersistence;
}
public static TaxonRowPersistence getTaxonDAO(ASLSession session) throws Exception
{
TaxonRowPersistence taxonDao = SessionUtil.getCurrentEJBTaxonRow(session);
if(taxonDao==null){
taxonDao = initTaxonDao(session);
SessionUtil.setCurrentEJBTaxonRow(session, taxonDao);
}
// System.out.println("Return taxon Dao : " + taxonDao + " table name: " + taxonDao.getTableConfig().getTableName());
// System.out.println("session id: " + session.getExternalSessionID() + " sessione username: " +session.getUsername() + " session scope: "+session.getScopeName());
return taxonDao;
}
public static TaxonomyRowPersistence getTaxonomyDAO(ASLSession session) throws Exception
{
logger.trace("In getTaxonomyDAO...");
TaxonomyRowPersistence taxonItemDAO = SessionUtil.getCurrentEJBTaxonomyItem(session);
if(taxonItemDAO==null){
taxonItemDAO = initTaxonomyItemDao(session, "taxonomyrow");
SessionUtil.setCurrentEJBTaxonomyItem(session, taxonItemDAO);
}
// logger.trace("Return taxonomy row Dao : " + taxonItemDAO + " table name: " + taxonItemDAO.getTableConfig().getTableName());
// logger.trace("session id: " + session.getExternalSessionID() + " sessione username: " +session.getUsername() + " session scope: "+session.getScopeName());
return taxonItemDAO;
}
private static TaxonomyRowPersistence initTaxonomyItemDao(ASLSession session, String tableName) throws Exception{
TaxonomyRowPersistence taxonomyRP = new TaxonomyRowPersistence(getEntityManagerFactory(session));
@ -268,26 +267,26 @@ public class DaoSession {
return taxonomyRP;
}
public static ResultRowPersistence getResultRowDAO(ASLSession session) throws Exception
{
{
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;
}
}

View File

@ -18,8 +18,6 @@ import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.spd.client.proxies.ClassificationClient;
import org.gcube.data.spd.client.proxies.ExecutorClient;
import org.gcube.data.spd.client.proxies.ManagerClient;
@ -59,59 +57,24 @@ public class SpeciesService {
protected Logger logger = Logger.getLogger(SpeciesService.class);
protected String scope;
protected ASLSession session;
protected ManagerClient call;
protected OccurrenceClient occurrencesCall;
protected ClassificationClient classificationCall;
protected ExecutorClient executorCall;
protected String lastQuery = "";
/**
* Instantiates a new species service.
*
* @param scope
* the scope
* @param session
* the session
* @throws Exception
* the exception
*/
public SpeciesService(String scope, ASLSession session)
throws Exception {
this(scope);
this.session = session;
}
/**
* Instantiates a new species service.
*
* @param scope
* the scope
* @throws Exception
* the exception
* @throws Exception the exception
*/
public SpeciesService(String scope)
throws Exception {
this.scope = scope;
ScopeProvider.instance.set(scope);
// this.call = manager().at(
// URI.create("http://node24.d.d4science.research-infrastructures.eu:9000")).withTimeout(3,
// TimeUnit.MINUTES).build();
// this.occurrencesCall = occurrences().at(
// URI.create("http://node24.d.d4science.research-infrastructures.eu:9000")).withTimeout(3,
// TimeUnit.MINUTES).build();
// this.classificationCall = classification().at(
// URI.create("http://node24.d.d4science.research-infrastructures.eu:9000")).withTimeout(3,
// TimeUnit.MINUTES).build();
public SpeciesService() throws Exception {
System.out.println("CALLING MANAGER ");
this.call = manager().withTimeout(3, TimeUnit.MINUTES).build();
this.executorCall = executor().withTimeout(3, TimeUnit.MINUTES).build();
OccurrenceClient a =
occurrences().withTimeout(3, TimeUnit.MINUTES).build();
this.classificationCall =
classification().withTimeout(3, TimeUnit.MINUTES).build();
this.occurrencesCall = occurrences().withTimeout(3, TimeUnit.MINUTES).build();
this.classificationCall = classification().withTimeout(3, TimeUnit.MINUTES).build();
}
/**
@ -129,7 +92,6 @@ public class SpeciesService {
this.scope = scope;
if (instanceOnlyOccurrence) {
ScopeProvider.instance.set(scope);
System.out.println("CALLING OCCURRENCE MANAGER ");
this.occurrencesCall = occurrences().withTimeout(3, TimeUnit.MINUTES).build();
}
@ -185,7 +147,6 @@ public class SpeciesService {
logger.trace("retrieveTaxonomyById...");
try {
ScopeProvider.instance.set(scope);
Stream<TaxonomyItem> stream = classificationCall.getTaxaByIds(ids);
return new StreamIterator<TaxonomyItem>(stream);
}
@ -211,7 +172,6 @@ public class SpeciesService {
logger.trace("retrieveSynonymsById...");
try {
ScopeProvider.instance.set(scope);
Stream<TaxonomyItem> stream =
classificationCall.getSynonymsById(id);
return new StreamIterator<TaxonomyItem>(stream);
@ -239,9 +199,7 @@ public class SpeciesService {
logger.trace("search by Query - query is: " + query);
// System.out.println("searchByQuery query: "+query);
try {
ScopeProvider.instance.set(scope);
lastQuery = query;
// System.err.println("ScopeProvider SCOPE "+ScopeProvider.instance.get());
logger.trace("call species service search...");
// System.out.println("call species service search...");
Stream<ResultElement> stream = call.search(query);
@ -286,10 +244,7 @@ public class SpeciesService {
throws SearchServiceException {
logger.trace("searchByQuery query: " + query);
// System.out.println("searchByQuery query: "+query);
try {
ScopeProvider.instance.set(scope);
// System.err.println("ScopeProvider SCOPE "+ScopeProvider.instance.get());
logger.trace("call species service search...");
System.out.println("call species service search...");
return call.search(query);
@ -316,7 +271,6 @@ public class SpeciesService {
try {
List<DataSourceModel> listDsModel =
new ArrayList<DataSourceModel>();
ScopeProvider.instance.set(scope);
System.out.println("setting scope " + scope);
List<PluginDescription> plugin = call.getPluginsDescription();
if (plugin != null) {
@ -475,9 +429,6 @@ public class SpeciesService {
throws SearchServiceException {
try {
// Stream<String> keysStream = convert(keys);
ScopeProvider.instance.set(scope);
logger.trace("Instancing scope: "+scope);
logger.trace("Calling occurrencesCall passing keys: "+keys);
logger.trace("occurrencesCall != null? "+(occurrencesCall==null));
Stream<OccurrencePoint> stream = occurrencesCall.getByKeys(keys);
@ -504,7 +455,6 @@ public class SpeciesService {
try {
// Stream<String> idsStream = convert(ids);
ScopeProvider.instance.set(scope);
Stream<OccurrencePoint> stream = occurrencesCall.getByIds(ids);
return new StreamIterator<OccurrencePoint>(stream);
}
@ -530,7 +480,6 @@ public class SpeciesService {
try {
// Stream<String> keysStream = convert(keys);
ScopeProvider.instance.set(scope);
return occurrencesCall.createLayer(streamKey);
}
catch (Exception e) {
@ -555,7 +504,6 @@ public class SpeciesService {
throws Exception {
try {
ScopeProvider.instance.set(scope);
Stream<TaxonomyItem> items =
classificationCall.getTaxonChildrenById(parentId);
return new StreamIterator<TaxonomyItem>(items);
@ -578,7 +526,6 @@ public class SpeciesService {
*/
public CompleteJobStatus getTaxonomyJobById(String jobId) {
ScopeProvider.instance.set(scope);
CompleteJobStatus status = null;
try {
status = this.executorCall.getStatus(jobId);
@ -609,7 +556,6 @@ public class SpeciesService {
throws Exception {
InputStream is = null;
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getResultLink(jobIdentifier);
if (url == null || url.isEmpty()) {
@ -640,7 +586,6 @@ public class SpeciesService {
throws Exception {
InputStream is = null;
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getErrorLink(jobIdentifier);
if (url == null || url.isEmpty()) {
@ -670,7 +615,6 @@ public class SpeciesService {
public boolean isAvailableTaxonomyJobErrorFileById(String jobIdentifier)
throws Exception {
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getErrorLink(jobIdentifier);
if (url == null || url.isEmpty()) {
@ -700,7 +644,6 @@ public class SpeciesService {
public String createTaxonomyJobForDWCAByChildren(String taxonomyId)
throws Exception {
ScopeProvider.instance.set(scope);
try {
return this.executorCall.createDwCAByChildren(taxonomyId);
}
@ -722,7 +665,6 @@ public class SpeciesService {
public String createTaxonomyJobForDWCAByIds(List<String> ids)
throws Exception {
ScopeProvider.instance.set(scope);
try {
Stream<String> keysStream = convert(ids);
return executorCall.createDwCAByIds(keysStream);
@ -744,7 +686,6 @@ public class SpeciesService {
public void cancelTaxonomyJobById(String jobIdentifier) {
try {
ScopeProvider.instance.set(scope);
this.executorCall.removeJob(jobIdentifier);
}
catch (Exception e) {
@ -763,7 +704,6 @@ public class SpeciesService {
public CompleteJobStatus getOccurrenceJobById(String jobId) {
try {
ScopeProvider.instance.set(scope);
return this.executorCall.getStatus(jobId); // CHANGE INTO OCCURRENCE
// JOB
// **************************************************************************************
@ -793,7 +733,6 @@ public class SpeciesService {
throws Exception {
try {
ScopeProvider.instance.set(scope);
return this.executorCall.createCSV(streamKey);
}
catch (Exception e) {
@ -817,7 +756,6 @@ public class SpeciesService {
throws Exception {
try {
ScopeProvider.instance.set(scope);
return this.executorCall.createDarwincoreFromOccurrenceKeys(streamKey);
}
catch (Exception e) {
@ -841,7 +779,6 @@ public class SpeciesService {
throws Exception {
try {
ScopeProvider.instance.set(scope);
return this.executorCall.createCSVforOM(streamKey);
}
catch (Exception e) {
@ -863,7 +800,6 @@ public class SpeciesService {
public void cancelOccurrenceJobById(String jobIdentifier) {
try {
ScopeProvider.instance.set(scope);
this.executorCall.removeJob(jobIdentifier); // CHANGE INTO
// OCCURRENCE JOB
// **************************************************************************************
@ -888,7 +824,6 @@ public class SpeciesService {
throws Exception {
InputStream is = null;
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getResultLink(jobIdentifier); // CHANGE
// INTO
@ -925,7 +860,6 @@ public class SpeciesService {
throws Exception {
InputStream is = null;
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getErrorLink(jobIdentifier);
logger.trace("URL returned by species service is: " + url);
@ -955,7 +889,6 @@ public class SpeciesService {
public boolean isAvailableOccurrenceJobErrorFileById(String jobIdentifier)
throws Exception {
ScopeProvider.instance.set(scope);
try {
String url = this.executorCall.getErrorLink(jobIdentifier);
if (url == null || url.isEmpty()) {

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.portlets.user.speciesdiscovery.server.util;
@ -7,7 +7,6 @@ import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.scope.api.ScopeProvider;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -17,26 +16,20 @@ import org.gcube.common.scope.api.ScopeProvider;
public class GetWorkspaceUtil {
protected static Logger logger = Logger.getLogger(GetWorkspaceUtil.class);
public static Workspace getWorskspace(ASLSession session) throws Exception {
if(session==null)
throw new Exception("ASL session is null");
if(session.getScope()==null)
throw new Exception("Scope into ASL session is null");
String scope = session.getScope().toString();
logger.trace("Get workspace for scope "+scope);
ScopeProvider.instance.set(scope);
logger.trace("ScopeProvider instancied for scope "+scope);
//logger.trace("Get workspace for scope "+scope);
//ScopeProvider.instance.set(scope);
//logger.trace("ScopeProvider instancied for scope "+scope);
logger.trace("retuning workspace for username "+session.getUsername());
return HomeLibrary.getUserWorkspace(session.getUsername());
}
}

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.portlets.user.speciesdiscovery.shared;
@ -10,16 +10,18 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
*
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
@Entity
public class CommonName implements Serializable {
public class CommonName implements IsSerializable, Serializable {
/**
*
*
*/
private static final long serialVersionUID = 1140787822064828769L;
@ -27,22 +29,22 @@ public class CommonName implements Serializable {
public final static String NAME= "name";
public final static String LANGUAGE= "language";
public final static String REFERENCE_RESULTROW_ID = "resultRowId";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int internalId;
protected int id;
private int resultRowId;
protected String name;
protected String language;
public CommonName(){}
/**
* @param name
* @param language
@ -97,5 +99,5 @@ public class CommonName implements Serializable {
public int getResultRowId() {
return resultRowId;
}
}

View File

@ -1,26 +1,28 @@
/**
*
*
*/
package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class Coordinate implements Serializable {
public class Coordinate implements IsSerializable, Serializable {
/**
*
*
*/
private static final long serialVersionUID = -2357675565732391317L;
protected float latitude;
protected float longitude;
public Coordinate(){}
/**
* @param latitude
* @param longitude
@ -29,35 +31,35 @@ public class Coordinate implements Serializable {
this.latitude = latitude;
this.longitude = longitude;
}
/**
* @return the latitude
*/
public float getLatitude() {
return latitude;
}
/**
* @param latitude the latitude to set
*/
public void setLatitude(float latitude) {
this.latitude = latitude;
}
/**
* @return the longitude
*/
public float getLongitude() {
return longitude;
}
/**
* @param longitude the longitude to set
*/
public void setLongitude(float longitude) {
this.longitude = longitude;
}
/**
* {@inheritDoc}
*/

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@ -15,7 +17,12 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* Jan 10, 2017
*/
@Entity
public class DataSource implements IsSerializable{
public class DataSource implements IsSerializable, Serializable{
/**
*
*/
private static final long serialVersionUID = -7978955895523864898L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import java.util.ArrayList;
import com.google.gwt.user.client.rpc.IsSerializable;
@ -12,8 +13,12 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 10, 2017
*/
public class DataSourceCapability implements IsSerializable{
public class DataSourceCapability implements IsSerializable, Serializable{
/**
*
*/
private static final long serialVersionUID = 844266531985842984L;
private ArrayList<SpeciesCapability> listFilters;
private SpeciesCapability capability;

View File

@ -1,7 +1,10 @@
package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import java.util.ArrayList;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class DataSourceModel.
@ -9,8 +12,12 @@ import java.util.ArrayList;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 10, 2017
*/
public class DataSourceModel extends DataSource {
public class DataSourceModel extends DataSource implements IsSerializable, Serializable{
/**
*
*/
private static final long serialVersionUID = -8314335099130160226L;
private ArrayList<DataSourceCapability> listCapabilities;
private DataSourceRepositoryInfo dataSourceRepositoryInfo;

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import java.util.Map;
import com.google.gwt.user.client.rpc.IsSerializable;
@ -11,8 +12,12 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 10, 2017
*/
public class DataSourceRepositoryInfo implements IsSerializable{
public class DataSourceRepositoryInfo implements IsSerializable, Serializable{
/**
*
*/
private static final long serialVersionUID = -2778021508260771963L;
private String logoUrl;
private String pageUrl;
private Map<String, String> properties;

View File

@ -2,13 +2,15 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
public enum DownloadState implements Serializable {
PENDING,
ONGOING,
ONGOINGWITHFAILURES,
FAILED,
COMPLETED,
COMPLETEDWITHFAILURES,
import com.google.gwt.user.client.rpc.IsSerializable;
public enum DownloadState implements IsSerializable, Serializable {
PENDING,
ONGOING,
ONGOINGWITHFAILURES,
FAILED,
COMPLETED,
COMPLETEDWITHFAILURES,
SAVING,
SAVED,
SERVICE_UNKNOWN

View File

@ -0,0 +1,33 @@
# Set root category priority to WARN and its only appender to A1.
log4j.rootCategory=ERROR, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} [%t,%M:%L] %m%n
# Display any warnings generated by our code
#log4j.category.org.gcube=trace
#log4j.category.org.globus=trace
#log4j.category.isclient=INFO
#log4j.category.org.gcube.common.homelibrary.jcr=TRACE
log4j.category.org.gcube.portlets.user.workspace=TRACE
log4j.logger.org.gcube=TRACE
log4j.logger.org.gcube.application.framework.core.session=INFO
log4j.logger.org.gcube.contentmanager=ERROR
log4j.logger.org.gcube.common.scope=ERROR
log4j.logger.org.gcube.contentmanagement=ERROR
log4j.logger.org.gcube.resources.discovery.icclient=ERROR
log4j.logger.org.gcube.common.clients=ERROR
#log4j.logger.org.gcube.common.homelibrary.jcr=TRACE
log4j.logger.org.gcube.application.framework.accesslogger=ERROR
log4j.logger.org.apache.pdfbox.util.PDFStreamEngine=ERROR