Source Code Cross Referenced for AllowDenyModel.java in  » Portal » Open-Portal » com » sun » portal » admin » console » sra » utils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.admin.console.sra.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * AllowDenyModel.java
003:         *
004:         * Created on September 13, 2005, 4:42 PM
005:         *
006:         * To change this template, choose Tools | Options and locate the template under
007:         * the Source Creation and Management node. Right-click the template and choose
008:         * Open. You can then make changes to the template in the Source Editor.
009:         */
010:
011:        package com.sun.portal.admin.console.sra.utils;
012:
013:        import com.sun.data.provider.DataProvider;
014:        import java.util.List;
015:        import java.util.ArrayList;
016:        import java.util.Iterator;
017:        import com.sun.web.ui.model.Option;
018:
019:        /**
020:         *
021:         * @author aa147324
022:         */
023:        public class AllowDenyModel {
024:
025:            private SraObjectListDataProvider _allowDenyDataProvider;
026:
027:            private ArrayList operations;
028:
029:            private static int ALLOW = 1;
030:
031:            private static int DENY = 2;
032:
033:            /** Creates a new instance of AllowDenyModel */
034:            private AllowDenyModel() {
035:            }
036:
037:            public AllowDenyModel(String id, ArrayList states, List allowList,
038:                    List denyList) {
039:                operations = new ArrayList();
040:                operations
041:                        .add(new Option(Boolean.TRUE, (String) states.get(0)));
042:                operations
043:                        .add(new Option(Boolean.FALSE, (String) states.get(1)));
044:
045:                List allowDenyList = new ArrayList(convertStrToADItem(
046:                        allowList, true));
047:                allowDenyList.addAll(convertStrToADItem(denyList, false));
048:                _allowDenyDataProvider = new SraObjectListDataProvider(
049:                        AllowDenyItem.class.getName() + "_" + id, allowDenyList);
050:            }
051:
052:            public DataProvider getAllowDenyDataProvider() {
053:                return _allowDenyDataProvider;
054:            }
055:
056:            public List getAllowList() {
057:                return convertADItemToStr(getAllowDenyList(ALLOW));
058:            }
059:
060:            public List getDenyList() {
061:                return convertADItemToStr(getAllowDenyList(DENY));
062:            }
063:
064:            private List convertADItemToStr(List aclObjectlist) {
065:                // Using a list of ACL objects, create a list of String objects of the
066:                // URL's contained in the ACL object
067:                List list = new ArrayList(aclObjectlist.size());
068:                Iterator iter = aclObjectlist.iterator();
069:                while (iter.hasNext()) {
070:                    AllowDenyItem element = (AllowDenyItem) iter.next();
071:                    list.add(element.getItem());
072:                }
073:                /*This done so that when we save at a level other than top the setAttributes() call 
074:                // throws an exception. As per Prashant, if the list being passed to setAttributes() is empty
075:                // we need to put an empty string in it.
076:                if ( list.isEmpty())
077:                	list.add("");*/
078:                return list;
079:            }
080:
081:            /**
082:             * @param
083:             * @return
084:             */
085:            private List convertStrToADItem(List thelist, boolean isAllowed) {
086:                List list = new ArrayList(thelist.size());
087:                Iterator iter = thelist.iterator();
088:
089:                while (iter.hasNext()) {
090:                    String element = (String) iter.next();
091:                    list.add(new AllowDenyItem(element, isAllowed));
092:                }
093:                return list;
094:            }
095:
096:            public void addNewItem() {
097:                if (_allowDenyDataProvider.canAppendRow()) {
098:                    _allowDenyDataProvider.appendRow(new AllowDenyItem("",
099:                            false));
100:                    _allowDenyDataProvider.commitChanges();
101:                }
102:            }
103:
104:            public void deleteItem() {
105:                _allowDenyDataProvider.commitChanges();
106:                AllowDenyItem[] allowDenyArray = (AllowDenyItem[]) _allowDenyDataProvider
107:                        .getList().toArray(new AllowDenyItem[0]);
108:
109:                for (int i = 0; i < allowDenyArray.length; i++) {
110:                    AllowDenyItem acl = allowDenyArray[i];
111:
112:                    if (acl.getSelected()) {
113:                        _allowDenyDataProvider.removeObject(acl);
114:                    }
115:                }
116:                _allowDenyDataProvider.commitChanges();
117:                //Following lines to be added        
118:                //        getAllowDenyHostList();
119:
120:                //        storeDataToStore(ACCESS_HOSTS);
121:                //        storeDataToStore(DENY_HOSTS);
122:            }
123:
124:            public ArrayList getOperations() {
125:                return operations;
126:            }
127:
128:            private List getAllowDenyList(int type) {
129:                List allowList = new ArrayList();
130:                List denyList = new ArrayList();
131:                _allowDenyDataProvider.commitChanges();
132:                AllowDenyItem[] allowDenyArray = (AllowDenyItem[]) _allowDenyDataProvider
133:                        .getList().toArray(new AllowDenyItem[0]);
134:                for (int i = 0; i < allowDenyArray.length; i++) {
135:                    AllowDenyItem element = allowDenyArray[i];
136:                    if (element.getIsAllowed())
137:                        allowList.add(element);
138:                    else
139:                        denyList.add(element);
140:                }
141:                if (type == ALLOW) {
142:                    return allowList;
143:                }
144:                return denyList;
145:            }
146:        }
w___w___w._j___a_v_a___2_s__.c_om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.