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: package org.apache.lenya.cms.cocoon.acting;
20:
21: import java.util.HashMap;
22: import java.util.Map;
23:
24: import org.apache.avalon.framework.parameters.Parameters;
25: import org.apache.cocoon.environment.Redirector;
26: import org.apache.cocoon.environment.SourceResolver;
27: import org.apache.lenya.cms.repository.Node;
28:
29: /**
30: * An action that tests if a document is already checked out by a given user.
31: * If it isn't, a check out will be tried.
32: */
33: public class DiscoverCheckoutAction extends RevisionControllerAction {
34:
35: /**
36: * @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)
37: */
38: public Map act(Redirector redirector, SourceResolver resolver,
39: Map objectModel, String src, Parameters parameters)
40: throws Exception {
41: super .act(redirector, resolver, objectModel, src, parameters);
42:
43: HashMap actionMap = new HashMap();
44: Node node = getNode();
45:
46: if (node.isCheckedOut()) {
47: actionMap.put("filename", node.getSourceURI());
48: actionMap.put("user", node.getCheckoutUserId());
49: return actionMap;
50: }
51: return null;
52: }
53: }
|