001: /**
002: * Copyright 2004 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.fabric.tasks;
013:
014: import java.util.*;
015: import java.util.logging.Level;
016: import java.util.logging.Logger;
017: import java.util.logging.LogRecord;
018:
019: import com.sun.portal.admin.common.context.PSConfigContext;
020: import com.sun.portal.admin.common.context.PortalDomainContext;
021: import com.sun.portal.admin.common.util.AdminUtil;
022: import com.sun.portal.admin.server.PASModule;
023: import com.sun.portal.fabric.tasks.SearchSetup;
024: import com.sun.portal.log.common.PortalLogger;
025:
026: public class CreateSearchServerThread extends Thread {
027:
028: //private Logger logger = null;
029: private static Logger logger = PortalLogger
030: .getLogger(CreateSearchServerThread.class);
031: private PSConfigContext cc = null;
032: private PortalDomainContext pdc = null;
033: private List path = null;
034: private String searchServerID = null;
035: private Properties webContainerProperties = null;
036: public int status = 0;
037:
038: public CreateSearchServerThread(PSConfigContext cc,
039: PortalDomainContext pdc, List path, String searchServerID,
040: Properties webContainerProperties) {
041: this .cc = cc;
042: this .pdc = pdc;
043: this .path = path;
044: this .searchServerID = searchServerID;
045: this .webContainerProperties = webContainerProperties;
046: this .status = 0;
047: }
048:
049: public void run() {
050: try {
051: status = 1;
052: SearchSetup ss = new SearchSetup();
053:
054: status = 2;
055: ss
056: .configuration(cc, searchServerID,
057: webContainerProperties);
058:
059: status = 3;
060: ss.deployment(cc, searchServerID, searchServerID,
061: webContainerProperties);
062:
063: status = 4;
064: Map m = new HashMap();
065: m.put("Type", getProperty(webContainerProperties,
066: "WebContainerType"));
067: m.put("Protocol", getProperty(webContainerProperties,
068: "Scheme"));
069: m.put("Host", getProperty(webContainerProperties, "Host"));
070: m.put("Port", getProperty(webContainerProperties, "Port"));
071: m.put("Domain", getProperty(webContainerProperties,
072: "WebContainerDomainName"));
073: m.put("Instance", getProperty(webContainerProperties,
074: "WebContainerInstanceName"));
075: m.put("Cell", getProperty(webContainerProperties,
076: "WebContainerDeployCell"));
077: m.put("Node", getProperty(webContainerProperties,
078: "WebContainerDeployNode"));
079: m.put("ManagedServer", getProperty(webContainerProperties,
080: "WebContainerManagedServer"));
081: m.put("AdministrationProtocol", getProperty(
082: webContainerProperties, "WebContainerAdminScheme"));
083: m.put("AdministrationHost", getProperty(
084: webContainerProperties, "WebContainerAdminHost"));
085: m.put("AdministrationPort", getProperty(
086: webContainerProperties, "WebContainerAdminPort"));
087: m.put("Administrator", getProperty(webContainerProperties,
088: "WebContainerAdminUid"));
089: m.put("AdministrationPassword",
090: getProperty(webContainerProperties,
091: "WebContainerAdminPassword"));
092: m.put("MasterPassword", getProperty(webContainerProperties,
093: "WebContainerMasterPassword"));
094: m.put("JDKDirectory", getProperty(webContainerProperties,
095: "WebContainerJDKDir"));
096: m.put("InstallDirectory", getProperty(
097: webContainerProperties, "WebContainerInstallDir"));
098: m.put("InstanceDirectory", getProperty(
099: webContainerProperties, "WebContainerInstanceDir"));
100: m.put("DocumentRootDirectory", getProperty(
101: webContainerProperties, "WebContainerDocRoot"));
102: pdc.createResource(AdminUtil.SEARCHSERVER_MBEAN_TYPE, path,
103: searchServerID, m);
104: List childPath = AdminUtil.getChildPath(path,
105: searchServerID);
106: pdc.createResource(AdminUtil.SEARCH_DATABASE_MBEAN_TYPE,
107: childPath, "database", m);
108: pdc.createResource(AdminUtil.SEARCH_ROBOT_MBEAN_TYPE,
109: childPath, "robot", m);
110: pdc.createResource(AdminUtil.SEARCH_SITEPROBE_MBEAN_TYPE,
111: childPath, "siteprobe", m);
112: pdc.createResource(
113: AdminUtil.SEARCH_AUTOCLASSIFY_MBEAN_TYPE,
114: childPath, "autoclassify", m);
115: pdc.createResource(AdminUtil.SEARCH_CATEGORY_MBEAN_TYPE,
116: childPath, "category", m);
117: PASModule.reloadMBeans(pdc,
118: AdminUtil.SEARCHSERVER_MBEAN_TYPE, path);
119:
120: status = 0;
121: } catch (Exception e) {
122: if (logger.isLoggable(Level.SEVERE)) {
123: LogRecord rec = new LogRecord(Level.SEVERE,
124: "PSFB_CSPFT0221");
125: rec.setLoggerName(logger.getName());
126: rec.setParameters(new Object[] { searchServerID });
127: rec.setThrown(e);
128: logger.log(rec);
129: }
130: status = -1;
131: }
132: }
133:
134: private String getProperty(Properties p, String key) {
135: if (p.containsKey(key)) {
136: return p.getProperty(key);
137: } else {
138: return "";
139: }
140: }
141:
142: }
|