Guest User

Untitled

a guest
Oct 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. private String getProcPropertiesString(HttpServletRequest request,
  2.             String procName) throws SIEIProxyServletException {
  3.         String propertiesSource = request.getHeader("X-Processor-Props");
  4.  
  5.         if (propertiesSource == null) {
  6.             log.debug("Processor properties are not specified");
  7.             return "";
  8.         }
  9.  
  10.         String[] procsProps = propertiesSource.split("^");
  11.         if (procsProps == null)
  12.             return "";
  13.  
  14.         // TODO: Make it with regex:
  15.         // \[Processor=([A-Za-z0-9_]+)\|(""([^""]+)"":""([^""]+)""\,?)+\]
  16.  
  17.         Pattern pattern = Pattern.compile(
  18.                 "\\[Processor=([A-Za-z0-9_]+)\\|(.)+\\]",
  19.                 Pattern.CASE_INSENSITIVE);
  20.  
  21.         for (String propLine : procsProps) {
  22.             Matcher matcher = pattern.matcher(propLine);
  23.             String processorName = null;
  24.             String processorProps = null;
  25.             boolean foundMatch = matcher.find();
  26.  
  27.             if (foundMatch && matcher.groupCount() == 2) {
  28.                 processorName = matcher.group(1);
  29.             }
  30.             if (processorName != null && procName.equals(processorName)) {
  31.                 CharSequence start = "[Processor=" + processorName + "|";
  32.                 CharSequence whitespace = "";
  33.                 processorProps = propLine.replace(start, whitespace);
  34.                 return processorProps.substring(0, processorProps.length() - 1);
  35.             }
  36.         }
  37.         return "";
  38.     }
Add Comment
Please, Sign In to add comment