1 7 8 package org.enhydra.snapper.presentation; 9 10 import org.enhydra.dods.DODS; 12 import org.enhydra.snapper.SnapperManager; 13 import org.enhydra.snapper.spec.IndexFactory; 14 15 import org.enhydra.snapper.spec.Index; 16 import org.enhydra.snapper.spec.IndexAll; 17 import org.enhydra.snapper.spec.IndexAllFactory; 18 import org.enhydra.snapper.spec.Path; 19 import org.enhydra.snapper.spec.PathType; 20 import org.enhydra.snapper.spec.Site; 21 import org.enhydra.snapper.spec.SiteFactory; 22 import org.enhydra.snapper.spec.SiteList; 23 import org.enhydra.snapper.spec.SiteListFactory; 24 import org.enhydra.xml.xmlc.XMLObject; 25 26 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException; 27 28 30 public class IndexSitePresentation extends BasePO { 31 Index index = null; 32 33 protected XMLObject getDOM() throws Exception { 34 35 String siteOID; 36 Site site = null; 37 Path[] pathArray = null; 38 PathType pathType = null; 39 String indexdir = ""; 40 42 if (comms.request.getParameter("action") != null) { 43 if (comms.request.getParameter("action").equals("indexAllAtOnce")) { 44 indexAtOnce(); 46 } 47 48 else 49 indexOneByOne(); 50 51 throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po")); 52 } 53 54 siteOID = comms.request.getParameter("id"); 55 try { 56 57 site = (SiteFactory.getSite("org.enhydra.snapper.business.SiteImpl")).findSiteByID(siteOID, dbTransaction); 58 59 if (site.getLOCKED() == true) { 60 61 SnapperManager.getInstance().getLoggingManager().info("Site locked! Indexing Aborted."); 62 throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po?l=" 63 + site.getName())); 64 } 65 } catch (Exception e) { 66 } 67 68 try { 69 index = IndexFactory.getIndex("org.enhydra.snapper.business.IndexImpl"); 70 } catch (Exception ex) { 71 System.out.println("Exception: " + ex); 72 } 73 74 76 index.index(siteOID, DODS.getDatabaseManager()); 77 Thread newThread = new Thread ((Runnable ) index, siteOID); 78 DODS.register(newThread,DODS.getDatabaseManager()); 79 newThread.start(); 80 SnapperManager.getInstance().addThread(siteOID, index); 81 82 throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po")); 85 } 86 87 private void indexAtOnce() { 88 Site[] list; 89 try { 90 SiteList sl = SiteListFactory.getSiteList("org.enhydra.snapper.business.SiteListImpl"); 91 list = sl.getList(dbTransaction); 92 93 } catch (Exception ex) { 94 System.out.println("Exception: " + ex); 95 list = null; 96 } 97 98 for (int numSites = 0; numSites < list.length; numSites++) { 99 try { 100 String id = list[numSites].getID(); 101 Index index = IndexFactory.getIndex("org.enhydra.snapper.business.IndexImpl"); 102 index.index(id, DODS.getDatabaseManager()); 103 104 Thread newThread = new Thread ((Runnable ) index, id); 105 DODS.register(newThread,DODS.getDatabaseManager()); 106 newThread.start(); 107 108 SnapperManager.getInstance().addThread(id, index); 110 } catch (Exception e) { 111 SnapperManager.getInstance().getLoggingManager().error("Could not index site"); 112 } 113 } 114 } 115 116 private void indexOneByOne() { 117 Site[] list; 118 try { 119 SiteList sl = SiteListFactory.getSiteList("org.enhydra.snapper.business.SiteListImpl"); 120 list = sl.getList(dbTransaction); 121 String [] ids = new String [list.length]; 122 for (int i = 0; i < list.length; i++) { 123 ids[i] = list[i].getID(); 124 } 125 IndexAll indexall; 126 indexall = IndexAllFactory.getIndexAll("org.enhydra.snapper.business.IndexAllImpl"); 127 indexall.index(ids, DODS.getDatabaseManager()); 128 129 Thread newThread = new Thread ((Runnable ) indexall); 130 DODS.register(newThread,DODS.getDatabaseManager()); 131 newThread.start(); 132 133 135 } catch (Exception ex) { 136 System.out.println("Exception: " + ex); 137 list = null; 138 } 139 140 } 141 142 } | Popular Tags |