KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > edit > StoreEditor


1  /*
2  * Created on Nov 16, 2004
3  */

4 package com.openedit.store.edit;
5
6 import java.awt.Dimension JavaDoc;
7 import java.io.File JavaDoc;
8 import java.io.Reader JavaDoc;
9 import java.util.ArrayList JavaDoc;
10 import java.util.HashMap JavaDoc;
11 import java.util.Iterator JavaDoc;
12 import java.util.List JavaDoc;
13
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16 import org.dom4j.DocumentHelper;
17 import org.dom4j.Element;
18 import org.dom4j.Node;
19 import org.dom4j.io.SAXReader;
20 import org.openedit.money.Money;
21 import org.openedit.repository.RepositoryException;
22 import org.openedit.repository.filesystem.StringItem;
23
24 import com.openedit.OpenEditException;
25 import com.openedit.modules.image.ImageResizer;
26 import com.openedit.page.Page;
27 import com.openedit.page.manage.PageManager;
28 import com.openedit.store.Category;
29 import com.openedit.store.Image;
30 import com.openedit.store.InventoryItem;
31 import com.openedit.store.Option;
32 import com.openedit.store.Product;
33 import com.openedit.store.Store;
34 import com.openedit.store.StoreException;
35 import com.openedit.store.products.Detail;
36 import com.openedit.store.products.PropertyDetails;
37 import com.openedit.util.XmlUtil;
38
39 /**
40  * @author cburkey
41  *
42  */

43 public class StoreEditor
44 {
45     protected Category fieldCurrentCatalog;
46     protected Category fieldPickedCatalog;
47     protected Store fieldStore;
48     protected Product fieldCurrentProduct;
49     protected InventoryItem fieldCurrentItem;
50     protected List JavaDoc fieldAllOptions;
51     protected PageManager fieldPageManager;
52     protected List JavaDoc fieldImageTypes;
53     
54     private static final Log log = LogFactory.getLog(StoreEditor.class);
55     public StoreEditor()
56     {
57     }
58
59     public Category getCurrentCatalog() throws StoreException
60     {
61         return fieldCurrentCatalog;
62     }
63
64     public void setCurrentCatalog(Category inCurrentCatalog)
65     {
66         if ( inCurrentCatalog == null)
67         {
68             throw new IllegalArgumentException JavaDoc("Category cannot be null");
69         }
70         fieldCurrentCatalog = inCurrentCatalog;
71         setCurrentProduct(null);
72         setCurrentItem(null);
73         
74     }
75
76     public Store getStore()
77     {
78         return fieldStore;
79     }
80
81     public void setStore(Store inStore)
82     {
83         fieldStore = inStore;
84     }
85
86     /**
87      * @param inString
88      * @return
89      */

90     public Category getCatalog(String JavaDoc inString) throws StoreException
91     {
92         Category catalog = getStore().getCatalogArchive().getCatalog(inString);
93         
94         return catalog;
95     }
96     
97     public void moveCatalogUp(Category inCatalog) throws StoreException
98     {
99         Category parent = inCatalog.getParentCatalog();
100         List JavaDoc children = (List JavaDoc)parent.getChildren();
101         Category prev = null;
102         for (Iterator JavaDoc iter = children.iterator(); iter.hasNext();)
103         {
104             Category child = (Category) iter.next();
105             if (child == inCatalog)
106             {
107                 if (prev != null)
108                 {
109                     int childIndex = children.indexOf(child);
110                     children.set(childIndex - 1, child);
111                     children.set(childIndex, prev);
112                 }
113                 break;
114             }
115             prev = child;
116         }
117         parent.setChildren(children);
118         saveCatalog(parent);
119     }
120     public void moveCatalogDown(Category inCatalog) throws StoreException
121     {
122         Category parent = inCatalog.getParentCatalog();
123         List JavaDoc children = (List JavaDoc)parent.getChildren();
124         for (Iterator JavaDoc iter = children.iterator(); iter.hasNext();)
125         {
126             Category child = (Category) iter.next();
127             if (child == inCatalog)
128             {
129                 if (iter.hasNext())
130                 {
131                     int childIndex = children.indexOf(child);
132                     children.set(childIndex, (Category) iter.next());
133                     children.set(childIndex + 1, child);
134                 }
135                 break;
136             }
137         }
138         parent.setChildren(children);
139         saveCatalog(parent);
140     }
141
142     /**
143      * @param inString
144      * @param inString2
145      * @return
146      */

147     public Category addNewCatalog(String JavaDoc inId, String JavaDoc inName) throws StoreException
148     {
149         Category newCat = new Category();
150         newCat.setId(inId);
151         newCat.setName(inName);
152         if (getCurrentCatalog() != null)
153         {
154             getCurrentCatalog().addChild(newCat);
155         }
156         else if (getRootCatalog() != null)
157         {
158             getRootCatalog().addChild(newCat);
159         }
160         else
161         {
162             getStore().getCatalogArchive().setRootCatalog(newCat);
163         }
164         getStore().getCatalogArchive().addCatalog(newCat);
165         return newCat;
166         //return getStore().getCatalogArchive().addCatalog(inString, inString2);
167
}
168
169     /**
170      * @param inBlank
171      */

172     public void saveCatalog(Category inBlank) throws StoreException
173     {
174         if ( inBlank.getParentCatalog() == null && getStore().getCatalogArchive().getRootCatalog() != inBlank)
175         {
176             getStore().getCatalogArchive().getRootCatalog().addChild(inBlank);
177             getStore().getCatalogArchive().addCatalog(inBlank);
178         }
179         try
180         {
181             Page desc = getPageManager().getPage(getStore().getStoreHome() + "/categories/" + inBlank.getId() + ".html");
182             if ( !desc.exists() )
183             {
184                 StringItem item = new StringItem(desc.getPath(), " ",desc.getCharacterEncoding() );
185                 desc.setContentItem(item);
186                 getPageManager().putPage(desc);
187             }
188         }
189         catch ( Exception JavaDoc ex )
190         {
191             throw new StoreException(ex);
192         }
193         getStore().getCatalogArchive().saveCatalog(inBlank);
194     }
195
196     /**
197      * @param inCatalog
198      */

199     public void deleteCatalog(Category inCatalog) throws StoreException
200     {
201         List JavaDoc products = getStore().getProductsInCatalog(inCatalog);
202         for (Iterator JavaDoc iter = products.iterator(); iter.hasNext();)
203         {
204             Product element = (Product) iter.next();
205             element.removeCatalog(inCatalog);
206         }
207         getStore().getCatalogArchive().deleteCatalog(inCatalog);
208         //getStore().reindexAll();
209
getStore().saveProducts(products);
210     }
211
212     /**
213      * @return
214      */

215     public Category getRootCatalog() throws StoreException
216     {
217         return getStore().getCatalogArchive().getRootCatalog();
218     }
219
220     /**
221      *
222      */

223     public void clearCatalogs() throws StoreException
224     {
225         getStore().getCatalogArchive().clearCatalogs();
226     }
227
228     public void reloadCatalogs() throws StoreException
229     {
230         if (getCurrentCatalog() != null)
231         {
232             String JavaDoc id = getCurrentCatalog().getId();
233             getStore().getCatalogArchive().reloadCatalogs();
234             Category catalog = getCatalog(id);
235             if ( catalog == null)
236             {
237                 catalog = getRootCatalog();
238             }
239             setCurrentCatalog(catalog);
240         }
241         else
242         {
243             getStore().getCatalogArchive().reloadCatalogs();
244         }
245     }
246
247     public Product createProduct()
248     {
249         return new Product();
250     }
251
252     public void addToCatalog(Product inProduct, Category inCatalog) throws StoreException
253     {
254         inProduct.addCatalog(inCatalog);
255         if ( inProduct.getCatalogs().size() == 1)
256         {
257             inProduct.setDefaultCatalog(inCatalog);
258         }
259     }
260
261     public void deleteProduct(Product inProduct) throws StoreException
262     {
263         
264
265         getStore().getProductArchive().deleteProduct(inProduct);
266         getStore().getStoreSearcher().deleteFromIndex(inProduct);
267
268         if (getCurrentProduct() != null && inProduct.getId().equals(getCurrentProduct().getId()))
269         {
270             setCurrentProduct(null);
271         }
272
273     }
274
275     public Product getProduct(String JavaDoc inProductId) throws StoreException
276     {
277         Product prod = getStore().getProductArchive().getProduct(inProductId);
278         if ( prod == null)
279         {
280             return null;
281         }
282         //load up the properties
283
List JavaDoc list = getStore().getProductArchive().getPropertyDetails().getDetails();
284         for (Iterator JavaDoc iter = list.iterator(); iter.hasNext();)
285         {
286             Detail detail = (Detail) iter.next();
287             if( prod.get(detail.getId()) == null )
288             {
289                 prod.getProperties().put(detail.getId(),""); //avoid null check
290
}
291         }
292         return prod;
293
294     }
295
296     public void deleteItem(InventoryItem inItem) throws StoreException
297     {
298         Product product = inItem.getProduct();
299         if (product != null)
300         {
301             inItem.setProduct(null);
302             product.getInventoryItems().remove(inItem);
303             saveProduct(product);
304             //getStore().reindexAll();
305
}
306     }
307
308     public void saveProduct(Product inProduct) throws StoreException
309     {
310         getStore().saveProduct(inProduct);
311     }
312     public void saveProducts(List JavaDoc inProducts) throws StoreException
313     {
314         getStore().saveProducts(inProducts);
315     }
316
317     public Product getCurrentProduct()
318     {
319         return fieldCurrentProduct;
320     }
321
322     public void setCurrentProduct(Product inCurrentProduct)
323     {
324         fieldCurrentProduct = inCurrentProduct;
325         setCurrentItem(null);
326     }
327
328     /**
329      * @return
330      */

331     public Product createProductWithDefaults() throws StoreException
332     {
333         Product product = createProduct();
334         String JavaDoc id = getStore().getProductArchive().nextProductNumber(getStore());
335         product.setId(id); //TODO: Load from serial ID
336
product.setName("No Name");
337         product.setDescription("No description available");
338         return product;
339
340     }
341
342     public InventoryItem createItem()
343     {
344         InventoryItem item = new InventoryItem();
345         item.setSku("newsku");
346         return item;
347     }
348
349     public InventoryItem getCurrentItem()
350     {
351         return fieldCurrentItem;
352     }
353
354     public void setCurrentItem(InventoryItem inCurrentItem)
355     {
356         fieldCurrentItem = inCurrentItem;
357     }
358
359     public Money getItemPrice(int inQuantity, InventoryItem inItem)
360     {
361         return inItem.getPriceSupport().getYourPriceByQuantity(inQuantity);
362     }
363
364     public void deleteImage(Image inImage)
365     {
366         File JavaDoc out = new File JavaDoc(getStore().getRootDirectory(), inImage.getPath());
367         out.delete();
368         
369     }
370     /**
371      * @param inType
372      * @return
373      */

374     public Image getImage(String JavaDoc inId) throws StoreException
375     {
376         for (Iterator JavaDoc iter = getImageList().iterator(); iter.hasNext();)
377         {
378             Image image = (Image) iter.next();
379             if (inId.equals(image.getId()) )
380             {
381                 return image;
382             }
383         }
384         return null;
385     }
386
387     /**
388      * @param inPath
389      */

390     public void resizeImage(Image inOriginal, String JavaDoc inId) throws StoreException
391     {
392         ImageResizer resizer = new ImageResizer();
393         File JavaDoc root = getStore().getRootDirectory();
394         File JavaDoc in = new File JavaDoc(root, inOriginal.getPath());
395         try
396         {
397             for (int i = 1; i < getImageList().size(); i++)
398             {
399                 Image image = (Image) getImageList().get(i);
400                 
401                 resizer.setMaxScaledSize(new Dimension JavaDoc(image.getWidth(), Integer.MAX_VALUE));
402                 
403                 String JavaDoc newpath = image.buildLink( inId );
404                 File JavaDoc out = new File JavaDoc(root, newpath);
405                 out.getParentFile().mkdirs();
406                 log.info("Output " + out.getPath());
407                 resizer.resizeImage(in, out);
408             }
409         }
410         catch (Exception JavaDoc ex)
411         {
412             throw new StoreException(ex);
413         }
414     }
415     
416     /**
417      * Returns a list of possible images (not actual images).
418      *
419      * @return A {@link List} of {@link Image}s
420      */

421     public List JavaDoc getImageList() throws StoreException
422     {
423         return getStore().getCatalogArchive().getImageList();
424     }
425     
426     public List JavaDoc getImageList(String JavaDoc type) throws StoreException
427     {
428         return getStore().getCatalogArchive().getImageList(type);
429     }
430     
431     /**
432      * @param inCurrentCatalog
433      * @param inLinks
434      */

435     /*
436     public void addCatalogAsLink(Category inCurrentCatalog, LinkTree inLinks, Link inParentLink, boolean withProducts, String[] productIds) throws OpenEditException
437     {
438         String parentId= null;
439         if ( inParentLink != null )
440         {
441             parentId = inParentLink.getId();
442         }
443         String id = inCurrentCatalog.getId();
444         id = inLinks.checkUnique(id);
445         Link link = new Link();
446         link.setId(id);
447         link.setUrl( getStore().getStoreHome() + "/catalogs/" + inCurrentCatalog.getId() + ".html");
448         link.setText(inCurrentCatalog.getName());
449         link.setUserData(inCurrentCatalog.getId());
450         
451         inLinks.addLink(parentId,link);
452
453         for (Iterator iter = inCurrentCatalog.getChildren().iterator(); iter.hasNext();)
454         {
455             Category child = (Category) iter.next();
456             addCatalogAsLink(child,inLinks, link,withProducts, productIds);
457         }
458         //add the products
459         if ( withProducts )
460         {
461             if ( productIds == null)
462             {
463                 String query = "catalogs:( " + inCurrentCatalog.getId() + ")";
464
465                 HitTracker hits = getStore().getStoreSearcher().search( query, "ordering" );
466                 for (int i = 0; i < hits.getTotal(); i++)
467                 {
468                     try
469                     {
470                         Document doc = hits.get(i);
471                         Link plink = new Link();
472                         String pid = doc.get("id");
473                         plink.setId(id + "-" + pid);
474                         
475                         plink.setUrl(getStore().getStoreHome() + "/products/" + pid + ".html"); //TODO: Use link finder
476                         plink.setText(doc.get("name"));
477                         plink.setUserData(pid);
478                         inLinks.addLink(link.getId(),plink);
479                     } catch ( IOException ex)
480                     {
481                         throw new OpenEditException(ex);
482                     }
483                 }
484             }
485             else
486             {
487                 for (int i = 0; i < productIds.length; i++)
488                 {
489                     Link plink = new Link();
490                     String pid = productIds[i];
491                     plink.setId(inParentLink.getId() + "-" + pid);
492                     Product prod = getStore().getProduct(pid);
493                     plink.setUrl(getStore().getStoreHome() +"/products/" + pid + ".html"); //TODO: Use link finder
494                     plink.setText(prod.getName());
495                     plink.setUserData(pid);
496                     inLinks.addLink(inParentLink.getId(),plink);
497                 }
498             }
499         }
500
501     }
502     */

503     
504     
505     public List JavaDoc getAllOptions() throws StoreException
506     {
507         //Replace with the PageManager lookup
508
List JavaDoc all = new ArrayList JavaDoc();
509         File JavaDoc file = new File JavaDoc( getStore().getRootDirectory(),getStore().getStoreHome() + "/configuration/alloptions.xml");
510         if ( file.exists() )
511         {
512             Element root = null;
513             try
514             {
515                 root = new XmlUtil().getXml(file,"UTF-8");
516             }
517             catch ( Exception JavaDoc ex)
518             {
519                 throw new StoreException(ex);
520             }
521             for (Iterator JavaDoc iter = root.elementIterator("option"); iter.hasNext();)
522             {
523                 Element element = (Element) iter.next();
524                 Option op = new Option();
525                 op.setId(element.attributeValue("id"));
526                 op.setName(element.attributeValue("name"));
527                 all.add( op);
528             }
529         }
530         return all;
531         
532     }
533
534     /**
535      * @param inOption
536      * @throws OpenEditException
537      */

538     public void addOptionToAll(Option inOption) throws OpenEditException
539     {
540         
541         List JavaDoc all = getAllOptions();
542         for (Iterator JavaDoc iter = all.iterator(); iter.hasNext();)
543         {
544             Option option = (Option) iter.next();
545             if ( inOption.getId().equals(option.getId()))
546             {
547                 return;
548             }
549         }
550         
551         Page settings = getPageManager().getPage(getStore().getStoreHome() +"/configuration/alloptions.xml");
552         
553         Element root = null;
554         if (settings.exists())
555         {
556             try
557             {
558                 Reader JavaDoc read = settings.getReader();
559                 root = new SAXReader().read(read).getRootElement();
560                 //root = new XmlUtil().getXml(new FileReader(file));
561
}
562             catch ( Exception JavaDoc ex)
563             {
564                 throw new StoreException(ex);
565             }
566         }
567         else
568         {
569             root = DocumentHelper.createElement("optionlist");
570         }
571         Element opt = root.addElement("option");
572         opt.addAttribute("id",inOption.getId());
573         opt.addAttribute("name",inOption.getName());
574         //new XmlUtil().saveXml(root.getDocument(),file);
575
StringItem item = new StringItem(settings.getPath(),root.asXML(),"UTF-8");
576         settings.setContentItem(item);
577         getPageManager().putPage(settings);
578     }
579     
580     public void removeOptionFromAll(String JavaDoc id) throws StoreException
581     {
582         
583         File JavaDoc file = new File JavaDoc( getStore().getStoreDirectory(), "/configuration/alloptions.xml");
584         Element root = null;
585         try
586         {
587             root = new XmlUtil().getXml(file,"UTF-8");
588         }
589         catch ( Exception JavaDoc ex)
590         {
591             throw new StoreException(ex);
592         }
593         Node node = root.selectSingleNode("//option[@id='" + id +"']");
594         if (node != null)
595         {
596             root.remove(node);
597             new XmlUtil().saveXml(root.getDocument(),file);
598         }
599     }
600     
601     //this method takes the products in the current catalog, adds affixes, then saves them in the new catalog
602
public void addProductAffixes( Category newCatalog, String JavaDoc newPrefix, String JavaDoc newSuffix ) throws StoreException
603     {
604         Category oldCatalog = getCurrentCatalog();
605         List JavaDoc products = getStore().getProductsInCatalog(oldCatalog); //this is the list of the products in the old catalog
606
String JavaDoc newId;
607         List JavaDoc productsToSave = new ArrayList JavaDoc(); //this is the list of products that we will save at the end
608
if (products != null)
609         {
610             for (Iterator JavaDoc iter = products.iterator(); iter.hasNext();)
611             {
612                 Product element = (Product) iter.next(); //element is an existing product
613
if (newPrefix.length() > 0 || newSuffix.length() > 0)
614                 {
615                     newId = element.getId();
616                     newId = newPrefix + newId + newSuffix;
617                     Product product = copyProduct(element, newId ); //product is a new product that is a copy of an existing product
618
product.addCatalog(newCatalog); //add the new product (with the new id) to the new catalog
619
productsToSave.add(product); //add the new product to the list of products to save
620
}
621                 else //we don't have to add affixes, so update the existing product instead
622
{
623                     element.addCatalog(newCatalog); //add the existing product to the new catalog
624
productsToSave.add(element); //add the existing product to the list of products to save
625
}
626             }
627             getStore().saveProducts(productsToSave); //save all the products that need to be
628
}
629     }
630     
631
632     /**
633      * @return Returns the pageManager.
634      */

635     public PageManager getPageManager()
636     {
637         return fieldPageManager;
638     }
639     /**
640      * @param inPageManager The pageManager to set.
641      */

642     public void setPageManager(PageManager inPageManager)
643     {
644         fieldPageManager = inPageManager;
645     }
646
647     
648     public Product copyProduct(Product inProduct, String JavaDoc inId)
649     {
650         Product product = null;
651         if (inProduct != null)
652         {
653             product = new Product();
654             product.setId(inId);
655             product.setName(inProduct.getName());
656             product.setDescription(inProduct.getDescription());
657             product.setHandlingChargeLevel(inProduct.getHandlingChargeLevel());
658             product.setOptions(inProduct.getOptions());
659             product.setOrdering(inProduct.getOrdering());
660             product.setDepartment(inProduct.getDepartment());
661             product.setPriceSupport(inProduct.getPriceSupport());
662             product.setKeywords(inProduct.getKeywords());
663             product.setProperties(new HashMap JavaDoc(inProduct.getProperties()));
664             product.setInventoryItems(inProduct.getInventoryItems());
665         }
666         return product;
667     }
668
669     /**
670      * @param inCatalog
671      * @param inId
672      * @throws Exception
673      */

674     public void changeCatalogId(Category inCatalog, String JavaDoc inId) throws OpenEditException
675     {
676         inId = inId.replace('(', '-');
677         inId = inId.replace(')', '-');
678         inId = inId.replace(' ', '-');
679         
680         List JavaDoc products = getStore().getProductsInCatalog(inCatalog);
681         
682         PageManager pageManager = getPageManager();
683 // reload = true;
684
Page oldPage = pageManager.getPage(getStore().getStoreHome() +"/catalogs/" + inCatalog.getId() + ".html");
685         Page newPage = pageManager.getPage(getStore().getStoreHome() +"/catalogs/" + inId + ".html");
686         if (oldPage.exists() && !newPage.exists())
687         {
688             try
689             {
690                 pageManager.movePage(oldPage, newPage);
691             }
692             catch ( RepositoryException re )
693             {
694                 throw new OpenEditException( re );
695             }
696         }
697         if (products != null)
698         {
699             for (Iterator JavaDoc iter = products.iterator(); iter.hasNext();)
700             {
701                 Product element = (Product) iter.next(); //element is an existing product
702
element.removeCatalog(inCatalog); //add the new product (with the new id) to the new catalog
703
}
704         }
705         
706         inCatalog.setId( inId );
707         saveCatalog( inCatalog );
708                 
709         if (products != null)
710         {
711             for (Iterator JavaDoc iter = products.iterator(); iter.hasNext();)
712             {
713                 Product element = (Product) iter.next(); //element is an existing product
714
element.addCatalog(inCatalog); //add the new product (with the new id) to the new catalog
715
}
716             getStore().saveProducts(products); //save all the products that need to be
717
}
718                 
719     }
720     public List JavaDoc getItemProperties() throws OpenEditException
721     {
722
723         Page config = getPageManager().getPage(getStore().getStoreHome() +"/configuration/itemproperties.xml");
724         PropertyDetails d = new PropertyDetails();
725         d.addAllDetails(config.getReader());
726         
727         return d.getDetails();
728     }
729
730     public Category getPickedCatalog()
731     {
732         return fieldPickedCatalog;
733     }
734
735     public void setPickedCatalog(Category inCatalog)
736     {
737         fieldPickedCatalog = inCatalog;
738     }
739
740     public void removeProductFromCatalog(Category catalog, String JavaDoc[] productIds) throws OpenEditException
741     {
742         if ( catalog == null )
743         {
744             throw new OpenEditException("No catalog found ");
745         }
746         List JavaDoc productsToSave = new ArrayList JavaDoc();
747         
748         for (int i = 0; i < productIds.length; i++)
749         {
750             Product product = getProduct( productIds[i] );
751             if ( product != null )
752             {
753                 product.removeCatalog(catalog);
754                 productsToSave.add(product);
755             }
756         }
757         saveProducts(productsToSave);
758
759     }
760     
761     public void addProductsToCatalog(String JavaDoc[] productid, String JavaDoc prefix, String JavaDoc suffix, Category catalog) throws StoreException
762     {
763         List JavaDoc productsToSave = new ArrayList JavaDoc();
764         
765         if (catalog != null)
766         {
767             List JavaDoc products = null;
768             if ( productid == null)
769             {
770                 //copy all of them
771
products = getStore().getProductsInCatalog(getCurrentCatalog());
772             }
773             else
774             {
775                 products = new ArrayList JavaDoc();
776                 for (int i = 0; i < productid.length; i++)
777                 {
778                     Product element = getProduct(productid[i]);
779                     products.add(element);
780                 }
781             }
782             for (Iterator JavaDoc iter = products.iterator(); iter.hasNext();)
783             {
784                 Product element = (Product) iter.next();
785                 Product product = element;
786                 if (prefix != null || suffix != null)
787                 {
788                     if ( prefix == null) prefix = "";
789                     if ( suffix == null) suffix = "";
790                     
791                     product = copyProduct(element, prefix + element.getId() + suffix);
792                 }
793                 if (product != null)
794                 {
795                     product.addCatalog(catalog);
796                     productsToSave.add(product);
797                 }
798             }
799             saveProducts(productsToSave);
800         }
801     }
802     public void moveProductsToCatalog(String JavaDoc[] inProductid, Category inCatalog1, Category inCatalog2) throws StoreException
803     {
804         List JavaDoc productsToSave = new ArrayList JavaDoc();
805         
806         if (inCatalog1 != null && inCatalog2 != null && inCatalog1 != inCatalog2)
807         {
808             for (int i = 0; i < inProductid.length; i++)
809             {
810                 Product product = getProduct(inProductid[i]);
811                 if (product != null)
812                 {
813                     product.removeCatalog(inCatalog1);
814                     product.addCatalog(inCatalog2);
815                     productsToSave.add(product);
816                 }
817             }
818             saveProducts(productsToSave);
819         }
820
821
822     }
823     
824 }
Popular Tags