KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > presentation > DeleteIndexed


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.snapper.presentation;
9
10 // Enhydra SuperServlet imports
11
import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
12 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
13
14
15 // Enhydra SuperServlet specification imports
16
import org.enhydra.snapper.Log;
17 import org.enhydra.snapper.spec.*;
18
19 import org.enhydra.xml.xmlc.XMLObject;
20
21 // Standard imports
22

23 public class DeleteIndexed extends BasePO {
24
25
26     protected XMLObject getDOM() throws Exception JavaDoc {
27
28         Indexed[] isites = null;
29         NotIndexed[] niFiles = null;
30         String JavaDoc action = comms.request.getParameter("action");
31         String JavaDoc id = comms.request.getParameter("id");
32         
33         if (action.equals("files")){
34             niFiles = (NotIndexedFactory.getNotIndexed("org.enhydra.snapper.business.NotIndexedImpl")).getListForID(dbTransaction, id);
35             for (int p=0; p< niFiles.length; p++){
36                 niFiles[p].delete();
37             }
38             throw new ClientPageRedirectException(comms.request.getAppFileURIPath("IndexedSitesPresentation.po"));
39         }
40         
41         try {
42             isites = (IndexedFactory.getIndexed("org.enhydra.snapper.business.IndexedImpl")).getList(dbTransaction);
43             for (int i=0; i< isites.length; i++){
44                 niFiles = (NotIndexedFactory.getNotIndexed("org.enhydra.snapper.business.NotIndexedImpl")). getListForID(dbTransaction, isites[i].getID());
45                 for (int p=0; p< niFiles.length; p++){
46                     niFiles[p].delete();
47                     dbTransaction.commit();
48                 }
49                 isites[i].delete();
50                 dbTransaction.commit();
51                 
52             }
53             
54             Log.log("Indexed sites successfully deleted");
55                 } catch(Exception JavaDoc ex) {
56                      Log.logException(ex);
57                      throw new HttpPresentationException("Could not delete", ex);
58                 }
59    
60         throw new ClientPageRedirectException(comms.request.getAppFileURIPath("IndexedSitesPresentation.po"));
61
62     }
63 }
64
Popular Tags