コード例 #1
0
 public Boolean canViewAsset(WebPageRequest inReq) {
   //		String orderid = inReq.getRequestParameter("orderid");
   //		if (orderid == null)
   //		{
   //			return false;
   //		}
   Order order = loadOrder(inReq);
   if (order == null) {
     order = (Order) inReq.getSessionValue("vieworder");
   }
   if (order == null) {
     return false;
   }
   Asset asset = getAsset(inReq);
   if (asset == null) {
     log.info("Asset not found");
     return false;
   }
   String catalogid = inReq.findValue("catalogid");
   HitTracker assets = getOrderManager().findOrderItems(inReq, catalogid, order);
   int found = assets.findRow("assetid", asset.getId());
   if (found > -1 && !order.isExpired()) {
     return true;
   }
   return false;
 }
コード例 #2
0
  /* (non-Javadoc)
   * @see com.openedit.action.Command#execute(java.util.Map, java.util.Map)
   */
  public void execute(WebPageRequest inReq) throws OpenEditException {
    configure(inReq);
    Page page = (Page) inReq.getPage(); // urlUtils.requestPath();
    String requestPath = page.getPath();

    if (!inExcludeList(requestPath)) {
      Permission filter = inReq.getPage().getPermission("view");
      if ((filter != null)) {
        if (!filter.passes(inReq)) {
          if (isForbid()) {
            if (inReq.getResponse() != null) {
              inReq.getResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
              inReq.setHasRedirected(true);
            }
          } else {
            log.error("No view permission for " + page.getPath() + " sending redirect");
            inReq.putPageValue(
                "oe-exception", "You do not have permission to view " + page.getPath());

            // this is the original page someone might have been on. Used in login
            inReq.putSessionValue("originalEntryPage", inReq.getContentPage().getPath());
            String fullOriginalEntryPage = (String) inReq.getSessionValue("fullOriginalEntryPage");
            if (fullOriginalEntryPage == null) {
              inReq.putSessionValue("fullOriginalEntryPage", inReq.getPathUrlWithoutContext());
            }
            inReq.redirect(getLoginPath());
          }
        }
      } else {
        log.info("No view restrictions have been set for " + requestPath);
      }
    }
  }
コード例 #3
0
  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;
  }
コード例 #4
0
  /**
   * Is this needed?
   *
   * @deprecated
   * @param inReq
   */
  public void createQuickOrder(WebPageRequest inReq) {

    MediaArchive archive = getMediaArchive(inReq);

    OrderManager manager = getOrderManager();
    String catalogid = inReq.findValue("catalogid");
    Searcher searcher = getSearcherManager().getSearcher(catalogid, "order");
    Searcher itemsearcher = getSearcherManager().getSearcher(catalogid, "orderitem");

    Order order = (Order) searcher.createNewData();
    order.setProperty("userid", inReq.getUserName());
    String quickpublishid = inReq.getRequestParameter("quickid");
    Data publishtemplate = archive.getData("quickpublish", quickpublishid);

    order.setProperty(
        "publishdestination",
        publishtemplate.get(
            "publishdestination")); // assume 0 for most orders, 0 can be told to use Aspera
    searcher.saveData(order, inReq.getUser());

    String hitssessionid = inReq.getRequestParameter("hitssessionid");
    HitTracker hits = (HitTracker) inReq.getSessionValue(hitssessionid);
    for (Iterator iterator = hits.getSelectedHitracker().iterator(); iterator.hasNext(); ) {
      Data hit = (Data) iterator.next();
      Data item = itemsearcher.createNewData();
      item.setProperty("presetid", publishtemplate.get("convertpreset"));
      item.setProperty("assetid", hit.getId());
      item.setProperty("orderid", order.getId());

      item.setId(itemsearcher.nextId());
      itemsearcher.saveData(item, inReq.getUser());
    }

    List assetids =
        manager.addConversionAndPublishRequest(
            inReq, order, archive, new HashMap(), inReq.getUser());
    // OrderHistory history =
    // getOrderManager().createNewHistory(archive.getCatalogId(), order,
    // inReq.getUser(), "pending");
    // history.setAssetIds(assetids);
    // manager.saveOrderWithHistory(archive.getCatalogId(), inReq.getUser(),
    // order, history);
    //		if (assetids.size() > 0)
    //		{
    //			order.setProperty("orderstatus", "ordered");
    //		}
    //		manager.saveOrder(archive.getCatalogId(), inReq.getUser(), order);
    inReq.putPageValue("order", order);
    inReq.putPageValue("data", order);

    log.info("Added conversion and publish requests for order id:" + order.getId());
  }
コード例 #5
0
  public Order createOrderFromData(WebPageRequest inReq) {
    String catalogid = inReq.findValue("catalogid");

    String hitssessionid = inReq.getRequestParameter("hitssessionid");
    String mergefield = inReq.getRequestParameter("mergefield");
    if (mergefield == null) {
      mergefield = "assetid";
    }
    HitTracker datalist = null;
    if (hitssessionid != null) {
      datalist = (HitTracker) inReq.getSessionValue(hitssessionid);
    }

    Searcher itemsearcher = getSearcherManager().getSearcher(catalogid, "orderitem");
    List orderitems = new ArrayList();

    if (datalist.getSelectedHitracker().size() > 0) {
      Map props = new HashMap();

      String applicationid = inReq.findValue("applicationid");
      Order order =
          (Order) getOrderManager().createNewOrder(applicationid, catalogid, inReq.getUserName());
      inReq.putPageValue("order", order);
      inReq.setRequestParameter("orderid", order.getId());

      for (Iterator iterator = datalist.getSelectedHitracker().iterator(); iterator.hasNext(); ) {
        Data hit = (Data) iterator.next();
        String targetid = hit.get(mergefield);
        Asset asset = getMediaArchive(catalogid).getAsset(targetid);
        getOrderManager().addItemToOrder(catalogid, order, asset, null);
      }
      if (order.get("expireson") == null) {
        String days = getMediaArchive(catalogid).getCatalogSettingValue("orderexpiresdays");
        if (days == null) {
          days = "30";
        }
        GregorianCalendar cal = new GregorianCalendar();
        cal.add(Calendar.DAY_OF_YEAR, Integer.parseInt(days));
        order.setProperty(
            "expireson", DateStorageUtil.getStorageUtil().formatForStorage(cal.getTime()));
      }

      getOrderManager().saveOrder(catalogid, inReq.getUser(), order);

      return order;
    } else {
      inReq.setCancelActions(true);
    }

    return null;
  }
コード例 #6
0
  public void removeSelectionFromOrderBasket(WebPageRequest inReq) {
    MediaArchive archive = getMediaArchive(inReq);
    Order basket = loadOrderBasket(inReq);
    String hitssessionid = inReq.getRequestParameter("hitssessionid");
    HitTracker assets = (HitTracker) inReq.getSessionValue(hitssessionid);

    for (Iterator iterator = assets.getSelectedHitracker().iterator(); iterator.hasNext(); ) {

      Data hit = (Data) iterator.next();
      Asset asset = getMediaArchive(archive.getCatalogId()).getAsset(hit.getId());
      getOrderManager().removeItemFromOrder(archive.getCatalogId(), basket, asset);
    }
    inReq.removeSessionValue(hitssessionid);
    loadAssets(inReq);
  }
コード例 #7
0
  public Data addSelectionsToOrderBasket(WebPageRequest inReq) {
    MediaArchive archive = getMediaArchive(inReq);
    Order basket = loadOrderBasket(inReq);
    String hitssessionid = inReq.getRequestParameter("hitssessionid");
    HitTracker assets = (HitTracker) inReq.getSessionValue(hitssessionid);

    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);
      }
    }

    int added =
        getOrderManager()
            .addItemsToBasket(inReq, archive, basket, assets.getSelectedHitracker(), props);
    inReq.putPageValue("added", Integer.valueOf(added));
    return basket;
  }
コード例 #8
0
  public Order createOrderFromSelections(WebPageRequest inReq) {
    String catalogid = inReq.findValue("catalogid");

    String hitssessionid = inReq.getRequestParameter("hitssessionid");
    HitTracker assets = null;
    if (hitssessionid != null) {
      assets = (HitTracker) inReq.getSessionValue(hitssessionid);
    } else {
      assets = new ListHitTracker();
      String[] sourcepaths = inReq.getRequestParameters("sourcepath");
      if (sourcepaths == null) {
        log.error("No assets passed in");
        return null;
      }
      for (int i = 0; i < sourcepaths.length; i++) {
        Data hit = new BaseData();
        hit.setSourcePath(sourcepaths[i]);
        assets.add(hit);
        assets.addSelection(hit.getId());
      }
    }
    if (assets == null) {
      return null;
    }
    Searcher itemsearcher = getSearcherManager().getSearcher(catalogid, "orderitem");
    List orderitems = new ArrayList();

    if (assets.hasSelections()) {
      Map props = new HashMap();

      String applicationid = inReq.findValue("applicationid");
      Order order =
          (Order) getOrderManager().createNewOrder(applicationid, catalogid, inReq.getUserName());
      inReq.putPageValue("order", order);
      inReq.setRequestParameter("orderid", order.getId());

      for (Iterator iterator = assets.getSelectedHitracker().iterator(); iterator.hasNext(); ) {
        Data hit = (Data) iterator.next();
        Asset asset = getMediaArchive(catalogid).getAssetBySourcePath(hit.getSourcePath());
        if (asset != null) {
          getOrderManager().addItemToOrder(catalogid, order, asset, null);
        }
      }
      if (order.get("expireson") == null) {
        String days = getMediaArchive(catalogid).getCatalogSettingValue("orderexpiresdays");
        if (days == null) {
          days = "30";
        }
        GregorianCalendar cal = new GregorianCalendar();
        cal.add(Calendar.DAY_OF_YEAR, Integer.parseInt(days));
        order.setProperty(
            "expireson", DateStorageUtil.getStorageUtil().formatForStorage(cal.getTime()));
      }

      getOrderManager().saveOrder(catalogid, inReq.getUser(), order);

      return order;
    } else {
      inReq.setCancelActions(true);
    }

    return null;
  }