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: package org.apache.lenya.cms.site.usecases;
19:
20: import org.apache.lenya.cms.publication.Document;
21: import org.apache.lenya.cms.repository.Node;
22: import org.apache.lenya.cms.usecase.DocumentUsecase;
23: import org.apache.lenya.cms.usecase.UsecaseException;
24: import org.apache.lenya.cms.workflow.WorkflowUtil;
25: import org.apache.lenya.cms.workflow.usecases.UsecaseWorkflowHelper;
26:
27: /**
28: * Rollback.
29: */
30: public class Rollback extends DocumentUsecase {
31:
32: /**
33: * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
34: */
35: protected org.apache.lenya.cms.repository.Node[] getNodesToLock()
36: throws UsecaseException {
37: org.apache.lenya.cms.repository.Node[] objects = { getSourceDocument()
38: .getRepositoryNode() };
39: return objects;
40: }
41:
42: /**
43: * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
44: */
45: protected void doCheckPreconditions() throws Exception {
46: super .doCheckPreconditions();
47: UsecaseWorkflowHelper.checkWorkflow(this .manager, this ,
48: getEvent(), getSourceDocument(), getLogger());
49: }
50:
51: /**
52: * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
53: */
54: protected void doExecute() throws Exception {
55: super .doExecute();
56:
57: int revision = getParameterAsInteger("rollbackRevision", -1);
58:
59: Document document = getSourceDocument();
60: Node node = document.getRepositoryNode();
61: node.rollback(revision);
62:
63: WorkflowUtil.invoke(this .manager, getSession(), getLogger(),
64: getSourceDocument(), getEvent());
65: }
66:
67: protected String getEvent() {
68: return getParameterAsString("workflowEvent");
69: }
70:
71: }
|