List of usage examples for org.apache.commons.lang StringUtils stripToEmpty
public static String stripToEmpty(String str)
Strips whitespace from the start and end of a String returning an empty String if null
input.
From source file:com.da.daum.DaumCafeBungList.java
protected void executeURL(String p_page, String p_author_id, String p_gnum) throws IOException, ClientProtocolException, URISyntaxException { HttpClient httpclient = null;//from w w w . j a v a 2s.c o m try { httpclient = getPoolHttpClient(); String responseBody = ""; String strUrl = ""; String file = ""; //httpclient.setRedirectHandler(new spaceRedirectHandler()); List<DaumListVo> lst = null; executeLogin(httpclient); this.parser = new DaumCafeBungParser(); int max_page = 10000; int init_page = 1; p_page = "1"; String viewBody = ""; if (!"".equals(StringUtils.stripToEmpty(p_page))) { init_page = Integer.parseInt(p_page); } String output = "", bodyAndComment = ""; InputStream istream; for (int i = init_page; i < max_page; i++) { lst = getBoardList(httpclient, String.valueOf(i)); if (lst.size() < 1) { break; } for (DaumListVo vo : lst) { strUrl = host_url + vo.getViewUrl(); System.out.println("========================================="); System.out.println(strUrl); System.out.println("========================================="); file = SAVE_DIR + DaumCafeBungParser.boardType + "/" + vo.getRnum() + "." + vo.getSubject() + "_" + vo.getIdAlais().replaceAll("\\*", "").replaceAll("\\/", "_") + "_" + vo.getCreatYmd() + "" + ".txt"; System.out.println("save file:" + file); // ? responseBody = execGetUrl(httpclient, strUrl); //? ? saveImageFile(httpclient, responseBody, vo); // String comment = getSaveComment(httpclient, vo); bodyAndComment = saveViewFile(responseBody, file) + "\r\n\r\n" + comment; FileHelper.createFile(file); FileUtils.writeStringToFile(new File(file), bodyAndComment, "utf-8"); // ? //strUrl+/comments?page=1 // ? ? . /316 //strUrl = host_url+"/CHILIL/LPN/"+vo.getRnum()+"/comments?page=1"; // List<DaumListVo> lstComment = parser.setDaumListVoCommentList(responseBody, "316", commentPageMap); } } } catch (Exception ex) { ex.printStackTrace(System.out); System.out.println("ERROR: " + ex.getLocalizedMessage()); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } }
From source file:com.da.daum.DaumCafeLevelUpList.java
protected void executeURL(String p_page, String p_author_id, String p_gnum) throws IOException, ClientProtocolException, URISyntaxException { HttpClient httpclient = null;/* w w w . j a v a2s. co m*/ try { httpclient = getPoolHttpClient(); String responseBody = ""; String strUrl = ""; String file = ""; //httpclient.setRedirectHandler(new spaceRedirectHandler()); List<DaumListVo> lst = null; executeLogin(httpclient); this.parser = new DaumCafeLevelUpParser(); int max_page = 10000; int init_page = 1; p_page = "1"; String viewBody = ""; if (!"".equals(StringUtils.stripToEmpty(p_page))) { init_page = Integer.parseInt(p_page); } String output = "", bodyAndComment = ""; InputStream istream; String body = ""; String comment = ""; StringBuilder sb = new StringBuilder(); for (int i = init_page; i < max_page; i++) { lst = getBoardList(httpclient, String.valueOf(i)); if (lst.size() < 1) { break; } for (DaumListVo vo : lst) { strUrl = host_url + vo.getViewUrl(); System.out.println("========================================="); System.out.println(strUrl); System.out.println("========================================="); /*file = SAVE_DIR+DaumCafeLevelUpParser.boardType+"/"+vo.getRnum()+"."+vo.getSubject()+"_" +vo.getIdAlais().replaceAll("\\*", "").replaceAll("\\/", "_") +"_"+vo.getCreatYmd()+"" +".txt";*/ file = SAVE_DIR + DaumCafeLevelUpParser.boardType + "/" + vo.getRnum() + "." + vo.getIdAlais().replaceAll("\\*", "").replaceAll("\\/", "_") + "_" + vo.getCreatYmd() + "" + ".txt"; System.out.println("save file:" + file); // ? responseBody = execGetUrl(httpclient, strUrl); //? ? saveImageFile(httpclient, responseBody, vo); // comment = getComment(httpclient, vo); body = saveViewFile(responseBody, file); //?? // .?() =?? =B // . = 011-9645-6141 // . = (? ). //.??( =71.2.22 ) ?~~ // (? = ) ??? ?^^ /* * * . -? . -AB . ?- 090-7634-9430 . ? ? -? .. ?? ??青? ?.??(?= ==4.17 ) */ /*try { int nName = body.indexOf(". "); String name = body.substring(nName+7,nName+11); sb.append(name+","); System.out.println("name:"+name); nName = body.indexOf(". "); name = body.substring(nName+7,nName+9); sb.append(name+","); System.out.println("name:"+name); nName = body.indexOf(". ?"); name = body.substring(nName+8,nName+20); sb.append(name+","); System.out.println("name:"+name); nName = body.indexOf("?.??("); name = body.substring(nName+5,nName+23); sb.append(name+"\r\n"); System.out.println("name:"+name); }catch(Exception ex){}*/ // bodyAndComment = body + "\r\n\r\n" + comment; FileHelper.createFile(file); FileUtils.writeStringToFile(new File(file), bodyAndComment, "utf-8"); } } } catch (Exception ex) { ex.printStackTrace(System.out); System.out.println("ERROR: " + ex.getLocalizedMessage()); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } }
From source file:com.da.daum.DaumCafeBungImgList.java
protected void executeURL(String p_page, String p_author_id, String p_gnum) throws IOException, ClientProtocolException, URISyntaxException { HttpClient httpclient = null;//from ww w . j a va 2s . c o m try { httpclient = getPoolHttpClient(); String responseBody = ""; String strUrl = ""; String file = ""; //httpclient.setRedirectHandler(new spaceRedirectHandler()); List<DaumListVo> lst = null; executeLogin(httpclient); this.parser = new DaumCafeBungImgParser(); int max_page = 10000; int init_page = 1; p_page = "1"; String viewBody = ""; if (!"".equals(StringUtils.stripToEmpty(p_page))) { init_page = Integer.parseInt(p_page); } String output = ""; InputStream istream; for (int i = init_page; i < max_page; i++) { lst = getBoardList(httpclient, String.valueOf(i)); if (lst.size() < 1) { break; } for (DaumListVo vo : lst) { strUrl = host_url + vo.getViewUrl(); System.out.println("========================================="); System.out.println(strUrl); System.out.println("========================================="); file = SAVE_DIR + "/QQN/" + vo.getRnum() + "." + vo.getSubject() + "_" + vo.getIdAlais().replaceAll("\\*", "").replaceAll("\\/", "_") + "_" + vo.getCreatYmd() + "" + ".txt"; System.out.println("save file:" + file); responseBody = execGetUrl(httpclient, strUrl); //? ? Matcher match = pattern_img.matcher(responseBody); int idx = 0; while (match.find()) { String imgUrl = match.group(1); if (!"http://m1.daumcdn.net/cafeimg/mobile/320/v02/common/2010/blue/daumlogo.gif" .equals(imgUrl)) { idx++; // System.out.println("imgUrl:"+imgUrl); istream = getDownloadUrlInputStream(httpclient, imgUrl); output = SAVE_DIR + "/QQN/" + vo.getRnum() + "_" + String.valueOf(idx) + ".jpg"; fileDownCopy(output, istream); if (istream != null) { istream.close(); } } } saveViewFile(responseBody, file); } } } catch (Exception ex) { ex.printStackTrace(System.out); System.out.println("ERROR: " + ex.getLocalizedMessage()); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } }
From source file:com.da.img.SoStroyInfoList.java
private List<ImageVo> getBoardList(DefaultHttpClient httpclient, HttpGet httpget, ResponseHandler<String> responseHandler, String p_gnum, String n_page, String p_author_id) throws URISyntaxException, IOException, ClientProtocolException { String listBody = "", viewBody = ""; // String strUrl = // "http://photo.soraspace.info/album/theme/pic_list.php?p_page=1&p_sort=D&p_anum=173&p_gnum=351&p_soption=&p_stxt="; // thskrsns67 // bluesman/*from w w w. j a v a 2 s . c o m*/ /* String strUrl = "http://photo." + SO_URL + "/album/theme/pic_list.php?p_page=" + n_page + "&p_sort=D&p_anum=" + p_anum + "&p_gnum=" + p_gnum + "&p_soption=&p_stxt=";*/ if ("".equals(StringUtils.stripToEmpty(p_author_id))) { p_author_id = "bluesman"; } String strUrl = "http://story." + SO_URL + "/honor/author_board_list.php?p_page=" + n_page + "&p_userid=" + p_author_id; System.out.println("========================================="); System.out.println(strUrl); System.out.println("========================================="); // httpget.setURI(new URI(strUrl)); // lip 689576 // http://photo.soraspace.info/album/theme/pic_list.php?p_page=1&p_sort=D&p_anum=173&p_gnum=481&p_soption=&p_stxt= listBody = getDownloadUrl(httpclient, httpget, responseHandler, strUrl); /* String file = SAVE_DIR+"/list_"+p_author_id+"_"+n_page; System.out.println(file); FileHelper.createFile(file+".txt"); FileUtils.writeStringToFile(new File(file+".txt"), listBody, "utf-8");*/ int nlastIdx = listBody.lastIndexOf( "<img src=\"http://image." + SO_URL + "/common/btn_brd_next.gif\" align=absmiddle></a>"); // System.out.println("nlastIdx:" + nlastIdx); Matcher match = pattern.matcher(listBody); String listurl = ""; String viewurl = ""; String p_num = ""; List<ImageVo> lst = new ArrayList<ImageVo>(); ImageVo vo = null; while (match.find()) { listurl = match.group(1); if (listurl.indexOf("author_board_view.php") == 0) // href ? { vo = new ImageVo(); System.out.println(" ba listurl :" + listurl); String p_storyname = listurl.substring(listurl.indexOf("p_storyname=") + 12, listurl.indexOf("&p_userid=")); System.out.println("p_storyname: " + p_storyname); p_num = listurl.substring(listurl.indexOf("?") + 1, listurl.indexOf("&")); p_num = p_num.replaceAll("p_num=", ""); System.out.println(" ba p_num :" + p_num); vo.setFileName(SAVE_DIR + "/" + p_author_id + "_" + p_storyname + "_" + p_num + ".txt"); p_storyname = URLEncoder.encode(p_storyname, "euc-kr"); listurl = listurl.substring(0, listurl.indexOf("&p_grade=")); listurl = listurl + "&p_storyname=" + p_storyname + "&p_userid=" + p_author_id; //URLEncoder.encode(p_url, "utf-8"); // System.out.println("story_url+listurl: "+story_url+listurl); try { // httpget = executeLogin(httpclient); viewBody = getDownloadUrl(httpclient, httpget, responseHandler, story_url + listurl); String file = vo.getFileName(); System.out.println(file); FileHelper.createFile(file); FileUtils.writeStringToFile(new File(file), viewBody, "utf-8"); viewBody = viewBody.substring(viewBody.indexOf("<!-- START ? -->"), viewBody.indexOf("<!-- END -->")); viewBody = htmlRemove(viewBody); viewBody = viewBody.replaceAll(""", ""); FileHelper.createFile(vo.getFileName()); FileUtils.writeStringToFile(new File(vo.getFileName()), viewBody, "utf-8"); // lastindex if (nlastIdx > -1) { lst.add(vo); } } catch (Exception ex) { System.out.println(ex.getLocalizedMessage()); } } } return lst; }
From source file:com.adobe.acs.commons.workflow.process.impl.WorkflowDelegationStep.java
private WorkflowModel getWorkflowModel(WorkflowSession workflowSession, String workflowModelId) { workflowModelId = StringUtils.stripToEmpty(workflowModelId); WorkflowModel workflowModel = null;//ww w .j a v a 2 s. c om if (StringUtils.isNotBlank(workflowModelId)) { if (!workflowModelId.endsWith("/jcr:content/model")) { ResourceResolver resourceResolver = workflowHelper.getResourceResolver(workflowSession); Resource resource = resourceResolver.getResource(workflowModelId + "/jcr:content/model"); if (resource != null && StringUtils.equals( resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class), "cq:WorkflowModel")) { workflowModelId = resource.getPath(); } } try { workflowModel = workflowSession.getModel(workflowModelId); } catch (WorkflowException e) { log.warn("Could not find Workflow Model for [ {} ]", workflowModelId); } } return workflowModel; }
From source file:com.activecq.tools.flipbook.components.impl.FlipbookServiceImpl.java
public String getReadme(final Component component, final ResourceResolver resourceResolver) { String contents = ""; final Resource cr = resourceResolver.resolve(component.getPath()); final Resource flipbook = cr.getChild(COMPONENT_FLIPBOOK_NODE); if (flipbook == null) { return contents; }/*from www . j a va 2s . c om*/ Resource readme = null; for (String name : README_NAMES) { final Resource tmp = flipbook.getChild(name); if (tmp != null && ResourceUtil.isA(tmp, JcrConstants.NT_FILE)) { // Use the first README nt:file node found readme = tmp; break; } } try { if (readme != null) { final Node node = readme.adaptTo(Node.class); final Node jcrContent = node.getNode(JcrConstants.JCR_CONTENT); final InputStream content = jcrContent.getProperty(JcrConstants.JCR_DATA).getBinary().getStream(); try { contents = IOUtils.toString(content); } catch (IOException e) { contents = "Could not read README"; } /* Handle markdown */ if (StringUtils.endsWith(readme.getName(), ".md")) { contents = new PegDownProcessor().markdownToHtml(contents); } else if (StringUtils.endsWith(readme.getName(), ".txt")) { // Wrap .txt with PRE tags contents = "<pre>" + contents + "</pre>"; } } } catch (RepositoryException ex) { contents = "Could not read README"; } catch (NullPointerException ex) { contents = "Could not read README"; } return StringUtils.stripToEmpty(contents); }
From source file:com.da.daum.DaumCafeImgAllList.java
protected void executeURL(String p_page, String p_author_id, String p_gnum) throws IOException, ClientProtocolException, URISyntaxException { HttpClient httpclient = null;/*from w w w . jav a 2 s .c om*/ try { httpclient = getPoolHttpClient(); String responseBody = ""; String strUrl = ""; String file = ""; executeLogin(httpclient); this.parser = new DaumCafeBungImgParser(); int max_page = 10000; int init_page = 188; p_page = "188"; if (!"".equals(StringUtils.stripToEmpty(p_page))) { init_page = Integer.parseInt(p_page); } String output = ""; String next_page = ""; InputStream istream; int idx = 0; for (int i = init_page; i < max_page; i++) { if (i == init_page) { //strUrl = "http://cafe308.daum.net/_c21_/image_bbs_read?grpid=i6V&fldid=_album&page=&prev_page=&firstbbsdepth=&lastbbsdepth=&contentval=000Hzzzzzzzzzzzzzzzzzzzzzzzzzz&datanum=1115&edge=&listnum="; //15 //strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=_album&listnum=&datanum=1073&contentval=000HJzzzzzzzzzzzzzzzzzzzzzzzzz"; //75 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=_album&listnum=&datanum=847&contentval=000Dfzzzzzzzzzzzzzzzzzzzzzzzzz"; //207 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=_album&listnum=&datanum=373&contentval=00061zzzzzzzzzzzzzzzzzzzzzzzzz"; // strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&fldid=QQN&page=1&prev_page=0&firstbbsdepth=&lastbbsdepth=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz&contentval=0007szzzzzzzzzzzzzzzzzzzzzzzzz&datanum=488&edge=F&listnum=15"; //4 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=QQN&listnum=&datanum=478&contentval=0007izzzzzzzzzzzzzzzzzzzzzzzzz"; //63 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=QQN&listnum=&datanum=313&contentval=00053zzzzzzzzzzzzzzzzzzzzzzzzz"; //166 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=QQN&listnum=&datanum=55&contentval=0000tzzzzzzzzzzzzzzzzzzzzzzzzz"; //188 strUrl = "http://cafe308.daum.net/_c21_/album_read?grpid=i6V&mgrpid=&fldid=QQN&listnum=&datanum=2&contentval=00002zzzzzzzzzzzzzzzzzzzzzzzzz"; } else { strUrl = next_page; } Thread.sleep(1500); //System.out.println("strUrl:"+strUrl); responseBody = execGetUrl(httpclient, strUrl); Matcher match_next = pattern.matcher(responseBody); while (match_next.find()) { next_page = match_next.group(1); next_page = "http://cafe308.daum.net/_c21_/album_read" + next_page.replaceAll("&", "&"); } System.out.println("strUrl " + String.valueOf(i) + ":" + strUrl); //? ? Matcher match = pattern_img.matcher(responseBody); while (match.find()) { String imgUrl = match.group(2); idx++; System.out.println("imgUrl:" + imgUrl); istream = getDownloadUrlInputStream(httpclient, imgUrl); output = SAVE_DIR + "/img/chiLil_" + i + "_" + StringUtils.leftPad(String.valueOf(idx), 10, "0") + ".jpg"; fileDownCopy(output, istream); if (istream != null) { istream.close(); } } //saveViewFile(responseBody, file); } } catch (Exception ex) { ex.printStackTrace(System.out); System.out.println("ERROR: " + ex.getLocalizedMessage()); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } }
From source file:com.da.img.SoStroyAllList.java
private List<ImageVo> getBoardList(DefaultHttpClient httpclient, HttpGet httpget, ResponseHandler<String> responseHandler, String p_gnum, String n_page, String p_author_id) throws URISyntaxException, IOException, ClientProtocolException { String listBody = "", viewBody = ""; // String strUrl = // "http://photo.soraspace.info/album/theme/pic_list.php?p_page=1&p_sort=D&p_anum=173&p_gnum=351&p_soption=&p_stxt="; // thskrsns67 // bluesman//from w w w. jav a2 s.c o m /* String strUrl = "http://photo." + SO_URL + "/album/theme/pic_list.php?p_page=" + n_page + "&p_sort=D&p_anum=" + p_anum + "&p_gnum=" + p_gnum + "&p_soption=&p_stxt=";*/ if ("".equals(StringUtils.stripToEmpty(p_author_id))) { p_author_id = "bluesman"; } String strUrl = "http://story." + SO_URL + "/honor/author_board_list.php?p_page=" + n_page + "&p_userid=" + p_author_id; System.out.println("========================================="); System.out.println(strUrl); System.out.println("========================================="); // httpget.setURI(new URI(strUrl)); // lip 689576 // http://photo.soraspace.info/album/theme/pic_list.php?p_page=1&p_sort=D&p_anum=173&p_gnum=481&p_soption=&p_stxt= listBody = getDownloadUrl(httpclient, httpget, responseHandler, strUrl); /* String file = SAVE_DIR+"/list_"+p_author_id+"_"+n_page; System.out.println(file); FileHelper.createFile(file+".txt"); FileUtils.writeStringToFile(new File(file+".txt"), listBody, "utf-8"); */ int nlastIdx = listBody.lastIndexOf( "<img src=\"http://image." + SO_URL + "/common/btn_brd_next.gif\" align=absmiddle></a>"); // System.out.println("nlastIdx:" + nlastIdx); Matcher match = pattern.matcher(listBody); String listurl = ""; String viewurl = ""; String p_num = ""; List<ImageVo> lst = new ArrayList<ImageVo>(); ImageVo vo = null; while (match.find()) { listurl = match.group(1); if (listurl.indexOf("author_board_view.php") == 0) // href ? { vo = new ImageVo(); System.out.println(" ba listurl :" + listurl); String p_storyname = listurl.substring(listurl.indexOf("p_storyname=") + 12, listurl.indexOf("&p_userid=")); System.out.println("p_storyname: " + p_storyname); p_num = listurl.substring(listurl.indexOf("?") + 1, listurl.indexOf("&")); p_num = p_num.replaceAll("p_num=", ""); System.out.println(" ba p_num :" + p_num); vo.setFileName(SAVE_DIR + "/" + p_author_id + "_" + p_storyname + "_" + p_num + ".txt"); p_storyname = URLEncoder.encode(p_storyname, "euc-kr"); listurl = listurl.substring(0, listurl.indexOf("&p_grade=")); listurl = listurl + "&p_storyname=" + p_storyname + "&p_userid=" + p_author_id; //URLEncoder.encode(p_url, "utf-8"); //System.out.println("story_url+listurl: "+story_url+listurl); try { viewBody = getDownloadUrl(httpclient, httpget, responseHandler, story_url + listurl); viewBody = viewBody.substring(viewBody.indexOf("<!-- START ? -->"), viewBody.indexOf("<!-- END -->")); viewBody = htmlRemove(viewBody); viewBody = viewBody.replaceAll(""", ""); FileHelper.createFile(vo.getFileName()); FileUtils.writeStringToFile(new File(vo.getFileName()), viewBody, "utf-8"); // lastindex if (nlastIdx > -1) { lst.add(vo); } } catch (Exception ex) { System.out.println(ex.getLocalizedMessage()); } } } return lst; }
From source file:com.activecq.api.ActiveForm.java
/** * Build and ActiveForm object from the provided SlingHttpServletRequest * - Inspects Request Attributes and Query Parameters * * @param <T>/*from w w w . ja va 2 s. c o m*/ * @param request * @param properties A list of keys used to pull data from the Request */ public <T extends ActiveProperties> ActiveForm(SlingHttpServletRequest request, String... properties) { if (properties == null || properties.length < 1) { for (Object okey : request.getParameterMap().keySet()) { if (okey instanceof String) { String key = (String) okey; this.data.put(key, StringUtils.stripToEmpty(request.getParameter(key))); } } } else { for (String key : properties) { this.data.put(key, StringUtils.stripToEmpty(request.getParameter(key))); } } if (hasIncomingRequestAttributeData(request)) { // Get Form and Errors from Request Attr // This is to handle when the "Forward" method is used final ActiveForm incomingForm = (ActiveForm) request.getAttribute(ActiveForm.CQ_FORM_REQUEST_ATTRIBUTE); this.data = incomingForm.toMap(); this.errors = new ActiveErrors(request); } else if (hasIncomingQueryParamData(request)) { // Get Form and Errors from Query Params // This is to handle the "Redirect" method String formData = request.getRequestParameter(ActiveForm.CQ_FORM).getString(); this.errors = new ActiveErrors(request); if (StringUtils.isNotBlank(formData)) { try { JSONObject jsonForm = new JSONObject(EncodingUtil.decode(formData)); this.data = TypeUtil.toMap(jsonForm); } catch (UnsupportedEncodingException e) { } catch (JSONException e) { } } } }
From source file:com.adobe.acs.tools.explain_query.impl.ExplainQueryServlet.java
private JSONObject explainQuery(final Session session, final String statement, final String language) throws RepositoryException, JSONException { final QueryManager queryManager = session.getWorkspace().getQueryManager(); final JSONObject json = new JSONObject(); final String collectorKey = startCollection(); final QueryResult queryResult; final String effectiveLanguage; final String effectiveStatement; if (language.equals(QUERY_BUILDER)) { effectiveLanguage = XPATH;//from w w w . j a va 2 s . com final String[] lines = StringUtils.split(statement, '\n'); final Map<String, String> params = OsgiPropertyUtil.toMap(lines, "=", false, null, true); final com.day.cq.search.Query query = queryBuilder.createQuery(PredicateGroup.create(params), session); effectiveStatement = query.getResult().getQueryStatement(); } else { effectiveStatement = statement; effectiveLanguage = language; } try { final Query query = queryManager.createQuery("explain " + effectiveStatement, effectiveLanguage); queryResult = query.execute(); } finally { synchronized (this.logCollector) { if (this.logCollector != null) { List<String> logs = this.logCollector.getLogs(collectorKey); json.put("logs", this.logCollector.getLogs(collectorKey)); if (logs.size() == this.logCollector.msgCountLimit) { json.put("logsTruncated", true); } } stopCollection(collectorKey); } } final RowIterator rows = queryResult.getRows(); final Row firstRow = rows.nextRow(); final String plan = firstRow.getValue("plan").getString(); json.put("plan", plan); final JSONArray propertyIndexes = new JSONArray(); final Matcher propertyMatcher = PROPERTY_INDEX_PATTERN.matcher(plan); /* Property Index */ while (propertyMatcher.find()) { final String match = propertyMatcher.group(1); if (StringUtils.isNotBlank(match)) { propertyIndexes.put(StringUtils.stripToEmpty(match)); } } if (propertyIndexes.length() > 0) { json.put("propertyIndexes", propertyIndexes); } final Matcher filterMatcher = FILTER_PATTERN.matcher(plan); if (filterMatcher.find()) { /* Filter (nodeType index) */ propertyIndexes.put("nodeType"); json.put("propertyIndexes", propertyIndexes); json.put("slow", true); } if (StringUtils.contains(plan, " /* traverse ")) { /* Traversal */ json.put("traversal", true); json.put("slow", true); } if (StringUtils.contains(plan, " /* aggregate ")) { /* Aggregate - Fulltext */ json.put("aggregate", true); } return json; }