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; }
public Order saveOrder(WebPageRequest inReq, boolean saveitems) throws Exception { Order order = loadOrder(inReq); if (order != null) { String catalogid = inReq.findValue("catalogid"); order = getOrderManager().createOrder(catalogid, inReq, saveitems); inReq.putPageValue("savedok", "true"); } return order; }
public Order updateOrder(WebPageRequest inReq) throws Exception { Order order = loadOrder(inReq); String[] fields = inReq.getRequestParameters("field"); String catalogid = inReq.findValue("catalogid"); Searcher searcher = getSearcherManager().getSearcher(catalogid, "order"); searcher.updateData(inReq, fields, order); searcher.saveData(order, inReq.getUser()); return order; }
public Collection saveItems(WebPageRequest inReq) throws Exception { String[] fields = inReq.getRequestParameters("field"); if (fields != null) { String[] items = inReq.getRequestParameters("itemid"); String catalogid = inReq.findValue("catalogid"); ArrayList toSave = getOrderManager().saveItems(catalogid, inReq, fields, items); return toSave; } return null; }
public Order createOrderWithItems(WebPageRequest inReq) { String orderid = inReq.findValue("orderid"); if (orderid != null) { return loadOrder(inReq); } String[] assetids = inReq.getRequestParameters("assetid"); if (assetids != null && assetids.length > 0 && assetids[0].length() > 0) { return createOrderFromAssets(inReq); } return createOrderFromSelections(inReq); }
public Order placeOrderById(WebPageRequest inReq) { Order order = loadOrder(inReq); getOrderManager().placeOrder(inReq, getMediaArchive(inReq), order, false); inReq.removeSessionValue("orderbasket"); inReq.putPageValue("order", order); return order; // change the status of all the items and the order and save everything // fire event }
public HitTracker findOrdersForUser(WebPageRequest req) { String catalogid = req.findValue("catalogid"); User owner = (User) req.getPageValue("owner"); if (owner == null) { owner = req.getUser(); } HitTracker orders = getOrderManager().findOrdersForUser(catalogid, owner); req.putPageValue("orders", orders); req.putPageValue("searcher", getSearcherManager().getSearcher(catalogid, "order")); return orders; }
/** * 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()); }
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; }
public HitTracker findOrderHistory(WebPageRequest req) { Order order = loadOrder(req); if (order != null) { String catalogid = req.findValue("catalogid"); String orderid = order.getId(); if (orderid == null) { orderid = req.getRequestParameter("orderid"); } HitTracker items = getOrderManager().findOrderHistory(catalogid, order); req.putPageValue("orderhistory", items); return items; } return null; }
/* (non-Javadoc) * @see com.openedit.command.Command#load(com.anthonyeden.lib.config.Configuration) */ public void configure(WebPageRequest inReq) { fieldLoginPath = inReq.findValue("login-path"); Configuration element = inReq.getCurrentAction().getConfig(); PageSettings settings = inReq.getPage().getPageSettings(); for (Iterator iter = element.getChildren("exclude").iterator(); iter.hasNext(); ) { Configuration excludeElem = (Configuration) iter.next(); String path = excludeElem.getValue(); path = settings.replaceProperty(path); getExcludes().add(path); } String forbid = element.getAttribute("forbid"); setForbid(Boolean.valueOf(forbid)); }
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); }
public Order loadOrderForVisitor(WebPageRequest inReq) { Order order = loadOrder(inReq); // check the expriation if (order.isExpired()) { inReq.putPageValue("expired", Boolean.TRUE); } else { inReq.putPageValue("expired", Boolean.FALSE); } // load up hits and select all the items. HitTracker hits = loadAssets(inReq); hits.selectAll(); inReq.putPageValue("hits", hits); inReq.putSessionValue("vieworder", order); return order; }
/** * DOCUMENT ME! * * @param inParameters * @param inPropertyContainer * @throws UserManagerException */ public void deleteProperties(WebPageRequest inContext, Map inPropertyContainer) throws UserManagerException { String[] propertyNames = inContext.getRequestParameters("deletePropertyNames"); for (int i = 0; i < propertyNames.length; i++) { inPropertyContainer.remove(propertyNames[i]); } }
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 Order loadOrder(WebPageRequest inReq) { Order order = (Order) inReq.getPageValue("order"); if (order != null) { return order; } String catalogid = inReq.findValue("catalogid"); String orderid = inReq.findValue("orderid"); if (orderid == null) { orderid = inReq.getRequestParameter("id"); } if (orderid == null) { return null; } order = getOrderManager().loadOrder(catalogid, orderid); inReq.putPageValue("order", order); return order; }
public void clearOrderItems(WebPageRequest inReq) { MediaArchive archive = getMediaArchive(inReq); HitTracker items = findOrderItems(inReq); Searcher searcher = getSearcherManager().getSearcher(archive.getCatalogId(), "orderitem"); for (Iterator iterator = items.iterator(); iterator.hasNext(); ) { Data item = (Data) iterator.next(); searcher.delete(item, inReq.getUser()); } }
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); }
public void filterOrderItems(WebPageRequest req) { ArrayList<String> list = new ArrayList<String>(); // add omitted orders to a list String publishtype = req.getRequestParameter("publishdestination.value"); String catalogid = req.findValue("catalogid"); HitTracker items = (HitTracker) req.getPageValue("orderitems"); if (items == null) { Order order = loadOrder(req); if (order != null) { String orderid = order.getId(); if (orderid == null) { orderid = req.getRequestParameter("orderid"); } items = getOrderManager().findOrderItems(req, catalogid, order); } } if (items != null) { // get searchers Searcher publishdestsearcher = getMediaArchive(req).getSearcherManager().getSearcher(catalogid, "publishdestination"); Data publisher = (Data) publishdestsearcher.searchById(publishtype); String publishername = publisher.getName(); Searcher convertpresetsearcher = getMediaArchive(req).getSearcherManager().getSearcher(catalogid, "convertpreset"); // see if convertpreset has the appropriate field String publishtofield = "publishto" + publishername.replace(" ", "").toLowerCase(); if (convertpresetsearcher.getDetail(publishtofield) != null) // field is present { for (int i = 0; i < items.size(); i++) { Data data = items.get(i); Asset asset = getMediaArchive(req).getAsset(data.get("assetid")); String fileformat = asset.get("fileformat"); String rendertype = getMediaArchive(req).getMediaRenderType(fileformat); // build query SearchQuery presetquery = convertpresetsearcher.createSearchQuery(); presetquery.append(publishtofield, "true").append("inputtype", rendertype); // execute query HitTracker hits = convertpresetsearcher.search(presetquery); if (hits.size() > 0) continue; list.add(asset.getId()); } } } req.putPageValue("invaliditems", list); // process this in step2 }
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; }
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; }
/** @see com.openedit.util.strainer.Filter#passes(java.lang.Object) */ public boolean passes(Object inObj) throws FilterException, ClassCastException { WebPageRequest req = (WebPageRequest) inObj; User data = req.getUser(); if (data == null) { return false; } if (getValue() == null) { return true; } for (Iterator iterator = data.getGroups().iterator(); iterator.hasNext(); ) { Group group = (Group) iterator.next(); String value = group.get(getPropertyName()); if (value != null && value.equals(getValue())) { return true; } } return false; }
public void createConversionAndPublishRequest(WebPageRequest inReq) { // Order and item should be created from previous step. // now we get the items and update the destination information Order order = loadOrder(inReq); OrderManager manager = getOrderManager(); String catalogid = inReq.findValue("catalogid"); Searcher searcher = getSearcherManager().getSearcher(catalogid, "order"); if (order == null) { order = (Order) searcher.createNewData(); } String[] fields = inReq.getRequestParameters("field"); searcher.updateData(inReq, fields, order); MediaArchive archive = getMediaArchive(inReq); Map params = inReq.getParameterMap(); if (order.get("publishdestination") == null) { // String publishdestination = inReq.findValue("publishdestination.value"); // do something? default it to browser? order.setProperty( "publishdestination", "0"); // assume 0 for most orders, 0 can be told to use Aspera } List assetids = manager.addConversionAndPublishRequest(inReq, order, archive, params, 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"); //what is pendig // } // manager.saveOrder(archive.getCatalogId(), inReq.getUser(), order); log.info("Added conversion and publish requests for order id:" + order.getId()); }
public boolean checkItemApproval(WebPageRequest inReq) throws Exception { if (inReq.getUser() == null) { return false; } MediaArchive archive = getMediaArchive(inReq); // Searcher ordersearcher = // archive.getSearcherManager().getSearcher(archive.getCatalogId(), // "order"); // SearchQuery search = ordersearcinKeyher.createSearchQuery(); // search.addExact("userid", inReq.getUser().getId()); // search.addExact("orderstatus", "processed"); // search.addSortBy("date"); // HitTracker hits = ordersearcher.search(search); // look for the most recent order for an approved asset Asset asset = (Asset) inReq.getPageValue("asset"); String sourcepath = null; if (asset != null) { sourcepath = asset.getSourcePath(); } else { sourcepath = archive.getSourcePathForPage(inReq); } if (sourcepath == null) { return false; } Searcher itemsearcher = archive.getSearcherManager().getSearcher(archive.getCatalogId(), "orderitem"); SearchQuery search = itemsearcher.createSearchQuery(); search.addExact("userid", inReq.getUser().getId()); search.addExact("assetsourcepath", sourcepath); search.addMatches("status", "approved"); HitTracker results = itemsearcher.search(search); if (results.size() > 0) { return true; } return false; }
public Order loadOrderBasket(WebPageRequest inReq) { Order basket = null; try { MediaArchive archive = getMediaArchive(inReq); basket = (Order) inReq.getPageValue("orderbasket"); if (basket == null) { String id = inReq.getUserName() + "_orderbasket"; String appid = inReq.findValue("applicationid"); Searcher searcher = getSearcherManager().getSearcher(archive.getCatalogId(), "order"); basket = (Order) searcher.searchById(id); if (basket == null) { basket = getOrderManager().createNewOrder(appid, archive.getCatalogId(), inReq.getUserName()); basket.setId(id); basket.setProperty("ordertype", "basket"); getOrderManager().saveOrder(archive.getCatalogId(), inReq.getUser(), basket); } basket.setProperty("basket", "true"); basket.setProperty("ordertype", "basket"); inReq.putSessionValue("orderbasket", basket); } inReq.putPageValue("order", basket); HitTracker items = loadOrderManager(inReq).findOrderItems(inReq, archive.getCatalogId(), basket); inReq.putPageValue("orderitems", items); String check = inReq.findValue("clearmissing"); if (Boolean.parseBoolean(check)) { // Make sure these have the same number of assets found getOrderManager().removeMissingAssets(inReq, archive, basket, items); } } catch (Throwable ex) { log.error(ex); } return basket; }
/* * public Data placeOrder(WebPageRequest req) { String catalogid = * req.findValue("catalogid"); * * Album album = getEnterMedia(req).getAlbumArchive().loadAlbum("4", * req.getUserName()); HitTracker assets = album.getAssets(catalogid, req); * if (assets.size() > 0) { Map props = new HashMap(); * * String applicationid = req.findValue("applicationid"); Data order = * getOrderManager().placeOrder(applicationid, catalogid, req.getUser(), * assets, props); req.putPageValue("order", order); * req.setRequestParameter("orderid", order.getId()); List realassets = new * ArrayList(); // this is really bizarre. We're loading the assets into * memory // simply to have them turned into BaseData objects. // Need a * better way to remove stuff from an album. for (Iterator iterator = * assets.iterator(); iterator.hasNext();) { Data hit = (Data) * iterator.next(); Asset asset = * getMediaArchive(catalogid).getAsset(hit.getId()); if (asset != null) { * realassets.add(asset); } } album.removeAssets(realassets, req); * * // <property name="subject">Order Placed</property> // TODO: Move these * to generic fields String prefix = req.findValue("subjectprefix"); if * (prefix == null) { prefix = "Order received:"; } prefix = prefix + " " + * order.getId(); * * String postfix = req.findValue("subjectpostfix"); if (postfix != null) { * prefix = prefix + " " + postfix; } req.putPageValue("subject", prefix); * * return order; } else { req.setCancelActions(true); } * * return null; } */ public Data createNewOrder(WebPageRequest inReq) { String catalogid = inReq.findValue("catalogid"); String applicationid = inReq.findValue("applicationid"); Order order = (Order) getOrderManager().createNewOrder(applicationid, catalogid, inReq.getUserName()); inReq.putPageValue("order", order); // OrderHistory history = getOrderManager().createNewHistory(catalogid, order, inReq.getUser(), // "newrecord"); getOrderManager().saveOrder(catalogid, inReq.getUser(), order); inReq.setRequestParameter("orderid", order.getId()); return order; }
public Order placeOrderFromBasket(WebPageRequest inReq) { Order order = loadOrderBasket(inReq); boolean resetid = Boolean.parseBoolean(inReq.findValue("resetid")); String prefix = inReq.findValue("subjectprefix"); if (prefix == null) { prefix = "Order received:"; } prefix = prefix + " " + order.getId(); String postfix = inReq.findValue("subjectpostfix"); if (postfix != null) { prefix = prefix + " " + postfix; } inReq.putPageValue("subject", prefix); getOrderManager().placeOrder(inReq, getMediaArchive(inReq), order, resetid); inReq.removeSessionValue("orderbasket"); inReq.putPageValue("order", order); return order; }
public void preprocessOrder(WebPageRequest inReq) { String[] orderids = inReq.getRequestParameters("itemid"); if (orderids != null) { for (String orderid : orderids) { String formatkey = new StringBuilder().append(orderid).append(".itemfiletype.value").toString(); if (!inReq.getParameterMap().containsKey(formatkey)) { continue; } String format = inReq.getParameterMap().get(formatkey).toString(); String presetkey = new StringBuilder().append(format).append(".presetid.value").toString(); if (!inReq.getParameterMap().containsKey(presetkey)) { continue; } String preset = inReq.getParameterMap().get(presetkey).toString(); String itempresetkey = new StringBuilder().append(orderid).append(".presetid.value").toString(); inReq.setRequestParameter(itempresetkey, preset); } } }
public void removeItem(WebPageRequest inReq) throws Exception { String catalogid = inReq.findValue("catalogid"); String itemid = inReq.getRequestParameter("id"); getOrderManager().removeItem(catalogid, itemid); }
/* public void sendOrderEmail(WebPageRequest inReq) { // just a basic email download Order order = loadOrder(inReq); MediaArchive archive = getMediaArchive(inReq); String catalogid = archive.getCatalogId(); String[] emails = inReq.getRequestParameters("sharewithemail.value"); //String[] organizations = inReq.getRequestParameters("organization.value"); HitTracker orderItems = getOrderManager().findOrderItems(inReq, archive.getCatalogId(), order); inReq.putPageValue("orderitems", orderItems); inReq.putPageValue("order", order); try { OrderHistory history = getOrderManager().createNewHistory(catalogid, order, inReq.getUser(), "created"); inReq.putPageValue("order", order); TemplateWebEmail mailer = getPostMail().getTemplateWebEmail(); String templatepage = inReq.findValue("sharetemplate"); Page template = getPageManager().getPage(templatepage); mailer.loadSettings(inReq.copy(template)); mailer.setMailTemplatePage(template); String subject = mailer.getWebPageContext().findValue("subject"); if (subject == null) { subject = "Share notification"; } mailer.setSubject(subject); mailer.setRecipientsFromStrings(Arrays.asList(emails)); mailer.send(); getOrderManager().saveOrderWithHistory(catalogid, inReq.getUser(), order, history); } catch (Exception e) { throw new OpenEditException(e); } } */ public void deleteOrder(WebPageRequest inReq) throws Exception { Order order = loadOrder(inReq); String catalogid = inReq.findValue("catalogid"); getOrderManager().delete(catalogid, order); }