1 17 18 19 20 package org.apache.lenya.cms.cocoon.acting; 21 22 import java.io.FileNotFoundException ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 import org.apache.avalon.framework.parameters.Parameters; 27 import org.apache.cocoon.environment.ObjectModelHelper; 28 import org.apache.cocoon.environment.Redirector; 29 import org.apache.cocoon.environment.Request; 30 import org.apache.cocoon.environment.SourceResolver; 31 32 33 public class RollbackAction extends RevisionControllerAction { 34 47 public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, 48 Parameters parameters) throws Exception { 49 super.act(redirector, resolver, objectModel, src, parameters); 50 51 HashMap actionMap = new HashMap (); 52 53 Request request = ObjectModelHelper.getRequest(objectModel); 55 56 if (request == null) { 57 getLogger().error("No request object"); 58 59 return null; 60 } 61 62 String rollbackTime = request.getParameter("rollbackTime"); 64 65 long newtime = 0; 67 68 try { 69 newtime = getRc().rollback(getFilename(), getUsername(), true, new Long (rollbackTime).longValue()); 70 } catch (FileNotFoundException e) { 71 getLogger().error("Unable to roll back!" + e); 72 73 return null; 74 } catch (Exception e) { 75 getLogger().error("Unable to roll back!" + e); 76 77 return null; 78 } 79 80 getLogger().debug("rollback complete, old (and now current) time was " + rollbackTime + 81 " backup time is " + newtime); 82 83 String location = request.getHeader("Referer"); 84 85 getLogger().debug("redirect to " + location); 86 actionMap.put("location", location); 87 88 return actionMap; 89 } 90 } 91 | Popular Tags |