Exemplo n.º 1
0
 /**
  * 通过Title 查询是相似分类信息
  *
  * @param xml
  * @return
  * @throws DocumentException
  */
 public static List<TradingReseCategory> selectCategoryByKey(String xml) throws Exception {
   List<TradingReseCategory> litrc = new ArrayList();
   // 商品分类目录查询
   Document document = formatStr2Doc(xml);
   Element rootElt = document.getRootElement();
   if (rootElt == null) {
     return litrc;
   }
   Element recommend = rootElt.element("SuggestedCategoryArray");
   if (recommend == null) {
     return litrc;
   }
   Iterator<Element> ite = recommend.elementIterator("SuggestedCategory");
   while (ite.hasNext()) {
     Element ele = ite.next();
     Element cate = ele.element("Category");
     Element PercentItemFound = ele.element("PercentItemFound");
     TradingReseCategory trc = new TradingReseCategory();
     trc.setId(Long.parseLong(cate.elementText("CategoryID")));
     trc.setCategoryId(cate.elementText("CategoryID"));
     Iterator<Element> ites = cate.elementIterator("CategoryParentName");
     String cateName = "";
     while (ites.hasNext()) {
       Element ent = ites.next();
       cateName = cateName + ent.getText() + ":";
     }
     trc.setCategoryKey(PercentItemFound.getText() + "%");
     trc.setCategoryName(cateName + cate.elementText("CategoryName"));
     litrc.add(trc);
   }
   return litrc;
 }
Exemplo n.º 2
0
 /**
  * 得到反馈信息列表
  *
  * @param xml
  * @return
  * @throws DocumentException
  */
 public static List<TradingFeedBackDetail> getFeedBackListElement(String xml) throws Exception {
   List<TradingFeedBackDetail> lifb = new ArrayList();
   Document document = formatStr2Doc(xml);
   Element rootElt = document.getRootElement();
   Element recommend = rootElt.element("FeedbackDetailArray");
   Iterator<Element> iter = recommend.elementIterator("FeedbackDetail");
   while (iter.hasNext()) {
     Element element = iter.next();
     TradingFeedBackDetail tfbd = new TradingFeedBackDetail();
     tfbd.setCommentinguser(element.elementText("CommentingUser"));
     tfbd.setCommentinguserscore(Long.parseLong(element.elementText("CommentingUserScore")));
     tfbd.setCommenttext(
         StringEscapeUtils.escapeXml(element.element("CommentText").getStringValue()));
     tfbd.setCommenttime(DateUtils.returnDate(element.elementText("CommentTime")));
     tfbd.setCommenttype(element.elementText("CommentType"));
     tfbd.setItemid(element.elementText("ItemID"));
     tfbd.setRole(element.elementText("Role"));
     tfbd.setFeedbackid(element.elementText("FeedbackID"));
     tfbd.setTransactionid(element.elementText("TransactionID"));
     tfbd.setOrderlineitemid(element.elementText("OrderLineItemID"));
     tfbd.setItemtitle(element.elementText("ItemTitle"));
     tfbd.setCreateTime(new Date());
     if (element.elementText("ItemPrice") != null) {
       tfbd.setItemprice(Double.parseDouble(element.elementText("ItemPrice")));
     }
     lifb.add(tfbd);
   }
   return lifb;
 }
Exemplo n.º 3
0
  /**
   * 通过Title 商品所属分类查询
   *
   * @param xml
   * @param key
   * @return
   * @throws DocumentException
   */
  public static List<TradingReseCategory> selectCategoryBytitle(String xml, String key)
      throws Exception {
    List<TradingReseCategory> litrc = new ArrayList();
    // 之前是做商品所属分类查询
    Document document = formatStr2Doc(xml);
    Element rootElt = document.getRootElement();
    Element recommend = rootElt.element("searchResult");
    Iterator<Element> iter = recommend.elementIterator("item");
    while (iter.hasNext()) {
      Element ele = iter.next();
      Element elecate = ele.element("primaryCategory");
      TradingReseCategory trc = new TradingReseCategory();
      trc.setId(Long.parseLong(elecate.elementText("categoryId")));
      trc.setCategoryId(elecate.elementText("categoryId"));
      trc.setCategoryName(StringEscapeUtils.escapeHtml(elecate.elementText("categoryName")));
      trc.setCategoryKey(key);
      litrc.add(trc);
    }

    return litrc;
  }
Exemplo n.º 4
0
  /**
   * Returns the Clearspace user id the user by username.
   *
   * @param username Username to retrieve ID of.
   * @return The ID number of the user in Clearspace.
   * @throws org.jivesoftware.openfire.user.UserNotFoundException If the user was not found.
   */
  protected long getUserID(String username) throws UserNotFoundException {
    // Gets the part before of @ of the username param
    if (username.contains("@")) {
      // User's id are only for local users
      if (!XMPPServer.getInstance().isLocal(new JID(username))) {
        throw new UserNotFoundException("Cannot load user of remote server: " + username);
      }
      username = username.substring(0, username.lastIndexOf("@"));
    }

    // Checks if it is in the cache
    if (userIDCache.containsKey(username)) {
      return userIDCache.get(username);
    }

    // Un-escape username.
    String unescapedUsername = JID.unescapeNode(username);
    // Encode potentially non-ASCII characters
    unescapedUsername = URLUTF8Encoder.encode(unescapedUsername);
    // Gets the user's ID from Clearspace
    try {
      String path = ClearspaceUserProvider.USER_URL_PREFIX + "users/" + unescapedUsername;
      Element element =
          executeRequest(org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET, path);

      Long id = Long.valueOf(WSUtils.getElementText(element.selectSingleNode("return"), "ID"));

      userIDCache.put(username, id);

      return id;
    } catch (UserNotFoundException unfe) {
      // It is a supported exception, throw it again
      throw unfe;
    } catch (Exception e) {
      // It is not a supported exception, wrap it into a UserNotFoundException
      throw new UserNotFoundException("Unexpected error", e);
    }
  }
Exemplo n.º 5
0
  /**
   * Returns the Clearspace group id of the group.
   *
   * @param groupname Name of the group to retrieve ID of.
   * @return The ID number of the group in Clearspace.
   * @throws org.jivesoftware.openfire.group.GroupNotFoundException If the group was not found.
   */
  protected long getGroupID(String groupname) throws GroupNotFoundException {
    if (groupIDCache.containsKey(groupname)) {
      return groupIDCache.get(groupname);
    }
    try {
      // Encode potentially non-ASCII characters
      groupname = URLUTF8Encoder.encode(groupname);
      String path = ClearspaceGroupProvider.URL_PREFIX + "groups/" + groupname;
      Element element =
          executeRequest(org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET, path);

      Long id = Long.valueOf(WSUtils.getElementText(element.selectSingleNode("return"), "ID"));
      // Saves it into the cache
      groupIDCache.put(groupname, id);

      return id;
    } catch (GroupNotFoundException gnfe) {
      // It is a supported exception, throw it again
      throw gnfe;
    } catch (Exception e) {
      // It is not a supported exception, wrap it into a GroupNotFoundException
      throw new GroupNotFoundException("Unexpected error", e);
    }
  }
Exemplo n.º 6
0
  /**
   * 定时从在线商品中同步数据下来,行成在线数据
   *
   * @param xml
   * @return
   * @throws DocumentException
   */
  public static List<TradingListingData> getItemListElememt(String xml, String ebayAccount)
      throws Exception {
    List li = new ArrayList();
    Document document = formatStr2Doc(xml);
    Element rootElt = document.getRootElement();
    Element recommend = rootElt.element("ItemArray");
    Iterator<Element> iter = recommend.elementIterator("Item");
    String listType = "";
    while (iter.hasNext()) {
      TradingListingData item = new TradingListingData();
      Element element = iter.next();
      item.setTitle(StringEscapeUtils.escapeXml(element.elementText("Title")));
      item.setItemId(element.elementText("ItemID"));
      item.setSite(element.elementText("Site"));
      item.setSku(element.elementText("SKU"));
      item.setEbayAccount(ebayAccount);
      if ("FixedPriceItem".equals(element.elementText("ListingType"))) {
        if (element.element("Variations") != null) {
          listType = "2";
        } else {
          listType = element.elementText("ListingType");
        }
      } else {
        listType = element.elementText("ListingType");
      }
      item.setListingType(listType);
      item.setPrice(
          Double.parseDouble(element.element("SellingStatus").elementText("CurrentPrice")));
      Element shippingdes = element.element("ShippingDetails");
      if (shippingdes != null) {
        List<Element> shippingit = shippingdes.elements("ShippingServiceOptions");
        Element shippingOption = shippingit.get(0);
        if (shippingOption != null) {
          Element option = shippingOption.element("ShippingServiceCost");
          if (option != null) {
            item.setShippingPrice(Double.parseDouble(option.getText()));
          } else {
            item.setShippingPrice(0.00);
          }
        } else {
          item.setShippingPrice(0.00);
        }
      } else {
        item.setShippingPrice(0.00);
      }
      item.setQuantity(
          Long.parseLong(element.elementText("Quantity"))
              - Long.parseLong(element.element("SellingStatus").elementText("QuantitySold")));
      item.setQuantitysold(
          Long.parseLong(element.element("SellingStatus").elementText("QuantitySold")));
      Element elflag = element.element("SellingStatus").element("ListingStatus");
      if (elflag != null) {
        if (elflag.getText().equals("Active")) {
          item.setIsFlag("0");
        } else {
          item.setIsFlag("1");
        }
      } else {
        item.setIsFlag("1");
      }
      item.setSubtitle("");
      item.setBuyitnowprice(
          Double.parseDouble(
              element.element("ListingDetails").elementText("ConvertedBuyItNowPrice")));
      item.setReserveprice(
          Double.parseDouble(
              element.element("ListingDetails").elementText("ConvertedReservePrice")));
      item.setListingduration(element.elementText("ListingDuration"));
      item.setStarttime(
          DateUtils.returnDate(element.element("ListingDetails").elementText("StartTime")));
      item.setEndtime(
          DateUtils.returnDate(element.element("ListingDetails").elementText("EndTime")));
      String url = element.element("PictureDetails").elementText("GalleryURL");

      // item.setPicUrl(url.substring(0,url.lastIndexOf("_")+1)+"14"+url.substring(url.lastIndexOf(".")));
      item.setPicUrl("http://thumbs.ebaystatic.com/pict/" + item.getItemId() + ".jpg");
      li.add(item);
    }
    return li;
  }
Exemplo n.º 7
0
 private void CountInstancesBtnMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_CountInstancesBtnMouseClicked
   // TODO add your handling code here:
   LoggingAreaTA.append("Total: " + Long.toString(InstancesCount()) + " instances");
 } // GEN-LAST:event_CountInstancesBtnMouseClicked