Пример #1
0
 /**
  * 解析用户是否满足条件 ,判断条件的值有3中来源,分别为组织结构中、表单字段中和标准值 ${currentTransactorName} operator.text.et
  * '吴荣[wurong]' ${currentTransactorName} operator.text.et '${documentCreatorName}'
  * ${currentTransactorName} operator.text.et '${field[姓名[name]]}
  */
 public static boolean parseUser(String atomicExpress, String loginName) {
   if (StringUtils.contains(atomicExpress, TextOperator.NET.getCode())) {
     String userLoginName = StringUtils.substringBetween(atomicExpress, "'", "'").trim();
     return !loginName.equals(userLoginName);
   } else if (StringUtils.contains(atomicExpress, TextOperator.ET.getCode())) {
     String userLoginName = StringUtils.substringBetween(atomicExpress, "'", "'").trim();
     return loginName.equals(userLoginName);
   }
   return false;
 }
Пример #2
0
 /** 解析用户和工作组的关系 */
 public static boolean parseWorkGroup(String atomicExpress, String loginName) {
   if (StringUtils.contains(atomicExpress, TextOperator.NET.getCode())) {
     String workGroupName = StringUtils.substringBetween(atomicExpress, "'", "'").trim();
     return !userInWorkGroup(ContextUtils.getCompanyId(), loginName, workGroupName);
   } else if (StringUtils.contains(atomicExpress, TextOperator.ET.getCode())) {
     String workGroupName = StringUtils.substringBetween(atomicExpress, "'", "'").trim();
     return userInWorkGroup(ContextUtils.getCompanyId(), loginName, workGroupName);
   }
   return false;
 }
Пример #3
0
 public String getPrice(String html) {
   String price = "";
   String[] tmpPrice = StringUtils.substringsBetween(html, "tdfamilia", "</td>");
   for (String tp : tmpPrice) {
     String strPrice = StringUtils.substringBetween(tp, "valor_tarifa_seg", "/>");
     if (strPrice != null) {
       price = StringUtils.substringBetween(strPrice, "value=\"", "\"");
       break;
     }
   }
   return price;
 }
  /**
   * sqlite의 relation을 만든다.
   *
   * @param userDB
   * @return
   */
  private static List<ReferencedTableDAO> makeSQLiteRelation(UserDBDAO userDB) {
    List<ReferencedTableDAO> listRealRefTableDAO = new ArrayList<ReferencedTableDAO>();

    try {
      // 실제 레퍼런스를 생성합니다.
      for (SQLiteRefTableDAO sqliteRefTableDAO : getSQLiteRefTbl(userDB)) {

        int indexKey = StringUtils.indexOf(sqliteRefTableDAO.getSql(), "FOREIGN KEY");
        String forKey = sqliteRefTableDAO.getSql().substring(indexKey);
        if (logger.isDebugEnabled()) logger.debug("\t full text:" + sqliteRefTableDAO.getSql());
        if (logger.isDebugEnabled()) logger.debug("\t=================>[forKeys]\n" + forKey);
        String[] foreignInfo = forKey.split("FOREIGN KEY");

        for (int i = 1; i < foreignInfo.length; i++) {
          try {
            String strForeign = foreignInfo[i];
            if (logger.isDebugEnabled())
              logger.debug("\t ==========================> sub[\n" + strForeign + "]");
            ReferencedTableDAO ref = new ReferencedTableDAO();

            // 테이블 명
            ref.setTable_name(sqliteRefTableDAO.getTbl_name());

            // 컬럼명, 첫번째 ( 시작 부터 ) 끝날때까지...
            String colName = StringUtils.substringBetween(strForeign, "(", ")");

            // 참조 테이블,  REFERENCES 로 시작 하는 다음 부터 (까지
            String refTbName = StringUtils.substringBetween(strForeign, "REFERENCES", "(");

            // 참조 컬럼,  refTbName의 끝나는 것부터 ) 까지...
            String refCol = StringUtils.substringBetween(strForeign, refTbName + "(", ")");

            ref.setColumn_name(moveSpec(colName));
            ref.setReferenced_table_name(moveSpec(refTbName));
            ref.setReferenced_column_name(moveSpec(refCol));

            // sqlite는 인덱스 네임이 없으므로.... 생성합니다.
            ref.setConstraint_name(ref.toString());

            listRealRefTableDAO.add(ref);

          } catch (Exception e) {
            logger.error("SQLLite Relation making", e);
          }
        } // inner if
      } // last for
    } catch (Exception e) {
      logger.error("SQLite Relation check 2", e);
    }

    return listRealRefTableDAO;
  }
Пример #5
0
  @Test
  public void testNginxDockerfileBuilder() throws DockerException, IOException {
    File baseDir =
        new File(Thread.currentThread().getContextClassLoader().getResource("nginx").getFile());

    ClientResponse response = dockerClient.buildImageCmd(baseDir).exec();

    StringWriter logwriter = new StringWriter();

    try {
      LineIterator itr = IOUtils.lineIterator(response.getEntityInputStream(), "UTF-8");
      while (itr.hasNext()) {
        String line = itr.next();
        logwriter.write(line + "\n");
        LOG.info(line);
      }
    } finally {
      IOUtils.closeQuietly(response.getEntityInputStream());
    }

    String fullLog = logwriter.toString();
    assertThat(fullLog, containsString("Successfully built"));

    String imageId = StringUtils.substringBetween(fullLog, "Successfully built ", "\\n\"}").trim();

    ImageInspectResponse imageInspectResponse = dockerClient.inspectImageCmd(imageId).exec();
    assertThat(imageInspectResponse, not(nullValue()));
    LOG.info("Image Inspect: {}", imageInspectResponse.toString());
    tmpImgs.add(imageInspectResponse.getId());

    assertThat(
        imageInspectResponse.getAuthor(),
        equalTo("Guillaume J. Charmes \"[email protected]\""));
  }
Пример #6
0
 public Chunk getCunck(String htmlTags, String text) {
   String cleanedText = text.replaceAll("\\<.*?\\>", "").replaceAll("(?m)^[ \t]*\r?\n", "").trim();
   Chunk result = null;
   float h1_size = 14;
   float h2_size = 13;
   float h3_size = 12;
   float default_size = 11;
   String default_font_style = FontFactory.COURIER;
   int default_font = Font.NORMAL;
   boolean bold = false;
   boolean italic = false;
   boolean href = false;
   boolean underline = false;
   if (htmlTags.indexOf("<b>") != -1) {
     bold = true;
   }
   if (htmlTags.indexOf("href") != -1) {
     href = true;
     underline = true;
   }
   if (htmlTags.indexOf("<strong>") != -1) {
     bold = true;
   }
   if (htmlTags.indexOf("<em>") != -1) {
     italic = true;
   }
   if (htmlTags.indexOf("<i>") != -1) {
     italic = true;
   }
   if (htmlTags.indexOf("<h1>") != -1) {
     bold = true;
     default_size = h1_size;
   }
   if (htmlTags.indexOf("<h2>") != -1) {
     bold = true;
     default_size = h2_size;
   }
   if (htmlTags.indexOf("<h3>") != -1) {
     bold = true;
     default_size = h3_size;
   }
   if (bold && italic) {
     default_font = Font.BOLDITALIC;
   } else if (italic) {
     default_font = Font.ITALIC;
   } else if (bold) {
     default_font = Font.BOLD;
   } else if (underline) {
     default_font = Font.UNDERLINE;
   }
   result =
       new Chunk(
           cleanedText,
           FontFactory.getFont(
               default_font_style, default_size, default_font, new Color(0, 0, 0)));
   if (href) {
     result.setAnchor(StringUtils.substringBetween(htmlTags, "href=\"", "\""));
   }
   return result;
 }
Пример #7
0
  public static Map<String, String> getTranslateAttrs(String transAttr) {
    Map<String, String> result = new HashMap<String, String>();
    if (transAttr == null) {
      return result;
    }
    String tmp = transAttr.replaceAll(" ", ",");
    tmp = tmp.replaceAll(",,", ",");
    String translate = StringUtils.substringBetween(tmp, "translate(", ")");
    String scale = StringUtils.substringBetween(tmp, "scale(", ")");
    String rotate = StringUtils.substringBetween(tmp, "rotate(", ")");
    if (translate != null) {
      String[] txy = translate.split(",");
      if (txy.length == 1) {
        result.put("android:translateX", txy[0]);
      } else if (txy.length > 1) {
        result.put("android:translateX", txy[0]);
        result.put("android:translateY", txy[1]);
      }
    }

    if (scale != null) {
      String[] sxy = scale.split(",");
      if (sxy.length == 1) {
        result.put("android:scaleX", sxy[0]);
        result.put("android:scaleY", sxy[0]);
      } else if (sxy.length > 1) {
        result.put("android:scaleX", sxy[0]);
        result.put("android:scaleY", sxy[1]);
      }
    }

    if (rotate != null) {
      String[] rxy = rotate.split(",");
      if (rxy.length == 1) {
        result.put("android:rotation", rxy[0]);
      } else if (rxy.length == 2) {
        result.put("android:rotation", rxy[0]);
        result.put("android:pivotX", rxy[1]);
      } else if (rxy.length > 2) {
        result.put("android:rotation", rxy[0]);
        result.put("android:pivotX", rxy[1]);
        result.put("android:pivotY", rxy[2]);
      }
    }
    Logger.debug("Attrs Transformer: " + transAttr + " ===> " + result.toString());
    return result;
  }
 protected String getDelegationRoleMemberToJumpTo(HttpServletRequest request) {
   String delegationRoleMemberIdToJumpTo = "";
   String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
   if (StringUtils.isNotBlank(parameterName)) {
     delegationRoleMemberIdToJumpTo = StringUtils.substringBetween(parameterName, ".dmrmi", ".");
   }
   return delegationRoleMemberIdToJumpTo;
 }
 protected String getSelectedAwardNumber(HttpServletRequest request) {
   String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
   if (StringUtils.isNotBlank(parameterName)) {
     return StringUtils.substringBetween(parameterName, ".awardNumber", ".");
   } else {
     return null;
   }
 }
Пример #10
0
  /**
   * Parses the method to call attribute to pick off the line number which should have an action
   * performed on it.
   *
   * @param request the HTTP request
   * @return the line number
   */
  private int getSelectedLine(HttpServletRequest request) {
    int selectedLine = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
      String lineNumber = StringUtils.substringBetween(parameterName, ".line", ".");
      selectedLine = Integer.parseInt(lineNumber);
    }

    return selectedLine;
  }
  /**
   * Will return an array of Strings containing 2 indexes, the first String is the item index and
   * the second String is the account index. These are obtained by parsing the method to call
   * parameter from the request, between the word ".line" and "." The indexes are separated by a
   * semicolon (:)
   *
   * @param request The HttpServletRequest
   * @return An array of Strings containing pairs of two indices, an item index
   */
  protected String[] getSelectedItemNumber(HttpServletRequest request) {
    String itemString = new String();
    String parameterName = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
      itemString = StringUtils.substringBetween(parameterName, ".line", ".");
    }
    String[] result = StringUtils.split(itemString, ":");

    return result;
  }
 /**
  * Parses the method to call parameter passed in as a post parameter
  *
  * <p>The parameter should be something like methodToCall.sort.1.(::;true;::).x, this method will
  * return the value between (::; and ;::) as a boolean
  *
  * @param methodToCallParam the method to call in a format described above
  * @return the value between the delimiters, false if there are no delimiters
  */
 protected boolean parseSearchUsingOnlyPrimaryKeyValues(String methodToCallParam) {
   String searchUsingOnlyPrimaryKeyValuesStr =
       StringUtils.substringBetween(
           methodToCallParam,
           KRADConstants.METHOD_TO_CALL_PARM12_LEFT_DEL,
           KRADConstants.METHOD_TO_CALL_PARM12_RIGHT_DEL);
   if (StringUtils.isBlank(searchUsingOnlyPrimaryKeyValuesStr)) {
     return false;
   }
   return Boolean.parseBoolean(searchUsingOnlyPrimaryKeyValuesStr);
 }
Пример #13
0
 public List<String> getRoles(WorkflowExecution execution) {
   List<String> processedRoles = new ArrayList<>();
   for (String role : roles) {
     if (role.startsWith("${")) {
       processedRoles.add(execution.getVariable(StringUtils.substringBetween(role, "${", "}")));
     } else {
       processedRoles.add(role);
     }
   }
   return processedRoles;
 }
Пример #14
0
 protected int getSelectedBeanIndex(
     HttpServletRequest request, String beanNameOpen, String beanNameClose) {
   int selectedBeanIndex = -1;
   String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
   if (StringUtils.isNotBlank(parameterName)) {
     selectedBeanIndex =
         Integer.parseInt(
             StringUtils.substringBetween(parameterName, beanNameOpen, beanNameClose));
   }
   return selectedBeanIndex;
 }
Пример #15
0
 /**
  * Overrides the method in AccountingLineAuthorizerBase so that the delete button would have both
  * the line item number and the accounting line number for methodToCall when the user clicks on
  * the delete button.
  *
  * @see
  *     org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#getDeleteLineMethod(org.kuali.ole.sys.businessobject.AccountingLine,
  *     java.lang.String, java.lang.Integer)
  */
 @Override
 protected String getDeleteLineMethod(
     AccountingLine accountingLine, String accountingLineProperty, Integer accountingLineIndex) {
   final String infix =
       getActionInfixForExtantAccountingLine(accountingLine, accountingLineProperty);
   String lineNumber =
       StringUtils.substringBetween(accountingLineProperty, "item[", "].sourceAccountingLine");
   if (lineNumber == null) {
     lineNumber = "-2";
   }
   String accountingLineNumber =
       StringUtils.substringBetween(accountingLineProperty, "sourceAccountingLine[", "]");
   return "delete"
       + infix
       + "Line.line"
       + lineNumber
       + ":"
       + accountingLineNumber
       + ".anchoraccounting"
       + infix
       + "Anchor";
 }
Пример #16
0
  /**
   * Read part headers
   *
   * @param in
   * @throws java.io.IOException
   */
  private Hashtable readHeaders(DSpaceTokenStream in) throws IOException {

    Hashtable headers = new Hashtable();
    String hdrline = readln(in);

    while (!"".equals(hdrline)) {
      String name = StringUtils.substringBefore(hdrline, ": ").toLowerCase();
      String value;
      if (hdrline.contains(";")) {
        value = StringUtils.substringBetween(hdrline, ": ", "; ");
      } else {
        value = StringUtils.substringAfter(hdrline, ": ");
      }

      headers.put(name, value);

      hdrline = StringUtils.substringAfter(hdrline, ";");

      // The extra tokenizer.hasMoreTokens() hdrline headers.put
      // handles the filename="" case IE6 submits for an empty
      // upload field.
      while (0 < hdrline.length()) {
        name = StringUtils.substringBetween(hdrline, " ", "=");
        if (hdrline.contains("; ")) {
          value = StringUtils.substringBetween(hdrline, "=\"", "\";");
          hdrline = StringUtils.substringAfter(hdrline, ";");
        } else {
          value = StringUtils.substringBetween(hdrline, "=\"", "\"");
          hdrline = "";
        }

        headers.put(name, value);
      }

      hdrline = readln(in);
    }

    return headers;
  }
Пример #17
0
  @Test
  public void testNetCatDockerfileBuilder()
      throws DockerException, IOException, InterruptedException {
    File baseDir =
        new File(Thread.currentThread().getContextClassLoader().getResource("netcat").getFile());

    ClientResponse response = dockerClient.buildImageCmd(baseDir).exec();

    StringWriter logwriter = new StringWriter();

    try {
      LineIterator itr = IOUtils.lineIterator(response.getEntityInputStream(), "UTF-8");
      while (itr.hasNext()) {
        String line = itr.next();
        logwriter.write(line + "\n");
        LOG.info(line);
      }
    } finally {
      IOUtils.closeQuietly(response.getEntityInputStream());
    }

    String fullLog = logwriter.toString();
    assertThat(fullLog, containsString("Successfully built"));

    String imageId = StringUtils.substringBetween(fullLog, "Successfully built ", "\\n\"}").trim();

    ImageInspectResponse imageInspectResponse = dockerClient.inspectImageCmd(imageId).exec();
    assertThat(imageInspectResponse, not(nullValue()));
    LOG.info("Image Inspect: {}", imageInspectResponse.toString());
    tmpImgs.add(imageInspectResponse.getId());

    ContainerCreateResponse container =
        dockerClient.createContainerCmd(imageInspectResponse.getId()).exec();
    assertThat(container.getId(), not(isEmptyString()));
    dockerClient.startContainerCmd(container.getId()).exec();
    tmpContainers.add(container.getId());

    ContainerInspectResponse containerInspectResponse =
        dockerClient.inspectContainerCmd(container.getId()).exec();

    assertThat(containerInspectResponse.getId(), notNullValue());
    assertThat(containerInspectResponse.getNetworkSettings().getPorts(), notNullValue());

    // No use as such if not running on the server
    for (Ports.Port p : containerInspectResponse.getNetworkSettings().getPorts().getAllPorts()) {
      int port = Integer.valueOf(p.getHostPort());
      LOG.info("Checking port {} is open", port);
      assertThat(available(port), is(false));
    }
    dockerClient.stopContainerCmd(container.getId()).withTimeout(0).exec();
  }
Пример #18
0
 /**
  * Overrides the method in AccountingLineAuthorizerBase so that the balance inquiry button would
  * have both the line item number and the accounting line number for methodToCall when the user
  * clicks on the balance inquiry button.
  *
  * @see
  *     org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#getBalanceInquiryMethod(org.kuali.ole.sys.businessobject.AccountingLine,
  *     java.lang.String, java.lang.Integer)
  */
 @Override
 protected String getBalanceInquiryMethod(
     AccountingLine accountingLine, String accountingLineProperty, Integer accountingLineIndex) {
   final String infix = getActionInfixForNewAccountingLine(accountingLine, accountingLineProperty);
   String lineNumber =
       StringUtils.substringBetween(accountingLineProperty, "item[", "].sourceAccountingLine");
   if (lineNumber == null) {
     lineNumber = "-2";
   }
   String accountingLineNumber =
       StringUtils.substringBetween(accountingLineProperty, "sourceAccountingLine[", "]");
   return "performBalanceInquiryFor"
       + infix
       + "Line.line"
       + ":"
       + lineNumber
       + ":"
       + accountingLineNumber
       + ".anchoraccounting"
       + infix
       + "existingLineLineAnchor"
       + accountingLineNumber;
 }
 private static String extractAttributes(String comment, Map<IssueAttribute, String> attr) {
   String attributesSubstr = StringUtils.substringBetween(comment, "[[", "]]");
   if (!StringUtils.isEmpty(attributesSubstr)) {
     Iterable<String> attributes = Splitter.on(";").split(attributesSubstr);
     for (String attribute : attributes) {
       String[] split = StringUtils.split(attribute, '=');
       if (split.length == 2 && CheckVerifier.ATTRIBUTE_MAP.containsKey(split[0])) {
         attr.put(CheckVerifier.ATTRIBUTE_MAP.get(split[0]), split[1]);
       } else {
         Fail.fail("// Noncompliant attributes not valid: " + attributesSubstr);
       }
     }
   }
   return attributesSubstr;
 }
  /**
   * Add hidden search criteria components.
   *
   * @param lookupCriteriaFields
   */
  protected void addHiddenComponentPostMetadata(
      Map<String, Map<String, Object>> lookupCriteriaFields) {
    for (String hiddenPropertyName : this.getAdditionalHiddenPropertyNames()) {
      hiddenPropertyName =
          StringUtils.substringBetween(
              hiddenPropertyName, UifPropertyPaths.LOOKUP_CRITERIA + "[", "]");

      // Prevent overwriting of visible components. Note, hidden components are allowed to be
      // overwritten.
      if (!lookupCriteriaFields.containsKey(hiddenPropertyName)) {
        Map<String, Object> criteriaAttributes = new HashMap<String, Object>();
        criteriaAttributes.put(UifConstants.LookupCriteriaPostMetadata.HIDDEN, true);
        lookupCriteriaFields.put(hiddenPropertyName, criteriaAttributes);
      }
    }
  }
Пример #21
0
 /**
  * Overrides the method in AccountingLineAuthorizerBase so that the add button would have the line
  * item number in addition to the rest of the insertxxxx String for methodToCall when the user
  * clicks on the add button.
  *
  * @param accountingLine
  * @param accountingLineProperty
  * @return
  */
 @Override
 protected String getAddMethod(AccountingLine accountingLine, String accountingLineProperty) {
   final String infix = getActionInfixForNewAccountingLine(accountingLine, accountingLineProperty);
   String lineNumber = null;
   if (accountingLineProperty.equals(PurapPropertyConstants.ACCOUNT_DISTRIBUTION_NEW_SRC_LINE)) {
     lineNumber = "-2";
   } else {
     lineNumber = StringUtils.substringBetween(accountingLineProperty, "[", "]");
   }
   return "insert"
       + infix
       + "Line.line"
       + lineNumber
       + "."
       + "anchoraccounting"
       + infix
       + "Anchor";
 }
Пример #22
0
 // 新建word/excel
 @Action("office-createOffice")
 public String createOffice() throws Exception {
   WorkflowInstance instance = null;
   WorkflowTask task = null;
   if (id == null) {
     task = ApiFactory.getTaskService().getTask(taskId);
     instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     document.setTaskName(task.getName());
     document.setTaskMode(task.getProcessingMode());
     document.setWorkflowId(instance.getProcessInstanceId());
     document.setCreator(ContextUtils.getLoginName());
     document.setCreatorName(ContextUtils.getUserName());
     document.setCompanyId(ContextUtils.getCompanyId());
     document.setEditType("-1,0,0,0,0,0,1,1"); // 允许编辑,不显示和保留痕迹,允许批注
     document.setPrintSetting(true);
     document.setDownloadSetting(true);
     if (document.getFileType().equalsIgnoreCase("pdf")) {
       return "office-pdf";
     } else {
       String template =
           DefinitionXmlParse.getOfficialTextTemplate(
               instance.getProcessDefinitionId(), task.getName());
       if (StringUtils.isNotEmpty(template))
         document.setTemplateId(Long.valueOf(StringUtils.substringBetween(template, "[", "]")));
       setOfficeRight(document, instance, task);
       return "office-view";
     }
   } else {
     if (taskId == null) {
       instance = workflowInstanceManager.getWorkflowInstance(document.getWorkflowId());
       task = ApiFactory.getTaskService().getTask(instance.getFirstTaskId());
     } else {
       task = ApiFactory.getTaskService().getTask(taskId);
       instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     }
     setOfficeRight(document, instance, task);
     if (document.getFileType().equalsIgnoreCase("pdf")) {
       return "office-pdf";
     } else {
       return "office-view";
     }
   }
 }
Пример #23
0
  private String dockerfileBuild(File baseDir, String expectedText)
      throws DockerException, IOException {

    // Build image
    ClientResponse response = dockerClient.buildImageCmd(baseDir).exec();

    StringWriter logwriter = new StringWriter();

    try {
      LineIterator itr = IOUtils.lineIterator(response.getEntityInputStream(), "UTF-8");
      while (itr.hasNext()) {
        String line = itr.next();
        logwriter.write(line + "\n");
        LOG.info(line);
      }
    } finally {
      IOUtils.closeQuietly(response.getEntityInputStream());
    }

    String fullLog = logwriter.toString();
    assertThat(fullLog, containsString("Successfully built"));

    String imageId = StringUtils.substringBetween(fullLog, "Successfully built ", "\\n\"}").trim();

    // Create container based on image
    ContainerCreateResponse container = dockerClient.createContainerCmd(imageId).exec();

    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));

    dockerClient.startContainerCmd(container.getId()).exec();
    dockerClient.waitContainerCmd(container.getId()).exec();

    tmpContainers.add(container.getId());

    // Log container
    ClientResponse logResponse = logContainer(container.getId());

    assertThat(logResponseStream(logResponse), containsString(expectedText));

    return container.getId();
  }
Пример #24
0
 public ActionForward deleteAccount(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   // Remove the travel account at the index specified in the "methodToCall" parameter.
   TravelDocumentForm2 travelForm = (TravelDocumentForm2) form;
   String strIndex =
       StringUtils.substringBetween(
           (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE),
           KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL,
           KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
   if (StringUtils.isNotBlank(strIndex)) {
     ((TravelDocument2) travelForm.getDocument())
         .getTravelAccounts()
         .remove(Integer.parseInt(strIndex));
   }
   return mapping.findForward(RiceConstants.MAPPING_BASIC);
 }
Пример #25
0
  private static void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder)
      throws XMLStreamException {
    SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
    while (line.getNext() != null) {
      int lineId = Integer.parseInt(line.getAttrValue("number"));
      try {
        builder.setHits(lineId, (int) parseNumber(line.getAttrValue("hits"), ENGLISH));
      } catch (ParseException e) {
        throw new XmlParserException(e);
      }

      String isBranch = line.getAttrValue("branch");
      String text = line.getAttrValue("condition-coverage");
      if (StringUtils.equals(isBranch, "true") && StringUtils.isNotBlank(text)) {
        String[] conditions = StringUtils.split(StringUtils.substringBetween(text, "(", ")"), "/");
        builder.setConditions(
            lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
      }
    }
  }
  protected void collectExpectedIssues(String comment, int line) {
    String expectedStart = getExpectedIssueTrigger();
    if (comment.startsWith(expectedStart)) {
      String cleanedComment = StringUtils.remove(comment, expectedStart);

      EnumMap<IssueAttribute, String> attr = new EnumMap<>(IssueAttribute.class);
      String expectedMessage = StringUtils.substringBetween(cleanedComment, "{{", "}}");
      if (StringUtils.isNotEmpty(expectedMessage)) {
        attr.put(IssueAttribute.MESSAGE, expectedMessage);
      }
      int expectedLine = line;
      String attributesSubstr = extractAttributes(comment, attr);

      cleanedComment =
          StringUtils.stripEnd(
              StringUtils.remove(
                  StringUtils.remove(cleanedComment, "[[" + attributesSubstr + "]]"),
                  "{{" + expectedMessage + "}}"),
              " \t");
      if (StringUtils.startsWith(cleanedComment, "@")) {
        final int lineAdjustment;
        final char firstChar = cleanedComment.charAt(1);
        final int endIndex = cleanedComment.indexOf(' ');
        if (endIndex == -1) {
          lineAdjustment = Integer.parseInt(cleanedComment.substring(2));
        } else {
          lineAdjustment = Integer.parseInt(cleanedComment.substring(2, endIndex));
        }
        if (firstChar == '+') {
          expectedLine += lineAdjustment;
        } else if (firstChar == '-') {
          expectedLine -= lineAdjustment;
        } else {
          Fail.fail("Use only '@+N' or '@-N' to shifts messages.");
        }
      }
      updateEndLine(expectedLine, attr);
      expected.put(expectedLine, attr);
    }
  }
 /**
  * Evaluates the condition.
  *
  * @param condition the condition like "lt IE 7"
  * @param browserVersion the browser version. Note that currently it can only be an IE browser.
  * @return the evaluation result
  */
 public static boolean evaluate(String condition, final BrowserVersion browserVersion) {
   condition = condition.trim();
   if ("IE".equals(condition)) {
     return true;
   } else if ("true".equals(condition)) {
     return true;
   } else if ("false".equals(condition)) {
     return false;
   } else if (condition.contains("&")) {
     return evaluate(StringUtils.substringBefore(condition, "&"), browserVersion)
         && evaluate(StringUtils.substringAfter(condition, "&"), browserVersion);
   } else if (condition.contains("|")) {
     return evaluate(StringUtils.substringBefore(condition, "|"), browserVersion)
         || evaluate(StringUtils.substringAfter(condition, "|"), browserVersion);
   } else if (condition.startsWith("!")) {
     return !evaluate(condition.substring(1), browserVersion);
   } else if (condition.startsWith("IE")) {
     final String currentVersion = Float.toString(browserVersion.getBrowserVersionNumeric());
     return currentVersion.startsWith(condition.substring(2).trim());
   } else if (condition.startsWith("lte IE")) {
     return browserVersion.getBrowserVersionNumeric() <= parseVersion(condition.substring(6));
   } else if (condition.startsWith("lt IE")) {
     return browserVersion.getBrowserVersionNumeric() < parseVersion(condition.substring(5));
   } else if (condition.startsWith("gt IE")) {
     return browserVersion.getBrowserVersionNumeric() > parseVersion(condition.substring(5));
   } else if (condition.startsWith("gte IE")) {
     return browserVersion.getBrowserVersionNumeric() >= parseVersion(condition.substring(6));
   } else if (condition.startsWith("lt")) {
     return true;
   } else if (condition.startsWith("gt")) {
     return false;
   } else if (condition.startsWith("(")) {
     // in fact not fully correct if () can be nested
     return evaluate(StringUtils.substringBetween(condition, "(", ")"), browserVersion);
   } else {
     return false;
   }
 }
Пример #28
0
 private Item createItemFromModelItem(ModelItem modelItem) {
   GenericItem item = null;
   if (modelItem instanceof ModelGroupItem) {
     ModelGroupItem modelGroupItem = (ModelGroupItem) modelItem;
     String baseItemType = modelGroupItem.getType();
     GenericItem baseItem = createItemOfType(baseItemType, modelGroupItem.getName());
     if (baseItem != null) {
       ModelGroupFunction function = modelGroupItem.getFunction();
       if (function == null) {
         item = new GroupItem(modelGroupItem.getName(), baseItem);
       } else {
         item = applyGroupFunction(baseItem, modelGroupItem, function);
       }
     } else {
       item = new GroupItem(modelGroupItem.getName());
     }
   } else {
     ModelNormalItem normalItem = (ModelNormalItem) modelItem;
     String itemName = normalItem.getName();
     item = createItemOfType(normalItem.getType(), itemName);
   }
   if (item != null) {
     String label = modelItem.getLabel();
     String format = StringUtils.substringBetween(label, "[", "]");
     if (format != null) {
       label = StringUtils.substringBefore(label, "[").trim();
       stateDescriptions.put(
           modelItem.getName(), new StateDescription(null, null, null, format, false, null));
     }
     item.setLabel(label);
     item.setCategory(modelItem.getIcon());
     assignTags(modelItem, item);
     return item;
   } else {
     return null;
   }
 }
  @Override
  public ActionForward performLookup(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // parse out the business object name from our methodToCall parameter
    String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    String boClassName =
        StringUtils.substringBetween(
            fullParameter,
            KFSConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL,
            KFSConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL);

    if (!StringUtils.equals(boClassName, GeneralLedgerPendingEntry.class.getName())) {
      return super.performLookup(mapping, form, request, response);
    }

    String path = super.performLookup(mapping, form, request, response).getPath();
    path = path.replaceFirst(KFSConstants.LOOKUP_ACTION, KFSConstants.GL_MODIFIED_INQUIRY_ACTION);

    return new ActionForward(path, true);
  }
Пример #30
0
  public Object iso8583ToObject(ISOMsg msg, Map<String, String> mappings) {
    Object res = null;
    try {
      for (String key : mappings.keySet()) {
        String[] paths = parseObjPath(key);
        String oPath = paths[0];
        String thisName = paths[1];

        debug("================oPath=" + oPath + ", att=" + thisName);

        // this is to save the "Document." from mapping rule
        // todo is there a better way?
        // TODO this is not generic enough
        Object obj = findObject("Document." + oPath);

        String mapto = mappings.get(key);
        Object value = null;
        if (!mapto.contains(MAP_ISO_PREFIX)) {
          // not a ISO mapping
          value = mapto;
        } else {
          Integer fldno =
              Integer.valueOf(StringUtils.substringBetween(mapto, MAP_ISO_PREFIX, MAP_ISO_SURFIX));

          value = Iso8583Util.getField(msg, fldno);
        }

        // the leaf node itself is a List (of Strings?) see 101 RemittanceInformation5.ustrd
        if (thisName.contains("[")) {
          if (value == null) {
            // ISO msg does not contain the mapping field
            // TODO what to do?
            // now just neglect
          } else {
            String fName = StringUtils.substringBefore(thisName, "[");
            Collection collection = (Collection) PropertyUtils.getProperty(obj, fName);
            collection.add(value);
          }
        } else {
          Field field = obj.getClass().getDeclaredField(thisName);
          Class type = field.getType();
          debug("type=" + type);

          if (value == null) {
            // ISO msg does not contain the mapping field
            // TODO what to do?
            // now just neglect
          } else if (type.isEnum()) {
            Object[] values = type.getEnumConstants();
            Method m = type.getDeclaredMethod("fromValue", String.class);
            value = m.invoke(obj, (String) value);
          }

          BeanUtils.setProperty(obj, thisName, value);
        }
      }

      res = pool.get(rootName);

    } catch (Exception ex) {
      ex.printStackTrace();
      throw new RuntimeException(ex);
    }
    return res;
  }