Attachment 'ForcedCheckinAction.java'

Download

   1 /*
   2  * Copyright  1999-2004 The Apache Software Foundation
   3  *
   4  *  Licensed under the Apache License, Version 2.0 (the "License");
   5  *  you may not use this file except in compliance with the License.
   6  *  You may obtain a copy of the License at
   7  *
   8  *      http://www.apache.org/licenses/LICENSE-2.0
   9  *
  10  *  Unless required by applicable law or agreed to in writing, software
  11  *  distributed under the License is distributed on an "AS IS" BASIS,
  12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13  *  See the License for the specific language governing permissions and
  14  *  limitations under the License.
  15  *
  16  */
  17 
  18 /* $Id: ForcedCheckinAction.java,v 1.16 2004/05/23 12:52:43 gregor Exp $  */
  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.FileReservedCheckInException;
  29 
  30 
  31 /**
  32  * Checkin document
  33  */
  34 public class ForcedCheckinAction extends RevisionControllerAction {
  35     /**
  36      * Checkin document
  37      *
  38      * @param redirector DOCUMENT ME!
  39      * @param resolver DOCUMENT ME!
  40      * @param objectModel DOCUMENT ME!
  41      * @param src DOCUMENT ME!
  42      * @param parameters DOCUMENT ME!
  43      *
  44      * @return HashMap with checkin parameters
  45      *
  46      * @throws Exception DOCUMENT ME!
  47      */
  48     public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws Exception {
  49         super.act(redirector, resolver, objectModel, src, parameters);
  50 
  51         HashMap actionMap = new HashMap();
  52 
  53         boolean backup = true;
  54 	if (parameters.getParameter("backup", "true").equals("false")) backup = false;
  55         log.debug("Backup: " + backup);
  56 
  57         try {
  58             getRc().reservedCheckIn(getFilename(), "System", true);
  59         } catch (FileReservedCheckInException e) {
  60             actionMap.put("exception", "fileReservedCheckInException");
  61             actionMap.put("filename", getFilename());
  62             actionMap.put("checkType", e.getTypeString());
  63             actionMap.put("user", e.getUsername());
  64             actionMap.put("date", e.getDate());
  65             getLogger().warn(e.getMessage());
  66 
  67             return actionMap;
  68         } catch (Exception e) {
  69             actionMap.put("exception", "genericException");
  70             actionMap.put("filename", getFilename());
  71             actionMap.put("message", e.getMessage());
  72             getLogger().warn("The document " + getFilename() + " couldn't be checked in");
  73 
  74             return actionMap;
  75         }
  76 
  77         return null;
  78     }
  79 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.