1 23 24 25 package org.infoglue.deliver.applications.actions; 26 27 import java.util.ArrayList ; 28 import java.util.List ; 29 30 import javax.servlet.http.HttpServletResponse ; 31 32 import org.apache.log4j.Logger; 33 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 34 import org.infoglue.cms.controllers.kernel.impl.simple.ServerNodeController; 35 import org.infoglue.cms.util.CmsPropertyHandler; 36 import org.infoglue.deliver.applications.databeans.CacheEvictionBean; 37 import org.infoglue.deliver.util.CacheController; 38 import org.infoglue.deliver.util.RequestAnalyser; 39 import org.infoglue.deliver.util.ThreadMonitor; 40 41 42 49 50 public class UpdateCacheAction extends InfoGlueAbstractAction 51 { 52 private final static Logger logger = Logger.getLogger(UpdateCacheAction.class.getName()); 53 54 60 61 private String repositoryName = null; 62 private Integer languageId = null; 63 private Integer siteNodeId = null; 64 65 private static boolean cachingInProgress = false; 66 67 private ThreadMonitor tk = null; 68 69 72 73 public UpdateCacheAction() 74 { 75 76 } 77 78 81 82 public String doTest() throws Exception 83 { 84 String operatingMode = CmsPropertyHandler.getOperatingMode(); 85 86 if(operatingMode != null && operatingMode.equalsIgnoreCase("3")) 87 { 88 if(!ServerNodeController.getController().getIsIPAllowed(this.getRequest())) 89 { 90 this.getResponse().setContentType("text/plain"); 91 this.getResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); 92 this.getResponse().getWriter().println("You have no access to this view - talk to your administrator if you should."); 93 94 return NONE; 95 } 96 } 97 98 this.getResponse().getWriter().println("test ok - cache action available"); 99 100 102 return NONE; 103 } 104 105 109 110 public String doExecute() throws Exception 111 { 112 if(!CmsPropertyHandler.getOperatingMode().equals("3")) 113 tk = new ThreadMonitor(2000, this.getRequest(), "Update cache took to long", false); 114 115 logger.info("Update Cache starts.."); 116 String operatingMode = CmsPropertyHandler.getOperatingMode(); 117 118 if(operatingMode != null && operatingMode.equalsIgnoreCase("3")) 119 { 120 long start = System.currentTimeMillis(); 121 if(!ServerNodeController.getController().getIsIPAllowed(this.getRequest())) 122 { 123 this.getResponse().setContentType("text/plain"); 124 this.getResponse().setStatus(HttpServletResponse.SC_FORBIDDEN); 125 this.getResponse().getWriter().println("You have no access to this view - talk to your administrator if you should."); 126 127 return NONE; 128 } 129 130 } 131 132 try 133 { 134 136 List newNotificationList = new ArrayList (); 139 140 int i = 0; 141 142 String className = this.getRequest().getParameter(i + ".className"); 143 String typeId = this.getRequest().getParameter(i + ".typeId"); 144 String objectId = this.getRequest().getParameter(i + ".objectId"); 145 String objectName = this.getRequest().getParameter(i + ".objectName"); 146 while(className != null && !className.equals("")) 147 { 148 logger.info("className:" + className); 149 logger.info("objectId:" + objectId); 150 151 CacheEvictionBean cacheEvictionBean = new CacheEvictionBean(className, typeId, objectId, objectName); 152 newNotificationList.add(cacheEvictionBean); 153 159 logger.info("Added a cacheEvictionBean " + cacheEvictionBean.getClassName() + ":" + cacheEvictionBean.getTypeId() + ":" + cacheEvictionBean.getObjectName() + ":" + cacheEvictionBean.getObjectId()); 160 161 i++; 162 className = this.getRequest().getParameter(i + ".className"); 163 typeId = this.getRequest().getParameter(i + ".typeId"); 164 objectId = this.getRequest().getParameter(i + ".objectId"); 165 objectName = this.getRequest().getParameter(i + ".objectName"); 166 } 167 168 if(i == 0) 169 { 170 className = this.getRequest().getParameter("className"); 171 typeId = this.getRequest().getParameter("typeId"); 172 objectId = this.getRequest().getParameter("objectId"); 173 objectName = this.getRequest().getParameter("objectName"); 174 CacheEvictionBean cacheEvictionBean = new CacheEvictionBean(className, typeId, objectId, objectName); 175 newNotificationList.add(cacheEvictionBean); 176 183 184 } 185 186 199 200 synchronized(CacheController.notifications) 203 { 204 CacheController.notifications.addAll(newNotificationList); 205 } 206 208 logger.info("UpdateCache finished..."); 209 } 210 catch(Exception e) 211 { 212 logger.error(e.getMessage(), e); 213 } 214 catch(Throwable t) 215 { 216 logger.error(t.getMessage()); 217 } 218 219 logger.info("Update Cache stops.."); 221 222 if(tk != null) 223 tk.done(); 224 225 return NONE; 226 } 227 228 229 232 253 } 254 | Popular Tags |