dsmiley commented on code in PR #3200:
URL: https://github.com/apache/solr/pull/3200#discussion_r1966668902
##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java:
##########
@@ -368,147 +368,39 @@ public void setDeleteQuery(List<String> deleteQuery) {
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
+ /**
+ * @deprecated Method will be removed in Solr 10.0. Use {@link
XMLRequestWriter} instead.
+ */
+ @Deprecated(since = "9.9")
@Override
public Collection<ContentStream> getContentStreams() throws IOException {
return ClientUtils.toContentStreams(getXML(), ClientUtils.TEXT_XML);
}
+ /**
+ * @deprecated Method will be removed in Solr 10.0. Use {@link
XMLRequestWriter} instead.
+ */
+ @Deprecated(since = "9.9")
public String getXML() throws IOException {
StringWriter writer = new StringWriter();
writeXML(writer);
writer.flush();
// If action is COMMIT or OPTIMIZE, it is sent with params
String xml = writer.toString();
- // System.out.println( "SEND:"+xml );
return (xml.length() > 0) ? xml : null;
}
- private List<Map<SolrInputDocument, Map<String, Object>>> getDocLists(
- Map<SolrInputDocument, Map<String, Object>> documents) {
- List<Map<SolrInputDocument, Map<String, Object>>> docLists = new
ArrayList<>();
- Map<SolrInputDocument, Map<String, Object>> docList = null;
- if (this.documents != null) {
-
- Boolean lastOverwrite = true;
- Integer lastCommitWithin = -1;
-
- Set<Entry<SolrInputDocument, Map<String, Object>>> entries =
this.documents.entrySet();
- for (Entry<SolrInputDocument, Map<String, Object>> entry : entries) {
- Map<String, Object> map = entry.getValue();
- Boolean overwrite = null;
- Integer commitWithin = null;
- if (map != null) {
- overwrite = (Boolean) entry.getValue().get(OVERWRITE);
- commitWithin = (Integer) entry.getValue().get(COMMIT_WITHIN);
- }
- if (!Objects.equals(overwrite, lastOverwrite)
- || !Objects.equals(commitWithin, lastCommitWithin)
- || docLists.isEmpty()) {
- docList = new LinkedHashMap<>();
- docLists.add(docList);
- }
- docList.put(entry.getKey(), entry.getValue());
- lastCommitWithin = commitWithin;
- lastOverwrite = overwrite;
- }
- }
-
- if (docIterator != null) {
- docList = new LinkedHashMap<>();
- docLists.add(docList);
- while (docIterator.hasNext()) {
- SolrInputDocument doc = docIterator.next();
- if (doc != null) {
- docList.put(doc, null);
- }
- }
- }
-
- return docLists;
- }
-
/**
- * @since solr 1.4
+ * @deprecated Method will be removed in Solr 10.0. Use {@link
XMLRequestWriter} instead.
*/
+ @Deprecated(since = "9.9")
public UpdateRequest writeXML(Writer writer) throws IOException {
- List<Map<SolrInputDocument, Map<String, Object>>> getDocLists =
getDocLists(documents);
-
- for (Map<SolrInputDocument, Map<String, Object>> docs : getDocLists) {
-
- if ((docs != null && docs.size() > 0)) {
- Entry<SolrInputDocument, Map<String, Object>> firstDoc =
docs.entrySet().iterator().next();
- Map<String, Object> map = firstDoc.getValue();
- Integer cw = null;
- Boolean ow = null;
- if (map != null) {
- cw = (Integer) firstDoc.getValue().get(COMMIT_WITHIN);
- ow = (Boolean) firstDoc.getValue().get(OVERWRITE);
- }
- if (ow == null) ow = true;
- int commitWithin = (cw != null && cw != -1) ? cw : this.commitWithin;
- boolean overwrite = ow;
- if (commitWithin > -1 || overwrite != true) {
- writer.write(
- "<add commitWithin=\"" + commitWithin + "\" " + "overwrite=\"" +
overwrite + "\">");
- } else {
- writer.write("<add>");
- }
-
- Set<Entry<SolrInputDocument, Map<String, Object>>> entries =
docs.entrySet();
- for (Entry<SolrInputDocument, Map<String, Object>> entry : entries) {
- ClientUtils.writeXML(entry.getKey(), writer);
- }
-
- writer.write("</add>");
- }
- }
-
- // Add the delete commands
- boolean deleteI = deleteById != null && deleteById.size() > 0;
- boolean deleteQ = deleteQuery != null && deleteQuery.size() > 0;
- if (deleteI || deleteQ) {
- if (commitWithin > 0) {
- writer.append("<delete
commitWithin=\"").append(String.valueOf(commitWithin)).append("\">");
- } else {
- writer.append("<delete>");
- }
- if (deleteI) {
- for (Map.Entry<String, Map<String, Object>> entry :
deleteById.entrySet()) {
- writer.append("<id");
- Map<String, Object> map = entry.getValue();
- if (map != null) {
- Long version = (Long) map.get(VER);
- String route = (String) map.get(_ROUTE_);
- if (version != null) {
- writer.append("
version=\"").append(String.valueOf(version)).append('"');
- }
-
- if (route != null) {
- writer.append(" _route_=\"").append(route).append('"');
- }
- }
- writer.append(">");
-
- XML.escapeCharData(entry.getKey(), writer);
- writer.append("</id>");
- }
- }
- if (deleteQ) {
- for (String q : deleteQuery) {
- writer.append("<query>");
- XML.escapeCharData(q, writer);
- writer.append("</query>");
- }
- }
- writer.append("</delete>");
- }
+ XMLRequestWriter requestWriter = new XMLRequestWriter();
+ requestWriter.writeXML(this, writer);
return this;
}
- // --------------------------------------------------------------------------
- // --------------------------------------------------------------------------
-
// --------------------------------------------------------------------------
Review Comment:
as you are cleaning things up; maybe these horizontal dividers are no longer
useful (if they ever were)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]