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.workflow.usecases;
19:
20: import java.util.HashMap;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: import org.apache.lenya.cms.usecase.AbstractUsecase;
25: import org.apache.lenya.cms.usecase.UsecaseInvoker;
26: import org.apache.lenya.cms.usecase.UsecaseMessage;
27: import org.apache.lenya.util.Assert;
28:
29: /**
30: * Invocation usecase for the multi-workflow usecase.
31: */
32: public class MultiWorkflowInvoke extends AbstractUsecase {
33:
34: protected static final String URL = "url";
35: protected static final String USECASE_NAME = "usecaseName";
36:
37: protected void doExecute() throws Exception {
38: super .doExecute();
39:
40: String usecase = getParameterAsString(USECASE_NAME);
41: Assert.notNull("usecase", usecase);
42: String url = getParameterAsString(URL);
43: Assert.notNull("url", url);
44:
45: UsecaseInvoker invoker = null;
46: try {
47: invoker = (UsecaseInvoker) this .manager
48: .lookup(UsecaseInvoker.ROLE);
49: invoker.invoke(url, usecase, new HashMap());
50:
51: if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
52: List messages = invoker.getErrorMessages();
53: for (Iterator i = messages.iterator(); i.hasNext();) {
54: UsecaseMessage message = (UsecaseMessage) i.next();
55: addErrorMessage(message.getMessage(), message
56: .getParameters());
57: }
58: }
59: } finally {
60: if (invoker == null) {
61: this.manager.release(invoker);
62: }
63: }
64: }
65:
66: }
|