0001: package com.sun.portal.search.admin.mbeans;
0002:
0003: import java.io.*;
0004: import java.util.*;
0005: import java.util.logging.*;
0006: import java.net.*;
0007: import java.lang.*;
0008: import java.text.*;
0009:
0010: import javax.management.remote.JMXConnector;
0011: import javax.management.MBeanServerConnection;
0012: import javax.management.ObjectName;
0013:
0014: import com.sun.portal.log.common.*;
0015:
0016: import com.sun.portal.admin.server.PASModule;
0017: import com.sun.portal.admin.server.AdminServerUtil;
0018: import com.sun.portal.admin.server.mbeans.PSResource;
0019: import com.sun.portal.admin.common.InstanceAttributes;
0020: import com.sun.portal.admin.common.context.PortalDomainContext;
0021: import com.sun.portal.admin.common.context.PSConfigContext;
0022: import com.sun.portal.admin.common.util.AdminUtil;
0023: import com.sun.portal.admin.common.PSMBeanException;
0024: import com.sun.portal.log.common.PortalLogger;
0025: import com.sun.portal.search.admin.CSDebug;
0026: import com.sun.portal.search.admin.CSConfig;
0027: import com.sun.portal.search.admin.mbeans.tasks.*;
0028: import com.sun.portal.search.admin.ImportConfig;
0029: import com.sun.portal.search.util.OrderedMap;
0030: import com.sun.portal.search.util.PBlock;
0031: import com.sun.portal.search.util.SearchConfig;
0032: import com.sun.portal.search.rdmgr.*;
0033:
0034: import com.sun.portal.util.Platform;
0035:
0036: public class SearchServer extends PSResource implements
0037: SearchServerMBean {
0038:
0039: private ObjectName objectName = null;
0040: private String host = null;
0041: private String port = null;
0042: private String instance = null;
0043: private String searchServerID = null;
0044: private String searchServerURL = null;
0045: private String psDir = null;
0046: private String searchServerRoot = null;
0047: private OrderedMap searchConfig = null;
0048: private ImportAgent importAgent = null;
0049: private Schema schema = null;
0050: private static Logger logger = PortalLogger
0051: .getLogger(SearchServer.class);
0052:
0053: public void init(PSConfigContext cc, PortalDomainContext pdc,
0054: List path) {
0055: super .init(cc, pdc, path);
0056:
0057: searchServerID = getID();
0058:
0059: try {
0060: objectName = AdminUtil.getResourceMBeanObjectName(TYPE,
0061: path);
0062:
0063: String protocol = pdc.getAttributeValue(TYPE, path,
0064: "Protocol");
0065: host = pdc.getAttributeValue(TYPE, path, "Host");
0066: port = pdc.getAttributeValue(TYPE, path, "Port");
0067: instance = pdc.getAttributeValue(TYPE, path, "Instance");
0068:
0069: searchServerURL = protocol + "://" + host + ":" + port
0070: + "/" + searchServerID;
0071: } catch (Exception e) {
0072: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0073: }
0074:
0075: psDir = cc.getPSBaseDir();
0076:
0077: searchServerRoot = cc.getPSDataDir() + File.separator
0078: + "searchservers" + File.separator + searchServerID;
0079:
0080: try {
0081: if (AdminUtil.isLocal(host)) {
0082: loadConfig();
0083: }
0084: } catch (Exception e) {
0085: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0086: }
0087: }
0088:
0089: public String getHost() {
0090: return host;
0091: }
0092:
0093: public String getPort() {
0094: return port;
0095: }
0096:
0097: public String getInstance() {
0098: return instance;
0099: }
0100:
0101: public String getSearchServerID() {
0102: return searchServerID;
0103: }
0104:
0105: public String getSearchServerRoot() {
0106: return searchServerRoot;
0107: }
0108:
0109: public String getSearchServerURL() {
0110: return searchServerURL;
0111: }
0112:
0113: public String getBinDir() {
0114: return (String) searchConfig.get("bindir");
0115: }
0116:
0117: public String getLibDir() {
0118: return (String) searchConfig.get("libdir");
0119: }
0120:
0121: public String getConfigDir() {
0122: return getSearchServerRoot() + File.separator + "config";
0123: }
0124:
0125: public String getLogDir() {
0126: return getSearchServerRoot() + File.separator + "logs";
0127: }
0128:
0129: public String getTmpDir() {
0130: return getSearchServerRoot() + File.separator + "tmp";
0131: }
0132:
0133: public String getDatabaseDir() {
0134: return (String) searchConfig.get("database-directory");
0135: }
0136:
0137: public String getLibPath() {
0138: return (String) searchConfig.get("libpath");
0139: }
0140:
0141: public HashMap getConfigMap() {
0142: return (HashMap) searchConfig;
0143: }
0144:
0145: public String getConfigValue(String key) {
0146: return (String) searchConfig.get(key);
0147: }
0148:
0149: public void setConfigValue(String key, String value) {
0150: searchConfig.put(key, value);
0151: storeConfig();
0152: }
0153:
0154: public void removeConfigValue(String key) {
0155: searchConfig.remove(key);
0156: storeConfig();
0157: }
0158:
0159: public void loadConfig() {
0160: searchConfig = new OrderedMap();
0161: try {
0162: String path = getSearchServerRoot() + File.separator
0163: + "config" + File.separator + "search.conf";
0164: BufferedReader br = new BufferedReader(
0165: new InputStreamReader(new FileInputStream(path),
0166: "UTF-8"));
0167: int comments = 1;
0168: String line;
0169: while ((line = br.readLine()) != null) {
0170: line = line.trim();
0171: if (line.length() != 0) {
0172: if (line.charAt(0) == '#') {
0173: searchConfig.put("__configComment_"
0174: + String.valueOf(comments++), line);
0175: } else {
0176: int index = line.indexOf("=");
0177: if (index != -1) {
0178: String key = line.substring(0, index);
0179: String value = line.substring(index + 1)
0180: .trim();
0181: if (value.startsWith("\"")) {
0182: value = value.substring(1, value
0183: .length());
0184: }
0185: if (value.endsWith("\"")) {
0186: value = value.substring(0, value
0187: .length() - 1);
0188: }
0189: searchConfig.put(key, value);
0190: } else {
0191: //searchConfig.put(line, null);
0192: }
0193: }
0194: } else {
0195: searchConfig.put("__configComment_"
0196: + String.valueOf(comments++), line);
0197: }
0198: }
0199: } catch (Exception e) {
0200: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0201: }
0202: }
0203:
0204: public void storeConfig() {
0205: try {
0206: String path = getSearchServerRoot() + File.separator
0207: + "config" + File.separator + "search.conf";
0208: PrintWriter pw = new PrintWriter(new BufferedWriter(
0209: new OutputStreamWriter(new FileOutputStream(path),
0210: "UTF-8")));
0211: String[] keys = searchConfig.getOrderedKeys();
0212: for (int i = 0; i < keys.length; i++) {
0213: String key = keys[i];
0214: String value = (String) searchConfig.get(key);
0215: if (!key.startsWith("__configComment_")) {
0216: pw.print(key + "=" + PBlock.quotedString(value)
0217: + "\n");
0218: } else {
0219: pw.print(value + "\n");
0220: }
0221: }
0222: pw.close();
0223:
0224: SearchConfig.init(path);
0225: } catch (Exception e) {
0226: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0227: }
0228: }
0229:
0230: /*
0231: ** retrieveVitals
0232: **
0233: ** Output:
0234: ** id, url, root (Properties) - key (String)
0235: ** value (String)
0236: */
0237: public Properties retrieveVitals() throws PSMBeanException,
0238: java.net.UnknownHostException {
0239: if (!AdminUtil.isLocal(host)) {
0240: try {
0241: JMXConnector jmxc = AdminServerUtil
0242: .getJMXConnector(host);
0243: MBeanServerConnection msc = jmxc
0244: .getMBeanServerConnection();
0245: Object[] params = {};
0246: String[] signatures = {};
0247: Properties result = (Properties) msc.invoke(objectName,
0248: "retrieveVitals", params, signatures);
0249: jmxc.close();
0250: return result;
0251: } catch (Exception e) {
0252: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0253: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0254: .toString(), e);
0255: }
0256: } else {
0257: Properties result = new Properties();
0258: result.setProperty("url", searchServerURL);
0259: result.setProperty("root", searchServerRoot);
0260: return result;
0261: }
0262: }
0263:
0264: /*
0265: ** retrieveDocumentLevelSecurity
0266: **
0267: ** Output:
0268: ** state (Boolean)
0269: */
0270: public Boolean retrieveDocumentLevelSecurity()
0271: throws PSMBeanException, java.net.UnknownHostException {
0272: if (!AdminUtil.isLocal(host)) {
0273: try {
0274: JMXConnector jmxc = AdminServerUtil
0275: .getJMXConnector(host);
0276: MBeanServerConnection msc = jmxc
0277: .getMBeanServerConnection();
0278: Object[] params = {};
0279: String[] signatures = {};
0280: Boolean result = (Boolean) msc.invoke(objectName,
0281: "retrieveDocumentLevelSecurity", params,
0282: signatures);
0283: jmxc.close();
0284: return result;
0285: } catch (Exception e) {
0286: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0287: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0288: .toString(), e);
0289: }
0290: } else {
0291: String value = getConfigValue(SearchConfig.SECMODE);
0292: if (value.equals("OFF")) {
0293: return new Boolean(false);
0294: } else {
0295: return new Boolean(true);
0296: }
0297: }
0298: }
0299:
0300: /*
0301: ** enableDocumentLevelSecurity
0302: */
0303: public void enableDocumentLevelSecurity() throws PSMBeanException,
0304: java.net.UnknownHostException {
0305: if (!AdminUtil.isLocal(host)) {
0306: try {
0307: JMXConnector jmxc = AdminServerUtil
0308: .getJMXConnector(host);
0309: MBeanServerConnection msc = jmxc
0310: .getMBeanServerConnection();
0311: Object[] params = {};
0312: String[] signatures = {};
0313: msc.invoke(objectName, "enableDocumentLevelSecurity",
0314: params, signatures);
0315: jmxc.close();
0316: } catch (Exception e) {
0317: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0318: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0319: .toString(), e);
0320: }
0321: } else {
0322: setConfigValue(SearchConfig.SECMODE, "ON");
0323: }
0324: }
0325:
0326: /*
0327: ** disableDocumentLevelSecurity
0328: */
0329: public void disableDocumentLevelSecurity() throws PSMBeanException,
0330: java.net.UnknownHostException {
0331: if (!AdminUtil.isLocal(host)) {
0332: try {
0333: JMXConnector jmxc = AdminServerUtil
0334: .getJMXConnector(host);
0335: MBeanServerConnection msc = jmxc
0336: .getMBeanServerConnection();
0337: Object[] params = {};
0338: String[] signatures = {};
0339: msc.invoke(objectName, "disableDocumentLevelSecurity",
0340: params, signatures);
0341: jmxc.close();
0342: } catch (Exception e) {
0343: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0344: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0345: .toString(), e);
0346: }
0347: } else {
0348: setConfigValue(SearchConfig.SECMODE, "OFF");
0349: }
0350: }
0351:
0352: /*
0353: ** createImportAgent
0354: */
0355: public void createImportAgent(String fileName,
0356: String destinationDatabase) throws PSMBeanException,
0357: java.net.UnknownHostException {
0358: if (!AdminUtil.isLocal(host)) {
0359: try {
0360: JMXConnector jmxc = AdminServerUtil
0361: .getJMXConnector(host);
0362: MBeanServerConnection msc = jmxc
0363: .getMBeanServerConnection();
0364: Object[] params = { fileName, destinationDatabase };
0365: String[] signatures = { "java.lang.String",
0366: "java.lang.String" };
0367: msc.invoke(objectName, "createImportAgent", params,
0368: signatures);
0369: jmxc.close();
0370: } catch (Exception e) {
0371: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0372: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0373: .toString(), e);
0374: }
0375: } else {
0376: if (fileName == null) {
0377: String message = "No import agent SOIF file specified";
0378: Object tokens[] = { message };
0379: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0380: throw new PSMBeanException("PSALI_CSPACCSH0001");
0381: }
0382: if (destinationDatabase == null) {
0383: String message = "No import agent destination database specified";
0384: Object tokens[] = { message };
0385: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0386: throw new PSMBeanException("PSALI_CSPACCSH0001");
0387: }
0388:
0389: if (importAgent == null) {
0390: importAgent = new ImportAgent(searchServerID, psDir,
0391: searchServerRoot, logger);
0392: }
0393: importAgent.create(fileName, destinationDatabase);
0394: }
0395: }
0396:
0397: /*
0398: ** createImportAgent
0399: */
0400: public void createImportAgent(Properties p,
0401: String destinationDatabase) throws PSMBeanException,
0402: java.net.UnknownHostException {
0403: if (!AdminUtil.isLocal(host)) {
0404: try {
0405: JMXConnector jmxc = AdminServerUtil
0406: .getJMXConnector(host);
0407: MBeanServerConnection msc = jmxc
0408: .getMBeanServerConnection();
0409: Object[] params = { p, destinationDatabase };
0410: String[] signatures = { "java.util.Properties",
0411: "java.lang.String" };
0412: msc.invoke(objectName, "createImportAgent", params,
0413: signatures);
0414: jmxc.close();
0415: } catch (Exception e) {
0416: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0417: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0418: .toString(), e);
0419: }
0420: } else {
0421: if (p == null) {
0422: String message = "No import agent properties specified";
0423: Object tokens[] = { message };
0424: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0425: throw new PSMBeanException("PSALI_CSPACCSH0001");
0426: }
0427: if (destinationDatabase == null) {
0428: String message = "No import agent destination database specified";
0429: Object tokens[] = { message };
0430: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0431: throw new PSMBeanException("PSALI_CSPACCSH0001");
0432: }
0433:
0434: if (importAgent == null) {
0435: importAgent = new ImportAgent(searchServerID, psDir,
0436: searchServerRoot, logger);
0437: }
0438: importAgent.create(p, destinationDatabase);
0439: }
0440: }
0441:
0442: /*
0443: ** deleteImportAgents
0444: */
0445: public void deleteImportAgents(List ids) throws PSMBeanException,
0446: java.net.UnknownHostException {
0447: if (!AdminUtil.isLocal(host)) {
0448: try {
0449: JMXConnector jmxc = AdminServerUtil
0450: .getJMXConnector(host);
0451: MBeanServerConnection msc = jmxc
0452: .getMBeanServerConnection();
0453: Object[] params = { ids };
0454: String[] signatures = { "java.util.List" };
0455: msc.invoke(objectName, "deleteImportAgents", params,
0456: signatures);
0457: jmxc.close();
0458: } catch (Exception e) {
0459: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0460: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0461: .toString(), e);
0462: }
0463: } else {
0464: if (ids == null) {
0465: ids = new ArrayList();
0466: }
0467:
0468: if (importAgent == null) {
0469: importAgent = new ImportAgent(searchServerID, psDir,
0470: searchServerRoot, logger);
0471: }
0472: importAgent.delete(ids);
0473: }
0474: }
0475:
0476: /*
0477: ** getAllImportAgents
0478: **
0479: ** Output:
0480: ** data (ArrayList) - [attributes] (Properties) - key (Sting)
0481: ** value (String)
0482: */
0483: public ArrayList getAllImportAgents(List attributes)
0484: throws PSMBeanException, java.net.UnknownHostException {
0485: if (!AdminUtil.isLocal(host)) {
0486: try {
0487: JMXConnector jmxc = AdminServerUtil
0488: .getJMXConnector(host);
0489: MBeanServerConnection msc = jmxc
0490: .getMBeanServerConnection();
0491: Object[] params = { attributes };
0492: String[] signatures = { "java.util.List" };
0493: ArrayList result = (ArrayList) msc.invoke(objectName,
0494: "getAllImportAgents", params, signatures);
0495: jmxc.close();
0496: return result;
0497: } catch (Exception e) {
0498: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0499: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0500: .toString(), e);
0501: }
0502: } else {
0503: if (attributes == null) {
0504: String message = "No import agent attributes specified";
0505: Object tokens[] = { message };
0506: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0507: throw new PSMBeanException("PSALI_CSPACCSH0001");
0508: }
0509:
0510: if (importAgent == null) {
0511: importAgent = new ImportAgent(searchServerID, psDir,
0512: searchServerRoot, logger);
0513: }
0514: return importAgent.getAll(attributes);
0515: }
0516: }
0517:
0518: /*
0519: ** getImportAgent
0520: **
0521: ** Output:
0522: ** [attributes] (Properties) - key (String)
0523: ** value (String)
0524: */
0525: public Properties getImportAgent(String id, List attributes)
0526: throws PSMBeanException, java.net.UnknownHostException {
0527: if (!AdminUtil.isLocal(host)) {
0528: try {
0529: JMXConnector jmxc = AdminServerUtil
0530: .getJMXConnector(host);
0531: MBeanServerConnection msc = jmxc
0532: .getMBeanServerConnection();
0533: Object[] params = { id, attributes };
0534: String[] signatures = { "java.lang.String",
0535: "java.util.List" };
0536: Properties result = (Properties) msc.invoke(objectName,
0537: "getImportAgent", params, signatures);
0538: jmxc.close();
0539: return result;
0540: } catch (Exception e) {
0541: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0542: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0543: .toString(), e);
0544: }
0545: } else {
0546: if (id == null) {
0547: String message = "No import agent specified";
0548: Object tokens[] = { message };
0549: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0550: throw new PSMBeanException("PSALI_CSPACCSH0001");
0551: }
0552: if (attributes == null) {
0553: String message = "No import agent attributes specified";
0554: Object tokens[] = { message };
0555: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0556: throw new PSMBeanException("PSALI_CSPACCSH0001");
0557: }
0558:
0559: if (importAgent == null) {
0560: importAgent = new ImportAgent(searchServerID, psDir,
0561: searchServerRoot, logger);
0562: }
0563: return importAgent.get(id, attributes);
0564: }
0565: }
0566:
0567: /*
0568: ** editImportAgent
0569: */
0570: public void editImportAgent(String id, String fileName,
0571: String destinationDatabase) throws PSMBeanException,
0572: java.net.UnknownHostException {
0573: if (!AdminUtil.isLocal(host)) {
0574: try {
0575: JMXConnector jmxc = AdminServerUtil
0576: .getJMXConnector(host);
0577: MBeanServerConnection msc = jmxc
0578: .getMBeanServerConnection();
0579: Object[] params = { id, fileName, destinationDatabase };
0580: String[] signatures = { "java.lang.String",
0581: "java.lang.String", "java.lang.String" };
0582: msc.invoke(objectName, "editImportAgent", params,
0583: signatures);
0584: jmxc.close();
0585: } catch (Exception e) {
0586: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0587: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0588: .toString(), e);
0589: }
0590: } else {
0591: if (id == null) {
0592: String message = "No import agent ID specified";
0593: Object tokens[] = { message };
0594: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0595: throw new PSMBeanException("PSALI_CSPACCSH0001");
0596: }
0597: if (fileName == null) {
0598: String message = "No import agent SOIF file specified";
0599: Object tokens[] = { message };
0600: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0601: throw new PSMBeanException("PSALI_CSPACCSH0001");
0602: }
0603:
0604: if (importAgent == null) {
0605: importAgent = new ImportAgent(searchServerID, psDir,
0606: searchServerRoot, logger);
0607: }
0608: importAgent.edit(id, fileName, destinationDatabase);
0609: }
0610: }
0611:
0612: /*
0613: ** editImportAgent
0614: */
0615: public void editImportAgent(String id, Properties p,
0616: String destinationDatabase) throws PSMBeanException,
0617: java.net.UnknownHostException {
0618: if (!AdminUtil.isLocal(host)) {
0619: try {
0620: JMXConnector jmxc = AdminServerUtil
0621: .getJMXConnector(host);
0622: MBeanServerConnection msc = jmxc
0623: .getMBeanServerConnection();
0624: Object[] params = { id, p, destinationDatabase };
0625: String[] signatures = { "java.lang.String",
0626: "java.util.Properties", "java.lang.String" };
0627: msc.invoke(objectName, "editImportAgent", params,
0628: signatures);
0629: jmxc.close();
0630: } catch (Exception e) {
0631: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0632: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0633: .toString(), e);
0634: }
0635: } else {
0636: if (id == null) {
0637: String message = "No import agent ID specified";
0638: Object tokens[] = { message };
0639: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0640: throw new PSMBeanException("PSALI_CSPACCSH0001");
0641: }
0642: if (p == null) {
0643: String message = "No import agent properties specified";
0644: Object tokens[] = { message };
0645: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0646: throw new PSMBeanException("PSALI_CSPACCSH0001");
0647: }
0648:
0649: if (importAgent == null) {
0650: importAgent = new ImportAgent(searchServerID, psDir,
0651: searchServerRoot, logger);
0652: }
0653: importAgent.edit(id, p, destinationDatabase);
0654: }
0655: }
0656:
0657: /*
0658: ** enableImportAgents
0659: */
0660: public void enableImportAgents(List ids) throws PSMBeanException,
0661: java.net.UnknownHostException {
0662: if (!AdminUtil.isLocal(host)) {
0663: try {
0664: JMXConnector jmxc = AdminServerUtil
0665: .getJMXConnector(host);
0666: MBeanServerConnection msc = jmxc
0667: .getMBeanServerConnection();
0668: Object[] params = { ids };
0669: String[] signatures = { "java.util.List" };
0670: msc.invoke(objectName, "enableImportAgents", params,
0671: signatures);
0672: jmxc.close();
0673: } catch (Exception e) {
0674: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0675: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0676: .toString(), e);
0677: }
0678: } else {
0679: if (ids == null) {
0680: String message = "No import agent IDs specified";
0681: Object tokens[] = { message };
0682: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0683: throw new PSMBeanException("PSALI_CSPACCSH0001");
0684: }
0685:
0686: if (importAgent == null) {
0687: importAgent = new ImportAgent(searchServerID, psDir,
0688: searchServerRoot, logger);
0689: }
0690: importAgent.enable(ids);
0691: }
0692: }
0693:
0694: /*
0695: ** disableImportAgents
0696: */
0697: public void disableImportAgents(List ids) throws PSMBeanException,
0698: java.net.UnknownHostException {
0699: if (!AdminUtil.isLocal(host)) {
0700: try {
0701: JMXConnector jmxc = AdminServerUtil
0702: .getJMXConnector(host);
0703: MBeanServerConnection msc = jmxc
0704: .getMBeanServerConnection();
0705: Object[] params = { ids };
0706: String[] signatures = { "java.util.List" };
0707: msc.invoke(objectName, "disableImportAgents", params,
0708: signatures);
0709: jmxc.close();
0710: } catch (Exception e) {
0711: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0712: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0713: .toString(), e);
0714: }
0715: } else {
0716: if (ids == null) {
0717: String message = "No import agent IDs specified";
0718: Object tokens[] = { message };
0719: logger.log(Level.INFO, "PSSH_CSPSAMB0002", tokens);
0720: throw new PSMBeanException("PSALI_CSPACCSH0001");
0721: }
0722:
0723: if (importAgent == null) {
0724: importAgent = new ImportAgent(searchServerID, psDir,
0725: searchServerRoot, logger);
0726: }
0727: importAgent.disable(ids);
0728: }
0729: }
0730:
0731: /*
0732: ** runImportAgents
0733: */
0734: public void runImportAgents() throws PSMBeanException,
0735: java.net.UnknownHostException {
0736: if (!AdminUtil.isLocal(host)) {
0737: try {
0738: JMXConnector jmxc = AdminServerUtil
0739: .getJMXConnector(host);
0740: MBeanServerConnection msc = jmxc
0741: .getMBeanServerConnection();
0742: Object[] params = {};
0743: String[] signatures = {};
0744: msc.invoke(objectName, "runImportAgents", params,
0745: signatures);
0746: jmxc.close();
0747: } catch (Exception e) {
0748: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0749: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0750: .toString(), e);
0751: }
0752: } else {
0753: if (importAgent == null) {
0754: importAgent = new ImportAgent(searchServerID, psDir,
0755: searchServerRoot, logger);
0756: }
0757: importAgent.run();
0758: }
0759: }
0760:
0761: /*
0762: ** isImportAgentsRunning
0763: **
0764: ** Output:
0765: ** status (Boolean)
0766: **
0767: */
0768: public Boolean isImportAgentsRunning() throws PSMBeanException,
0769: java.net.UnknownHostException {
0770: if (!AdminUtil.isLocal(host)) {
0771: try {
0772: JMXConnector jmxc = AdminServerUtil
0773: .getJMXConnector(host);
0774: MBeanServerConnection msc = jmxc
0775: .getMBeanServerConnection();
0776: Object[] params = {};
0777: String[] signatures = {};
0778: Boolean result = (Boolean) msc.invoke(objectName,
0779: "isImportAgentsRunning", params, signatures);
0780: jmxc.close();
0781: return result;
0782: } catch (Exception e) {
0783: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0784: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0785: .toString(), e);
0786: }
0787: } else {
0788: if (importAgent == null) {
0789: importAgent = new ImportAgent(searchServerID, psDir,
0790: searchServerRoot, logger);
0791: }
0792: return new Boolean(importAgent.stillRunning());
0793: }
0794: }
0795:
0796: /*
0797: ** createResourceDescription
0798: */
0799: public void createResourceDescription(byte[] fileData,
0800: String database) throws PSMBeanException,
0801: java.net.UnknownHostException {
0802: if (!AdminUtil.isLocal(host)) {
0803: try {
0804: JMXConnector jmxc = AdminServerUtil
0805: .getJMXConnector(host);
0806: MBeanServerConnection msc = jmxc
0807: .getMBeanServerConnection();
0808: Object[] params = { fileData, database };
0809: String[] signatures = { "[B", "java.lang.String" };
0810: msc.invoke(objectName, "createResourceDescription",
0811: params, signatures);
0812: jmxc.close();
0813: } catch (Exception e) {
0814: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0815: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0816: .toString(), e);
0817: }
0818: } else {
0819: if (fileData == null) {
0820: String message = "No resource description SOIF file specified";
0821: Object tokens[] = { message };
0822: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0823: throw new PSMBeanException("PSALI_CSPACCSH0001");
0824: }
0825: if (database == null) {
0826: String message = "No resource description database specified";
0827: Object tokens[] = { message };
0828: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0829: throw new PSMBeanException("PSALI_CSPACCSH0001");
0830: }
0831:
0832: ResourceDescription resourceDescription = new ResourceDescription(
0833: searchServerRoot, searchServerURL,
0834: getConfigValue(SearchConfig.SECMODE), logger);
0835: resourceDescription.create(fileData, database);
0836: }
0837: }
0838:
0839: /*
0840: ** createResourceDescription
0841: */
0842: public void createResourceDescription(Map attributes,
0843: String database) throws PSMBeanException,
0844: java.net.UnknownHostException {
0845: if (!AdminUtil.isLocal(host)) {
0846: try {
0847: JMXConnector jmxc = AdminServerUtil
0848: .getJMXConnector(host);
0849: MBeanServerConnection msc = jmxc
0850: .getMBeanServerConnection();
0851: Object[] params = { attributes, database };
0852: String[] signatures = { "java.util.Map",
0853: "java.lang.String" };
0854: msc.invoke(objectName, "createResourceDescription",
0855: params, signatures);
0856: jmxc.close();
0857: } catch (Exception e) {
0858: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0859: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0860: .toString(), e);
0861: }
0862: } else {
0863: if (attributes == null) {
0864: String message = "No resource description attributes specified";
0865: Object tokens[] = { message };
0866: logger.log(Level.INFO, "PSSH_CSPSAMB0002", tokens);
0867: throw new PSMBeanException("PSALI_CSPACCSH0001");
0868: }
0869: if (database == null) {
0870: String message = "No resource description database specified";
0871: Object tokens[] = { message };
0872: logger.log(Level.INFO, "PSSH_CSPSAMB0002", tokens);
0873: throw new PSMBeanException("PSALI_CSPACCSH0001");
0874: }
0875:
0876: ResourceDescription resourceDescription = new ResourceDescription(
0877: searchServerRoot, searchServerURL,
0878: getConfigValue(SearchConfig.SECMODE), logger);
0879: resourceDescription.create(attributes, database);
0880: }
0881: }
0882:
0883: /*
0884: ** deleteResourceDescriptions
0885: */
0886: public void deleteResourceDescriptions(List urls, String database)
0887: throws PSMBeanException, java.net.UnknownHostException {
0888: if (!AdminUtil.isLocal(host)) {
0889: try {
0890: JMXConnector jmxc = AdminServerUtil
0891: .getJMXConnector(host);
0892: MBeanServerConnection msc = jmxc
0893: .getMBeanServerConnection();
0894: Object[] params = { urls, database };
0895: String[] signatures = { "java.util.List",
0896: "java.lang.String" };
0897: msc.invoke(objectName, "deleteResourceDescriptions",
0898: params, signatures);
0899: jmxc.close();
0900: } catch (Exception e) {
0901: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0902: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0903: .toString(), e);
0904: }
0905: } else {
0906: if (urls == null) {
0907: String message = "No resource description URLs specified";
0908: Object tokens[] = { message };
0909: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
0910: throw new PSMBeanException("PSALI_CSPACCSH0001");
0911: }
0912: if (database == null) {
0913: String message = "No resource description database specified";
0914: Object tokens[] = { message };
0915: logger.log(Level.INFO, "PSSH_CSPSAMB0002", tokens);
0916: throw new PSMBeanException("PSALI_CSPACCSH0001");
0917: }
0918:
0919: ResourceDescription resourceDescription = new ResourceDescription(
0920: searchServerRoot, searchServerURL,
0921: getConfigValue(SearchConfig.SECMODE), logger);
0922: resourceDescription.delete(urls, database);
0923: }
0924: }
0925:
0926: /*
0927: ** getAllResourceDescriptions
0928: **
0929: ** Output:
0930: ** data (ArrayList) - total hits (Integer)
0931: ** start page (Integer)
0932: ** total pages (Integer)
0933: ** data (ArrayList) - [attributes] (Map) - key (String)
0934: ** values (ArrayList) - value (String)
0935: */
0936: public ArrayList getAllResourceDescriptions(String searchType,
0937: String query, List viewAttributes, Integer startPage,
0938: Integer hitsPerPage, String database)
0939: throws PSMBeanException, java.net.UnknownHostException {
0940: if (!AdminUtil.isLocal(host)) {
0941: try {
0942: JMXConnector jmxc = AdminServerUtil
0943: .getJMXConnector(host);
0944: MBeanServerConnection msc = jmxc
0945: .getMBeanServerConnection();
0946: Object[] params = { searchType, query, viewAttributes,
0947: startPage, hitsPerPage, database };
0948: String[] signatures = { "java.lang.String",
0949: "java.lang.String", "java.util.List",
0950: "java.lang.Integer", "java.lang.Integer",
0951: "java.lang.String" };
0952: ArrayList result = (ArrayList) msc.invoke(objectName,
0953: "getAllResourceDescriptions", params,
0954: signatures);
0955: jmxc.close();
0956: return result;
0957: } catch (Exception e) {
0958: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
0959: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0960: .toString(), e);
0961: }
0962: } else {
0963: if (searchType == null) {
0964: searchType = "";
0965: }
0966: if (query == null) {
0967: query = "";
0968: }
0969: if (viewAttributes == null) {
0970: viewAttributes = new ArrayList();
0971: }
0972: if (startPage == null) {
0973: startPage = new Integer(0);
0974: }
0975: if (hitsPerPage == null) {
0976: hitsPerPage = new Integer(0);
0977: }
0978: if (database == null) {
0979: String message = "No resource description database specified";
0980: Object tokens[] = { message };
0981: logger.log(Level.INFO, "PSSH_CSPSAMB0002", tokens);
0982: throw new PSMBeanException("PSALI_CSPACCSH0001");
0983: }
0984:
0985: ResourceDescription resourceDescription = new ResourceDescription(
0986: searchServerRoot, searchServerURL,
0987: getConfigValue(SearchConfig.SECMODE), logger);
0988: return resourceDescription.getAll(searchType, query,
0989: viewAttributes, startPage.intValue(), hitsPerPage
0990: .intValue(), database);
0991: }
0992: }
0993:
0994: /*
0995: ** editResourceDescriptions
0996: */
0997: public void editResourceDescriptions(String fileData,
0998: String database) throws PSMBeanException,
0999: java.net.UnknownHostException {
1000: if (!AdminUtil.isLocal(host)) {
1001: try {
1002: JMXConnector jmxc = AdminServerUtil
1003: .getJMXConnector(host);
1004: MBeanServerConnection msc = jmxc
1005: .getMBeanServerConnection();
1006: Object[] params = { fileData, database };
1007: String[] signatures = { "java.lang.String",
1008: "java.lang.String" };
1009: msc.invoke(objectName, "editResourceDescriptions",
1010: params, signatures);
1011: jmxc.close();
1012: } catch (Exception e) {
1013: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1014: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1015: .toString(), e);
1016: }
1017: } else {
1018: if (fileData == null) {
1019: String message = "No resource description SOIF file specified";
1020: Object tokens[] = { message };
1021: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1022: throw new PSMBeanException("PSALI_CSPACCSH0001");
1023: }
1024: if (database == null) {
1025: String message = "No resource description database specified";
1026: Object tokens[] = { message };
1027: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1028: throw new PSMBeanException("PSALI_CSPACCSH0001");
1029: }
1030:
1031: ResourceDescription resourceDescription = new ResourceDescription(
1032: searchServerRoot, searchServerURL,
1033: getConfigValue(SearchConfig.SECMODE), logger);
1034: resourceDescription.edit(fileData, database);
1035: }
1036: }
1037:
1038: /*
1039: ** editResourceDescriptions
1040: */
1041: public void editResourceDescriptions(List urls, Map attributes,
1042: String database) throws PSMBeanException,
1043: java.net.UnknownHostException {
1044: if (!AdminUtil.isLocal(host)) {
1045: try {
1046: JMXConnector jmxc = AdminServerUtil
1047: .getJMXConnector(host);
1048: MBeanServerConnection msc = jmxc
1049: .getMBeanServerConnection();
1050: Object[] params = { urls, attributes, database };
1051: String[] signatures = { "java.util.List",
1052: "java.util.Map", "java.lang.String" };
1053: msc.invoke(objectName, "editResourceDescriptions",
1054: params, signatures);
1055: jmxc.close();
1056: } catch (Exception e) {
1057: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1058: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1059: .toString(), e);
1060: }
1061: } else {
1062: if (urls == null) {
1063: String message = "No resource description URLs specified";
1064: Object tokens[] = { message };
1065: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1066: throw new PSMBeanException("PSALI_CSPACCSH0001");
1067: }
1068: if (attributes == null) {
1069: String message = "No resource description attributes specified";
1070: Object tokens[] = { message };
1071: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1072: throw new PSMBeanException("PSALI_CSPACCSH0001");
1073: }
1074: if (database == null) {
1075: String message = "No resource description database specified";
1076: Object tokens[] = { message };
1077: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1078: throw new PSMBeanException("PSALI_CSPACCSH0001");
1079: }
1080:
1081: ResourceDescription resourceDescription = new ResourceDescription(
1082: searchServerRoot, searchServerURL,
1083: getConfigValue(SearchConfig.SECMODE), logger);
1084: resourceDescription.edit(urls, attributes, database);
1085: }
1086: }
1087:
1088: /*
1089: ** createSchema
1090: */
1091: public void createSchema(String name, String description,
1092: String aliases, Boolean editable, Boolean indexable,
1093: String scoreMultiplier, String dataType)
1094: throws PSMBeanException, java.net.UnknownHostException {
1095: if (!AdminUtil.isLocal(host)) {
1096: try {
1097: JMXConnector jmxc = AdminServerUtil
1098: .getJMXConnector(host);
1099: MBeanServerConnection msc = jmxc
1100: .getMBeanServerConnection();
1101: Object[] params = { name, description, aliases,
1102: editable, indexable, scoreMultiplier, dataType };
1103: String[] signatures = { "java.lang.String",
1104: "java.lang.String", "java.lang.String",
1105: "java.lang.Boolean", "java.lang.Boolean",
1106: "java.lang.String", "java.lang.String" };
1107: msc.invoke(objectName, "createSchema", params,
1108: signatures);
1109: jmxc.close();
1110: } catch (Exception e) {
1111: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1112: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1113: .toString(), e);
1114: }
1115: } else {
1116: if (name == null) {
1117: String message = "No schema attribute specified";
1118: Object tokens[] = { message };
1119: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1120: throw new PSMBeanException("PSALI_CSPACCSH0001");
1121: }
1122: if (description == null) {
1123: description = "";
1124: }
1125: if (aliases == null) {
1126: aliases = "";
1127: }
1128: if (editable == null) {
1129: editable = new Boolean(false);
1130: }
1131: if (indexable == null) {
1132: indexable = new Boolean(false);
1133: }
1134: if (scoreMultiplier == null) {
1135: scoreMultiplier = "";
1136: }
1137: if (dataType == null) {
1138: dataType = "";
1139: }
1140:
1141: if (schema == null) {
1142: schema = new Schema(psDir, getSearchServerRoot(),
1143: logger);
1144: }
1145: schema.create(name, description, aliases, editable,
1146: indexable, scoreMultiplier, dataType);
1147: }
1148: }
1149:
1150: /*
1151: ** deleteSchema
1152: */
1153: public void deleteSchema(String name) throws PSMBeanException,
1154: java.net.UnknownHostException {
1155: if (!AdminUtil.isLocal(host)) {
1156: try {
1157: JMXConnector jmxc = AdminServerUtil
1158: .getJMXConnector(host);
1159: MBeanServerConnection msc = jmxc
1160: .getMBeanServerConnection();
1161: Object[] params = { name };
1162: String[] signatures = { "java.lang.String" };
1163: msc.invoke(objectName, "deleteSchema", params,
1164: signatures);
1165: jmxc.close();
1166: } catch (Exception e) {
1167: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1168: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1169: .toString(), e);
1170: }
1171: } else {
1172: if (name == null) {
1173: String message = "No schema attribute specified";
1174: Object tokens[] = { message };
1175: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1176: throw new PSMBeanException("PSALI_CSPACCSH0001");
1177: }
1178:
1179: if (schema == null) {
1180: schema = new Schema(psDir, getSearchServerRoot(),
1181: logger);
1182: }
1183: schema.delete(name);
1184: }
1185: }
1186:
1187: /*
1188: ** retrieveAllSchema
1189: **
1190: ** Output:
1191: ** data (ArrayList) - attribute (String)
1192: */
1193: public ArrayList retrieveAllSchema() throws PSMBeanException,
1194: java.net.UnknownHostException {
1195: if (!AdminUtil.isLocal(host)) {
1196: try {
1197: JMXConnector jmxc = AdminServerUtil
1198: .getJMXConnector(host);
1199: MBeanServerConnection msc = jmxc
1200: .getMBeanServerConnection();
1201: Object[] params = {};
1202: String[] signatures = {};
1203: ArrayList result = (ArrayList) msc.invoke(objectName,
1204: "retrieveAllSchema", params, signatures);
1205: jmxc.close();
1206: return result;
1207: } catch (Exception e) {
1208: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1209: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1210: .toString(), e);
1211: }
1212: } else {
1213: if (schema == null) {
1214: schema = new Schema(psDir, getSearchServerRoot(),
1215: logger);
1216: }
1217: return schema.getAll();
1218: }
1219: }
1220:
1221: /*
1222: ** getSchemaAttributes
1223: **
1224: ** Output:
1225: ** description, aliases, editable, indexable, scoreMultiplier, dataType, noninternal (Properties) - key (String)
1226: ** value (String)
1227: */
1228: public Properties getSchemaAttributes(String name)
1229: throws PSMBeanException, java.net.UnknownHostException {
1230: if (!AdminUtil.isLocal(host)) {
1231: try {
1232: JMXConnector jmxc = AdminServerUtil
1233: .getJMXConnector(host);
1234: MBeanServerConnection msc = jmxc
1235: .getMBeanServerConnection();
1236: Object[] params = { name };
1237: String[] signatures = { "java.lang.String" };
1238: Properties result = (Properties) msc.invoke(objectName,
1239: "getSchemaAttributes", params, signatures);
1240: jmxc.close();
1241: return result;
1242: } catch (Exception e) {
1243: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1244: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1245: .toString(), e);
1246: }
1247: } else {
1248: if (name == null) {
1249: String message = "No schema attribute specified";
1250: Object tokens[] = { message };
1251: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1252: throw new PSMBeanException("PSALI_CSPACCSH0001");
1253: }
1254:
1255: if (schema == null) {
1256: schema = new Schema(psDir, getSearchServerRoot(),
1257: logger);
1258: }
1259: return schema.getAttributes(name);
1260: }
1261: }
1262:
1263: /*
1264: ** setSchemaAttributes
1265: */
1266: public void setSchemaAttributes(String schemaName, String name,
1267: String description, String aliases, Boolean editable,
1268: Boolean indexable, String scoreMultiplier, String dataType)
1269: throws PSMBeanException, java.net.UnknownHostException {
1270: if (!AdminUtil.isLocal(host)) {
1271: try {
1272: JMXConnector jmxc = AdminServerUtil
1273: .getJMXConnector(host);
1274: MBeanServerConnection msc = jmxc
1275: .getMBeanServerConnection();
1276: Object[] params = { schemaName, name, description,
1277: aliases, editable, indexable, scoreMultiplier,
1278: dataType };
1279: String[] signatures = { "java.lang.String",
1280: "java.lang.String", "java.lang.String",
1281: "java.lang.String", "java.lang.Boolean",
1282: "java.lang.Boolean", "java.lang.String",
1283: "java.lang.String" };
1284: msc.invoke(objectName, "setSchemaAttributes", params,
1285: signatures);
1286: jmxc.close();
1287: } catch (Exception e) {
1288: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1289: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1290: .toString(), e);
1291: }
1292: } else {
1293: if (schemaName == null) {
1294: String message = "No schema attribute specified";
1295: Object tokens[] = { message };
1296: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1297: throw new PSMBeanException("PSALI_CSPACCSH0001");
1298: }
1299: if (name == null) {
1300: name = "";
1301: }
1302: if (description == null) {
1303: description = "";
1304: }
1305: if (aliases == null) {
1306: aliases = "";
1307: }
1308: if (editable == null) {
1309: editable = new Boolean(false);
1310: }
1311: if (indexable == null) {
1312: indexable = new Boolean(false);
1313: }
1314: if (scoreMultiplier == null) {
1315: scoreMultiplier = "";
1316: }
1317: if (dataType == null) {
1318: dataType = "";
1319: }
1320:
1321: if (schema == null) {
1322: schema = new Schema(psDir, getSearchServerRoot(),
1323: logger);
1324: }
1325: schema.setAttributes(schemaName, name, description,
1326: aliases, editable, indexable, scoreMultiplier,
1327: dataType);
1328: }
1329: }
1330:
1331: /*
1332: ** restoreSchema
1333: */
1334: public void restoreSchema() throws PSMBeanException,
1335: java.net.UnknownHostException {
1336: if (!AdminUtil.isLocal(host)) {
1337: try {
1338: JMXConnector jmxc = AdminServerUtil
1339: .getJMXConnector(host);
1340: MBeanServerConnection msc = jmxc
1341: .getMBeanServerConnection();
1342: Object[] params = {};
1343: String[] signatures = {};
1344: msc.invoke(objectName, "restoreSchema", params,
1345: signatures);
1346: jmxc.close();
1347: } catch (Exception e) {
1348: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1349: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1350: .toString(), e);
1351: }
1352: } else {
1353: if (schema == null) {
1354: schema = new Schema(psDir, getSearchServerRoot(),
1355: logger);
1356: }
1357: schema.restore();
1358: }
1359: }
1360:
1361: /*
1362: ** getReport
1363: **
1364: ** Output:
1365: ** log (String)
1366: */
1367: public String getReport(String logType, Integer lineLimit)
1368: throws PSMBeanException, java.net.UnknownHostException {
1369: if (!AdminUtil.isLocal(host)) {
1370: try {
1371: JMXConnector jmxc = AdminServerUtil
1372: .getJMXConnector(host);
1373: MBeanServerConnection msc = jmxc
1374: .getMBeanServerConnection();
1375: Object[] params = { logType, lineLimit };
1376: String[] signatures = { "java.lang.String",
1377: "java.lang.Integer" };
1378: String result = (String) msc.invoke(objectName,
1379: "getReport", params, signatures);
1380: jmxc.close();
1381: return result;
1382: } catch (Exception e) {
1383: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1384: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1385: .toString(), e);
1386: }
1387: } else {
1388: if (logType == null) {
1389: String message = "Log type not specified";
1390: Object tokens[] = { message };
1391: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1392: throw new PSMBeanException("PSALI_CSPACCSH0001");
1393: }
1394: if (lineLimit == null) {
1395: lineLimit = new Integer(0);
1396: }
1397:
1398: Report report = new Report(getSearchServerRoot(), logger);
1399: return report.get(logType, lineLimit.intValue());
1400: }
1401: }
1402:
1403: /*
1404: ** getPopularSearch
1405: **
1406: ** Output:
1407: ** data (ArrayList) - number of queries (Integer)
1408: ** date (Date)
1409: ** data (ArrayList) - frequency, scope (Properties) - key (String)
1410: ** value (String)
1411: */
1412: public ArrayList getPopularSearch(Boolean cache, Boolean skipBrowse)
1413: throws PSMBeanException, java.net.UnknownHostException {
1414: if (!AdminUtil.isLocal(host)) {
1415: try {
1416: JMXConnector jmxc = AdminServerUtil
1417: .getJMXConnector(host);
1418: MBeanServerConnection msc = jmxc
1419: .getMBeanServerConnection();
1420: Object[] params = { cache, skipBrowse };
1421: String[] signatures = { "java.lang.Boolean",
1422: "java.lang.Boolean" };
1423: ArrayList result = (ArrayList) msc.invoke(objectName,
1424: "getPopularSearch", params, signatures);
1425: jmxc.close();
1426: return result;
1427: } catch (Exception e) {
1428: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1429: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1430: .toString(), e);
1431: }
1432: } else {
1433: if (cache == null) {
1434: cache = new Boolean(false);
1435: }
1436: if (skipBrowse == null) {
1437: skipBrowse = new Boolean(false);
1438: }
1439:
1440: PopularSearch ps = new PopularSearch(getSearchServerRoot(),
1441: logger);
1442: return ps.get(cache, skipBrowse);
1443: }
1444: }
1445:
1446: /*
1447: ** runRDManager
1448: */
1449: public String runRDManager(String arguments)
1450: throws PSMBeanException, java.net.UnknownHostException {
1451: if (!AdminUtil.isLocal(host)) {
1452: try {
1453: JMXConnector jmxc = AdminServerUtil
1454: .getJMXConnector(host);
1455: MBeanServerConnection msc = jmxc
1456: .getMBeanServerConnection();
1457: Object[] params = { arguments };
1458: String[] signatures = { "java.lang.String" };
1459: String result = (String) msc.invoke(objectName,
1460: "runRDManager", params, signatures);
1461: jmxc.close();
1462: return result;
1463: } catch (Exception e) {
1464: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1465: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1466: .toString(), e);
1467: }
1468: } else {
1469: if (arguments == null) {
1470: String message = "No arguments specified";
1471: Object tokens[] = { message };
1472: logger.log(Level.SEVERE, "PSSH_CSPSAMB0002", tokens);
1473: throw new PSMBeanException("PSALI_CSPACCSH0001");
1474: }
1475:
1476: try {
1477: String command = Platform.getCommand("run-cs-cli");
1478: String call = searchServerRoot + File.separator
1479: + command + " rdmgr " + arguments;
1480: Runtime rt = Runtime.getRuntime();
1481: Process p = rt.exec(call);
1482: p.waitFor();
1483: BufferedReader br = new BufferedReader(
1484: new InputStreamReader(p.getInputStream()));
1485: StringBuffer sb = new StringBuffer();
1486: String line = null;
1487: while ((line = br.readLine()) != null) {
1488: sb.append(line + "\n");
1489: }
1490: int value = p.exitValue();
1491: if (value != 0) {
1492: String message = "rdmgr failed with " + value;
1493: Object tokens[] = { message };
1494: logger
1495: .log(Level.SEVERE, "PSSH_CSPSAMB0002",
1496: tokens);
1497: throw new PSMBeanException("PSALI_CSPACCSH0001");
1498: }
1499: return sb.toString();
1500: } catch (Exception e) {
1501: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1502: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1503: .toString(), e);
1504: }
1505: }
1506: }
1507:
1508: /*
1509: ** retrieveStartRobotCommand
1510: **
1511: ** Output:
1512: ** command (String)
1513: */
1514: public String retrieveStartRobotCommand() throws PSMBeanException,
1515: java.net.UnknownHostException {
1516: if (!AdminUtil.isLocal(host)) {
1517: try {
1518: JMXConnector jmxc = AdminServerUtil
1519: .getJMXConnector(host);
1520: MBeanServerConnection msc = jmxc
1521: .getMBeanServerConnection();
1522: Object[] params = {};
1523: String[] signatures = {};
1524: String result = (String) msc
1525: .invoke(objectName,
1526: "retrieveStartRobotCommand", params,
1527: signatures);
1528: jmxc.close();
1529: return result;
1530: } catch (Exception e) {
1531: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1532: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1533: .toString(), e);
1534: }
1535: } else {
1536: return searchServerRoot + File.separator
1537: + Platform.getCommand("StartRobot");
1538: }
1539: }
1540:
1541: /*
1542: ** retrieveStopRobotCommand
1543: **
1544: ** Output:
1545: ** command (String)
1546: */
1547: public String retrieveStopRobotCommand() throws PSMBeanException,
1548: java.net.UnknownHostException {
1549: if (!AdminUtil.isLocal(host)) {
1550: try {
1551: JMXConnector jmxc = AdminServerUtil
1552: .getJMXConnector(host);
1553: MBeanServerConnection msc = jmxc
1554: .getMBeanServerConnection();
1555: Object[] params = {};
1556: String[] signatures = {};
1557: String result = (String) msc.invoke(objectName,
1558: "retrieveStopRobotCommand", params, signatures);
1559: jmxc.close();
1560: return result;
1561: } catch (Exception e) {
1562: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1563: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1564: .toString(), e);
1565: }
1566: } else {
1567: return searchServerRoot + File.separator
1568: + Platform.getCommand("StopRobot");
1569: }
1570: }
1571:
1572: /*
1573: ** retrieveStartImportAgentCommand
1574: **
1575: ** Output:
1576: ** command (String)
1577: */
1578: public String retrieveStartImportAgentCommand()
1579: throws PSMBeanException, java.net.UnknownHostException {
1580: if (!AdminUtil.isLocal(host)) {
1581: try {
1582: JMXConnector jmxc = AdminServerUtil
1583: .getJMXConnector(host);
1584: MBeanServerConnection msc = jmxc
1585: .getMBeanServerConnection();
1586: Object[] params = {};
1587: String[] signatures = {};
1588: String result = (String) msc.invoke(objectName,
1589: "retrieveStartImportAgentCommand", params,
1590: signatures);
1591: jmxc.close();
1592: return result;
1593: } catch (Exception e) {
1594: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1595: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1596: .toString(), e);
1597: }
1598: } else {
1599: return searchServerRoot + File.separator
1600: + Platform.getCommand("run-cs-cli")
1601: + " importmgr -c " + getConfigDir()
1602: + File.separator + SearchConfig.SEARCH_CONF + " "
1603: + getConfigValue(SearchConfig.CSID) + " run all";
1604: }
1605: }
1606:
1607: /*
1608: ** retrieveStartAutoclassifyCommand
1609: **
1610: ** Output:
1611: ** command (String)
1612: */
1613: public String retrieveStartAutoclassifyCommand()
1614: throws PSMBeanException, java.net.UnknownHostException {
1615: if (!AdminUtil.isLocal(host)) {
1616: try {
1617: JMXConnector jmxc = AdminServerUtil
1618: .getJMXConnector(host);
1619: MBeanServerConnection msc = jmxc
1620: .getMBeanServerConnection();
1621: Object[] params = {};
1622: String[] signatures = {};
1623: String result = (String) msc.invoke(objectName,
1624: "retrieveStartAutoclassifyCommand", params,
1625: signatures);
1626: jmxc.close();
1627: return result;
1628: } catch (Exception e) {
1629: logger.log(Level.SEVERE, "PSSH_CSPSAMB0003", e);
1630: throw new PSMBeanException("PSALI_CSPACCSH0001", e
1631: .toString(), e);
1632: }
1633: } else {
1634: return searchServerRoot + File.separator
1635: + Platform.getCommand("run-cs-cli")
1636: + " autoclassify -s " + searchServerURL + "/search";
1637: }
1638: }
1639:
1640: }
|