KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > cocoon > acting > ReservedCheckinAction


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: ReservedCheckinAction.java 43040 2004-05-23 12:52:44Z gregor $ */
19
20 package org.apache.lenya.cms.cocoon.acting;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
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 ReservedCheckinAction 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 JavaDoc act(Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc src, Parameters parameters) throws Exception JavaDoc {
49         super.act(redirector, resolver, objectModel, src, parameters);
50
51         HashMap JavaDoc actionMap = new HashMap JavaDoc();
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(), getUsername(), backup);
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 JavaDoc 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 }
80
Popular Tags