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.lenya.cms.rc.RCML; 30 import org.apache.lenya.cms.rc.RCMLEntry; 31 32 33 37 38 public class ReservedCheckoutTestAction extends RevisionControllerAction { 39 40 43 public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, 44 Parameters parameters) throws Exception { 45 super.act(redirector, resolver, objectModel, src, parameters); 46 47 HashMap actionMap = new HashMap (); 48 49 try { 50 RCMLEntry entry =getRc().getRCML(getFilename()).getLatestEntry(); 51 52 if ((entry == null) || (entry.getType() != RCML.co) || !entry.getIdentity().equals(getUsername())) { 53 getRc().reservedCheckOut(getFilename(),getUsername()); 55 } 56 } catch (FileReservedCheckOutException e) { 57 actionMap.put("exception", "fileReservedCheckOutException"); 58 actionMap.put("filename", getFilename()); 59 actionMap.put("user", e.getCheckOutUsername()); 60 actionMap.put("date", e.getCheckOutDate()); 61 getLogger().warn("Document " + getFilename() + " already checked-out by " + e.getCheckOutUsername() + " since " + e.getCheckOutDate()); 62 63 return actionMap; 64 } catch (Exception e) { 65 actionMap.put("exception", "genericException"); 66 actionMap.put("filename", getFilename()); 67 actionMap.put("message", e.getMessage()); 68 getLogger().error(".act(): The document " + getFilename() + " couldn't be checked out: ", e); 69 70 return actionMap; 71 } 72 return null; 73 } 74 } 75 | Popular Tags |