SEARCH-251: adjusted logic for handling UUID

This commit is contained in:
Joel
2016-12-06 14:45:56 -05:00
parent c6605e6c54
commit 553911886e
2 changed files with 37 additions and 21 deletions
@@ -72,18 +72,14 @@ public class FingerPrintComponent extends SearchComponent implements SolrCoreAwa
NamedList response = responseBuilder.rsp.getValues();
String id = responseBuilder.req.getParams().get("id");
if(id.contains("-")) {
long dbid = fetchDBID(id, responseBuilder.req.getSearcher());
if(dbid > -1) {
id = Long.toString(dbid);
} else {
id = null;
}
long dbid = fetchDBID(id, responseBuilder.req.getSearcher());
if(dbid == -1 && isNumber(id) ) {
dbid = Long.parseLong(id);
}
NamedList fingerPrint = new NamedList();
if(id != null) {
SolrInputDocument solrDoc = solrContentStore.retrieveDocFromSolrContentStore(AlfrescoSolrDataModel.getTenantId(TenantService.DEFAULT_DOMAIN), Long.parseLong(id));
if(dbid > -1) {
SolrInputDocument solrDoc = solrContentStore.retrieveDocFromSolrContentStore(AlfrescoSolrDataModel.getTenantId(TenantService.DEFAULT_DOMAIN), dbid);
if (solrDoc != null) {
SolrInputField mh = solrDoc.getField("MINHASH");
if (mh != null) {
@@ -114,6 +110,16 @@ public class FingerPrintComponent extends SearchComponent implements SolrCoreAwa
return -1;
}
private boolean isNumber(String s) {
for(int i=0; i<s.length(); i++) {
if(!Character.isDigit(s.charAt(i))) {
return false;
}
}
return true;
}
private SolrContentStore getContentStore(SolrQueryRequest req)
{
@@ -707,21 +707,22 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
//Is the fingerprint in the local SolrContentStore
if(values == null) {
long dbid = -1;
//Do we have a UUID or DBID
if(nodeId.contains("-")) {
//It's a UUID. We need the DBID.
dbid = fetchDBID(nodeId);
} else {
if(values == null)
{
long dbid = fetchDBID(nodeId);
if(dbid == -1 && isNumber(nodeId))
{
dbid = Long.parseLong(nodeId);
}
if(dbid > -1) {
if(dbid > -1)
{
SolrInputDocument solrDoc = solrContentStore.retrieveDocFromSolrContentStore(AlfrescoSolrDataModel.getTenantId(TenantService.DEFAULT_DOMAIN), dbid);
if (solrDoc != null) {
if (solrDoc != null)
{
SolrInputField mh = solrDoc.getField("MINHASH");
if (mh != null) {
if (mh != null)
{
values = mh.getValues();
}
}
@@ -733,7 +734,7 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
{
//we are in distributed mode
//Fetch the fingerPrint from the shards.
//The UUID and DBID will work both work for method call.
//The UUID and DBID will both work for method call.
values = fetchFingerPrint(shards, nodeId);
}
@@ -767,6 +768,16 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
}
private boolean isNumber(String s) {
for(int i=0; i<s.length(); i++) {
if(!Character.isDigit(s.charAt(i))) {
return false;
}
}
return true;
}
private String join(Collection col, String delimiter){
StringBuilder builder = new StringBuilder();
for(Object o : col){
@@ -796,7 +807,6 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
return -1;
}
private Collection fetchFingerPrint(String shards, String nodeId) {
shards = shards.replace(",", "|");
List<String> urls = ((HttpShardHandlerFactory)shardHandlerFactory).makeURLList(shards);