0001: /**
0002: * $Id: NetFileServlet.java,v 1.66 2005/09/21 11:04:23 dg154973 Exp $
0003: * Copyright 2002 Sun Microsystems, Inc. All
0004: * rights reserved. Use of this product is subject
0005: * to license terms. Federal Acquisitions:
0006: * Commercial Software -- Government Users
0007: * Subject to Standard License Terms and
0008: * Conditions.
0009: *
0010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011: * are trademarks or registered trademarks of Sun Microsystems,
0012: * Inc. in the United States and other countries.
0013: */package com.sun.portal.netfile.servlet.java1;
0014:
0015: import java.io.*;
0016: import com.sun.portal.log.common.PortalLogger;
0017: import java.util.*;
0018: import java.util.logging.*;
0019: import javax.servlet.*;
0020: import javax.servlet.http.*;
0021: import java.security.AccessController;
0022: import com.sun.identity.security.EncryptAction;
0023: import com.iplanet.am.util.SystemProperties;
0024: import com.iplanet.sso.SSOToken;
0025: import com.iplanet.sso.SSOTokenManager;
0026: import com.iplanet.sso.SSOException;
0027: import com.iplanet.sso.SSOTokenListener;
0028: import com.iplanet.sso.SSOTokenEvent;
0029:
0030: import com.sun.portal.netfile.servlet.java1.NetFileLogManager;
0031:
0032: public class NetFileServlet extends HttpServlet implements
0033: SSOTokenListener {
0034:
0035: private static HashMap funcnames = null;
0036: private static Vector interface_ip = null;
0037: public static Hashtable hm_session_to_temp_dir_mapping;
0038: public static boolean isEncoded = Boolean.valueOf(
0039: SystemProperties.get("com.iplanet.am.cookie.encode",
0040: "false")).booleanValue();
0041: public static Hashtable mapIDInUseCount;
0042:
0043: private static final String LOCAL_HOST_IP = "127.0.0.1";
0044: private static final String DOWN_INTERFACE_IP = "0.0.0.0";
0045: private static final String ERROR = "ERROR:";
0046: private static final String TEXT_SEPERATOR = "textseperator";
0047: private static final String FALSE = "false";
0048: private static final String CONTENT_TYPE_TEXT_PLAIN = "text/plain; charset=UTF-8";
0049: private static final String OK_MESSAGE = "OK";
0050:
0051: private static HashMap interface_server_cache = new java.util.HashMap();
0052: private static final int NETFILE_HOST_DATA = 79;
0053: private static final int DOWNLOAD_FOLDER = 98;
0054: private static final int MACHINE_ENCODING = 99;
0055: private static final int NEW_NAME = 100;
0056: private static final int CURRENT_MACHINES = 101;
0057: private static final int TERMINATE_SESSION = 102;
0058:
0059: static final int SOURCE_USER_NAME = 0;
0060: static final int SOURCE_PASSWORD = 1;
0061: static final int SOURCE_VMS = 2;
0062: static final int SOURCE_DIRECTORY = 3;
0063: static final int SOURCE_MACHINE_NAME = 4;
0064: static final int SOURCE_MACHINE_TYPE = 5;
0065: static final int SOURCE_MACHINE_DOMAIN = 6;
0066: static final int SOURCE_TEMP_DIR = 7;
0067: static final int ALLOW_HIDDEN_FILES = 8;
0068: static final int USER_SESSION = 9;
0069: private char c_eol = '\n';
0070: private String s_empty_string = "";
0071:
0072: private static Logger logger = PortalLogger
0073: .getLogger(NetFileServlet.class);
0074: String helpURL = s_empty_string;
0075:
0076: public static Hashtable logManagerCache = new Hashtable();
0077:
0078: static String HTMLcharsetname = "ISO-8859-1";
0079:
0080: public void init(ServletConfig config) throws ServletException {
0081: super .init(config);
0082: hm_session_to_temp_dir_mapping = new Hashtable();
0083: mapIDInUseCount = new Hashtable();
0084: runIfconfigA();
0085: }
0086:
0087: /**
0088: * To be invoked by NetFile classes to get the list of interface IPs.
0089: */
0090: public static Vector getInterfaceIPs() {
0091: return interface_ip;
0092: }
0093:
0094: /**
0095: * Returns the interface on which the given server can be contacted
0096: * If no match found, returns null.
0097: * The calling method should cast the returned value to String after
0098: * checking for null.
0099: */
0100: public static Object getInterface(String serverName) {
0101: if (serverName == null)
0102: return null;
0103: return interface_server_cache.get(serverName);
0104: }
0105:
0106: /**
0107: * Sets the servername as key and interface as value
0108: * in the interface_server_cache
0109: */
0110: public static void setInterface(String nameOfServer,
0111: String nameOfInterface) {
0112: interface_server_cache.put(nameOfServer, nameOfInterface);
0113: }
0114:
0115: /**
0116: * Meant to be called from init() ONLY.
0117: * Handles the data in thread-unsafe fashion.
0118: */
0119: private static final void runIfconfigA() {
0120: boolean isWin = (System.getProperty("os.name").toLowerCase()
0121: .indexOf("window") != -1);
0122: boolean isLinux = (System.getProperty("os.name").toLowerCase()
0123: .indexOf("linux") != -1);
0124:
0125: try {
0126: Runtime rt = Runtime.getRuntime();
0127: Process ifconfig;
0128: if (isWin)
0129: ifconfig = rt.exec("ipconfig -all");
0130: else
0131: ifconfig = rt.exec("/sbin/ifconfig -a");
0132: String s = null;
0133: int count = 0;
0134: java.io.InputStream ifconfig_input_stream = ifconfig
0135: .getInputStream();
0136: java.io.InputStream ifconfig_error_stream = ifconfig
0137: .getErrorStream();
0138:
0139: java.io.BufferedReader ifconfig_br = new java.io.BufferedReader(
0140: new java.io.InputStreamReader(ifconfig_input_stream));
0141: String output_line = null;
0142: int index_of_inet = -1;
0143: String octet_1 = null;
0144: String octet_2 = null;
0145: String octet_3 = null;
0146: String octet_4 = null;
0147: int i_octet_1 = -1;
0148: int i_octet_2 = -1;
0149: int i_octet_3 = -1;
0150: int i_octet_4 = -1;
0151: interface_ip = new Vector();
0152:
0153: while (true) {
0154: output_line = ifconfig_br.readLine();
0155: if (output_line == null)
0156: break;
0157: else {
0158: if (isWin) {
0159: int ipaddrindx = output_line.indexOf(
0160: "IP Address", 0);
0161: int icolonindx = output_line.indexOf(":", 0);
0162: if ((ipaddrindx >= 0) && (icolonindx >= 0)) {
0163: String ip = (output_line
0164: .substring(icolonindx + 2)).trim();
0165:
0166: if (ip.equals(LOCAL_HOST_IP))
0167: continue;
0168: if (ip.equals(DOWN_INTERFACE_IP))
0169: continue;
0170: java.util.StringTokenizer ip_octets = new java.util.StringTokenizer(
0171: ip, ".");
0172: try {
0173: octet_1 = ip_octets.nextToken();
0174: octet_2 = ip_octets.nextToken();
0175: octet_3 = ip_octets.nextToken();
0176: octet_4 = ip_octets.nextToken();
0177: i_octet_1 = Integer.parseInt(octet_1);
0178: i_octet_2 = Integer.parseInt(octet_2);
0179: i_octet_3 = Integer.parseInt(octet_3);
0180: i_octet_4 = Integer.parseInt(octet_4);
0181: interface_ip.add(ip);
0182: } catch (Exception e) {
0183: continue;
0184: }
0185: }
0186: } else {
0187: if ((output_line.indexOf("inet6")) > -1)
0188: continue;
0189: index_of_inet = output_line.indexOf("inet");
0190: if (index_of_inet < 0)
0191: continue;
0192: else {
0193: java.util.StringTokenizer tokens = new java.util.StringTokenizer(
0194: output_line);
0195: tokens.nextToken();
0196: String ip = tokens.nextToken();
0197:
0198: if (isLinux) {
0199: if (ip.indexOf("addr:") > -1) {
0200: ip = ip.substring(5);
0201: }
0202: }
0203:
0204: if (ip.equals(LOCAL_HOST_IP))
0205: continue;
0206: if (ip.equals(DOWN_INTERFACE_IP))
0207: continue;
0208: java.util.StringTokenizer ip_octets = new java.util.StringTokenizer(
0209: ip, ".");
0210: try {
0211: octet_1 = ip_octets.nextToken();
0212: octet_2 = ip_octets.nextToken();
0213: octet_3 = ip_octets.nextToken();
0214: octet_4 = ip_octets.nextToken();
0215: i_octet_1 = Integer.parseInt(octet_1);
0216: i_octet_2 = Integer.parseInt(octet_2);
0217: i_octet_3 = Integer.parseInt(octet_3);
0218: i_octet_4 = Integer.parseInt(octet_4);
0219: interface_ip.add(ip);
0220: } catch (Exception e) {
0221: continue;
0222: }
0223: }
0224: }
0225: }
0226: }
0227: } catch (Exception ioe) {
0228: // logger.log(Level.SEVERE, "Exception while enumerating network intefraces ",ioe);
0229: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1139");
0230: }
0231: }
0232:
0233: public void doGet(HttpServletRequest req, HttpServletResponse res)
0234: throws ServletException, IOException {
0235: doGetPost(req, res);
0236: }
0237:
0238: public void doPost(HttpServletRequest req, HttpServletResponse res)
0239: throws ServletException, IOException {
0240: doGetPost(req, res);
0241: }
0242:
0243: private void doGetPost(HttpServletRequest req,
0244: HttpServletResponse res) throws ServletException,
0245: IOException {
0246:
0247: String bufhostdata = s_empty_string;
0248: String bufwinsize = s_empty_string;
0249: String bufwinloc = s_empty_string;
0250: String share = s_empty_string;
0251: String allowdel = s_empty_string;
0252: String new_name = s_empty_string;
0253: String name = s_empty_string;
0254: String value = s_empty_string;
0255:
0256: String username = s_empty_string;
0257: String userid = s_empty_string;
0258: String password = s_empty_string;
0259: String machinename = s_empty_string;
0260: String machname = s_empty_string;
0261: String VMSname = s_empty_string;
0262: String domain = s_empty_string;
0263: String machinetype = s_empty_string;
0264: String dirname = s_empty_string;
0265: String origdirname = s_empty_string;
0266: String filename = s_empty_string;
0267: String localfile = s_empty_string;
0268: String mailserver = s_empty_string;
0269: String fromaddr = s_empty_string;
0270: String replyaddr = s_empty_string;
0271: String toaddr = s_empty_string;
0272: String ccaddr = s_empty_string;
0273: String bccaddr = s_empty_string;
0274: String subject = s_empty_string;
0275: String msgtxt = s_empty_string;
0276: String pattern = s_empty_string;
0277: String newfolder = s_empty_string;
0278: String funcname = s_empty_string;
0279: String hostfuncname = s_empty_string;
0280: String hostlistfuncname = s_empty_string;
0281: String dbug = NetFileServlet.FALSE;
0282: int maxsearchdir = 0;
0283: String tmpdir = s_empty_string;
0284: String usersession = s_empty_string;
0285: String nfid = s_empty_string;
0286: String locale = s_empty_string;
0287: String bundle = s_empty_string;
0288: String enterval = s_empty_string;
0289:
0290: String szCompressMethod = "zip";
0291:
0292: String[] sa_user_hosts_data = new String[0];
0293: String[] sa_current_machines = new String[0];
0294:
0295: PrintWriter out = null;
0296: NetFileLogManager logMgr = null;
0297: SSOTokenManager manager = null;
0298: SSOToken ssoToken = null;
0299: NetFileContext nfContext = null;
0300: NetFileResource nfr_user_locale_i18n_bucket = null;
0301: String s_machine_encoding = "UTF8";//Deafult machine encoding is UTF-8
0302:
0303: try {
0304: nfid = req.getHeader("nfid");
0305: Cookie[] cookie = req.getCookies();
0306:
0307: if (cookie != null) {
0308: for (int i = 0; i < cookie.length; i++) {
0309: if (cookie[i].getName().equalsIgnoreCase(
0310: SystemProperties.get(
0311: "com.iplanet.am.cookie.name",
0312: "iPlanetDirectoryPro"))) {
0313: usersession = cookie[i].getValue();
0314: if (isEncoded)
0315: usersession = java.net.URLDecoder
0316: .decode(usersession);
0317: }
0318: }
0319: }
0320: manager = SSOTokenManager.getInstance();
0321: ssoToken = manager.createSSOToken(usersession);
0322: if ((usersession == null) || (cookie == null)
0323: || (!usersession.equals(nfid))) {
0324: // logger.severe("Session Invalid in doGetPost of NetFileServlet");
0325: logger.severe("PSSRNF_CSPNSJ1140");
0326: if (out == null) {
0327: res.setContentType("application/octet-stream");
0328: out = new PrintWriter(new BufferedWriter(
0329: new OutputStreamWriter(res
0330: .getOutputStream(), "UTF8")));
0331: }
0332: out.println("ERROR: Session is Invalid ");
0333: out.close();
0334: return;
0335: }
0336:
0337: if (manager.isValidToken(ssoToken)) {
0338: nfContext = new NetFileContextImpl(ssoToken);
0339: locale = nfContext.getUserLocale().toString();
0340: nfContext.determineHTMLCharset(req);
0341: usersession = ssoToken.getTokenID().toString();
0342: } else {
0343: // logger.severe("Session Invalid in doGetPost of NetFileServlet");
0344: logger.severe("PSSRNF_CSPNSJ1141");
0345: if (out == null) {
0346: res.setContentType("application/octet-stream");
0347: out = new PrintWriter(new BufferedWriter(
0348: new OutputStreamWriter(res
0349: .getOutputStream(), "UTF8")));
0350: }
0351: out.println("ERROR: Session is Invalid ");
0352: out.close();
0353: return;
0354: }
0355: } catch (SSOException ssoe) {
0356: // logger.severe("Invalid Session received in doGetPost of NetFileServlet");
0357: logger.severe("PSSRNF_CSPNSJ1142");
0358: if (out == null) {
0359: res.setContentType("application/octet-stream");
0360: out = new PrintWriter(new BufferedWriter(
0361: new OutputStreamWriter(res.getOutputStream(),
0362: "UTF8")));
0363: }
0364: out.println("ERROR: Session is Invalid ");
0365: out.close();
0366: return;
0367: } catch (Exception e) {
0368: if (out == null) {
0369: res.setContentType("application/octet-stream");
0370: out = new PrintWriter(new BufferedWriter(
0371: new OutputStreamWriter(res.getOutputStream(),
0372: "UTF8")));
0373: }
0374: out.println(NetFileServlet.ERROR + e.getMessage());
0375: // logger.log(Level.SEVERE, "General Exception in doGetPost of NetFileServlet. Exception in re-creating the Session or in creating OutputStream",e);
0376: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1143");
0377: return;
0378: }
0379: /* Create the LogManager */
0380: if (logMgr == null) {
0381: logMgr = createLogManager(ssoToken);
0382: }
0383: try {
0384: res.setContentType("application/octet-stream");
0385: out = new PrintWriter(new BufferedWriter(
0386: new OutputStreamWriter(res.getOutputStream(),
0387: "UTF8")));
0388:
0389: funcnames = populateFuncMap();
0390: Hashtable params = parseHttpRequestData(req);
0391: String paramVals[] = null;
0392:
0393: // logger.info("Request parameters have been parsed.");
0394: logger.info("PSSRNF_CSPNSJ1144");
0395:
0396: for (Enumeration e = params.keys(); e.hasMoreElements();) {
0397: name = (String) e.nextElement();
0398:
0399: // logger.info("Parameter name = "+name);
0400: Object[] params6 = { name };
0401: logger.log(Level.INFO, "PSSRNF_CSPNSJ1145", params6);
0402:
0403: Object o = params.get(name);
0404:
0405: if (o instanceof String[]) {
0406: paramVals = (String[]) o;
0407: for (int z = 0; z < paramVals.length; z++) {
0408: value = paramVals[z];
0409: if (funcnames.get(name) == null) {
0410: continue;
0411: }
0412: Integer int_val = Integer.valueOf((funcnames
0413: .get(name)).toString());
0414: int namei = int_val.intValue();
0415: switch (namei) {
0416: case 1:
0417: case 2:
0418: case 3:
0419: case 4:
0420: case 5:
0421: case 6:
0422: case 7:
0423: case 8:
0424: case 9:
0425: case 10:
0426: case 11:
0427: case 12:
0428: case 13:
0429: case 14:
0430: case 15:
0431: case 16:
0432: case 17:
0433: case 18:
0434: case 19:
0435: case 20:
0436: case 21:
0437: case 77:
0438: case 78:
0439: funcname = name;
0440: enterval = value;
0441: break;
0442: case 30:
0443: share = value;
0444: break;
0445: case 31:
0446: origdirname = value;
0447: break;
0448: case 35:
0449: hostfuncname = name;
0450: bufhostdata = value;
0451: break;
0452: case 37:
0453: break;
0454: case 38:
0455: tmpdir = value;
0456: break;
0457: case 39:
0458: Integer intval = Integer.valueOf(value);
0459: maxsearchdir = intval.intValue();
0460: break;
0461: case 40:
0462: helpURL = value;
0463: break;
0464: case 41:
0465: funcname = value;
0466: break;
0467: case 42:
0468: username = value;
0469: break;
0470: case 43:
0471: userid = value;
0472: break;
0473: case 44:
0474: password = value;
0475: break;
0476: case 45:
0477: machinename = value;
0478: break;
0479: case 46:
0480: domain = value;
0481: break;
0482: case 47:
0483: machinetype = value;
0484: break;
0485: case 48:
0486: VMSname = value;
0487: break;
0488: case 49:
0489: dirname = value;
0490: if (dirname == null) {
0491: dirname = s_empty_string;
0492: }
0493: break;
0494: case 51:
0495: newfolder = value;
0496: break;
0497: case 52:
0498: filename = value;
0499: break;
0500: case 53:
0501: mailserver = value;
0502: break;
0503: case 54:
0504: case 55:
0505: replyaddr = value;
0506: break;
0507: case 56:
0508: fromaddr = value;
0509: break;
0510: case 57:
0511: toaddr = value;
0512: break;
0513: case 58:
0514: ccaddr = value;
0515: break;
0516: case 59:
0517: bccaddr = value;
0518: break;
0519: case 60:
0520: subject = value;
0521: break;
0522: case 61:
0523: msgtxt = value;
0524: break;
0525: case 62:
0526: pattern = value;
0527: break;
0528: case 63:
0529: localfile = value;
0530: break;
0531: case 66:
0532: funcname = value;
0533: break;
0534: case 69:
0535: bundle = value;
0536: break;
0537: case 71:
0538: bufwinsize = value;
0539: break;
0540: case 72:
0541: bufwinloc = value;
0542: break;
0543: case 73:
0544: allowdel = value;
0545: break;
0546: case 80:
0547: szCompressMethod = value;
0548: break;
0549: case 81:
0550: funcname = value;
0551: break;
0552: case NETFILE_HOST_DATA:
0553: if (paramVals == null) {
0554: sa_user_hosts_data = new String[] { value };
0555: } else {
0556: sa_user_hosts_data = paramVals;
0557: }
0558: break;
0559: case MACHINE_ENCODING:
0560: if (value != null
0561: && !(value.equals(s_empty_string))) {
0562: s_machine_encoding = value;
0563: }
0564: break;
0565: case NEW_NAME:
0566: new_name = value;
0567: break;
0568: case CURRENT_MACHINES:
0569: if (paramVals == null) {
0570: sa_current_machines = new String[] { value };
0571: } else {
0572: sa_current_machines = paramVals;
0573: }
0574: break;
0575:
0576: default:
0577: // logger.info("Illegal function to perform "+name);
0578: Object[] params7 = { name };
0579: logger.log(Level.INFO, "PSSRNF_CSPNSJ1146",
0580: params7);
0581: break;
0582: }
0583: } // switch
0584: } // if
0585: } // outer for
0586: FileOption file_option = null;
0587: if (!funcname.equalsIgnoreCase("getAppletResource")) {
0588: bundle = FileOption.SERVLET_PROPERTIES;
0589: }
0590:
0591: //nfr_user_locale_i18n_bucket= new NetFileResource("srapNetFileAppletJava1",locale);
0592: nfr_user_locale_i18n_bucket = NetFileResource.getInstance(
0593: FileOption.APPLET_PROPERTIES, locale);
0594:
0595: if (funcname.equals("initOptions")) {
0596: NetFileSessionInitializer nfInitSession = new NetFileSessionInitializer(
0597: logMgr);
0598: String s_session_info = nfInitSession
0599: .initialiseNewUserSession(ssoToken,
0600: nfr_user_locale_i18n_bucket, this ,
0601: nfContext.getHTMLCharset());
0602: try {
0603: res.setContentType("application/octet-stream");
0604: res.setHeader("Cache-Control", "max-age=0");
0605: PrintWriter prout = new PrintWriter(
0606: new BufferedWriter(new OutputStreamWriter(
0607: res.getOutputStream(), "UTF8")));
0608: prout.println(s_session_info);
0609: prout.close();
0610: } catch (Exception exc) {
0611: // logger.log(Level.SEVERE, "NetFileServlet printwriter exception for applet part ",exc);
0612: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1147");
0613: }
0614: return;
0615: }
0616:
0617: if (!tmpdir.equals(s_empty_string)) {
0618: if (!(new File(tmpdir).exists())) {
0619: NetFileSessionInitializer nfInitSession = new NetFileSessionInitializer(
0620: logMgr);
0621: nfInitSession.reInitialiseUserSession(ssoToken,
0622: this );
0623: }
0624: }
0625:
0626: if (funcname.equals("Exit")
0627: || funcname.equalsIgnoreCase("putsessioninfo")) {
0628: try {
0629: doExit(nfr_user_locale_i18n_bucket, bufwinloc,
0630: bufwinsize, logMgr, out,
0631: sa_user_hosts_data, ssoToken, nfContext);
0632: return;
0633: } catch (Exception e) {
0634: // logger.log(Level.SEVERE, "In doGetPost:NetFileServlet, funcname or cancelname ",e);
0635: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1148");
0636: }
0637: } else if (funcname.equals("Delete")
0638: || (funcname.indexOf("deleteFile") >= 0)) {
0639: doDelete(nfr_user_locale_i18n_bucket, username,
0640: password, machinename, machinetype, dirname,
0641: VMSname, tmpdir, logMgr, out, allowdel,
0642: filename, domain, s_machine_encoding, ssoToken);
0643: return;
0644: } else if (funcname.equals("Add")
0645: || funcname.equalsIgnoreCase("getmachinetype")
0646: || funcname.equalsIgnoreCase("AddSystem")) {
0647: doAdd(nfr_user_locale_i18n_bucket, machinename,
0648: machinetype, funcname, logMgr, out, domain,
0649: s_machine_encoding, sa_current_machines,
0650: ssoToken, nfContext);
0651: return;
0652: } else if (funcname.equals("rename")) {
0653: rename(logMgr, username, password, machinename,
0654: machinetype, domain, VMSname, dirname,
0655: filename, new_name, s_machine_encoding,
0656: ssoToken, nfr_user_locale_i18n_bucket);
0657: out.println("OK");
0658: } else if (funcname.equals("check_for_existance_of_file")) {
0659: // logger.info("Checking for file existance");
0660: logger.info("PSSRNF_CSPNSJ1149");
0661: FileOption fo_file_option = new FileOption(logMgr,
0662: s_machine_encoding, ssoToken);
0663: String outcome = fo_file_option.doesFileExist(username,
0664: password, machinename, machinetype, domain,
0665: VMSname, dirname, filename, tmpdir,
0666: nfr_user_locale_i18n_bucket);
0667: // logger.info("File exists?"+outcome);
0668: Object[] params11 = { outcome };
0669: logger.log(Level.INFO, "PSSRNF_CSPNSJ1150", params11);
0670: out.println(outcome);
0671: } else if (funcname.equals("terminate_session")) {
0672: terminateSession(ssoToken);
0673: out.println(OK_MESSAGE);
0674: } else if (funcname.equals("download_folder")) {
0675: String allow_hidden_files = NetFileServlet.FALSE;
0676: FileOption fileOption = new FileOption(logMgr,
0677: s_machine_encoding, ssoToken);
0678:
0679: String[] parameters = new String[] { username,
0680: password, VMSname, dirname, machinename,
0681: machinetype, domain, tmpdir,
0682: allow_hidden_files, usersession };
0683:
0684: fileOption
0685: .doLog(fileOption
0686: .getPlatformLocalisedString("download_folder_func")
0687: + fileOption
0688: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
0689: + machinename
0690: + fileOption
0691: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
0692: + VMSname + dirname);
0693:
0694: fileOption.downloadFolder(out, parameters,
0695: nfr_user_locale_i18n_bucket);
0696: return;
0697: }
0698:
0699: //--------------------------------------------------------------------------
0700: // This section of the code expands the root level of a machine
0701: // Calls expandVMS method in FileOption.java (called by applet)
0702: //--------------------------------------------------------------------------
0703:
0704: else if (funcname.equalsIgnoreCase("expandVMS")) {
0705: String[] retval_buf = new String[2];
0706: file_option = new FileOption(logMgr,
0707: s_machine_encoding, ssoToken);
0708: try {
0709: file_option
0710: .doLog(file_option
0711: .getPlatformLocalisedString("expand_dir")
0712: + file_option
0713: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
0714: + machinename
0715: + file_option
0716: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
0717: + VMSname);
0718: } catch (Exception e) {
0719: // logger.log(Level.SEVERE, "Could not log message",e);
0720: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1151");
0721: }
0722: retval_buf = file_option.expandVMS(username, password,
0723: machinename, domain, machinetype, VMSname,
0724: tmpdir, nfr_user_locale_i18n_bucket);
0725:
0726: // logger.info((retval_buf.length / 4) + " files in the listing");
0727: Object[] params13 = { " files in the listing" };
0728: logger.log(Level.INFO, "PSSRNF_CSPNSJ1152", params13);
0729:
0730: if (retval_buf.length < 1) {
0731: out.println(" ");
0732: } else {
0733: for (int ret = 0; ret < retval_buf.length; ret++) {
0734: out.println(retval_buf[ret]);
0735: }
0736: }
0737: return;
0738: }
0739:
0740: //--------------------------------------------------------------------------
0741: // This section of the code expands the machine and returns the shares.
0742: //--------------------------------------------------------------------------
0743: else if (funcname.equalsIgnoreCase("expandMachine")
0744: || funcname.equalsIgnoreCase("ViewShares")) {
0745: // logger.severe("This code is redundant. Does nothin!!");
0746: logger.severe("PSSRNF_CSPNSJ1153");
0747: //doExpView(nfr_user_locale_i18n_bucket,username,password,machinename,machinetype,
0748: // logMgr,out,domain,s_machine_encoding, ssoToken, nfContext);
0749: return;
0750: }
0751:
0752: //--------------------------------------------------------------------------
0753: // This section is for calling expandDir
0754: //--------------------------------------------------------------------------
0755:
0756: else if ((funcname.equalsIgnoreCase("expandDir"))
0757: || (enterval.indexOf(nfr_user_locale_i18n_bucket
0758: .getString("enter")) >= 0)
0759: || (hostfuncname.equals("hostdata"))) {
0760: try {
0761: doExpand(nfr_user_locale_i18n_bucket, username,
0762: password, machinename, machinetype,
0763: dirname, VMSname, tmpdir, logMgr, out,
0764: domain, s_machine_encoding, ssoToken);
0765: return;
0766: } catch (Exception e) {
0767: // logger.log(Level.SEVERE, "Exception in expanding directory ", e);
0768: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1154");
0769: }
0770: } else if (funcname.equalsIgnoreCase("compressFile")
0771: || funcname.equalsIgnoreCase("Compress")) {
0772: doCompress(nfr_user_locale_i18n_bucket, usersession,
0773: username, password, machinename, machinetype,
0774: dirname, VMSname, tmpdir, logMgr, out,
0775: filename, domain, s_machine_encoding,
0776: szCompressMethod, ssoToken);
0777: return;
0778: }
0779:
0780: //--------------------------------------------------------------------------
0781: // This section of the code is executed after Send button is clicked in
0782: // NetFile.
0783: //--------------------------------------------------------------------------
0784:
0785: else if (funcname.equalsIgnoreCase("mailFile")
0786: || funcname.equalsIgnoreCase("Send")) {
0787: doSendMail(nfr_user_locale_i18n_bucket, usersession,
0788: username, password, machinename, machinetype,
0789: dirname, VMSname, mailserver, fromaddr,
0790: replyaddr, tmpdir, logMgr, out, filename,
0791: domain, toaddr, ccaddr, bccaddr, subject,
0792: msgtxt, dbug, nfContext.getHTMLCharset(),
0793: ssoToken);
0794: return;
0795: }
0796:
0797: //--------------------------------------------------------------------------
0798: // This section of the code is executed for searchFile call from applet
0799: // This section is executed after accepting the pattern in NetFileLite GUI
0800: //--------------------------------------------------------------------------
0801: else if (funcname.equalsIgnoreCase("searchFile")
0802: || funcname.equalsIgnoreCase("startsearch")) {
0803: doSearchFile(nfr_user_locale_i18n_bucket, username,
0804: password, machinename, machinetype, dirname,
0805: VMSname, tmpdir, logMgr, out, domain,
0806: maxsearchdir, pattern, s_machine_encoding,
0807: ssoToken);
0808: return;
0809: }
0810:
0811: //--------------------------------------------------------------------------
0812: // This section of the code is called for make new folder option.
0813: //--------------------------------------------------------------------------
0814: else if (funcname.equalsIgnoreCase("createDir")
0815: || funcname.equalsIgnoreCase("Create")) {
0816: doCreate(nfr_user_locale_i18n_bucket, username,
0817: password, machinename, machinetype, dirname,
0818: VMSname, tmpdir, logMgr, out, domain,
0819: newfolder, s_machine_encoding, ssoToken);
0820: return;
0821: }
0822:
0823: //--------------------------------------------------------------------------
0824: // This section of the code is called by the applet to get the key=value
0825: // pairs defined in the srapNetFileAppletJava1 properties file.
0826: //--------------------------------------------------------------------------
0827: else if (funcname.equalsIgnoreCase("getAppletResource")) {
0828: String i18nRetval = s_empty_string;
0829: NetFileResource nfsrc = NetFileResource.getInstance(
0830: bundle, locale);
0831: i18nRetval = nfsrc.getAppletResources(bundle, locale);
0832: out.println(i18nRetval);
0833: out.close();
0834: return;
0835: }
0836: } catch (NetFileException e) {
0837: // logger.log(Level.SEVERE, "Exception in Netfile servelet", e);
0838: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1155");
0839: try {
0840: FileOption fo_log = new FileOption(logMgr,
0841: s_machine_encoding, ssoToken);
0842: String message = e.getMessage(fo_log
0843: .getPlatformLocalisedBundle());
0844:
0845: fo_log.doLog(message);
0846: fo_log = null;
0847: if (out == null) {
0848: res.setContentType("application/octet-stream");
0849: out = new PrintWriter(new BufferedWriter(
0850: new OutputStreamWriter(res
0851: .getOutputStream(), "UTF8")));
0852: }
0853: if (nfr_user_locale_i18n_bucket != null) {
0854: out
0855: .println(NetFileServlet.ERROR
0856: + e
0857: .getMessage(nfr_user_locale_i18n_bucket));
0858: } else {
0859: out.println("ERROR:Unknown error");
0860:
0861: }
0862: } catch (Throwable e1) {
0863: // logger.log(Level.SEVERE, "Error writing response back to the applet",e1);
0864: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1156");
0865: }
0866: } catch (Throwable e) {
0867: // logger.log(Level.SEVERE, "Exception in NetFile Servlet ", e);
0868: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1157");
0869: try {
0870: if (out == null) {
0871: res.setContentType("application/octet-stream");
0872: out = new PrintWriter(new BufferedWriter(
0873: new OutputStreamWriter(res
0874: .getOutputStream(), "UTF8")));
0875: }
0876: out.println(NetFileServlet.ERROR
0877: + nfr_user_locale_i18n_bucket
0878: .getString("no_op"));
0879: } catch (Exception e1) {
0880: // logger.log(Level.SEVERE, "Error writing response back to the applet",e1);
0881: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1158");
0882: }
0883: } finally {
0884: try {
0885: if (out != null) {
0886: out.close();
0887: out = null;
0888: }
0889: } catch (Exception e) {
0890: // logger.log(Level.SEVERE, "Problem closing output stream to the server",e);
0891: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1159");
0892: }
0893: }
0894:
0895: } //END OF doGetPost
0896:
0897: private synchronized HashMap populateFuncMap() {
0898:
0899: HashMap funcnames = new HashMap();
0900:
0901: final int ADD = 1;
0902: Integer add = new Integer(ADD);
0903: funcnames.put("Add", add);
0904: final int CONTINUE = 2;
0905: Integer cont = new Integer(CONTINUE);
0906: funcnames.put("Continue", cont);
0907: final int COMPRESS = 3;
0908: Integer compr = new Integer(COMPRESS);
0909: funcnames.put("Compress", compr);
0910: final int STARTSEARCH = 4;
0911: Integer stsrch = new Integer(STARTSEARCH);
0912: funcnames.put("startsearch", stsrch);
0913: final int UPLOADFILE = 5;
0914: Integer upload = new Integer(UPLOADFILE);
0915: funcnames.put("UploadFile", upload);
0916: final int VIEWSHARES = 7;
0917: Integer vsh = new Integer(VIEWSHARES);
0918: funcnames.put("viewshares", vsh);
0919: final int GO = 8;
0920: Integer go = new Integer(GO);
0921: funcnames.put("Go", go);
0922: final int GOBACK = 9;
0923: Integer goback = new Integer(GOBACK);
0924: funcnames.put("GoBack", goback);
0925: final int CREATE = 10;
0926: Integer create = new Integer(CREATE);
0927: funcnames.put("Create", create);
0928: final int EDITHOSTINFO = 11;
0929: Integer edit = new Integer(EDITHOSTINFO);
0930: funcnames.put("EditHostInfo", edit);
0931: final int ADDSYSTEM = 12;
0932: Integer addsys = new Integer(ADDSYSTEM);
0933: funcnames.put("AddSystem", addsys);
0934: final int HOSTENTER = 13;
0935: Integer hostenter = new Integer(HOSTENTER);
0936: funcnames.put("hostenter", hostenter);
0937: final int MACHENTER = 14;
0938: Integer machenter = new Integer(MACHENTER);
0939: funcnames.put("machenter", machenter);
0940: final int SRCHPAT = 15;
0941: Integer srchpat = new Integer(SRCHPAT);
0942: funcnames.put("SearchPattern", srchpat);
0943: final int DOWNLOAD = 16;
0944: Integer dnload = new Integer(DOWNLOAD);
0945: funcnames.put("Download", dnload);
0946: final int EXIT = 17;
0947: Integer exit = new Integer(EXIT);
0948: funcnames.put("Exit", exit);
0949: final int MAIL = 18;
0950: Integer mail = new Integer(MAIL);
0951: funcnames.put("Mail", mail);
0952: final int SEND = 19;
0953: Integer send = new Integer(SEND);
0954: funcnames.put("Send", send);
0955: final int OPEN = 20;
0956: Integer open = new Integer(OPEN);
0957: funcnames.put("Open", open);
0958: final int DELETE = 21;
0959: Integer delete = new Integer(DELETE);
0960: funcnames.put("Delete", delete);
0961: final int SHARE = 30;
0962: Integer shr = new Integer(SHARE);
0963: funcnames.put("share", shr);
0964: final int ORIGDIR = 31;
0965: Integer orig = new Integer(ORIGDIR);
0966: funcnames.put("origdirname", orig);
0967: final int EXDATA = 33;
0968: Integer exdata = new Integer(EXDATA);
0969: funcnames.put("exithost_data", exdata);
0970: final int HDATA = 35;
0971: Integer hdata = new Integer(HDATA);
0972: funcnames.put("hostdata", hdata);
0973: final int USESS = 37;
0974: Integer usess = new Integer(USESS);
0975: funcnames.put("usersession", usess);
0976: final int TDIR = 38;
0977: Integer tdir = new Integer(TDIR);
0978: funcnames.put("tmpdir", tdir);
0979: final int MAXD = 39;
0980: Integer maxd = new Integer(MAXD);
0981: funcnames.put("maxsearchdir", maxd);
0982: final int HELP = 40;
0983: Integer help = new Integer(HELP);
0984: funcnames.put("helpurl", help);
0985: final int FUNC = 41;
0986: Integer fnam = new Integer(FUNC);
0987: funcnames.put("func", fnam);
0988: final int USERNAM = 42;
0989: Integer unam = new Integer(USERNAM);
0990: funcnames.put("username", unam);
0991: final int USERID = 43;
0992: Integer uid = new Integer(USERID);
0993: funcnames.put("userid", uid);
0994: final int PASSW = 44;
0995: Integer pw = new Integer(PASSW);
0996: funcnames.put("pass", pw);
0997: final int MNAME = 45;
0998: Integer mn = new Integer(MNAME);
0999: funcnames.put("machine", mn);
1000: final int DOM = 46;
1001: Integer dom = new Integer(DOM);
1002: funcnames.put("domain", dom);
1003: final int TYP = 47;
1004: Integer typ = new Integer(TYP);
1005: funcnames.put("type", typ);
1006: final int VMSn = 48;
1007: Integer vms = new Integer(VMSn);
1008: funcnames.put("VMS", vms);
1009: final int DIR = 49;
1010: Integer dirn = new Integer(DIR);
1011: funcnames.put("dir", dirn);
1012: final int NDIR = 51;
1013: Integer ndirn = new Integer(NDIR);
1014: funcnames.put("newdir", ndirn);
1015: final int FILN = 52;
1016: Integer filn = new Integer(FILN);
1017: funcnames.put("filename", filn);
1018: final int MAILS = 53;
1019: Integer mails = new Integer(MAILS);
1020: funcnames.put("mailserver", mails);
1021: final int REPLY = 54;
1022: Integer reply = new Integer(REPLY);
1023: funcnames.put("replyto", reply);
1024: final int REPLYADD = 55;
1025: Integer replyadd = new Integer(REPLYADD);
1026: funcnames.put("replytoaddr", replyadd);
1027: final int FROM = 56;
1028: Integer from = new Integer(FROM);
1029: funcnames.put("fromaddr", from);
1030: final int TO = 57;
1031: Integer to = new Integer(TO);
1032: funcnames.put("toname", to);
1033: final int CC = 58;
1034: Integer cc = new Integer(CC);
1035: funcnames.put("ccname", cc);
1036: final int BCC = 59;
1037: Integer blcc = new Integer(BCC);
1038: funcnames.put("bccname", blcc);
1039: final int SUB = 60;
1040: Integer sub = new Integer(SUB);
1041: funcnames.put("subject", sub);
1042: final int MSG = 61;
1043: Integer msgt = new Integer(MSG);
1044: funcnames.put("msgtext", msgt);
1045: final int PAT = 62;
1046: Integer pat = new Integer(PAT);
1047: funcnames.put("pattern", pat);
1048: final int LFIL = 63;
1049: Integer lfil = new Integer(LFIL);
1050: funcnames.put("localfile", lfil);
1051: final int APPL = 66;
1052: Integer appl = new Integer(APPL);
1053: funcnames.put("getAppletResource", appl);
1054: final int LOC = 67;
1055: Integer loc = new Integer(LOC);
1056: funcnames.put("locale", loc);
1057: final int LOCN = 68;
1058: Integer locn = new Integer(LOCN);
1059: funcnames.put("localename", locn);
1060: final int BUND = 69;
1061: Integer bund = new Integer(BUND);
1062: funcnames.put("bundle", bund);
1063: final int WSIZ = 71;
1064: Integer wsiz = new Integer(WSIZ);
1065: funcnames.put("winsize", wsiz);
1066: final int WLOC = 72;
1067: Integer wloc = new Integer(WLOC);
1068: funcnames.put("winloc", wloc);
1069: final int ADEL = 73;
1070: Integer adel = new Integer(ADEL);
1071: funcnames.put("allowdel", adel);
1072: final int HTMLCH = 76;
1073: Integer htmlch = new Integer(HTMLCH);
1074: funcnames.put("HTMLcharsetname", htmlch);
1075: final int EXPANDVMS = 77;
1076: Integer expvms = new Integer(EXPANDVMS);
1077: funcnames.put("expandVMS", expvms);
1078: final int VERIFYVMS = 78;
1079: Integer vervms = new Integer(VERIFYVMS);
1080: funcnames.put("verifyVMS", vervms);
1081:
1082: Integer cmpMethod = new Integer(80);
1083: funcnames.put("compressMethod", cmpMethod);
1084:
1085: Integer initOptions = new Integer(81);
1086: funcnames.put("initOptions", initOptions);
1087:
1088: Integer i_netfile_host_data = new Integer(NETFILE_HOST_DATA);
1089: funcnames.put("machine_type_password_shares",
1090: i_netfile_host_data);
1091:
1092: Integer i_download_folder = new Integer(DOWNLOAD_FOLDER);
1093: funcnames.put("download_folder", i_download_folder);
1094:
1095: Integer i_machine_encoding = new Integer(MACHINE_ENCODING);
1096: funcnames.put("machine_encoding", i_machine_encoding);
1097:
1098: Integer i_rename = new Integer(NEW_NAME);
1099: funcnames.put("new_name", i_rename);
1100:
1101: Integer i_current_machines = new Integer(CURRENT_MACHINES);
1102: funcnames.put("current_machines", i_current_machines);
1103:
1104: Integer i_terminate_session = new Integer(TERMINATE_SESSION);
1105: funcnames.put("terminate_session", i_terminate_session);
1106:
1107: return funcnames;
1108: }
1109:
1110: //--------------------------------------------------------------------------
1111: // This section of the code is for Exit option.
1112: // Saves information to the profile service if Yes was selected
1113: //--------------------------------------------------------------------------
1114:
1115: void doExit(NetFileResource nfr_user_locale_i18n_bucket,
1116: String bufwinloc, String bufwinsize,
1117: NetFileLogManager logMgr, PrintWriter out,
1118: String[] sa_user_hosts_data, SSOToken ssoToken,
1119: NetFileContext nfContext) throws Exception,
1120: NetFileException {
1121: String szRetValue;
1122:
1123: HashSet hsHostData = new HashSet();
1124: for (int i = 0; i < sa_user_hosts_data.length; ++i) {
1125: hsHostData.add((String) AccessController
1126: .doPrivileged(new EncryptAction(
1127: sa_user_hosts_data[i])));
1128: }
1129:
1130: Map prefs = new HashMap();
1131: try {
1132: prefs.put("sunPortalNetFileHostTypePassShare", hsHostData);
1133: nfContext.savePreferences(prefs);
1134: } catch (Exception ex) {
1135: // logger.log(Level.SEVERE, "Exception in saving user host data", ex);
1136: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1160");
1137: }
1138:
1139: HashSet hsWinSize = new HashSet();
1140: hsWinSize.add(bufwinsize);
1141: prefs.remove("sunPortalNetFileHostTypePassShare");
1142: try {
1143: prefs.put("sunPortalNetFileWindowSize", hsWinSize);
1144: nfContext.savePreferences(prefs);
1145: } catch (Exception ex) {
1146: // logger.log(Level.SEVERE, "Exception in saving win size", ex);
1147: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1161");
1148: }
1149:
1150: HashSet hsWinLoc = new HashSet();
1151: hsWinLoc.add(bufwinloc);
1152: prefs.remove("sunPortalNetFileWindowSize");
1153: try {
1154: prefs.put("sunPortalNetFileWindowLocation", hsWinLoc);
1155: nfContext.savePreferences(prefs);
1156: } catch (Exception ex) {
1157: // logger.log(Level.SEVERE, "Exception in saving win location", ex);
1158: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1162");
1159: }
1160: terminateSession(ssoToken);
1161: out.println(nfr_user_locale_i18n_bucket
1162: .getString("prefsSaveSuccess"));
1163: out.close();
1164: return;
1165: }
1166:
1167: //--------------------------------------------------------------------------
1168: // This section of the code calls deleteFile method in FileOption.java
1169: // based on the deleteFile call from applet or Delete call from NetFile Lite.
1170: // This section also has code to display html for NetFile Lite.
1171: //--------------------------------------------------------------------------
1172:
1173: void doDelete(NetFileResource nfr_user_locale_i18n_bucket,
1174: String username, String password, String machinename,
1175: String machinetype, String dirname, String VMSname,
1176: String tmpdir, NetFileLogManager logMgr, PrintWriter out,
1177: String allowdel, String filename, String domain,
1178: String s_machine_encoding, SSOToken ssoToken)
1179: throws NetFileException {
1180: try {
1181: String retval = s_empty_string;
1182: FileOption fillog = new FileOption(logMgr,
1183: s_machine_encoding, ssoToken);
1184: fillog
1185: .doLog(fillog.getPlatformLocalisedString("func10")
1186: + fillog
1187: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1188: + machinename
1189: + fillog
1190: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1191: + dirname
1192: + fillog
1193: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1194: + filename);
1195:
1196: if (allowdel.equals(NetFileServlet.FALSE)) {
1197: return;
1198: } else {
1199: retval = fillog.deleteFile(username, password,
1200: machinename, domain, machinetype, dirname,
1201: VMSname, filename, tmpdir,
1202: nfr_user_locale_i18n_bucket);
1203: String saveretval = retval;
1204: out.print(retval);
1205: out.close();
1206: return;
1207: }
1208:
1209: } catch (Exception ee) {
1210: out.print(NetFileServlet.ERROR
1211: + nfr_user_locale_i18n_bucket
1212: .getString("problem_in_delete"));
1213: out.close();
1214: // logger.log(Level.SEVERE, "Exception deleting file ", ee);
1215: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1163");
1216: }
1217: }
1218:
1219: void doAdd(NetFileResource nfr, String machinename,
1220: String machinetype, String funcname,
1221: NetFileLogManager logMgr, PrintWriter out, String domain,
1222: String s_machine_encoding, String[] sa_current_machines,
1223: SSOToken token, NetFileContext nfContext)
1224: throws NetFileException {
1225:
1226: HashMap reqData = new HashMap();
1227: reqData.put("UserID", "");
1228: reqData.put("Pwd", "");
1229: reqData.put("SystemName", machinename);
1230: reqData.put("NTDomName", domain);
1231: reqData.put("SysType", machinetype);
1232: reqData.put("CharSet", s_machine_encoding);
1233: reqData.put("SSOToken", token);
1234: if (sa_current_machines != null) {
1235: ArrayList userAddedHosts = new ArrayList(
1236: sa_current_machines.length);
1237: for (int i = 0; i < sa_current_machines.length; i++)
1238: userAddedHosts.add(sa_current_machines[i]);
1239: reqData.put("UserAddedHosts", userAddedHosts);
1240: } else {
1241: reqData.put("UserAddedHosts", new ArrayList(1));
1242: }
1243:
1244: StringBuffer responseBuffer = new StringBuffer();
1245:
1246: AddSystemProcessor addSysProc = new AddSystemProcessor(logMgr,
1247: nfContext, nfr);
1248: addSysProc.addSystem(reqData, responseBuffer);
1249:
1250: out.print(responseBuffer.toString());
1251: out.close();
1252:
1253: return;
1254: }
1255:
1256: //--------------------------------------------------------------------------
1257: // This section calls expandDir method in FileOption.java and
1258: // displays all the files in the directory.
1259: // Also has code for display of html for NetFile Lite
1260: // Called for Continue,Go,Enter in Lite and expandDir in applet
1261: //--------------------------------------------------------------------------
1262:
1263: void doExpand(NetFileResource nfr_user_locale_i18n_bucket,
1264: String username, String password, String machinename,
1265: String machinetype, String dirname, String VMSname,
1266: String tmpdir, NetFileLogManager logMgr, PrintWriter out,
1267: String domain, String s_machine_encoding, SSOToken ssoToken) {
1268: // logger.info("doExpand() being called for directory " + dirname);
1269: Object[] params25 = { dirname };
1270: logger.log(Level.INFO, "PSSRNF_CSPNSJ1164", params25);
1271:
1272: FileOption file_option = new FileOption(logMgr,
1273: s_machine_encoding, ssoToken);
1274: try {
1275: try {
1276: file_option
1277: .doLog(file_option
1278: .getPlatformLocalisedString("expand_dir")
1279: + file_option
1280: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1281: + machinename
1282: + file_option
1283: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1284: + VMSname + dirname);
1285: } catch (Exception e) {
1286: // logger.log(Level.SEVERE, "doExpand: Execption in logging",e);
1287: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1165");
1288: }
1289: String[] retval_buf = file_option.expandDir(username,
1290: password, machinename, domain, machinetype,
1291: dirname, VMSname, tmpdir,
1292: nfr_user_locale_i18n_bucket);
1293:
1294: // logger.info((retval_buf.length / 4) + " files in the listing");
1295: Object[] params27 = { " files in the listing" };
1296: logger.log(Level.INFO, "PSSRNF_CSPNSJ1166", params27);
1297:
1298: if (retval_buf.length < 1) {
1299: out.println(" ");
1300: } else {
1301: for (int ret = 0; ret < retval_buf.length; ret++) {
1302: out.println(retval_buf[ret]);
1303: }
1304: }
1305: retval_buf = null;
1306: } catch (NetFileException e) {
1307: // logger.log(Level.SEVERE, "Exception while fetching files",e);
1308: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1167");
1309: String message = NetFileServlet.ERROR
1310: + e.getMessage(nfr_user_locale_i18n_bucket);
1311: file_option.doError(e.getMessage(file_option
1312: .getPlatformLocalisedBundle()));
1313: out.println(message);
1314: } catch (Throwable e) {
1315: // logger.log(Level.SEVERE, "Exception while fetching files",e);
1316: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1168");
1317: String message = (NetFileServlet.ERROR) + e.getMessage();
1318: file_option.doError(e.getMessage());
1319: out.println(message);
1320: }
1321: file_option = null;
1322: out.close();
1323: out = null;
1324: // logger.info("Returning from doExpand()");
1325: logger.info("PSSRNF_CSPNSJ1169");
1326: return;
1327: }
1328:
1329: //--------------------------------------------------------------------------
1330: // This section of the code calls compressFile method in FileOption.java
1331: // to get the file from the remote server and compress the file.
1332: // compressFile is called by applet and Compress is called by NetFile Lite.
1333: //--------------------------------------------------------------------------
1334:
1335: void doCompress(NetFileResource nfr_user_locale_i18n_bucket,
1336: String usersession, String username, String password,
1337: String machinename, String machinetype, String dirname,
1338: String VMSname, String tmpdir, NetFileLogManager logMgr,
1339: PrintWriter out, String filename, String domain,
1340: String s_machine_encoding, String szCompressMethod,
1341: SSOToken ssoToken) throws Exception, NetFileException {
1342: String[] retval_buf = new String[2];
1343: String retval = s_empty_string;
1344: FileOption fillog = new FileOption(logMgr, s_machine_encoding,
1345: ssoToken);
1346: try {
1347: fillog
1348: .doLog(fillog.getPlatformLocalisedString("func28")
1349: + machinename
1350: + fillog
1351: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1352: + dirname
1353: + fillog
1354: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1355: + filename);
1356: } catch (Exception ee) {
1357: // logger.log(Level.SEVERE, "NetFile directory name decoding exception while logging in compress ",ee);
1358: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1170");
1359: }
1360: // logger.info("File Name " + filename+"\nCompress Method " + szCompressMethod);
1361: Object[] params32 = { filename, "\nCompress Method ",
1362: szCompressMethod };
1363: logger.log(Level.INFO, "PSSRNF_CSPNSJ1171", params32);
1364: retval_buf = fillog.compressFile(username, password,
1365: machinename, domain, machinetype, dirname, VMSname,
1366: filename, tmpdir, nfr_user_locale_i18n_bucket,
1367: usersession, szCompressMethod);
1368:
1369: if (retval_buf[0] == null) {
1370: out.print(retval);
1371: } else {
1372: for (int ret = 0; ret < retval_buf.length; ret++) {
1373: if ((retval_buf[ret] == null)
1374: || (retval_buf[ret].equals(s_empty_string))
1375: || (retval_buf[ret].equals("\0"))) {
1376: break;
1377: } else {
1378: out.println(retval_buf[ret]);
1379: }
1380: }
1381: }
1382: out.close();
1383: return;
1384: }
1385:
1386: //--------------------------------------------------------------------------
1387: // This section of the code is executed after Send button is clicked in
1388: // NetFile Lite GUI. Also executed for mailFile call from applet.
1389: // The mailFile method in FileOption.java is called
1390: //--------------------------------------------------------------------------
1391:
1392: void doSendMail(NetFileResource nfr_user_locale_i18n_bucket,
1393: String usersession, String username, String password,
1394: String machinename, String machinetype, String dirname,
1395: String VMSname, String mailserver, String fromaddr,
1396: String replyaddr, String tmpdir, NetFileLogManager logMgr,
1397: PrintWriter out, String filename, String domain,
1398: String toaddr, String ccaddr, String bccaddr,
1399: String subject, String msgtxt, String dbug,
1400: String s_machine_encoding, SSOToken ssoToken)
1401: throws NetFileException {
1402: String retval = s_empty_string;
1403: FileOption fillog = new FileOption(logMgr, s_machine_encoding,
1404: ssoToken);
1405: fillog
1406: .doLog(fillog.getPlatformLocalisedString("func29")
1407: + machinename
1408: + fillog
1409: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1410: + dirname
1411: + fillog
1412: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1413: + filename);
1414: retval = fillog.mailFile(username, password, machinename,
1415: domain, machinetype, dirname, VMSname, filename,
1416: mailserver, fromaddr, toaddr, replyaddr, ccaddr,
1417: bccaddr, subject, msgtxt, dbug, tmpdir,
1418: nfr_user_locale_i18n_bucket, s_machine_encoding,
1419: usersession);
1420: out.print(retval);
1421: out.close();
1422: return;
1423: }
1424:
1425: //--------------------------------------------------------------------------
1426: // This section of the code is executed for searchFile call from applet
1427: // This section is executed after accepting the pattern in NetFileLite GUI
1428: //--------------------------------------------------------------------------
1429:
1430: void doSearchFile(NetFileResource nfr_user_locale_i18n_bucket,
1431: String username, String password, String machinename,
1432: String machinetype, String dirname, String VMSname,
1433: String tmpdir, NetFileLogManager logMgr, PrintWriter out,
1434: String domain, int maxsearchdir, String pattern,
1435: String s_machine_encoding, SSOToken ssoToken)
1436: throws NetFileException {
1437: Vector cache = new Vector();
1438: String[] retval_buf = new String[600];
1439: FileOption fillog = new FileOption(logMgr, s_machine_encoding,
1440: ssoToken);
1441: try {
1442: fillog
1443: .doLog(fillog.getPlatformLocalisedString("func31")
1444: + machinename
1445: + fillog
1446: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1447: + dirname
1448: + fillog
1449: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1450: + pattern);
1451: } catch (Exception ee) {
1452: // logger.log(Level.SEVERE, "NetFile directory name decoding exception while logging in search ",ee);
1453: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1172");
1454: }
1455: retval_buf = fillog.searchFile(username, password, machinename,
1456: domain, machinetype, dirname, VMSname, pattern,
1457: maxsearchdir, tmpdir, nfr_user_locale_i18n_bucket);
1458:
1459: for (int ret = 0; ret < retval_buf.length; ret++) {
1460: if ((retval_buf[ret].equals(s_empty_string))
1461: || (retval_buf[ret] == null)
1462: || (retval_buf[ret].equals("\0"))) {
1463: break;
1464: } else {
1465: out.println(retval_buf[ret]);
1466: }
1467: }
1468: out.close();
1469: return;
1470: }
1471:
1472: void doCreate(NetFileResource nfr_user_locale_i18n_bucket,
1473: String username, String password, String machinename,
1474: String machinetype, String dirname, String VMSname,
1475: String tmpdir, NetFileLogManager logMgr, PrintWriter out,
1476: String domain, String newfolder, String s_machine_encoding,
1477: SSOToken ssoToken) throws NetFileException, Exception {
1478:
1479: String retval = s_empty_string;
1480: String[] retval_buf = new String[600];
1481: FileOption fillog = new FileOption(logMgr, s_machine_encoding,
1482: ssoToken);
1483: try {
1484: fillog
1485: .doLog(fillog.getPlatformLocalisedString("func33")
1486: + machinename
1487: + fillog
1488: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1489: + dirname
1490: + fillog
1491: .getPlatformLocalisedString(NetFileServlet.TEXT_SEPERATOR)
1492: + newfolder);
1493: } catch (Exception ee) {
1494: // logger.log(Level.SEVERE, "NetFile directory name decoding exception while logging in create ",ee);
1495: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1173");
1496: }
1497: retval_buf = fillog.createDir(username, password, machinename,
1498: domain, machinetype, dirname, VMSname, newfolder,
1499: tmpdir, nfr_user_locale_i18n_bucket);
1500:
1501: if (retval_buf[0] == null) {
1502: out.print(retval);
1503: } else {
1504: // for (int ret=0;ret < retval_buf.toString().length(); ret++) {
1505: for (int ret = 0; ret < retval_buf.length; ret++) {
1506: out.println(retval_buf[ret]);
1507: }
1508: }
1509: out.close();
1510: return;
1511: }
1512:
1513: private Hashtable parseHttpRequestData(HttpServletRequest hsr_req)
1514: throws Exception {
1515: InputStream ips_request = hsr_req.getInputStream();
1516: ObjectInputStream oips_request = new ObjectInputStream(
1517: ips_request);
1518: Object o_request = oips_request.readObject();
1519: Hashtable ht_request = (Hashtable) o_request;
1520: Set s_request = ht_request.keySet();
1521: Iterator i_request = s_request.iterator();
1522: Hashtable ht_request_1 = new Hashtable();
1523: //String values=s_empty_string;
1524: while (i_request.hasNext()) {
1525: String key = (String) (i_request.next());
1526: Object o_value = ht_request.get(key);
1527: if (o_value instanceof String) {
1528: String[] sa_value = new String[] { (String) o_value };
1529: ht_request_1.put(key, sa_value);
1530: //values+=(key+"="+sa_value[0]+c_eol);
1531: } else {
1532: ht_request_1.put(key, o_value);
1533: }
1534:
1535: }
1536: // /*logger.info("------------------------------------\n"
1537: /*logger.info("------------------------------------\n"
1538: +values
1539: +"------------------------------------");*/
1540: return ht_request_1;
1541:
1542: }
1543:
1544: private void rename(NetFileLogManager logMgr, String username,
1545: String password, String machine, String type,
1546: String domain, String share, String directory,
1547: String old_file_name, String new_file_name,
1548: String s_machine_encoding, SSOToken ssoToken,
1549: NetFileResource nfRes) throws NetFileException {
1550: FileOption fo_file_option = new FileOption(logMgr,
1551: s_machine_encoding, ssoToken);
1552: fo_file_option.rename(username, password, machine, type,
1553: domain, share, directory, old_file_name, new_file_name,
1554: s_machine_encoding, nfRes);
1555:
1556: }
1557:
1558: /* Method ssoTokenChanged
1559: * - To catch the SSOTokenEvent and remove sessions.
1560: */
1561:
1562: public void ssoTokenChanged(SSOTokenEvent event) {
1563: try {
1564: SSOToken token = event.getToken();
1565: String tokenId = token.getTokenID().toString();
1566: int type = event.getType();
1567: SessionTempDirCounter counter = null;
1568: switch (type) {
1569: case SSOTokenEvent.SSO_TOKEN_IDLE_TIMEOUT:
1570: case SSOTokenEvent.SSO_TOKEN_MAX_TIMEOUT:
1571: case SSOTokenEvent.SSO_TOKEN_DESTROY:
1572: try {
1573: logManagerCache.remove(tokenId);
1574: } catch (Exception e) {
1575: }
1576: Object count = NetFileServlet.mapIDInUseCount
1577: .get(tokenId);
1578:
1579: if (count == null)
1580: ;
1581: else {
1582: counter = (SessionTempDirCounter) NetFileServlet.mapIDInUseCount
1583: .get(tokenId);
1584: counter.invalidate();
1585: }
1586: if (cleanup(token)) {
1587: if (counter != null)
1588: NetFileServlet.mapIDInUseCount.remove(tokenId);
1589: }
1590: break;
1591: }
1592: } catch (Exception e) {
1593: }
1594: }
1595:
1596: /*
1597: *Cleanup the resources reserved for the user for
1598: *the session upon session expiry
1599: */
1600: boolean cleanup(SSOToken ssoToken) {
1601: try {
1602: String s_sso_token = ssoToken.getTokenID().toString();
1603: Object o_temp_directory = hm_session_to_temp_dir_mapping
1604: .get(s_sso_token);
1605: // logger.info("Cleaning up "+o_temp_directory+" for "+s_sso_token);
1606: Object[] params36 = { o_temp_directory, " for ",
1607: s_sso_token };
1608: logger.log(Level.INFO, "PSSRNF_CSPNSJ1175", params36);
1609: if (o_temp_directory != null) {
1610: String s_temp_directory = (String) o_temp_directory;
1611: // logger.info("Cleaning up for "+s_temp_directory);
1612: Object[] params37 = { s_temp_directory };
1613: logger.log(Level.INFO, "PSSRNF_CSPNSJ1176", params37);
1614: File f_temp_directory = new File(s_temp_directory);
1615: if (f_temp_directory.exists()) {
1616: String[] filesList = f_temp_directory.list();
1617: for (int i = 0; i < filesList.length; i++) {
1618: File tempFile = new File(filesList[i]);
1619: if (tempFile.exists())
1620: if (!tempFile.delete())
1621: continue;
1622: tempFile = null;
1623: }
1624: if (!f_temp_directory.delete())
1625: return false;
1626: }
1627: // logger.info("Deleted "+f_temp_directory);
1628: Object[] params38 = { f_temp_directory };
1629: logger.log(Level.INFO, "PSSRNF_CSPNSJ1177", params38);
1630: }
1631: hm_session_to_temp_dir_mapping.remove(s_sso_token);
1632: } catch (Exception e) {
1633: // logger.log(Level.SEVERE, "Exception in cleaning up files for "+ssoToken,e);
1634: Object[] params39 = { ssoToken, e };
1635: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1178", params39);
1636: return false;
1637: }
1638: return true;
1639: }
1640:
1641: /* Terminate the session */
1642: void terminateSession(SSOToken ssoToken) {
1643: cleanup(ssoToken);
1644:
1645: }
1646:
1647: /*
1648: *The directory name which is put here will be cleaned up by method
1649: *cleanup() which is called whenever ssoToken becomes invalid or
1650: *when user logs out explicitly.
1651: */
1652: static void putTemporaryDirectoryForSSOToken(SSOToken ssoToken,
1653: String directory) {
1654: // logger.info("putTemporaryDirectoryForSSOToken("+ssoToken.getTokenID().toString()+","+directory+")");
1655: Object[] params40 = { ssoToken.getTokenID().toString(), ",",
1656: directory, ")" };
1657: logger.log(Level.INFO, "PSSRNF_CSPNSJ1179", params40);
1658: hm_session_to_temp_dir_mapping.put(ssoToken.getTokenID()
1659: .toString(), directory);
1660: }
1661:
1662: static void putTempDirCount(SSOToken ssoToken,
1663: SessionTempDirCounter count) {
1664: mapIDInUseCount.put(ssoToken.getTokenID().toString(), count);
1665: }
1666:
1667: private NetFileLogManager createLogManager(SSOToken ssoToken) {
1668: String tokenId = ssoToken.getTokenID().toString();
1669: try {
1670: Object obj = NetFileServlet.logManagerCache.get(tokenId);
1671: if (obj == null) {
1672: NetFileLogManager logMgr = new NetFileLogManager(
1673: ssoToken);
1674: NetFileServlet.logManagerCache.put(tokenId, logMgr);
1675: return logMgr;
1676: } else {
1677: return (NetFileLogManager) obj;
1678: }
1679: } catch (Exception e) {
1680: // logger.log(Level.SEVERE, "Unable to create LogManager for ssoToken - " + tokenId, e);
1681: Object[] params41 = { tokenId, e };
1682: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1180", params41);
1683: return null;
1684: }
1685: }
1686:
1687: }
|