01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /* $Id: ReservedCheckoutAction.java 567462 2007-08-19 20:31:38Z andreas $ */
20:
21: package org.apache.lenya.cms.cocoon.acting;
22:
23: import java.util.HashMap;
24: import java.util.Map;
25:
26: import org.apache.avalon.framework.parameters.Parameters;
27: import org.apache.cocoon.environment.Redirector;
28: import org.apache.cocoon.environment.SourceResolver;
29: import org.apache.lenya.cms.repository.Node;
30: import org.apache.lenya.cms.repository.RepositoryException;
31: import org.apache.lenya.util.Assert;
32:
33: /**
34: * Action doing reserved checkout
35: */
36: public class ReservedCheckoutAction extends RevisionControllerAction {
37:
38: /**
39: * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
40: */
41: public Map act(Redirector redirector, SourceResolver resolver,
42: Map objectModel, String src, Parameters parameters)
43: throws Exception {
44: super .act(redirector, resolver, objectModel, src, parameters);
45:
46: HashMap actionMap = new HashMap();
47:
48: //check out
49: try {
50:
51: Node node = getNode();
52: String username = getUsername();
53:
54: Assert.notNull("node", node);
55: Assert.notNull("username", username);
56:
57: if (!node.isCheckedOutBySession(node.getSession())) {
58: node.checkout();
59: }
60: } catch (RepositoryException e) {
61: actionMap.put("exception", "genericException");
62: actionMap.put("filename", getNode().getSourceURI());
63: actionMap.put("message", "" + e.getMessage());
64: getLogger().error(
65: "The node " + getNode().getSourceURI()
66: + " couldn't be checked out: ", e);
67:
68: return actionMap;
69: }
70:
71: return null;
72: }
73: }
|