org.apache.solr.common.StringUtils Java Examples
The following examples show how to use
org.apache.solr.common.StringUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IstioExecutor.java From istio-apim with Apache License 2.0 | 6 votes |
/** * Build the config for the client */ private Config buildConfig() throws APIManagementException { System.setProperty(TRY_KUBE_CONFIG, "false"); System.setProperty(TRY_SERVICE_ACCOUNT, "true"); ConfigBuilder configBuilder; configBuilder = new ConfigBuilder().withMasterUrl(kubernetesAPIServerUrl); if (!StringUtils.isEmpty(saTokenFileName)) { String token; String tokenFile = saTokenFilePath + "/" + saTokenFileName; try { token = FileUtil.readFileToString(tokenFile); } catch (IOException e) { throw new APIManagementException("Error while reading the SA Token FIle " + tokenFile); } configBuilder.withOauthToken(token); } return configBuilder.build(); }
Example #2
Source File: IstioExecutor.java From istio-apim with Apache License 2.0 | 6 votes |
/** * Verify whether the endpoint url is non empty * * @param endpoints Endpoint objects * @return Returns if endpoint is not empty */ private static boolean isEndpointURLNonEmpty(Object endpoints) { if (endpoints instanceof JSONObject) { JSONObject endpointJson = (JSONObject) endpoints; if (endpointJson.containsKey("url") && endpointJson.get("url") != null) { String url = endpointJson.get("url").toString(); if (org.apache.commons.lang.StringUtils.isNotBlank(url)) { return true; } } } else if (endpoints instanceof org.json.simple.JSONArray) { org.json.simple.JSONArray endpointsJson = (JSONArray) endpoints; for (int i = 0; i < endpointsJson.size(); ++i) { if (isEndpointURLNonEmpty(endpointsJson.get(i))) { return true; } } } return false; }
Example #3
Source File: IstioExecutor.java From istio-apim with Apache License 2.0 | 6 votes |
/** * Extract Endpoint url from the endpoints object * * @param endpoints Endpoints object * @return Returns endpoint url */ private String getEPUrl(Object endpoints) { if (endpoints instanceof JSONObject) { JSONObject endpointJson = (JSONObject) endpoints; if (endpointJson.containsKey("url") && endpointJson.get("url") != null) { String url = endpointJson.get("url").toString(); if (org.apache.commons.lang.StringUtils.isNotBlank(url)) { return url; } } } else if (endpoints instanceof org.json.simple.JSONArray) { org.json.simple.JSONArray endpointsJson = (JSONArray) endpoints; for (int i = 0; i < endpointsJson.size(); ++i) { if (isEndpointURLNonEmpty(endpointsJson.get(i))) { return endpointsJson.get(i).toString(); } } } return ""; }
Example #4
Source File: SpellcheckComponent.java From customized-symspell with MIT License | 6 votes |
private void loadDefault(String unigramsFile, String bigramsFile, String exclusionsFile, SpellChecker spellChecker, SolrCore core, String exclusionListSperatorRegex) { try { if (!StringUtils.isEmpty(unigramsFile)) { loadUniGramFile(core.getResourceLoader().openResource(unigramsFile), spellChecker.getDataHolder()); } if (!StringUtils.isEmpty(bigramsFile)) { loadBiGramFile(core.getResourceLoader().openResource(bigramsFile), spellChecker.getDataHolder()); } if (!StringUtils.isEmpty(exclusionsFile)) { loadExclusions(core.getResourceLoader().openResource(exclusionsFile), spellChecker.getDataHolder(), exclusionListSperatorRegex); } } catch (SpellCheckException | IOException ex) { log.error("Error occured while loading default Configs for Spellcheck"); } }
Example #5
Source File: TestPutSolrContentStream.java From localization_nifi with Apache License 2.0 | 6 votes |
@Test public void testJAASClientAppNameValidation() { final TestRunner runner = TestRunners.newTestRunner(PutSolrContentStream.class); runner.setProperty(PutSolrContentStream.SOLR_TYPE, PutSolrContentStream.SOLR_TYPE_STANDARD.getValue()); runner.setProperty(PutSolrContentStream.SOLR_LOCATION, "http://localhost:8443/solr"); runner.assertValid(); // clear the jaas config system property if it was set final String jaasConfig = System.getProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP); if (!StringUtils.isEmpty(jaasConfig)) { System.clearProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP); } // should be invalid if we have a client name but not config file runner.setProperty(PutSolrContentStream.JAAS_CLIENT_APP_NAME, "Client"); runner.assertNotValid(); // should be invalid if we have a client name that is not in the config file final File jaasConfigFile = new File("src/test/resources/jaas-client.conf"); System.setProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP, jaasConfigFile.getAbsolutePath()); runner.assertNotValid(); // should be valid now that the name matches up with the config file runner.setProperty(PutSolrContentStream.JAAS_CLIENT_APP_NAME, "SolrJClient"); runner.assertValid(); }
Example #6
Source File: NodePreferenceRulesComparator.java From lucene-solr with Apache License 2.0 | 6 votes |
private boolean hasCoreUrlPrefix(Object o, String prefix) { final String s; if (o instanceof String) { s = (String)o; } else if (o instanceof Replica) { s = ((Replica)o).getCoreUrl(); } else { return false; } if (prefix.equals(ShardParams.REPLICA_LOCAL)) { return !StringUtils.isEmpty(localHostAddress) && s.startsWith(localHostAddress); } else { return s.startsWith(prefix); } }
Example #7
Source File: CloudDescriptor.java From lucene-solr with Apache License 2.0 | 6 votes |
public void reload(CloudDescriptor reloadFrom) { if (reloadFrom == null) return; setShardId(StringUtils.isEmpty(reloadFrom.getShardId()) ? getShardId() : reloadFrom.getShardId()); setCollectionName(StringUtils.isEmpty(reloadFrom.getCollectionName()) ? getCollectionName() : reloadFrom.getCollectionName()); setRoles(StringUtils.isEmpty(reloadFrom.getRoles()) ? getRoles() : reloadFrom.getRoles()); if (reloadFrom.getNumShards() != null) { setNumShards(reloadFrom.getNumShards()); } setCoreNodeName(StringUtils.isEmpty(reloadFrom.getCoreNodeName()) ? getCoreNodeName() : reloadFrom.getCoreNodeName()); setLeader(reloadFrom.isLeader); setHasRegistered(reloadFrom.hasRegistered); setLastPublished(reloadFrom.getLastPublished()); for (Map.Entry<String, String> ent : reloadFrom.getParams().entrySet()) { collectionParams.put(ent.getKey(), ent.getValue()); } }
Example #8
Source File: SolrLogLayout.java From lucene-solr with Apache License 2.0 | 6 votes |
private void appendMDC(StringBuilder sb) { if (!StringUtils.isEmpty(MDC.get(NODE_NAME_PROP))) { sb.append(" n:").append(MDC.get(NODE_NAME_PROP)); } if (!StringUtils.isEmpty(MDC.get(COLLECTION_PROP))) { sb.append(" c:").append(MDC.get(COLLECTION_PROP)); } if (!StringUtils.isEmpty(MDC.get(SHARD_ID_PROP))) { sb.append(" s:").append(MDC.get(SHARD_ID_PROP)); } if (!StringUtils.isEmpty(MDC.get(REPLICA_PROP))) { sb.append(" r:").append(MDC.get(REPLICA_PROP)); } if (!StringUtils.isEmpty(MDC.get(CORE_NAME_PROP))) { sb.append(" x:").append(MDC.get(CORE_NAME_PROP)); } }
Example #9
Source File: MDCLoggingContext.java From lucene-solr with Apache License 2.0 | 5 votes |
public static void setTracerId(String traceId) { if (!StringUtils.isEmpty(traceId)) { MDC.put(TRACE_ID, "t:" + traceId); } else { MDC.remove(TRACE_ID); } }
Example #10
Source File: RangerPolicyResourceSignature.java From ranger with Apache License 2.0 | 5 votes |
@Override public String toString() { // invalid/empty policy gets a deterministic signature as if it had an // empty resource string if (!isPolicyValidForResourceSignatureComputation()) { return ""; } int type = RangerPolicy.POLICY_TYPE_ACCESS; if (_policy.getPolicyType() != null) { type = _policy.getPolicyType(); } Map<String, ResourceSerializer> resources = new TreeMap<>(); for (Map.Entry<String, RangerPolicyResource> entry : _policy.getResources().entrySet()) { String resourceName = entry.getKey(); ResourceSerializer resourceView = new ResourceSerializer(entry.getValue()); resources.put(resourceName, resourceView); } String resource = resources.toString(); if (CollectionUtils.isNotEmpty(_policy.getValiditySchedules())) { resource += _policy.getValiditySchedules().toString(); } if (_policy.getPolicyPriority() != null && _policy.getPolicyPriority() != RangerPolicy.POLICY_PRIORITY_NORMAL) { resource += _policy.getPolicyPriority(); } if (!StringUtils.isEmpty(_policy.getZoneName())) { resource += _policy.getZoneName(); } if (_policy.getConditions() != null) { CustomConditionSerialiser customConditionSerialiser = new CustomConditionSerialiser(_policy.getConditions()); resource += customConditionSerialiser.toString(); } String result = String.format("{version=%d,type=%d,resource=%s}", _SignatureVersion, type, resource); return result; }
Example #11
Source File: CatStream.java From lucene-solr with Apache License 2.0 | 5 votes |
public CatStream(String commaDelimitedFilepaths, int maxLines) { if (commaDelimitedFilepaths == null) { throw new IllegalArgumentException("No filepaths provided to stream"); } final String filepathsWithoutSurroundingQuotes = stripSurroundingQuotesIfTheyExist(commaDelimitedFilepaths); if (StringUtils.isEmpty(filepathsWithoutSurroundingQuotes)) { throw new IllegalArgumentException("No filepaths provided to stream"); } this.commaDelimitedFilepaths = filepathsWithoutSurroundingQuotes; this.maxLines = maxLines; }
Example #12
Source File: RealTimeGetComponent.java From lucene-solr with Apache License 2.0 | 5 votes |
private List<Long> resolveVersionRanges(String versionsStr, UpdateLog ulog) { if (StringUtils.isEmpty(versionsStr)) { return Collections.emptyList(); } List<String> ranges = StrUtils.splitSmart(versionsStr, ",", true); // TODO merge ranges. // get all the versions from updatelog and sort them List<Long> versionAvailable = null; try (UpdateLog.RecentUpdates recentUpdates = ulog.getRecentUpdates()) { versionAvailable = recentUpdates.getVersions(ulog.getNumRecordsToKeep()); } // sort versions Collections.sort(versionAvailable, PeerSync.absComparator); // This can be done with single pass over both ranges and versionsAvailable, that would require // merging ranges. We currently use Set to ensure there are no duplicates. Set<Long> versionsToRet = new HashSet<>(ulog.getNumRecordsToKeep()); for (String range : ranges) { String[] rangeBounds = range.split("\\.{3}"); int indexStart = Collections.binarySearch(versionAvailable, Long.valueOf(rangeBounds[1]), PeerSync.absComparator); int indexEnd = Collections.binarySearch(versionAvailable, Long.valueOf(rangeBounds[0]), PeerSync.absComparator); if(indexStart >=0 && indexEnd >= 0) { versionsToRet.addAll(versionAvailable.subList(indexStart, indexEnd + 1)); // indexEnd is exclusive } } // TODO do we need to sort versions using PeerSync.absComparator? return new ArrayList<>(versionsToRet); }
Example #13
Source File: HadoopSSLCredentialProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
public HadoopSSLCredentialProvider(Configuration hadoopConfigurationProvider) { if (StringUtils.isEmpty(System.getProperty(CREDENTIAL_PROVIDER_PATH))) { throw new RuntimeException("Cannot initialize Hadoop configuration provider without credential provider path. Use " + CREDENTIAL_PROVIDER_PATH + " system property to configure."); } this.hadoopConfigurationProvider = hadoopConfigurationProvider; hadoopConfigurationProvider.set(CREDENTIAL_PROVIDER_PATH, System.getProperty(CREDENTIAL_PROVIDER_PATH)); }
Example #14
Source File: OverriddenZkACLAndCredentialsProvidersTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public SolrZkClient getSolrZkClient(String zkServerAddress, int zkClientTimeout) { return new SolrZkClient(zkServerAddress, zkClientTimeout) { @Override protected ZkCredentialsProvider createZkCredentialsToAddAutomatically() { return new DefaultZkCredentialsProvider() { @Override protected Collection<ZkCredentials> createCredentials() { List<ZkCredentials> result = new ArrayList<>(); if (!StringUtils.isEmpty(digestUsername) && !StringUtils.isEmpty(digestPassword)) { result.add(new ZkCredentials("digest", (digestUsername + ":" + digestPassword).getBytes(StandardCharsets.UTF_8))); } return result; } }; } @Override public ZkACLProvider createZkACLProvider() { return new VMParamsAllAndReadonlyDigestZkACLProvider() { @Override protected List<ACL> createNonSecurityACLsToAdd() { return createACLsToAdd(true, digestUsername, digestPassword, digestReadonlyUsername, digestReadonlyPassword); } /** * @return Set of ACLs to return security-related znodes */ @Override protected List<ACL> createSecurityACLsToAdd() { return createACLsToAdd(false, digestUsername, digestPassword, digestReadonlyUsername, digestReadonlyPassword); } }; } }; }
Example #15
Source File: ZipFileResourceTestUtils.java From incubator-atlas with Apache License 2.0 | 5 votes |
public static String getModelJson(String fileName) throws IOException { final String userDir = System.getProperty("user.dir"); String filePath = userDir + "/../addons/models/" + fileName; File f = new File(filePath); String s = FileUtils.readFileToString(f); assertFalse(StringUtils.isEmpty(s), "Model file read correctly!"); return s; }
Example #16
Source File: SolrClientInterceptorTest.java From skywalking with Apache License 2.0 | 5 votes |
@Test public void testGet() throws Throwable { ModifiableSolrParams reqParams = new ModifiableSolrParams(); if (StringUtils.isEmpty(reqParams.get("qt"))) { reqParams.set("qt", new String[] {"/get"}); } reqParams.set("ids", new String[] { "99", "98" }); QueryRequest request = new QueryRequest(reqParams); arguments = new Object[] { request, null, collection }; interceptor.beforeMethod(enhancedInstance, method, arguments, argumentType, null); interceptor.afterMethod(enhancedInstance, method, arguments, argumentType, getGetResponse()); List<TraceSegment> segments = segmentStorage.getTraceSegments(); List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segments.get(0)); Assert.assertEquals(segments.size(), 1); Assert.assertEquals(spans.size(), 1); AbstractTracingSpan span = spans.get(0); querySpanAssert(span, "/get", 1, "solrJ/collection/get"); }
Example #17
Source File: ChangeUserNameUtil.java From ranger with Apache License 2.0 | 5 votes |
public static void main(String[] args) { logger.info("main()"); try { ChangeUserNameUtil loader = (ChangeUserNameUtil) CLIUtil.getBean(ChangeUserNameUtil.class); loader.init(); if (args.length == 3) { userLoginId = args[0]; currentPassword = args[1]; newUserName = args[2]; if(StringUtils.isEmpty(userLoginId)){ System.out.println("Invalid login ID. Exiting!!!"); logger.info("Invalid login ID. Exiting!!!"); System.exit(1); } if(StringUtils.isEmpty(currentPassword)){ System.out.println("Invalid current password. Exiting!!!"); logger.info("Invalid current password. Exiting!!!"); System.exit(1); } if(StringUtils.isEmpty(newUserName)){ System.out.println("Invalid new user name. Exiting!!!"); logger.info("Invalid new user name. Exiting!!!"); System.exit(1); } while (loader.isMoreToProcess()) { loader.load(); } logger.info("Load complete. Exiting!!!"); System.exit(0); }else{ System.out.println("ChangeUserNameUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-username>"); logger.error("ChangeUserNameUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-username>"); System.exit(1); } } catch (Exception e) { logger.error("Error loading", e); System.exit(1); } }
Example #18
Source File: IstioExecutor.java From istio-apim with Apache License 2.0 | 5 votes |
/** * @param parameterMap Map of parameters which passes to the executor */ public void init(Map parameterMap) { if (parameterMap != null) { istioSystemNamespace = (String) parameterMap.get("istioSystemNamespace"); appNamespace = (String) parameterMap.get("appNamespace"); kubernetesAPIServerUrl = (String) parameterMap.get("kubernetesAPIServerUrl"); saTokenFileName = (String) parameterMap.get("saTokenFileName"); saTokenFilePath = (String) parameterMap.get("saTokenFilePath"); kubernetesServiceDomain = (String) parameterMap.get("kubernetesServiceDomain"); } if (StringUtils.isEmpty(istioSystemNamespace)) { istioSystemNamespace = ISTIO_SYSTEM_NAMESPACE; } if (StringUtils.isEmpty(appNamespace)) { appNamespace = APP_NAMESPACE; } if (StringUtils.isEmpty(kubernetesAPIServerUrl)) { kubernetesAPIServerUrl = K8S_MASTER_URL; } if (StringUtils.isEmpty(saTokenFilePath)) { saTokenFilePath = SATOKEN_FILE_PATH; } if (StringUtils.isEmpty(kubernetesServiceDomain)) { kubernetesServiceDomain = K8S_SERVICE_DOMAIN; } }
Example #19
Source File: ZkDynamicConfig.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Parse a raw multi line config string with the full content of znode /zookeeper/config. * @param lines the multi line config string. If empty or null, this will return an empty list * @return an instance of ZkDynamicConfig */ public static ZkDynamicConfig parseLines(String lines) { ZkDynamicConfig zkDynamicConfig = new ZkDynamicConfig(); if (!StringUtils.isEmpty(lines)) { lines.lines().forEach(l -> { if (l.startsWith("version=")) { zkDynamicConfig.version = l.split("=")[1]; } if (l.startsWith("server.")) { zkDynamicConfig.servers.add(Server.parseLine(l)); } }); } return zkDynamicConfig; }
Example #20
Source File: GraphBackedSearchIndexer.java From atlas with Apache License 2.0 | 5 votes |
private void createEdgeLabelUsingLabelName(final AtlasGraphManagement management, final String label) { if (StringUtils.isEmpty(label)) { return; } org.apache.atlas.repository.graphdb.AtlasEdgeLabel edgeLabel = management.getEdgeLabel(label); if (edgeLabel == null) { management.makeEdgeLabel(label); LOG.info("Created edge label {} ", label); } }
Example #21
Source File: Http2SolrClient.java From lucene-solr with Apache License 2.0 | 5 votes |
boolean belongToThisStream(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) { ModifiableSolrParams solrParams = new ModifiableSolrParams(solrRequest.getParams()); if (!origParams.toNamedList().equals(solrParams.toNamedList()) || !StringUtils.equals(origCollection, collection)) { return false; } return true; }
Example #22
Source File: PublicKeyHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
private CryptoKeys.RSAKeyPair createKeyPair(CloudConfig config) throws IOException, InvalidKeySpecException { if (config == null) { return new CryptoKeys.RSAKeyPair(); } String publicKey = config.getPkiHandlerPublicKeyPath(); String privateKey = config.getPkiHandlerPrivateKeyPath(); // If both properties unset, then we fall back to generating a new key pair if (StringUtils.isEmpty(publicKey) && StringUtils.isEmpty(privateKey)) { return new CryptoKeys.RSAKeyPair(); } return new CryptoKeys.RSAKeyPair(new URL(privateKey), new URL(publicKey)); }
Example #23
Source File: VMParamsSingleSetCredentialsDigestZkCredentialsProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected Collection<ZkCredentials> createCredentials() { List<ZkCredentials> result = new ArrayList<ZkCredentials>(); String digestUsername = System.getProperty(zkDigestUsernameVMParamName); String digestPassword = System.getProperty(zkDigestPasswordVMParamName); if (!StringUtils.isEmpty(digestUsername) && !StringUtils.isEmpty(digestPassword)) { result.add(new ZkCredentials("digest", (digestUsername + ":" + digestPassword).getBytes(StandardCharsets.UTF_8))); } return result; }
Example #24
Source File: VMParamsAllAndReadonlyDigestZkACLProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Note: only used for tests */ protected List<ACL> createACLsToAdd(boolean includeReadOnly, String digestAllUsername, String digestAllPassword, String digestReadonlyUsername, String digestReadonlyPassword) { try { List<ACL> result = new ArrayList<ACL>(); // Not to have to provide too much credentials and ACL information to the process it is assumed that you want "ALL"-acls // added to the user you are using to connect to ZK (if you are using VMParamsSingleSetCredentialsDigestZkCredentialsProvider) if (!StringUtils.isEmpty(digestAllUsername) && !StringUtils.isEmpty(digestAllPassword)) { result.add(new ACL(ZooDefs.Perms.ALL, new Id("digest", DigestAuthenticationProvider.generateDigest(digestAllUsername + ":" + digestAllPassword)))); } if (includeReadOnly) { // Besides that support for adding additional "READONLY"-acls for another user if (!StringUtils.isEmpty(digestReadonlyUsername) && !StringUtils.isEmpty(digestReadonlyPassword)) { result.add(new ACL(ZooDefs.Perms.READ, new Id("digest", DigestAuthenticationProvider.generateDigest(digestReadonlyUsername + ":" + digestReadonlyPassword)))); } } if (result.isEmpty()) { result = ZooDefs.Ids.OPEN_ACL_UNSAFE; } return result; } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
Example #25
Source File: SolrZkClient.java From lucene-solr with Apache License 2.0 | 5 votes |
protected ZkCredentialsProvider createZkCredentialsToAddAutomatically() { String zkCredentialsProviderClassName = System.getProperty(ZK_CRED_PROVIDER_CLASS_NAME_VM_PARAM_NAME); if (!StringUtils.isEmpty(zkCredentialsProviderClassName)) { try { log.info("Using ZkCredentialsProvider: {}", zkCredentialsProviderClassName); return (ZkCredentialsProvider)Class.forName(zkCredentialsProviderClassName).getConstructor().newInstance(); } catch (Throwable t) { // just ignore - go default log.warn("VM param zkCredentialsProvider does not point to a class implementing ZkCredentialsProvider and with a non-arg constructor", t); } } log.debug("Using default ZkCredentialsProvider"); return new DefaultZkCredentialsProvider(); }
Example #26
Source File: SolrZkClient.java From lucene-solr with Apache License 2.0 | 5 votes |
protected ZkACLProvider createZkACLProvider() { String zkACLProviderClassName = System.getProperty(ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME); if (!StringUtils.isEmpty(zkACLProviderClassName)) { try { log.info("Using ZkACLProvider: {}", zkACLProviderClassName); return (ZkACLProvider)Class.forName(zkACLProviderClassName).getConstructor().newInstance(); } catch (Throwable t) { // just ignore - go default log.warn("VM param zkACLProvider does not point to a class implementing ZkACLProvider and with a non-arg constructor", t); } } log.debug("Using default ZkACLProvider"); return new DefaultZkACLProvider(); }
Example #27
Source File: SSLConfigurations.java From lucene-solr with Apache License 2.0 | 4 votes |
private boolean isEmpty(String str) { return StringUtils.isEmpty(str); }
Example #28
Source File: Http2SolrClient.java From lucene-solr with Apache License 2.0 | 4 votes |
private ContentType getContentType(Response response) { String contentType = response.getHeaders().get(HttpHeader.CONTENT_TYPE); return StringUtils.isEmpty(contentType)? null : ContentType.parse(contentType); }
Example #29
Source File: ChronixQueryHandler.java From chronix.server with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { LOGGER.debug("Handling request {}", req); final ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams(req.getParams()); final String originQuery = modifiableSolrParams.get(CommonParams.Q); final long[] startAndEnd = dateRangeParser.getNumericQueryTerms(originQuery); final long queryStart = or(startAndEnd[0], -1L, 0L); final long queryEnd = or(startAndEnd[1], -1L, Long.MAX_VALUE); modifiableSolrParams.set(ChronixQueryParams.QUERY_START_LONG, String.valueOf(queryStart)); modifiableSolrParams.set(ChronixQueryParams.QUERY_END_LONG, String.valueOf(queryEnd)); final String query = dateRangeParser.replaceRangeQueryTerms(originQuery); modifiableSolrParams.set(CommonParams.Q, query); //Set the min required fields if the user define a sub set of fields final String fields = modifiableSolrParams.get(CommonParams.FL); modifiableSolrParams.set(CommonParams.FL, requestedFields(fields, req.getSchema().getFields().keySet())); //Set the updated query req.setParams(modifiableSolrParams); //check the filter queries final String[] chronixFunctions = modifiableSolrParams.getParams(ChronixQueryParams.CHRONIX_FUNCTION); final String chronixJoin = modifiableSolrParams.get(ChronixQueryParams.CHRONIX_JOIN); //if we have an function query or someone wants the data as json or a join query if (arrayIsNotEmpty(chronixFunctions) || contains(ChronixQueryParams.DATA_AS_JSON, fields) || !StringUtils.isEmpty(chronixJoin)) { LOGGER.debug("Request is an analysis request."); analysisHandler.handleRequestBody(req, rsp); } else { //let the default search handler do its work LOGGER.debug("Request is a default request"); searchHandler.handleRequestBody(req, rsp); } //add the converted start and end to the response rsp.getResponseHeader().add(ChronixQueryParams.QUERY_START_LONG, queryStart); rsp.getResponseHeader().add(ChronixQueryParams.QUERY_END_LONG, queryEnd); }
Example #30
Source File: ChronixQueryHandler.java From chronix.server with Apache License 2.0 | 4 votes |
private boolean contains(String field, String fields) { return !(StringUtils.isEmpty(field) || StringUtils.isEmpty(fields)) && fields.contains(field); }