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: */package org.apache.geronimo.console.configcreator;
17:
18: import java.io.IOException;
19: import java.util.Collections;
20: import java.util.List;
21:
22: import javax.portlet.ActionRequest;
23: import javax.portlet.ActionResponse;
24: import javax.portlet.PortletException;
25: import javax.portlet.RenderRequest;
26: import javax.portlet.RenderResponse;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30: import org.apache.geronimo.console.MultiPageModel;
31:
32: /**
33: * A handler for ...
34: *
35: * @version $Rev: 565397 $ $Date: 2007-08-13 09:21:44 -0700 (Mon, 13 Aug 2007) $
36: */
37: public class DependenciesHandler extends AbstractHandler {
38: private static final Log log = LogFactory
39: .getLog(DependenciesHandler.class);
40:
41: public DependenciesHandler() {
42: super (DEPENDENCIES_MODE,
43: "/WEB-INF/view/configcreator/dependencies.jsp");
44: }
45:
46: public String actionBeforeView(ActionRequest request,
47: ActionResponse response, MultiPageModel model)
48: throws PortletException, IOException {
49: return getMode();
50: }
51:
52: public void renderView(RenderRequest request,
53: RenderResponse response, MultiPageModel model)
54: throws PortletException, IOException {
55: WARConfigData data = getSessionData(request);
56: request.setAttribute(DATA_PARAMETER, data);
57: List commonLibs = JSR77_Util.getCommonLibs(request);
58: List addedDependencies = data.getDependencies();
59: //addedDependencies will be a subset of commonLibs
60: //sort commonLibs so that addedDependencies show up towards the beginning
61: commonLibs.removeAll(addedDependencies);
62: Collections.sort(commonLibs);
63: Collections.sort(addedDependencies);
64: commonLibs.addAll(0, addedDependencies);
65: request.setAttribute(COMMON_LIBS_PARAMETER, commonLibs);
66: }
67:
68: public String actionAfterView(ActionRequest request,
69: ActionResponse response, MultiPageModel model)
70: throws PortletException, IOException {
71: WARConfigData data = getSessionData(request);
72: data.getDependencies().clear();
73: String[] selectedJars = request
74: .getParameterValues(SELECTED_LIBS_PARAMETER);
75: for (int i = 0; selectedJars != null && i < selectedJars.length; i++) {
76: data.getDependencies().add(selectedJars[i]);
77: }
78: return DISPLAY_PLAN_MODE + "-before";
79: }
80: }
|