001: package com.sun.portal.netfile.transport;
002:
003: /**
004: * Defines the class that holds the request information of NetFile.
005: * This class is then sent over the wire by the class implementing NetFileTransport
006: *
007: * @author Suresh Yellamaraju
008: * @version 1.0
009: */
010:
011: import java.io.Serializable;
012: import com.sun.portal.log.common.PortalLogger;
013: import java.util.Hashtable;
014: import java.util.Enumeration;
015:
016: import com.sun.portal.netfile.shared.*;
017:
018: public class NetFileRequest implements Serializable {
019:
020: // Identifier for the request
021: private String requestId;
022:
023: // Session id corresponding to the request
024: private String sessionId;
025:
026: // iPS User id for this request and session
027: private String userId;
028:
029: // Constant as defined in NetFileConstants
030: private int requestType;
031:
032: // The variable that holds a whole object of data.
033: // This can be null in the case where there is no specific request data
034: // This would be a defined object such as user session object when user
035: // is saving a NetFile session, or file data when a file is being uploaded.
036: private Object reqObject;
037:
038: // Control parameters that need to be passed.
039: // For example, for compression, compression type, names of files,
040: // machine, share, userid would be the parameters.
041: // This would serve as a easy encapsulater for data if desired.
042: // e.g., Compression Level in case of compression.
043: private Hashtable nfReqParams;
044:
045: /**
046: * Constructor
047: * At the time of request creation, the request id, session id, and request type
048: * are expected to be known. The user id is optional
049: */
050: public NetFileRequest(String reqId, String sess, String uid,
051: int reqType) {
052: if ((reqId != null) && (sess != null)) {
053: requestId = reqId;
054: sessionId = sess;
055: userId = uid;
056: requestType = reqType;
057: }
058: }
059:
060: public Object getParameter(String key) throws NetFileException {
061: if (key != null)
062: return nfReqParams.get(key);
063: else
064: throw new NetFileException(
065: NetFileException.NETFILE_NULLVALUE,
066: "Null value in key");
067: }
068:
069: public void setParameter(String name, Object value)
070: throws NetFileException {
071: if ((name != null) && (value != null)) {
072:
073: if (nfReqParams == null)
074: nfReqParams = new Hashtable();
075:
076: nfReqParams.put(name, value);
077: } else
078: throw new NetFileException(
079: NetFileException.NETFILE_NULLVALUE,
080: "Null value in request parameter key and/or value");
081: }
082:
083: public void setParameters(Hashtable params) throws NetFileException {
084: if (params == null) {
085: throw new NetFileException(
086: NetFileException.NETFILE_NULLVALUE,
087: "Request Parameters is null");
088: }
089: nfReqParams = params;
090: }
091:
092: public Enumeration getRequestParamNames() {
093: return nfReqParams.keys();
094: }
095:
096: public Enumeration getRequestParamVals() {
097: return nfReqParams.elements();
098: }
099:
100: public Object getRequestParams() {
101: return nfReqParams;
102: }
103:
104: public void setRequestParams(Hashtable params) {
105: nfReqParams = params;
106: }
107:
108: public void setRequestId(String reqId) {
109: if (reqId != null)
110: requestId = reqId;
111: }
112:
113: public String getRequestId() {
114: return requestId;
115: }
116:
117: public void setSessionId(String sessId) {
118: if (sessId != null)
119: sessionId = sessId;
120: }
121:
122: public String getSessionId() {
123: return sessionId;
124: }
125:
126: public void setUserId(String user) {
127: if (user != null)
128: userId = user;
129: }
130:
131: public String getUserId() {
132: return userId;
133: }
134:
135: public void setRequestType(int reqType) {
136: if (reqType > 0)
137: requestType = reqType;
138: }
139:
140: public int getRequestType() {
141: return requestType;
142: }
143:
144: /**
145: * If called a valid value must be set, else
146: * default value of NF_NOVALUE
147: */
148: public void setRequestObject(Object obj) throws NetFileException {
149: if (obj != null)
150: reqObject = obj;
151: else {
152: throw new NetFileException(
153: NetFileException.NETFILE_NULLVALUE,
154: "Additional request object cannot be set to null");
155: }
156: }
157:
158: public Object getRequestObject() {
159: return reqObject;
160: }
161:
162: }
|