summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/CMSPageFeeder.java
blob: 0abd28f296e1f1187b3d1ee8c4f842b9b03fdbd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.admin.certsrv;

import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import com.netscape.management.client.*;
import com.netscape.management.client.console.*;
import com.netscape.management.client.topology.*;
import com.netscape.management.client.util.*;
import com.netscape.admin.certsrv.config.*;
import netscape.ldap.*;

/**
 *	Netscape Certificate Server 4.0 page model.
 *
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 */
public class CMSPageFeeder extends FrameworkInitializer {
//public class CMSPageFeeder extends PageFeeder {
    /*==========================================================
     * variables
     *==========================================================*/
    public static String RESOURCE_TAB_TYPE = "RESOURCE_TAB_TYPE";
    public static String TASK_TAB_TYPE = "TASK_TAB_TYPE";
    
    private static String PREFIX = "CMSPAGEFEEDER_";

    private ConsoleInfo mConsoleInfo;		// global information
	private CMSServerInfo mServerInfo;		// instance information

	//private TaskPage mTaskPage;		    // task page
	private Hashtable mPages;               // resource pages
	//private ResourcePage mResourcePage;	// resource page
	//private ResourcePage mContentPage;    // content page
    //private ResourcePage mUGPage;         // identity and roles page
    
	private ResourceBundle mResource;       // resource boundle

	/*==========================================================
     * constructors
     *==========================================================*/

	/**
	 *	Constructor.
	 *
	 * @param admin The server instance.
	 * @param info	Global console connection information
	 * @param serverInfo Server instance connection information
	 */
    public CMSPageFeeder( ConsoleInfo info, CMSServerInfo serverInfo ) {
		mConsoleInfo = info;
		mServerInfo = serverInfo;
        mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName());
        mPages = new Hashtable();
        
		setFrameTitle(mResource.getString(PREFIX+"SERVERNAME"));
		setMinimizedImage(CMSAdminUtil.getImage(CMSAdminResources.IMAGE_CERTICON_MEDIUM).getImage());
		setBannerImage(CMSAdminUtil.getThemeImage(CMSAdminResources.IMAGE_BRANDING).getImage());
        setBannerText("");
		//setFrameImage(CMSAdminUtil.getImage(CMSAdminResources.IMAGE_CERTICON_SMALL).getImage());
	}

    /**
     * Retrieve the tab page as needed. If the tab page type not found
     * throws exceptions. If the tab page with the specified name already
     * exist, simply return that page.
     */
    public IPage getPage(String type, String name) throws EAdminException {
        //Debug.println("CMSPageFeeder: getPage() -"+type+"-"+name);
        if (type.trim().equals(TASK_TAB_TYPE)) {
            return null;
/*
            //XXX Support multiple task tab ???
            if (mPages.containsKey("TASK"))
                return (IPage) mPages.get("TASK");
            TaskPage task = createTaskPage();

            // TAKE THIS ONE OUT FOR BETA-1
            mPages.put("TASK", task);
            addPage(task);
            return task;
*/
        }
        
        if (!type.trim().equals(RESOURCE_TAB_TYPE)) {
            throw new EAdminException(mResource.getString(PREFIX+"RESOURCE_TAB_NOT_FOUND"), true);
        }
        
        if (mPages.containsKey(name.trim())) {
            return (IPage) mPages.get(name.trim());    
        } else {
            CMSResourcePage page = new CMSResourcePage(new CMSBaseResourceModel(mConsoleInfo,mServerInfo));
            String title;
            try {
                title = mResource.getString(PREFIX+name.trim());
            } catch (MissingResourceException e) {
                title = "Missing Title";
            }
            page.setPageTitle(title);
            mPages.put(name.trim(), page);
            addPage(page);
            return page;
        }
    }


    /**
     * Expend resource trees insde each individual pages
     */
    public void expendPages() {
        for (Enumeration e = mPages.keys() ; e.hasMoreElements() ;) {
              String name = (String)e.nextElement();
              IPage page = (IPage)mPages.get(name);
              if (page instanceof CMSResourcePage)
                  ((CMSResourcePage)page).getTree().expandRow(0);
          }
    }
    
    
    /*==========================================================
	 * private methods
     *==========================================================*/

	/**
	 * Create the directory server task tab page by finding all task
	 * entries in the directory for this instance.
	 */
	private TaskPage createTaskPage() {
		TaskModel model = new CMSTaskModel(mConsoleInfo, mServerInfo);
		return new TaskPage( model );
	}
}