1 17 18 19 20 package org.apache.lenya.cms.cocoon.acting; 21 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 import org.apache.avalon.framework.parameters.Parameters; 26 import org.apache.cocoon.environment.Redirector; 27 import org.apache.cocoon.environment.SourceResolver; 28 import org.apache.lenya.cms.rc.FileReservedCheckOutException; 29 import org.apache.log4j.Category; 30 31 34 public class ReservedCheckoutAction extends RevisionControllerAction { 35 Category log = Category.getInstance(ReservedCheckoutAction.class); 36 37 50 public Map act( 51 Redirector redirector, 52 SourceResolver resolver, 53 Map objectModel, 54 String src, 55 Parameters parameters) 56 throws Exception { 57 super.act(redirector, resolver, objectModel, src, parameters); 58 59 HashMap actionMap = new HashMap (); 60 61 try { 63 getLogger().debug(".act(): Filename: " + getFilename()); 64 getLogger().debug(".act(): Username: " + getUsername()); 65 66 if (getFilename() == null) { 67 throw new Exception ("Filename is null"); 68 } 69 70 if (getUsername() == null) { 71 throw new Exception ("Username is null"); 72 } 73 74 getRc().reservedCheckOut(getFilename(), getUsername()); 75 } catch (FileReservedCheckOutException e) { 76 actionMap.put("exception", "fileReservedCheckOutException"); 77 actionMap.put("filename", getFilename()); 78 actionMap.put("user", e.getCheckOutUsername()); 79 actionMap.put("date", e.getCheckOutDate()); 80 getLogger().warn( 81 "Document " 82 + getFilename() 83 + " already checked-out by " 84 + e.getCheckOutUsername() 85 + " since " 86 + e.getCheckOutDate()); 87 88 return actionMap; 89 } catch (Exception e) { 90 actionMap.put("exception", "genericException"); 91 actionMap.put("filename", getFilename()); 92 actionMap.put("message", "" + e.getMessage()); 93 log.error("The document " + getFilename() + " couldn't be checked out: ", e); 94 95 return actionMap; 96 } 97 98 return null; 99 } 100 } 101 | Popular Tags |