01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.search.admin.model;
07:
08: import java.lang.*;
09: import java.util.*;
10: import java.util.logging.Logger;
11: import java.util.logging.Level;
12: import java.io.*;
13:
14: import javax.servlet.http.HttpServletRequest;
15:
16: import com.iplanet.jato.view.*;
17: import com.iplanet.jato.model.*;
18: import com.iplanet.jato.util.*;
19:
20: import com.sun.portal.search.rdmserver.*;
21: import com.sun.portal.search.rdmgr.*;
22: import com.sun.portal.search.util.SearchConfig;
23: import com.sun.portal.search.admin.CSConfig;
24:
25: import com.sun.portal.search.admin.model.*;
26: import com.sun.portal.log.common.PortalLogger;
27:
28: public class PurgeModel extends DefaultModel {
29:
30: String serverRoot = null;
31: String output = "";
32:
33: // Create a Logger for this class
34: private static Logger debugLogger = PortalLogger
35: .getLogger(PurgeModel.class);
36:
37: public PurgeModel() {
38: serverRoot = CSConfig.getServerRoot();
39: }
40:
41: public PurgeModel(String name) {
42: serverRoot = CSConfig.getServerRoot();
43: }
44:
45: /*
46: * purge database
47: * run rdmgr -X -y dbname
48: */
49: public boolean purgeDatabase(String dbname) {
50: boolean res = false;
51:
52: String cmd;
53: if (System.getProperty("os.name").startsWith("win")
54: || System.getProperty("os.name").startsWith("Win")
55: || System.getProperty("os.name").startsWith("WIN")) {
56: cmd = CSConfig.getServerRoot() + File.separator
57: + "run-cs-cli.bat rdmgr -X -y " + dbname;
58: } else {
59: cmd = CSConfig.getServerRoot() + File.separator
60: + "run-cs-cli rdmgr -X -y " + dbname;
61: }
62:
63: Runtime rt = Runtime.getRuntime();
64: debugLogger.log(Level.FINER, "PSSH_CSPSAM0033", cmd);
65: try {
66: Process process = rt.exec(cmd);
67: BufferedReader buf = new BufferedReader(
68: new InputStreamReader(process.getInputStream()));
69: String outText = "";
70: String outLine = null;
71: while ((outLine = buf.readLine()) != null) {
72: debugLogger
73: .log(Level.FINER, "PSSH_CSPSAM0034", outLine);
74: outText = outText + outLine;
75: }
76: res = process.waitFor() == 0;
77: } catch (Exception e) {
78: // XXX Not logging exceptions? XXX
79: debugLogger.log(Level.INFO, "PSSH_CSPSAM0012", e
80: .getMessage());
81: }
82: return res;
83: }
84:
85: public String getOutput() {
86: return output;
87: }
88:
89: }
|