001: /**
002: * $Id: NetFileBean.java,v 1.13 2006/09/05 11:23:07 vp154433 Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.admin.console.sra.netfile;
014:
015: import com.sun.portal.admin.console.sra.SraBaseBean;
016: import com.sun.web.ui.model.Option;
017: import com.sun.data.provider.DataProvider;
018: import com.sun.portal.admin.console.sra.utils.Util;
019:
020: import java.util.StringTokenizer;
021: import java.util.List;
022: import java.util.ArrayList;
023:
024: import javax.faces.component.UIComponent;
025: import javax.faces.context.FacesContext;
026: import javax.faces.validator.ValidatorException;
027:
028: import com.sun.portal.admin.console.sra.utils.AllowDenyModel;
029:
030: public class NetFileBean extends SraBaseBean {
031:
032: //Basic tab attributes
033: private static final String ALLOWED_HOST_LIST = "sunPortalNetFileAllowedHostList";
034: private static final String DENIED_HOST_LIST = "sunPortalNetFileDeniedHostList";
035: private static final String FILE_COMP_TYPE = "sunPortalNetFileCompressionType";
036: private static final String FILE_COMP_LEVEL = "sunPortalNetFileCompressionLevel";
037: private static final String TEMP_DIR = "sunPortalNetFileTempDir";
038: private static final String FILE_UP_LIMIT = "sunPortalNetFileFileUploadLimit";
039: private static final String MAX_SRCH_DIR = "sunPortalNetFileMaxSearchDir";
040: private static final String ALLOW_RENAME = "sunPortalNetFileAllowRename";
041: private static final String ALLOW_DELETE = "sunPortalNetFileAllowDelete";
042: private static final String ALLOW_UPLOAD = "sunPortalNetFileAllowUpload";
043: private static final String ALLOW_DOWNLOAD = "sunPortalNetFileAllowDownload";
044: private static final String ALLOW_SEARCH = "sunPortalNetFileAllowSearch";
045: private static final String ALLOW_MAIL = "sunPortalNetFileAllowMail";
046: private static final String ALLOW_COMPRESSION = "sunPortalNetFileAllowCompression";
047: private static final String ALLOW_CH_UID = "sunPortalNetFileAllowChangeUserId";
048: private static final String ALLOW_CH_DOMAIN = "sunPortalNetFileAllowChangeDomain";
049:
050: //Advanced tab attributes
051: private static final String DEFAULT_DOMAIN = "sunPortalNetFileDefaultDomain";
052: private static final String WIN_SRVR = "sunPortalNetFileWINSServer";
053: private static final String HOST_DETECT_ORDER = "sunPortalNetFileHostDetectOrder";
054: private static final String COMMON_HOST_DATA = "sunPortalNetFileCommonHostData";
055: private static final String ACCESS_WIN = "sunPortalNetFileAccessWin";
056: private static final String ACCESS_FTP = "sunPortalNetFileAccessFTP";
057: private static final String ACCESS_NFS = "sunPortalNetFileAccessNFS";
058: private static final String ACCESS_NETWARE = "sunPortalNetFileAccessNetware";
059:
060: // private static final String SERVICE_NAME = "netfile";
061: static String[] attrList = { ALLOWED_HOST_LIST, DENIED_HOST_LIST,
062: FILE_COMP_TYPE, FILE_COMP_LEVEL, TEMP_DIR, FILE_UP_LIMIT,
063: MAX_SRCH_DIR, ALLOW_RENAME, ALLOW_DELETE, ALLOW_UPLOAD,
064: ALLOW_DOWNLOAD, ALLOW_SEARCH, ALLOW_MAIL,
065: ALLOW_COMPRESSION, ALLOW_CH_UID, ALLOW_CH_DOMAIN,
066: DEFAULT_DOMAIN, WIN_SRVR, HOST_DETECT_ORDER,
067: COMMON_HOST_DATA, ACCESS_WIN, ACCESS_FTP, ACCESS_NFS,
068: ACCESS_NETWARE, COS_PRIORITY };
069:
070: private Option[] compressionType;
071:
072: private Option[] compressionLevel;
073:
074: private String tempDir;
075:
076: private String fileUploadLimit;
077:
078: private String maxSearchDir;
079:
080: private boolean allowRename;
081:
082: private boolean allowDelete;
083:
084: private boolean allowUpload;
085:
086: private boolean allowDownload;
087:
088: private boolean allowSearch;
089:
090: private boolean allowMail;
091:
092: private boolean allowCompression;
093:
094: private boolean allowChangeUserId;
095:
096: private boolean allowChangeDomain;
097:
098: //Basic Tab attributes
099:
100: private String defaultDomain;
101:
102: private String WINSServer;
103:
104: private String[] hostDetectOrder;
105:
106: private String[] commonHostData;
107:
108: private boolean accessWin;
109:
110: private boolean accessFTP;
111:
112: private boolean accessNFS;
113:
114: private boolean accessNetware;
115:
116: /** Holds value of property compressionType. */
117: private String selectedCompressionType;
118:
119: /** Holds value of property selectedCompressionLevel. */
120: private String selectedCompressionLevel;
121:
122: private AllowDenyModel allowDenyHost;
123:
124: static {
125: setPropertyVisibility(ALLOWED_HOST_LIST, HIDE, SHOW, SHOW);
126: setPropertyVisibility(DENIED_HOST_LIST, HIDE, SHOW, SHOW);
127: setPropertyVisibility(FILE_COMP_TYPE, HIDE, SHOW, SHOW);
128: setPropertyVisibility(FILE_COMP_LEVEL, HIDE, SHOW, SHOW);
129: setPropertyVisibility(TEMP_DIR, HIDE, SHOW, SHOW);
130: setPropertyVisibility(FILE_UP_LIMIT, HIDE, SHOW, SHOW);
131: setPropertyVisibility(MAX_SRCH_DIR, HIDE, SHOW, SHOW);
132: setPropertyVisibility(ALLOW_RENAME, HIDE, SHOW, SHOW);
133: setPropertyVisibility(ALLOW_DELETE, HIDE, SHOW, SHOW);
134: setPropertyVisibility(ALLOW_UPLOAD, HIDE, SHOW, SHOW);
135: setPropertyVisibility(ALLOW_DOWNLOAD, HIDE, SHOW, SHOW);
136: setPropertyVisibility(ALLOW_SEARCH, HIDE, SHOW, SHOW);
137: setPropertyVisibility(ALLOW_MAIL, HIDE, SHOW, SHOW);
138: setPropertyVisibility(ALLOW_COMPRESSION, HIDE, SHOW, SHOW);
139: setPropertyVisibility(ALLOW_CH_UID, HIDE, SHOW, SHOW);
140: setPropertyVisibility(ALLOW_CH_DOMAIN, HIDE, SHOW, SHOW);
141:
142: //Advanced tab attributes
143: setPropertyVisibility(DEFAULT_DOMAIN, HIDE, SHOW, SHOW);
144: setPropertyVisibility(WIN_SRVR, HIDE, SHOW, SHOW);
145: setPropertyVisibility(HOST_DETECT_ORDER, HIDE, SHOW, SHOW);
146: setPropertyVisibility(COMMON_HOST_DATA, HIDE, SHOW, SHOW);
147: setPropertyVisibility(ACCESS_WIN, HIDE, SHOW, SHOW);
148: setPropertyVisibility(ACCESS_FTP, HIDE, SHOW, SHOW);
149: setPropertyVisibility(ACCESS_NFS, HIDE, SHOW, SHOW);
150: setPropertyVisibility(ACCESS_NETWARE, HIDE, SHOW, SHOW);
151: setPropertyVisibility(COS_PRIORITY, HIDE, SHOW, HIDE);
152: }
153:
154: public NetFileBean() {
155: super (NETFILE_SVC, attrList);
156: initData();
157: /*try {
158: _attributeNameValueMap = (HashMap) getDataFromStore();
159: initData();
160:
161: } catch (Exception e) {
162: e.printStackTrace();
163: }*/
164: }
165:
166: public void initData() {
167:
168: compressionType = new Option[2];
169: compressionType[0] = new Option("zip", "ZIP");
170: compressionType[1] = new Option("gz", "GZ");
171:
172: compressionLevel = new Option[10];
173: compressionLevel[0] = new Option("0", "0");
174: compressionLevel[1] = new Option("1", "1");
175: compressionLevel[2] = new Option("2", "2");
176: compressionLevel[3] = new Option("3", "3");
177: compressionLevel[4] = new Option("4", "4");
178: compressionLevel[5] = new Option("5", "5");
179: compressionLevel[6] = new Option("6", "6");
180: compressionLevel[7] = new Option("7", "7");
181: compressionLevel[8] = new Option("8", "8");
182: compressionLevel[9] = new Option("9", "9");
183:
184: selectedCompressionType = getStringValue(FILE_COMP_TYPE);
185: selectedCompressionLevel = getStringValue(FILE_COMP_LEVEL);
186: tempDir = getStringValue(TEMP_DIR);
187: fileUploadLimit = getStringValue(FILE_UP_LIMIT);
188: maxSearchDir = getStringValue(MAX_SRCH_DIR);
189: allowRename = getBooleanValue(ALLOW_RENAME);
190: allowDelete = getBooleanValue(ALLOW_DELETE);
191: allowUpload = getBooleanValue(ALLOW_UPLOAD);
192: allowDownload = getBooleanValue(ALLOW_DOWNLOAD);
193: allowSearch = getBooleanValue(ALLOW_SEARCH);
194: allowMail = getBooleanValue(ALLOW_MAIL);
195: allowCompression = getBooleanValue(ALLOW_COMPRESSION);
196: allowChangeUserId = getBooleanValue(ALLOW_CH_UID);
197: allowChangeDomain = getBooleanValue(ALLOW_CH_DOMAIN);
198:
199: defaultDomain = getStringValue(DEFAULT_DOMAIN);
200: WINSServer = getStringValue(WIN_SRVR);
201:
202: StringTokenizer stk = new StringTokenizer(
203: getStringValue(HOST_DETECT_ORDER));
204: int tokens = stk.countTokens();
205: if (tokens == 0)
206: hostDetectOrder = new String[] { "" };
207: else {
208: hostDetectOrder = new String[tokens];
209: for (int i = 0; i < tokens; i++)
210: hostDetectOrder[i] = (String) stk.nextElement();
211: }
212:
213: commonHostData = getStringArrayValue(COMMON_HOST_DATA);
214: accessWin = getBooleanValue(ACCESS_WIN);
215: accessFTP = getBooleanValue(ACCESS_FTP);
216: accessNFS = getBooleanValue(ACCESS_NFS);
217: accessNetware = getBooleanValue(ACCESS_NETWARE);
218:
219: ArrayList states = new ArrayList();
220: states
221: .add((String) Util
222: .evaluateCachedValueBinding("#{netfile['option.allow.string']}"));
223: states
224: .add((String) Util
225: .evaluateCachedValueBinding("#{netfile['option.deny.string']}"));
226:
227: allowDenyHost = new AllowDenyModel("NETFILE_ALLOW_DENY_HOST",
228: states, getListValue(ALLOWED_HOST_LIST),
229: getListValue(DENIED_HOST_LIST));
230: }
231:
232: public String getDefaultDomain() {
233: return defaultDomain;
234: }
235:
236: public void setDefaultDomain(String defDomain) {
237: defaultDomain = defDomain;
238: updateAttributeNVMap(DEFAULT_DOMAIN, defaultDomain);
239: }
240:
241: public String getWINSServer() {
242: return WINSServer;
243: }
244:
245: public void setWINSServer(String winSrvr) {
246: WINSServer = winSrvr;
247: updateAttributeNVMap(WIN_SRVR, WINSServer);
248: }
249:
250: public String[] getHostDetectOrder() {
251: return hostDetectOrder;
252: }
253:
254: public void setHostDetectOrder(String[] hostDtOrdr) {
255: hostDetectOrder = hostDtOrdr;
256: String order = hostDetectOrder[0] + " " + hostDetectOrder[1]
257: + " " + hostDetectOrder[2] + " " + hostDetectOrder[3];
258: updateAttributeNVMap(HOST_DETECT_ORDER, order);
259: }
260:
261: public String[] getCommonHostData() {
262: return commonHostData;
263: }
264:
265: public void setCommonHostData(String[] commonHostData) {
266: this .commonHostData = commonHostData;
267: updateAttributeNVMap(COMMON_HOST_DATA, commonHostData);
268: }
269:
270: public boolean getAccessWin() {
271: return accessWin;
272: }
273:
274: public void setAccessWin(boolean accessWin) {
275: this .accessWin = accessWin;
276: updateAttributeNVMap(ACCESS_WIN, Boolean.toString(accessWin));
277: }
278:
279: public boolean getAccessFTP() {
280: return accessFTP;
281: }
282:
283: public void setAccessFTP(boolean accessFTP) {
284: this .accessFTP = accessFTP;
285: updateAttributeNVMap(ACCESS_FTP, Boolean.toString(accessFTP));
286: }
287:
288: public boolean getAccessNFS() {
289: return accessNFS;
290: }
291:
292: public void setAccessNFS(boolean accessNFS) {
293: this .accessNFS = accessNFS;
294: updateAttributeNVMap(ACCESS_NFS, Boolean.toString(accessNFS));
295: }
296:
297: public boolean getAccessNetware() {
298: return accessNetware;
299: }
300:
301: public void setAccessNetware(boolean accessNetware) {
302: this .accessNetware = accessNetware;
303: updateAttributeNVMap(ACCESS_NETWARE, Boolean
304: .toString(accessNetware));
305: }
306:
307: public void setAllowedHostList(List allowList) {
308: updateAttributeNVMap(ALLOWED_HOST_LIST, allowList);
309: }
310:
311: public void setDeniedHostList(List deniedList) {
312: updateAttributeNVMap(DENIED_HOST_LIST, deniedList);
313: }
314:
315: public String getSelectedCompressionType() {
316: return selectedCompressionType;
317: }
318:
319: public void setSelectedCompressionType(
320: String selectedCompressionType) {
321: this .selectedCompressionType = selectedCompressionType;
322: updateAttributeNVMap(FILE_COMP_TYPE, selectedCompressionType);
323: }
324:
325: /**
326: * Getter for property compressionLevel.
327: *
328: * @return Value of property compressionLevel.
329: */
330: public Option[] getCompressionLevel() {
331:
332: return this .compressionLevel;
333: }
334:
335: /**
336: * Setter for property compressionLevel.
337: *
338: * @param compressionLevel
339: * New value of property compressionLevel.
340: */
341: public void setCompressionLevel(Option[] compressionLevel) {
342: this .compressionLevel = compressionLevel;
343: }
344:
345: public String getTempDir() {
346: return tempDir;
347: }
348:
349: public void setTempDir(String tempDir) {
350: this .tempDir = tempDir;
351: updateAttributeNVMap(TEMP_DIR, tempDir);
352: }
353:
354: public String getFileUploadLimit() {
355: return fileUploadLimit;
356: }
357:
358: public void setFileUploadLimit(String upLimit) {
359: fileUploadLimit = upLimit;
360: updateAttributeNVMap(FILE_UP_LIMIT, fileUploadLimit);
361: }
362:
363: public String getMaxSearchDir() {
364: return maxSearchDir;
365: }
366:
367: public void setMaxSearchDir(String maxSrchDir) {
368: maxSearchDir = maxSrchDir;
369: updateAttributeNVMap(MAX_SRCH_DIR, maxSearchDir);
370: }
371:
372: public boolean getallowRename() {
373: return allowRename;
374: }
375:
376: public void setAllowRename(boolean allowRename) {
377: this .allowRename = allowRename;
378: updateAttributeNVMap(ALLOW_RENAME, Boolean
379: .toString(allowRename));
380: }
381:
382: public boolean getAllowDelete() {
383: return allowDelete;
384: }
385:
386: public void setAllowDelete(boolean allowDelete) {
387: this .allowDelete = allowDelete;
388: updateAttributeNVMap(ALLOW_DELETE, Boolean
389: .toString(allowDelete));
390: }
391:
392: public boolean getAllowUpload() {
393: return allowUpload;
394: }
395:
396: public void setAllowUpload(boolean allowUpload) {
397: this .allowUpload = allowUpload;
398: updateAttributeNVMap(ALLOW_UPLOAD, Boolean
399: .toString(allowUpload));
400: }
401:
402: public boolean getAllowDownload() {
403: return allowDownload;
404: }
405:
406: public void setAllowDownload(boolean allowDownload) {
407: this .allowDownload = allowDownload;
408: updateAttributeNVMap(ALLOW_DOWNLOAD, Boolean
409: .toString(allowDownload));
410: }
411:
412: public boolean getAllowSearch() {
413: return allowSearch;
414: }
415:
416: public void setAllowSearch(boolean allowSearch) {
417: this .allowSearch = allowSearch;
418: updateAttributeNVMap(ALLOW_SEARCH, Boolean
419: .toString(allowSearch));
420: }
421:
422: public boolean getAllowMail() {
423: return allowMail;
424: }
425:
426: public void setAllowMail(boolean allowMail) {
427: this .allowMail = allowMail;
428: updateAttributeNVMap(ALLOW_MAIL, Boolean.toString(allowMail));
429: }
430:
431: public boolean getAllowCompression() {
432: return allowCompression;
433: }
434:
435: public void setAllowCompression(boolean allowCompression) {
436: this .allowCompression = allowCompression;
437: updateAttributeNVMap(ALLOW_COMPRESSION, Boolean
438: .toString(allowCompression));
439: }
440:
441: public boolean getAllowChangeUserId() {
442: return allowChangeUserId;
443: }
444:
445: public void setAllowChangeUserId(boolean allowChUid) {
446: allowChangeUserId = allowChUid;
447: updateAttributeNVMap(ALLOW_CH_UID, Boolean
448: .toString(allowChangeUserId));
449: }
450:
451: public boolean getAllowChangeDomain() {
452: return allowChangeDomain;
453: }
454:
455: public void setAllowChangeDomain(boolean allowChDom) {
456: allowChangeDomain = allowChDom;
457: updateAttributeNVMap(ALLOW_CH_DOMAIN, Boolean
458: .toString(allowChangeDomain));
459: }
460:
461: public void storeData() {
462: saveAllowDenyHostList();
463: super .storeDataToStore();
464: }
465:
466: /**
467: * Getter for property compressionType.
468: *
469: * @return Value of property compressionType.
470: */
471: public Option[] getCompressionType() {
472:
473: return this .compressionType;
474: }
475:
476: /**
477: * Setter for property compressionType.
478: *
479: * @param compressionType
480: * New value of property compressionType.
481: */
482: public void setCompressionType(Option[] compressionType) {
483:
484: this .compressionType = compressionType;
485: }
486:
487: /**
488: * Getter for property selectedCompressionLevel.
489: *
490: * @return Value of property selectedCompressionLevel.
491: */
492: public String getSelectedCompressionLevel() {
493:
494: return this .selectedCompressionLevel;
495: }
496:
497: /**
498: * Setter for property selectedCompressionLevel.
499: *
500: * @param selectedCompressionLevel
501: * New value of property selectedCompressionLevel.
502: */
503: public void setSelectedCompressionLevel(
504: String selectedCompressionLevel) {
505:
506: this .selectedCompressionLevel = selectedCompressionLevel;
507: ////updateAttributeNVMap(FILE_COMP_LEVEL , selectedCompressionLevel);
508: updateAttributeNVMap(FILE_COMP_LEVEL, selectedCompressionLevel);
509: }
510:
511: public void addNewHost() {
512: allowDenyHost.addNewItem();
513: }
514:
515: public void deleteHost() {
516: allowDenyHost.deleteItem();
517: saveAllowDenyHostList();
518: }
519:
520: private void saveAllowDenyHostList() {
521: setAllowedHostList(allowDenyHost.getAllowList());
522: storeDataToStore(ALLOWED_HOST_LIST);
523: setDeniedHostList(allowDenyHost.getDenyList());
524: storeDataToStore(DENIED_HOST_LIST);
525: }
526:
527: /*public boolean isAllowDenyHostListContainsEmpty()
528: {
529: return doesTableContainEmptyRow(allowDenyHost);
530: } */
531:
532: public DataProvider getAllowDenyHostList() {
533: return allowDenyHost.getAllowDenyDataProvider();
534: }
535:
536: public List getOperations() {
537: return allowDenyHost.getOperations();
538: }
539:
540: public boolean isServiceAssigned() {
541: return isServiceAssigned("srapNetFileService");
542: }
543: }
|