Skip to content

Commit

Permalink
use MCRSolrCoreManager instead of MCRSolrClientFactory #85
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteph-de committed Sep 13, 2024
1 parent 2988e87 commit d2916e9
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.datamodel.common.MCRXMLMetadataManager;
import org.mycore.frontend.jersey.MCRCacheControl;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import jakarta.servlet.ServletContext;
Expand Down Expand Up @@ -91,7 +91,7 @@ public Response exploreObjects(@QueryParam("start") String start, @QueryParam("r
//}
MCRAPIExploreResponse response = new MCRAPIExploreResponse();

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery q = new SolrQuery("*:*");
MCRConfiguration2.getString("MCR.API.Explore.FilterQuery").ifPresent(fq -> {
q.addFilterQuery(fq);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.config.MCRConfigurationException;
import org.mycore.jspdocportal.common.search.MCRSearchResultDataBean;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.GET;
Expand Down Expand Up @@ -65,7 +65,7 @@ public Response defaultRes(@PathParam("modus") String modus,
q.setRows(0);
q.setStart(0);

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();

firstSelector.clear();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import org.mycore.datamodel.niofs.MCRPath;
import org.mycore.frontend.MCRFrontendUtil;
import org.mycore.services.i18n.MCRTranslation;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;
import org.mycore.solr.MCRSolrUtils;

import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -113,7 +113,7 @@ public Response doGet(@PathParam("path") String uri, @Context HttpServletRequest
if ("gnd".equals(key)) {
//"gnd_uri": "http://d-nb.info/gnd/14075444X"
try {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery("gnd_uri:" + MCRSolrUtils.escapeSearchValue("http://d-nb.info/gnd/" + value.trim()));
solrQuery.setFields("id");
Expand Down Expand Up @@ -148,7 +148,7 @@ public Response doGet(@PathParam("path") String uri, @Context HttpServletRequest
value = value.replaceFirst("_", "/");
}

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery solrQuery = new SolrQuery(key + ":" + ClientUtils.escapeQueryChars(value));
solrQuery.setRows(1);
QueryResponse solrQueryResponse = solrClient.query(solrQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.glassfish.jersey.server.mvc.Viewable;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.DefaultValue;
Expand Down Expand Up @@ -66,7 +66,7 @@ public Response doGetWithFile(@PathParam("field") String field, @PathParam("iden

Viewable v = new Viewable("/mcrviewer", model);

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
String value = identifier;
if ("recordIdentifier".equals(field) && !value.contains("/")) {
value = value.replaceFirst("_", "/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.mycore.frontend.MCRFrontendUtil;
import org.mycore.jspdocportal.common.controller.MCRResolvingController;
import org.mycore.services.i18n.MCRTranslation;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;
import org.mycore.solr.MCRSolrUtils;

import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
if ("gnd".equals(key)) {
//"gnd_uri": "http://d-nb.info/gnd/14075444X"
try {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery("gnd_uri:" + MCRSolrUtils.escapeSearchValue("http://d-nb.info/gnd/" + value.trim()));
solrQuery.setFields("id");
Expand Down Expand Up @@ -141,7 +141,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
value = value.replaceFirst("_", "/");
}

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery solrQuery = new SolrQuery(key + ":" + ClientUtils.escapeQueryChars(value));
solrQuery.setRows(1);
QueryResponse solrQueryResponse = solrClient.query(solrQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.mycore.datamodel.niofs.MCRPath;
import org.mycore.frontend.MCRFrontendUtil;
import org.mycore.jspdocportal.common.controller.MCRResolvingController;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
Expand Down Expand Up @@ -122,7 +122,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
getServletContext().getRequestDispatcher("/nav?path=~mycore-error&messageKey=IdNotGiven").forward(request,
response);
} else {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery query = new SolrQuery();
query.setQuery(queryString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.jdom2.Document;
import org.mycore.access.MCRAccessManager;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -122,7 +122,7 @@ public static MCRSearchResultDataBean retrieveSearchresultFromSession(HttpServle

public void doSearch() {
solrQueryResponse = null;
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();

if (rows >= 0) {
solrQuery.setRows(rows);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.mycore.datamodel.classifications2.MCRCategoryID;
import org.mycore.frontend.MCRFrontendUtil;
import org.mycore.services.i18n.MCRTranslation;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
Expand Down Expand Up @@ -90,7 +90,7 @@ public class MCRClassificationBrowserTag extends SimpleTagSupport {
new CacheLoader<String, Integer>() {
@Override
public Integer load(String key) throws Exception {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery query = new SolrQuery(key);
query.setRows(0);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.mycore.datamodel.metadata.MCRObjectID;
import org.mycore.jspdocportal.common.MCRHibernateTransactionWrapper;
import org.mycore.jspdocportal.common.bpmn.MCRBPMNUtils;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
Expand Down Expand Up @@ -151,7 +151,7 @@ public void doTag() throws JspException, IOException {
PageContext pageContext = (PageContext) getJspContext();
if(StringUtils.isNotBlank(query)) {
try {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(query);
solrQuery.setFields("id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.solr.common.params.ModifiableSolrParams;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.datamodel.metadata.MCRObjectID;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;
Expand Down Expand Up @@ -78,7 +78,7 @@ public static MCRObjectID retrieveMCRDerIDfromSOLR(MCRObjectID mcrObjId, String
params.set("sort", "derivateOrder asc");
QueryResponse solrResponse = null;
try {
solrResponse = MCRSolrClientFactory.getMainSolrClient().query(params);
solrResponse = MCRSolrCoreManager.getMainSolrClient().query(params);
} catch (Exception e) {
LOGGER.error("Error retrieving derivate id from SOLR", e);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public static MCRObjectID retrieveMCRObjIDfromSOLR(String mcrid) {
params.set("q", key + ":" + ClientUtils.escapeQueryChars(value));
QueryResponse solrResponse = null;
try {
solrResponse = MCRSolrClientFactory.getMainSolrClient().query(params);
solrResponse = MCRSolrCoreManager.getMainSolrClient().query(params);
} catch (Exception e) {
LOGGER.error("Error retrieving object id from SOLR", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.mycore.jspdocportal.ir.depotapi.HashedDirectoryStructure;
import org.mycore.jspdocportal.ir.pdfdownload.PDFGenerator;
import org.mycore.jspdocportal.ir.pdfdownload.PDFGeneratorService;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -94,7 +94,7 @@ public Response delete(@Context HttpServletRequest request, @Context ServletCont
String recordIdentifier = path.endsWith(".pdf") ? path.substring(0, path.lastIndexOf("/")) : path;
recordIdentifier = recordIdentifier.replace("/", "_");

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery query = new SolrQuery();
query.setQuery("recordIdentifier:" + recordIdentifier.replaceFirst("_", "/"));

Expand Down Expand Up @@ -140,7 +140,7 @@ public Response get(@Context HttpServletRequest request, @Context ServletContext
String recordIdentifier = path.endsWith(".pdf") ? path.substring(0, path.lastIndexOf("/")) : path;
recordIdentifier = recordIdentifier.replace("/", "_");

SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
SolrQuery query = new SolrQuery();
query.setQuery("recordIdentifier:" + recordIdentifier.replaceFirst("_", "/"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.mycore.datamodel.metadata.MCRObject;
import org.mycore.datamodel.metadata.MCRObjectID;
import org.mycore.mcr.cronjob.MCRCronjob;
import org.mycore.solr.MCRSolrClientFactory;
import org.mycore.solr.MCRSolrCoreManager;
import org.mycore.util.concurrent.MCRFixedUserCallable;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ public void runJob() {
try {
new MCRFixedUserCallable<Boolean>(() -> {
if (MCRConfiguration2.getString("MCR.Solr.ServerURL").isPresent()) {
final SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
final SolrClient solrClient = MCRSolrCoreManager.getMainSolrClient();
final ModifiableSolrParams params = new ModifiableSolrParams();

params.set("start", 0);
Expand Down

0 comments on commit d2916e9

Please sign in to comment.