/*
(non-Javadoc)

@see
mtas.solr.handler.component.util.MtasSolrComponent#modifyRequest(org.apache
.solr.handler.component.ResponseBuilder,
org.apache.solr.handler.component.SearchComponent,
org.apache.solr.handler.component.ShardRequest)
485150
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
      ShardRequest sreq) {
    if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)) {
      if (sreq.params.getBool(PARAM_MTAS_KWIC, false)
          && (sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) {
        // do nothing
      } else {
        Set<String> keys = MtasSolrResultUtil
            .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_KWIC);
        sreq.params.remove(PARAM_MTAS_KWIC);
        for (String key : keys) {
          sreq.params
              .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_FIELD);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_TYPE);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_VALUE);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_PREFIX);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_IGNORE);
          sreq.params.remove(PARAM_MTAS_KWIC + "." + key + "."
              + NAME_MTAS_KWIC_QUERY_MAXIMUM_IGNORE_LENGTH);
          sreq.params
              .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_KEY);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_PREFIX);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_NUMBER);
          sreq.params
              .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_LEFT);
          sreq.params
              .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_RIGHT);
          sreq.params.remove(
              PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_OUTPUT);
        }
      }
    }
  }
1280708
@Override
  public ListenableFuture<Table> modifyColumnFamilyAsync(ModifyColumnFamiliesRequest request) {
    return createUnaryListener(request, modifyColumnFamilyRpc, request.getName()).getAsyncResult();
  }
1006112
@Override
	protected boolean doHandleRequest(final Request request) {
		boolean selected = getRequestValue(request);
		boolean current = getValue();

		boolean changed = current != selected;

		if (changed) {
			setData(selected);
		}

		return changed;
	}
982447
public SearchResponse search(SearchRequest request) {
    return call(
      new GetRequest(path("search"))
        .setParam("gateId", request.getGateId())
        .setParam("organization", request.getOrganization())
        .setParam("page", request.getPage())
        .setParam("pageSize", request.getPageSize())
        .setParam("query", request.getQuery())
        .setParam("selected", request.getSelected()),
      SearchResponse.parser());
  }
526495
private void handleExpansionRequest(final Request request) {
		String[] paramValue = request.getParameterValues(getId() + ".expanded");

		if (paramValue == null) {
			paramValue = new String[0];
		}

		String[] expandedRows = removeEmptyStrings(paramValue);

		List<Integer> oldExpansions = getExpandedRows();
		List<Integer> expansions;

		TableDataModel model = getDataModel();

		if (model.getRowCount() == 0) {
			setExpandedRows(new ArrayList<Integer>());
			return;
		} else if (getPaginationMode() == PaginationMode.NONE
				|| getPaginationMode() == PaginationMode.CLIENT
				|| oldExpansions == null) {
			expansions = new ArrayList<>(expandedRows.length);
		} else {
			// row expansions only apply to the current page
			expansions = new ArrayList<>(oldExpansions);

			int startRow = getCurrentPageStartRow();
			int endRow = getCurrentPageEndRow();
			expansions.removeAll(getRowIds(startRow, endRow));
		}

		for (String expandedRow : expandedRows) {
			try {
				expansions.add(Integer.parseInt(expandedRow));
			} catch (NumberFormatException e) {
				LOG.warn("Invalid row id for expansion: " + expandedRow);
			}
		}

		// For tree tables, we also have to tell the nodes to expand themselves
		if (model instanceof TreeTableDataModel) {
			TreeTableDataModel treeModel = (TreeTableDataModel) model;

			// We need the expanded indices sorted, as expanding/collapsing sections alters row indices
			Collections.sort(expansions);

			for (int row = 0; row < treeModel.getRowCount(); row++) {
				for (Iterator<TreeNode> i = treeModel.getNodeAtLine(row).depthFirst(); i.hasNext();) {
					TableTreeNode node = (TableTreeNode) i.next();
					node.setExpanded(false);
				}
			}

			for (int i = expansions.size() - 1; i >= 0; i--) {
				treeModel.getNodeAtLine(expansions.get(i)).setExpanded(true);
			}
		}

		setExpandedRows(expansions);
	}
1104141
@Override
	public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
		sec.getUserProperties().put(Constants.HANDSHAKEREQUEST, request);
		super.modifyHandshake(sec, request, response);
	}
1208318
private void addQueryParams(final Request request) {
        if (absoluteDateCreated != null) {
            request.addQueryParam("DateCreated", absoluteDateCreated.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeDateCreated != null) {
            request.addQueryDateRange("DateCreated", rangeDateCreated);
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
179496
protected void appendRequestHandler(SolrQuery solrQuery, @Nullable String requestHandler) {
		if (StringUtils.isNotBlank(requestHandler)) {
			solrQuery.add(CommonParams.QT, requestHandler);
		}
	}
1119297
public static HttpRequestHeader changeMethod(String method, String header, String body) throws URIException, HttpMalformedHeaderException {
		HttpRequestHeader hrh = new HttpRequestHeader(header);
		URI uri = hrh.getURI();
		String prevMethod = hrh.getMethod();
		if (prevMethod.equalsIgnoreCase(method)) {
			return hrh;
		}
		if (prevMethod.equals(HttpRequestHeader.POST)) {
			// Was POST, move all params onto the URL
			if (body != null && body.length() > 0) {
				StringBuilder sb = new StringBuilder();
				if (uri.getQuery() != null) {
					sb.append(uri.getQuery());
				}

				String [] params = body.split("&");
				for (String param : params) {
					if (sb.length() > 0) {
						sb.append('&');
					}
					String[] nv = param.split("=");
					if (nv.length == 1) {
						// This effectively strips out the equals if theres no value 
						sb.append(nv[0]);
					} else {
						sb.append(param);
					}
				}
				uri.setQuery(sb.toString());

			}
			hrh.setURI(uri);
			// Clear the body
			body = "";

		} else if (method.equals(HttpRequestHeader.POST)) {
			// To be a port, move all URL query params into the body
			String query = uri.getQuery();
			if (query != null) {
				StringBuilder sb = new StringBuilder();
				String [] params = query.split("&");
				for (String param : params) {
					if (sb.length() > 0) {
						sb.append('&');
					}
					sb.append(param);
					String[] nv = param.split("=");
					if (nv.length == 1) {
						// Cope with URL params with no values e.g. http://www.example.com/test?key
						sb.append('=');
					}
				}
				// fixed: dead store to variable body by commenting the following line
				// body = sb.toString();
				uri.setQuery(null);
				hrh.setURI(uri);
			}
		}
		hrh.setMethod(method);
		
		return hrh;
	}
749283
public void modifyingRequest( final String requestId ) {
        if ( _log.isDebugEnabled() ) {
            _log.debug( "Registering modifying request: " + requestId );
        }
        incrementOrPut( _blacklist, requestId );
        _readOnlyRequests.remove( requestId );
    }
508047
public void addRequest(RecordRequest request) {
        if (request.getRequestSize() + getRequestSize() > 248) {
            throw new IllegalArgumentException();
        }

        if (records == null) {
            records = new RecordRequest[1];
        }
        else {
            RecordRequest old[] = records;
            records = new RecordRequest[old.length + 1];

            System.arraycopy(old, 0, records, 0, old.length);
        }
        records[records.length - 1] = request;

        setDataLength(getRequestSize());
    }
394618
private void addQueryParams(final Request request) {
        if (log != null) {
            request.addQueryParam("Log", log.toString());
        }

        if (absoluteMessageDate != null) {
            request.addQueryParam("MessageDate", absoluteMessageDate.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeMessageDate != null) {
            request.addQueryDateRange("MessageDate", rangeMessageDate);
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
1231609
public synchronized void setRequest(HttpServletRequest request) {

        if (perThreadRequest == null) {
            perThreadRequest = new ThreadLocal<HttpServletRequest>();
        }
        perThreadRequest.set(request);
    }
818047
private void addQueryParams(final Request request) {
        if (order != null) {
            request.addQueryParam("Order", order.toString());
        }

        if (from != null) {
            request.addQueryParam("From", from);
        }

        if (bounds != null) {
            request.addQueryParam("Bounds", bounds.toString());
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
366076
public void changeSelected(String selectNode, ServletRequest request)
    {
        _selectedNode = TreeHelpers.changeSelected(this, _selectedNode, selectNode, request);
    }
210118
private void addPostParams(final Request request) {
        if (roleSid != null) {
            request.addPostParam("RoleSid", roleSid);
        }

        if (lastConsumedMessageIndex != null) {
            request.addPostParam("LastConsumedMessageIndex", lastConsumedMessageIndex.toString());
        }
    }
1049783
private void updateRequestContextInfo() {

        if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) {
            m_cmsObject.getRequestContext().setAttribute(
                CmsRequestUtil.HEADER_LAST_MODIFIED,
                m_flexContextInfoList.get(m_flexContextInfoList.size() - 1));
        }
    }