示例#1
0
  private static String toXml(Object objVo, ConsructionHeadVO consructionHeadVO) throws Exception {
    StringBuffer sb = new StringBuffer();

    String ENDL = "\n";
    String TABLE = "\t";
    String strVo = "";
    String strHead = "";

    strHead = TEST.headVoToXml(consructionHeadVO);

    // 构造XML
    sb.append(TABLE).append("<Root>").append(ENDL);

    // 报文头
    sb.append(TABLE).append(strHead);

    // 数据区数据
    sb.append(TABLE).append("<Body>").append(ENDL);

    // 数据区数据取得
    strVo = TEST.VoToXml(objVo);
    sb.append(TABLE).append(strVo);
    sb.append(TABLE).append("</Body>").append(ENDL);

    sb.append(TABLE).append("</Root>").append(ENDL);

    return sb.toString();
  }
 private JSONObject makeJson() {
   response.setContentType("text/json");
   JSONObject jsonObject = new JSONObject();
   String attributes[] =
       new String[] {
         TEST.toString(),
         PropertySEARCH,
         PropertyEDIT,
         PropertyPROPERTIES,
         PropertyVERSIONS,
         PropertyREFACTOR,
         PropertyWHERE_USED,
         PropertyRECENT_CHANGES,
         SUITE.toString(),
         PropertyPRUNE,
         PropertySECURE_READ,
         PropertySECURE_WRITE,
         PropertySECURE_TEST,
         PropertyFILES
       };
   for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);
   if (pageData.hasAttribute(PropertyHELP)) {
     jsonObject.put(PropertyHELP, pageData.getAttribute(PropertyHELP));
   }
   if (pageData.hasAttribute(PropertySUITES)) {
     JSONArray tags = new JSONArray();
     for (String tag : pageData.getAttribute(PropertySUITES).split(",")) {
       if (StringUtils.isNotBlank(tag)) {
         tags.put(tag.trim());
       }
     }
     jsonObject.put(PropertySUITES, tags);
   }
   return jsonObject;
 }
示例#3
0
  /** Retrieves the currently active singleton instance of {@link ConfidentialStore}. */
  public static @Nonnull ConfidentialStore get() {
    if (TEST != null) return TEST.get();

    Jenkins j = Jenkins.getInstance();
    if (j == null) {
      throw new IllegalStateException(
          "cannot initialize confidential key store until Jenkins has started");
    }
    Lookup lookup = j.lookup;
    ConfidentialStore cs = lookup.get(ConfidentialStore.class);
    if (cs == null) {
      try {
        List<ConfidentialStore> r =
            (List)
                Service.loadInstances(
                    ConfidentialStore.class.getClassLoader(), ConfidentialStore.class);
        if (!r.isEmpty()) cs = r.get(0);
      } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to list up ConfidentialStore implementations", e);
        // fall through
      }

      if (cs == null)
        try {
          cs = new DefaultConfidentialStore();
        } catch (Exception e) {
          // if it's still null, bail out
          throw new Error(e);
        }

      cs = lookup.setIfNull(ConfidentialStore.class, cs);
    }
    return cs;
  }
示例#4
0
  /**
   * 将RyJbxx转换为xml格式的字符串
   *
   * @param head XML的头名字<head>..</head>
   * @return 返回XML字符串
   * @throws Exception
   */
  public static String toXml(String head, ConsructionHeadVO headVo, Consruction1104RequestVO rj)
      throws Exception {

    StringBuffer sb = new StringBuffer();
    Field[] field = rj.getClass().getDeclaredFields();
    String ENDL = "\n";
    String TABLE = "\t";
    String name = "";

    for (int i = 0; i < field.length; i++) {
      // 跳过表态属性
      String mod = Modifier.toString(field[i].getModifiers());
      if (mod.indexOf("static") != -1) {
        continue;
      }
      name = TEST.FirstStringToUpperCase(field[i].getName());
      Method m = rj.getClass().getMethod("get" + name);
      String value = (String) m.invoke(rj);
      // 构造XML
      sb.append(TABLE)
          .append("<")
          .append(name)
          .append(">")
          .append(value)
          .append("</")
          .append(name)
          .append(">")
          .append(ENDL);
    }
    return "<" + head + ">" + sb.toString() + "</" + head + ">";
  }
 @Test
 public void testDefaultAttributesForSuitePageNames() throws Exception {
   WikiPage suitePage3 = WikiPageUtil.addPage(root, PathParser.parse("TestPageSuite"));
   PageData data = suitePage3.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
 @Test
 public void testThatTestAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage testPage2 = WikiPageUtil.addPage(root, PathParser.parse("PageTest"));
   PageData data = testPage2.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
 @Test
 public void testThatSuiteAtBeginningOfNameSetsSuiteProperty() throws Exception {
   WikiPage suitePage1 = WikiPageUtil.addPage(root, PathParser.parse("SuitePage"));
   PageData data = suitePage1.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
 @Test
 public void testDefaultAttributesForNormalPageNames() throws Exception {
   WikiPage normalPage = WikiPageUtil.addPage(root, PathParser.parse("NormalPage"));
   PageData data = normalPage.getData();
   assertTrue(data.hasAttribute(PropertyEDIT));
   assertTrue(data.hasAttribute(PropertySEARCH));
   assertTrue(data.hasAttribute(PropertyVERSIONS));
   assertTrue(data.hasAttribute(PropertyFILES));
   assertFalse(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
  public static PageType fromWikiPage(WikiPage page) {
    PageData data = page.getData();
    if (data.hasAttribute(SUITE.toString())) {
      return SUITE;
    }

    if (data.hasAttribute(TEST.toString())) {
      return TEST;
    }

    return STATIC;
  }
示例#10
0
  /**
   * 将VO转换为xml格式的字符串
   *
   * @return 返回XML字符串
   * @throws Exception
   */
  public static String headVoToXml(ConsructionHeadVO consructionHeadVO) throws Exception {

    StringBuffer sb = new StringBuffer();

    String ENDL = "\n";
    String TABLE = "\t";
    String strVo = "";
    strVo = TEST.VoToXml(consructionHeadVO);

    // 构造XML
    sb.append(TABLE).append("<head>").append(ENDL);
    sb.append(TABLE).append(strVo);
    sb.append(TABLE).append("</head>").append(ENDL);

    return sb.toString();
  }
示例#11
0
  private JSONObject makeJson() {
    response.setContentType("text/json");
    JSONObject jsonObject = new JSONObject();
    String attributes[] =
        new String[] {
          TEST.toString(),
          PropertySEARCH,
          PropertyEDIT,
          PropertyPROPERTIES,
          PropertyVERSIONS,
          PropertyREFACTOR,
          PropertyWHERE_USED,
          PropertyRECENT_CHANGES,
          SUITE.toString(),
          PropertyPRUNE,
          PropertySECURE_READ,
          PropertySECURE_WRITE,
          PropertySECURE_TEST
        };
    for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);

    return jsonObject;
  }
示例#12
0
  /**
   * 将VO转换为xml格式的字符串
   *
   * @param strVo
   * @return 返回XML字符串
   * @throws Exception
   */
  public static String VoToXml(Object objVo) throws Exception {

    StringBuffer sb = new StringBuffer();
    Field[] field = objVo.getClass().getDeclaredFields();
    String ENDL = "\n";
    String TABLE = "\t";
    String name = "";

    for (int i = 0; i < field.length; i++) {
      // 跳过表态属性
      String mod = Modifier.toString(field[i].getModifiers());
      if (mod.indexOf("static") != -1) {
        continue;
      }
      name = TEST.FirstStringToUpperCase(field[i].getName());
      Method m = objVo.getClass().getMethod("get" + name);
      String value = (String) m.invoke(objVo);

      // 当value是null的时候,变成“”
      if (StringUtil.isBlank(value)) {
        value = "";
      }

      // 构造XML
      sb.append(TABLE)
          .append("<")
          .append(name)
          .append(">")
          .append(value)
          .append("</")
          .append(name)
          .append(">")
          .append(ENDL);
    }
    return sb.toString();
  }
示例#13
0
 @Test
 public void testThatExampleAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("PageExample"));
   PageData data = page.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
 }