KickJava   Java API By Example, From Geeks To Geeks.

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


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: ReservedCheckoutAction.java 43039 2004-05-22 19:43:41Z 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.FileReservedCheckOutException;
29 import org.apache.log4j.Category;
30
31 /**
32  * Action doing reserved checkout
33  */

34 public class ReservedCheckoutAction extends RevisionControllerAction {
35     Category log = Category.getInstance(ReservedCheckoutAction.class);
36
37     /**
38      * DOCUMENT ME!
39      *
40      * @param redirector DOCUMENT ME!
41      * @param resolver DOCUMENT ME!
42      * @param objectModel DOCUMENT ME!
43      * @param src DOCUMENT ME!
44      * @param parameters DOCUMENT ME!
45      *
46      * @return DOCUMENT ME!
47      *
48      * @throws Exception DOCUMENT ME!
49      */

50     public Map JavaDoc act(
51         Redirector redirector,
52         SourceResolver resolver,
53         Map JavaDoc objectModel,
54         String JavaDoc src,
55         Parameters parameters)
56         throws Exception JavaDoc {
57         super.act(redirector, resolver, objectModel, src, parameters);
58
59         HashMap JavaDoc actionMap = new HashMap JavaDoc();
60
61         //check out
62
try {
63             getLogger().debug(".act(): Filename: " + getFilename());
64             getLogger().debug(".act(): Username: " + getUsername());
65
66             if (getFilename() == null) {
67                 throw new Exception JavaDoc("Filename is null");
68             }
69
70             if (getUsername() == null) {
71                 throw new Exception JavaDoc("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 JavaDoc 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