001: /**
002: * $Id: TaskNavigatorBean.java,v 1.9 2005/10/08 02:05:45 ru111118 Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.admin.console.common;
014:
015: import java.util.Map;
016: import java.util.logging.Level;
017: import javax.faces.context.FacesContext;
018: import javax.servlet.http.HttpServletRequest;
019:
020: public class TaskNavigatorBean extends PSBaseBean {
021:
022: private static final String QUERY_PARAM = "type";
023:
024: private boolean isPortalTask = true;
025: private boolean isInstanceTask = false;
026: private boolean isShowDNSelector = false;
027: private int taskType = 1;
028: private String navUrl = null;
029: private String jsCalls = null;
030:
031: public TaskNavigatorBean() {
032: HttpServletRequest req = (HttpServletRequest) FacesContext
033: .getCurrentInstance().getExternalContext().getRequest();
034: String paramVal = (String) req.getParameter(QUERY_PARAM);
035: if (paramVal != null) {
036: try {
037: taskType = Integer.parseInt(paramVal);
038: } catch (Exception e) {
039: log(Level.SEVERE,
040: "TaskNavigatorBean.TaskNavigatorBean(): Invalid Query Param or Value: "
041: + paramVal, e);
042: }
043: setupVars();
044: }
045: // Cleanup session attributes
046: cleanSessionAttributes();
047: }
048:
049: public String navigate() {
050: jsCalls = "navigateTaskOnAction(); window.close()";
051: return "";
052: }
053:
054: public boolean isPortalTask() {
055: return isPortalTask;
056: }
057:
058: public boolean isInstanceTask() {
059: return isInstanceTask;
060: }
061:
062: public boolean isShowDNSelector() {
063: return isShowDNSelector;
064: }
065:
066: public String getNavUrl() {
067: return navUrl;
068: }
069:
070: public void setNavUrl(String value) {
071: navUrl = value;
072: }
073:
074: public String getJavaScript() {
075: return jsCalls;
076: }
077:
078: public String getTaskType() {
079: return String.valueOf(taskType);
080: }
081:
082: public void setTaskType(String ttype) {
083: taskType = Integer.parseInt(ttype);
084: setupVars();
085: }
086:
087: private void setupVars() {
088:
089: switch (taskType) {
090: case 1:
091: navUrl = "../faces/desktop/DesktopManager.jsp";
092: isShowDNSelector = true;
093: isPortalTask = true;
094: // Set the session attribute that will be used to setup the
095: // url to the Common Tasks page when the back button in the
096: // DesktopManagerHeader.jsp is clicked
097: setSessionAttribute(ATTR_DESKTOP_MANAGER_RETURN_URL,
098: "../faces/common/CommonTasks.jsp");
099: break;
100: case 2:
101: navUrl = "../faces/ubt/UBTReports.jsp";
102: isPortalTask = true;
103: break;
104: case 3:
105: navUrl = "../faces/logging/LogViewer.jsp";
106: isPortalTask = true;
107: break;
108: case 4:
109: navUrl = "../faces/logging/CommonLoggerSettings.jsp";
110: isPortalTask = true;
111: break;
112: case 5:
113: navUrl = "../faces/search/ReportPopularSearchesHome.jsp";
114: isPortalTask = false;
115: break;
116: case 6:
117: navUrl = "../faces/search/RobotHome.jsp";
118: isPortalTask = false;
119: break;
120: case 7:
121: navUrl = "../faces/search/RobotSitesHome.jsp";
122: isPortalTask = false;
123: break;
124: default:
125: navUrl = "";
126: break;
127: }
128:
129: }
130:
131: private void cleanSessionAttributes() {
132: Map smap = FacesContext.getCurrentInstance()
133: .getExternalContext().getSessionMap();
134: if (smap != null) {
135: smap.remove(SessionAttributeNames.ATTR_CHANNEL);
136: smap
137: .remove(SessionAttributeNames.ATTR_DELETE_CHANNEL_DISABLED);
138: smap.remove(SessionAttributeNames.ATTR_REGENERATE_CHANNELS);
139: smap.remove(SessionAttributeNames.ATTR_RPDS);
140: smap.remove(SessionAttributeNames.ATTR_SELECTED_CONFIG);
141: smap.remove(SessionAttributeNames.ATTR_SELECTED_INSTANCE);
142: smap.remove(SessionAttributeNames.ATTR_SELECTED_PORTAL);
143: smap.remove(SessionAttributeNames.ATTR_SELECTED_PRODUCER);
144: smap
145: .remove(SessionAttributeNames.ATTR_SELECTED_TREE_CHANNEL);
146: smap
147: .remove(SessionAttributeNames.ATTR_SELECTED_TREE_CONTAINER);
148: smap
149: .remove(SessionAttributeNames.ATTR_DESKTOP_MANAGER_RETURN_URL);
150: }
151: }
152: }
|