001: /**
002: * Copyright 2005 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.admin.console.search;
013:
014: import java.util.*;
015: import java.util.logging.Level;
016: import java.io.*;
017:
018: import javax.faces.context.FacesContext;
019: import javax.faces.el.ValueBinding;
020: import javax.servlet.http.HttpServletRequest;
021: import javax.management.*;
022:
023: import com.sun.web.ui.model.*;
024: import com.sun.web.ui.event.*;
025: import com.sun.web.ui.component.*;
026:
027: import com.sun.data.provider.*;
028: import com.sun.data.provider.impl.ObjectListDataProvider;
029:
030: import com.sun.portal.admin.common.util.AdminClientUtil;
031: import com.sun.portal.admin.console.common.PSBaseBean;
032:
033: public class ServerHomeBean extends PSBaseBean {
034:
035: private String id = null;
036: private String url = null;
037: private String root = null;
038: private String documentLevelSecurity = null;
039:
040: public ServerHomeBean() {
041: retrieve();
042: }
043:
044: public Option[] getAvailableBoolean() {
045: Option[] options = new Option[2];
046: options[0] = new Option("on", getLocalizedString("search",
047: "search.general.on"));
048: options[1] = new Option("off", getLocalizedString("search",
049: "search.general.off"));
050: return options;
051: }
052:
053: public String getId() {
054: return id;
055: }
056:
057: public String getUrl() {
058: return url;
059: }
060:
061: public String getRoot() {
062: return root;
063: }
064:
065: public String getDocumentLevelSecurity() {
066: return documentLevelSecurity;
067: }
068:
069: public void setDocumentLevelSecurity(String documentLevelSecurity) {
070: this .documentLevelSecurity = documentLevelSecurity;
071: }
072:
073: public String save() {
074: try {
075: LinkedList path = new LinkedList();
076: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
077: path.addFirst(id);
078: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
079: AdminClientUtil.SEARCHSERVER_MBEAN_TYPE, path);
080: Object[] params = {};
081: String[] signatures = {};
082: if (documentLevelSecurity.equals("on")) {
083: getMBeanServerConnection().invoke(on,
084: "enableDocumentLevelSecurity", params,
085: signatures);
086: } else {
087: getMBeanServerConnection().invoke(on,
088: "disableDocumentLevelSecurity", params,
089: signatures);
090: }
091: } catch (Exception e) {
092: log(Level.SEVERE, "ServerHomeBean.save() : Exception ", e);
093: }
094: retrieve();
095: return "gotoServerHome";
096: }
097:
098: public String reset() {
099: retrieve();
100: return "gotoServerHome";
101: }
102:
103: private void retrieve() {
104: id = (String) getSessionAttribute("search.server.selected");
105: try {
106: LinkedList path = new LinkedList();
107: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
108: path.addFirst(id);
109: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
110: AdminClientUtil.SEARCHSERVER_MBEAN_TYPE, path);
111:
112: Object[] params = {};
113: String[] signatures = {};
114:
115: Properties p = (Properties) getMBeanServerConnection()
116: .invoke(on, "retrieveVitals", params, signatures);
117: url = p.getProperty("url");
118: root = p.getProperty("root");
119:
120: Boolean b = (Boolean) getMBeanServerConnection()
121: .invoke(on, "retrieveDocumentLevelSecurity",
122: params, signatures);
123: documentLevelSecurity = (b.booleanValue()) ? "on" : "off";
124: } catch (Exception e) {
125: log(Level.SEVERE, "ServerHomeBean.retrieve() : Exception ",
126: e);
127: }
128: }
129:
130: }
|