use of edu.harvard.iq.dataverse.search.SearchException in project dataverse by IQSS.
the class SavedSearches method makeLinksForSingleSavedSearch.
@PUT
@Path("makelinks/{id}")
public Response makeLinksForSingleSavedSearch(@PathParam("id") long savedSearchIdToLookUp, @QueryParam("debug") boolean debug) {
SavedSearch savedSearchToMakeLinksFor = savedSearchSvc.find(savedSearchIdToLookUp);
if (savedSearchToMakeLinksFor == null) {
return error(BAD_REQUEST, "Count not find saved search id " + savedSearchIdToLookUp);
}
try {
DataverseRequest dataverseRequest = new DataverseRequest(savedSearchToMakeLinksFor.getCreator(), SavedSearchServiceBean.getHttpServletRequest());
JsonObjectBuilder response = savedSearchSvc.makeLinksForSingleSavedSearch(dataverseRequest, savedSearchToMakeLinksFor, debug);
return ok(response);
} catch (CommandException ex) {
return error(BAD_REQUEST, ex.getLocalizedMessage());
} catch (SearchException ex) {
return error(INTERNAL_SERVER_ERROR, ex.getLocalizedMessage());
}
}
use of edu.harvard.iq.dataverse.search.SearchException in project dataverse by IQSS.
the class Index method indexStatus.
@GET
@Path("status")
public Response indexStatus() {
JsonObjectBuilder contentInDatabaseButStaleInOrMissingFromSolr = getContentInDatabaseButStaleInOrMissingFromSolr();
JsonObjectBuilder contentInSolrButNotDatabase;
try {
contentInSolrButNotDatabase = getContentInSolrButNotDatabase();
} catch (SearchException ex) {
return error(Response.Status.INTERNAL_SERVER_ERROR, "Can not determine index status. " + ex.getLocalizedMessage() + ". Is Solr down? Exception: " + ex.getCause().getLocalizedMessage());
}
JsonObjectBuilder permissionsInDatabaseButStaleInOrMissingFromSolr = getPermissionsInDatabaseButStaleInOrMissingFromSolr();
JsonObjectBuilder permissionsInSolrButNotDatabase = getPermissionsInSolrButNotDatabase();
JsonObjectBuilder data = Json.createObjectBuilder().add("contentInDatabaseButStaleInOrMissingFromIndex", contentInDatabaseButStaleInOrMissingFromSolr).add("contentInIndexButNotDatabase", contentInSolrButNotDatabase).add("permissionsInDatabaseButStaleInOrMissingFromIndex", permissionsInDatabaseButStaleInOrMissingFromSolr).add("permissionsInIndexButNotDatabase", permissionsInSolrButNotDatabase);
return ok(data);
}
use of edu.harvard.iq.dataverse.search.SearchException in project dataverse by IQSS.
the class DataRetrieverAPI method getTotalCountsFromSolr.
private SolrQueryResponse getTotalCountsFromSolr(DataverseRequest dataverseRequest, MyDataFinder myDataFinder) {
if (myDataFinder == null) {
throw new NullPointerException("myDataFinder cannot be null");
}
if (dataverseRequest == null) {
throw new NullPointerException("dataverseRequest cannot be null");
}
// -------------------------------------------------------
// Create new filter params that only check by the User
// -------------------------------------------------------
MyDataFilterParams filterParams = new MyDataFilterParams(dataverseRequest, myDataFinder.getRolePermissionHelper());
if (filterParams.hasError()) {
logger.severe("getTotalCountsFromSolr. filterParams error: " + filterParams.getErrorMessage());
return null;
}
// -------------------------------------------------------
// Re-run all of the entity queries (sigh)
// -------------------------------------------------------
myDataFinder.initFields();
myDataFinder.runFindDataSteps(filterParams);
if (myDataFinder.hasError()) {
logger.severe("getTotalCountsFromSolr. myDataFinder error: " + myDataFinder.getErrorMessage());
return null;
}
// -------------------------------------------------------
// Generate filterQueries for total counts
// -------------------------------------------------------
List<String> filterQueries = myDataFinder.getSolrFilterQueriesForTotalCounts();
if (filterQueries == null) {
logger.severe("getTotalCountsFromSolr. filterQueries was null!");
return null;
}
// msgt("getTotalCountsFromSolr");
// msgt(StringUtils.join(filterQueries, " AND "));
// -------------------------------------------------------
// Run Solr
// -------------------------------------------------------
SolrQueryResponse solrQueryResponseForCounts;
try {
solrQueryResponseForCounts = searchService.search(dataverseRequest, // subtree, default it to Dataverse for now
null, // Get everything--always
"*", // filterQueries,
filterQueries, SearchFields.NAME_SORT, SortBy.ASCENDING, // paginationStart,
0, // dataRelatedToMe
true, // 10 // SearchFields.NUM_SOLR_DOCS_TO_RETRIEVE
SearchConstants.NUM_SOLR_DOCS_TO_RETRIEVE);
} catch (SearchException ex) {
logger.severe("Search for total counts failed with filter query");
logger.severe("filterQueries: " + StringUtils.join(filterQueries, "(separator)"));
return null;
}
return solrQueryResponseForCounts;
}
Aggregations