public Order createOrderFromAssets(WebPageRequest inReq) {
    String catalogId = inReq.findValue("catalogid");
    MediaArchive archive = getMediaArchive(catalogId);
    String[] assetids = inReq.getRequestParameters("assetid");
    Order order =
        getOrderManager()
            .createNewOrder(inReq.findValue("applicationid"), catalogId, inReq.getUserName());

    for (int i = 0; i < assetids.length; i++) {
      String id = assetids[i];
      if (id.startsWith("multiedit:hits")) {
        HitTracker hits = (HitTracker) inReq.getSessionValue(id.substring("multiedit:".length()));
        if (hits != null) {
          for (Iterator iterator = hits.iterator(); iterator.hasNext(); ) {
            Data data = (Data) iterator.next();
            Asset asset = archive.getAssetBySourcePath(data.getSourcePath());
            getOrderManager().addItemToOrder(catalogId, order, asset, null);
          }
        }
      } else {
        Asset asset = archive.getAsset(id);
        getOrderManager().addItemToOrder(catalogId, order, asset, null);
      }
    }

    getOrderManager().saveOrder(catalogId, inReq.getUser(), order);
    inReq.putPageValue("order", order);

    return order;
  }
  public void toggleItemInOrderBasket(WebPageRequest inReq) {
    MediaArchive archive = getMediaArchive(inReq);
    Order basket = loadOrderBasket(inReq);
    String assetid = inReq.getRequestParameter("assetid");

    Asset asset = archive.getAsset(assetid, inReq);

    getOrderManager().toggleItemInOrder(archive, basket, asset);
  }
  /**
   * @param inArchive
   * @param inAssetID
   * @throws StoreException
   */
  protected void deleteAsset(MediaArchive inArchive, String inAssetID) {
    // String id = findAssetId(tabs[5],tabs[4],catName);

    Asset product = inArchive.getAsset(inAssetID);
    if (product == null) {
      inArchive.getAssetSearcher().deleteFromIndex(inAssetID); // Just in case index is out of date
    } else {
      String sourcePath = product.getSourcePath();
      Page thumb = inArchive.getCreatorManager().getThumbImageFile(sourcePath);
      Page medium = inArchive.getCreatorManager().getMediumImageFile(sourcePath);
      getPageManager().removePage(thumb);
      getPageManager().removePage(medium);

      inArchive.getAssetSearcher().deleteFromIndex(inAssetID);
      inArchive.getAssetArchive().deleteAsset(product);
      inArchive.getAssetArchive().clearAsset(product);
    }
  }
  public Data addItemToOrderBasket(WebPageRequest inReq) {
    MediaArchive archive = getMediaArchive(inReq);
    Order basket = loadOrderBasket(inReq);
    String[] assetids = inReq.getRequestParameters("assetid");
    String[] fields = inReq.getRequestParameters("field");
    Map props = new HashMap();
    if (fields != null) {
      for (int i = 0; i < fields.length; i++) {
        String key = fields[i];
        String value = inReq.getRequestParameter(key + ".value");
        props.put(key, value);
      }
    }

    for (int i = 0; i < assetids.length; i++) {
      String assetid = assetids[i];
      Asset asset = archive.getAsset(assetid);
      getOrderManager().addItemToOrder(archive.getCatalogId(), basket, asset, props);
    }

    return basket;
  }