diff --git a/src/main/java/org/ndexbio/common/models/dao/postgresql/NetworkDAO.java b/src/main/java/org/ndexbio/common/models/dao/postgresql/NetworkDAO.java index 6e71327e..0e79c0cf 100644 --- a/src/main/java/org/ndexbio/common/models/dao/postgresql/NetworkDAO.java +++ b/src/main/java/org/ndexbio/common/models/dao/postgresql/NetworkDAO.java @@ -30,11 +30,7 @@ */ package org.ndexbio.common.models.dao.postgresql; -import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; import java.security.SecureRandom; import java.sql.Array; import java.sql.PreparedStatement; @@ -57,7 +53,6 @@ import javax.xml.bind.DatatypeConverter; -import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; @@ -79,7 +74,6 @@ import org.ndexbio.model.object.network.NetworkIndexLevel; import org.ndexbio.model.object.network.NetworkSummary; import org.ndexbio.model.object.network.VisibilityType; -import org.ndexbio.rest.Configuration; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; @@ -1705,15 +1699,18 @@ public int revokeUserPrivilege(UUID networkUUID, UUID userUUID) throws SQLExcept } /** - * Becareful when using this function, it commit the db connection of the current DAO object. + * Be careful when using this function, it commit the db connection of the current DAO object. * * @param networkId - * @param ErrorMessage + * @param errorMessage */ - public void setErrorMessage(UUID networkId, String ErrorMessage) { + public void setErrorMessage(UUID networkId, String errorMessage) { String sql = "update network set error = ? where \"UUID\" = ? and is_deleted=false"; + + String trimedMsg = ( errorMessage.length()>2000) ? + (errorMessage.substring(0, 1996) + "...") : errorMessage ; try ( PreparedStatement pst = db.prepareStatement(sql)) { - pst.setString(1, ErrorMessage); + pst.setString(1, trimedMsg); pst.setObject(2, networkId); int i = pst.executeUpdate(); if ( i !=1) diff --git a/src/main/java/org/ndexbio/common/solr/GroupIndexManager.java b/src/main/java/org/ndexbio/common/solr/GroupIndexManager.java index 3b5bbfbb..846fbd52 100644 --- a/src/main/java/org/ndexbio/common/solr/GroupIndexManager.java +++ b/src/main/java/org/ndexbio/common/solr/GroupIndexManager.java @@ -47,6 +47,7 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.NamedList; import org.ndexbio.model.exceptions.NdexException; +import org.ndexbio.model.tools.SearchUtilities; import org.ndexbio.rest.Configuration; public class GroupIndexManager implements AutoCloseable{ @@ -101,7 +102,7 @@ public SolrDocumentList searchGroups (String searchTerms, int limit, int offset) SolrQuery solrQuery = new SolrQuery(); - solrQuery.setQuery(searchTerms).setFields(UUID); + solrQuery.setQuery(SearchUtilities.preprocessSearchTerm(searchTerms)).setFields(UUID); if ( searchTerms.equalsIgnoreCase("*:*")) solrQuery.setSort(UUID, ORDER.desc); if ( offset >=0) diff --git a/src/main/java/org/ndexbio/common/solr/NetworkGlobalIndexManager.java b/src/main/java/org/ndexbio/common/solr/NetworkGlobalIndexManager.java index 688d58c2..f8bebb26 100644 --- a/src/main/java/org/ndexbio/common/solr/NetworkGlobalIndexManager.java +++ b/src/main/java/org/ndexbio/common/solr/NetworkGlobalIndexManager.java @@ -58,6 +58,7 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.NamedList; import org.ndexbio.common.NdexClasses; +import org.ndexbio.model.tools.SearchUtilities; import org.ndexbio.model.tools.TermUtilities; import org.ndexbio.common.util.Util; import org.ndexbio.cxio.aspects.datamodels.ATTRIBUTE_DATA_TYPE; @@ -239,7 +240,7 @@ else if ( permission == Permissions.READ) { solrQuery.setSort(MODIFICATION_TIME, ORDER.desc); // solrQuery.setQuery( searchTerms ).setFields(UUID); - solrQuery.setQuery("( " + searchTerms + " ) AND _val_:\"div(" + NDEX_SCORE+ ",10)\"" ).setFields(UUID); + solrQuery.setQuery("( " + SearchUtilities.preprocessSearchTerm(searchTerms) + " ) AND _val_:\"div(" + NDEX_SCORE+ ",10)\"" ).setFields(UUID); solrQuery.set("defType", "edismax"); solrQuery.set("qf","uuid^20 name^10 description^5 labels^6 owner^2 networkType^4 organism^3 disease^3 tissue^3 author^2 methods nodeName represents alias rights^0.6 rightsHolder^0.6"); if ( offset >=0) diff --git a/src/main/java/org/ndexbio/common/solr/SingleNetworkSolrIdxManager.java b/src/main/java/org/ndexbio/common/solr/SingleNetworkSolrIdxManager.java index 1cf55a13..9e216380 100644 --- a/src/main/java/org/ndexbio/common/solr/SingleNetworkSolrIdxManager.java +++ b/src/main/java/org/ndexbio/common/solr/SingleNetworkSolrIdxManager.java @@ -61,6 +61,7 @@ import org.ndexbio.cxio.core.AspectIterator; import org.ndexbio.model.cx.FunctionTermElement; import org.ndexbio.model.exceptions.NdexException; +import org.ndexbio.model.tools.SearchUtilities; import org.ndexbio.rest.Configuration; import com.fasterxml.jackson.core.JsonProcessingException; @@ -99,7 +100,7 @@ public SolrDocumentList getNodeIdsByQuery(String query, int limit) throws SolrSe SolrQuery solrQuery = new SolrQuery(); - solrQuery.setQuery(query).setFields(ID); + solrQuery.setQuery(SearchUtilities.preprocessSearchTerm(query)).setFields(ID); solrQuery.set("defType", "edismax"); solrQuery.set("qf", NAME + " " + REPRESENTS + " " + ALIAS); solrQuery.setStart(0); diff --git a/src/main/java/org/ndexbio/common/solr/UserIndexManager.java b/src/main/java/org/ndexbio/common/solr/UserIndexManager.java index 8fddb2ae..0867ff68 100644 --- a/src/main/java/org/ndexbio/common/solr/UserIndexManager.java +++ b/src/main/java/org/ndexbio/common/solr/UserIndexManager.java @@ -47,6 +47,7 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.NamedList; import org.ndexbio.model.exceptions.NdexException; +import org.ndexbio.model.tools.SearchUtilities; import org.ndexbio.rest.Configuration; public class UserIndexManager implements AutoCloseable{ @@ -109,7 +110,7 @@ public SolrDocumentList searchUsers (String searchTerms, int limit, int offset) SolrQuery solrQuery = new SolrQuery(); - solrQuery.setQuery(searchTerms).setFields(UUID); + solrQuery.setQuery(SearchUtilities.preprocessSearchTerm(searchTerms)).setFields(UUID); if ( searchTerms.equalsIgnoreCase("*:*")) solrQuery.setSort(UUID, ORDER.desc); if ( offset >=0)