Source Code Cross Referenced for OrganizationImpl.java in  » Web-Services » XML-Registry-JAXR » org » apache » ws » scout » registry » infomodel » 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 » Web Services » XML Registry JAXR » org.apache.ws.scout.registry.infomodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.ws.scout.registry.infomodel;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.HashSet;
022:        import java.util.Iterator;
023:        import java.util.Set;
024:
025:        import javax.xml.registry.JAXRException;
026:        import javax.xml.registry.LifeCycleManager;
027:        import javax.xml.registry.UnsupportedCapabilityException;
028:        import javax.xml.registry.infomodel.Organization;
029:        import javax.xml.registry.infomodel.PostalAddress;
030:        import javax.xml.registry.infomodel.Service;
031:        import javax.xml.registry.infomodel.TelephoneNumber;
032:        import javax.xml.registry.infomodel.User;
033:
034:        /**
035:         * Organization Interface
036:         * * Implements JAXR Interface.
037:         * For futher details, look into the JAXR API Javadoc.
038:         *
039:         * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
040:         * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
041:         */
042:        public class OrganizationImpl extends RegistryObjectImpl implements 
043:                Organization {
044:            private User primaryContact;
045:            private Set<User> users = new HashSet<User>();
046:            private Set<TelephoneNumber> telephoneNumbers = new HashSet<TelephoneNumber>();
047:            private Collection<Service> services = new ArrayList<Service>();
048:
049:            public OrganizationImpl(LifeCycleManager lifeCycleManager) {
050:                super (lifeCycleManager);
051:            }
052:
053:            public User getPrimaryContact() throws JAXRException {
054:                //TODO: How do we fix this? Run JAXRQueryTest and you will hit this problem.
055:                //
056:                //  gmj : I think I fixed w/ primary contact hack...
057:                //
058:                //if (primaryContact == null) {
059:                //    throw new IllegalStateException("primaryContact is null and the spec says we cannot return a null value");
060:                //}
061:                return primaryContact;
062:            }
063:
064:            public void setPrimaryContact(User user) throws JAXRException {
065:                if (user == null) {
066:                    throw new IllegalArgumentException(
067:                            "primaryContact must not be null");
068:                }
069:
070:                /*
071:                 * first check to see if user already exists in user set
072:                 */
073:
074:                primaryContact = user;
075:
076:                if (!users.contains(user)) {
077:                    addUser(user);
078:                }
079:            }
080:
081:            public void addUser(User user) throws JAXRException {
082:                doPrimaryContactHack(user);
083:
084:                users.add(user);
085:                ((UserImpl) user).setOrganization(this );
086:            }
087:
088:            /**
089:             *
090:             *  to solve the getPrimaryContactProblem(), if we have no defined
091:             *  primaryContact, we'll designate the first user as such
092:             *
093:             * @param user
094:             */
095:            private void doPrimaryContactHack(User user) {
096:
097:                if (primaryContact == null && users.size() == 0) {
098:                    primaryContact = user;
099:                }
100:            }
101:
102:            public void addUsers(Collection collection) throws JAXRException {
103:                // do this by hand to ensure all members are actually instances of User
104:                for (Iterator iterator = collection.iterator(); iterator
105:                        .hasNext();) {
106:                    User user = (User) iterator.next();
107:                    addUser(user);
108:                }
109:            }
110:
111:            public Collection<User> getUsers() throws JAXRException {
112:                return users;
113:            }
114:
115:            public void removeUser(User user) throws JAXRException {
116:                if (user != null) {
117:                    users.remove(user);
118:                }
119:
120:                /*
121:                 * more primaryContact hakiness - nothing says that you can't
122:                 * remove the user that is the PC...
123:                 */
124:
125:                if (!users.contains(primaryContact)) {
126:                    primaryContact = null;
127:                }
128:            }
129:
130:            public void removeUsers(Collection collection) throws JAXRException {
131:                if (collection != null) {
132:                    users.removeAll(collection);
133:                }
134:
135:                /*
136:                 * more primaryContact hakiness - nothing says that you can't
137:                 * remove the user that is the PC...
138:                 */
139:
140:                if (!users.contains(primaryContact)) {
141:                    primaryContact = null;
142:                }
143:
144:            }
145:
146:            public Collection<TelephoneNumber> getTelephoneNumbers(
147:                    String phoneType) throws JAXRException {
148:                Set<TelephoneNumber> filteredNumbers;
149:                if (phoneType == null) {
150:                    filteredNumbers = telephoneNumbers;
151:                } else {
152:                    filteredNumbers = new HashSet<TelephoneNumber>(
153:                            telephoneNumbers.size());
154:                    for (Iterator i = telephoneNumbers.iterator(); i.hasNext();) {
155:                        TelephoneNumber number = (TelephoneNumber) i.next();
156:                        if (phoneType.equals(number.getType())) {
157:                            filteredNumbers.add(number);
158:                        }
159:                    }
160:                }
161:                return filteredNumbers;
162:            }
163:
164:            public void setTelephoneNumbers(
165:                    Collection<TelephoneNumber> collection)
166:                    throws JAXRException {
167:                // do this by hand to ensure all members are actually instances of TelephoneNumber
168:                Set<TelephoneNumber> numbers = new HashSet<TelephoneNumber>(
169:                        collection.size());
170:                for (Iterator i = collection.iterator(); i.hasNext();) {
171:                    TelephoneNumber number = (TelephoneNumber) i.next();
172:                    numbers.add(number);
173:                }
174:                this .telephoneNumbers = numbers;
175:            }
176:
177:            public void addService(Service service) throws JAXRException {
178:                services.add(service);
179:
180:                /*
181:                 * we need to tell the service who it's organization is so
182:                 * we can set the UDDI Business Key...
183:                 */
184:
185:                service.setProvidingOrganization(this );
186:            }
187:
188:            public void addServices(Collection collection) throws JAXRException {
189:                // do this by hand to ensure all members are actually instances of Service
190:                for (Iterator iterator = collection.iterator(); iterator
191:                        .hasNext();) {
192:                    Service service = (Service) iterator.next();
193:
194:                    addService(service);
195:                }
196:            }
197:
198:            public Collection<Service> getServices() throws JAXRException {
199:                return services;
200:            }
201:
202:            public void removeService(Service service) throws JAXRException {
203:                services.remove(service);
204:            }
205:
206:            public void removeServices(Collection collection)
207:                    throws JAXRException {
208:                services.removeAll(collection);
209:            }
210:
211:            ///////////////////////////////////////////////////////////////////////////
212:            // Level 1 features must throw exceptions
213:            ///////////////////////////////////////////////////////////////////////////
214:
215:            public Organization getParentOrganization() throws JAXRException {
216:                throw new UnsupportedCapabilityException("Level 1 feature");
217:            }
218:
219:            public Collection<Organization> getDescendantOrganizations()
220:                    throws JAXRException {
221:                throw new UnsupportedCapabilityException("Level 1 feature");
222:            }
223:
224:            public Organization getRootOrganization() throws JAXRException {
225:                throw new UnsupportedCapabilityException("Level 1 feature");
226:            }
227:
228:            public void addChildOrganization(Organization organization)
229:                    throws JAXRException {
230:                throw new UnsupportedCapabilityException("Level 1 feature");
231:            }
232:
233:            public void addChildOrganizations(Collection collection)
234:                    throws JAXRException {
235:                throw new UnsupportedCapabilityException("Level 1 feature");
236:            }
237:
238:            public int getChildOrganizationCount() throws JAXRException {
239:                throw new UnsupportedCapabilityException("Level 1 feature");
240:            }
241:
242:            public Collection<Organization> getChildOrganizations()
243:                    throws JAXRException {
244:                throw new UnsupportedCapabilityException("Level 1 feature");
245:            }
246:
247:            public void removeChildOrganization(Organization organization)
248:                    throws JAXRException {
249:                throw new UnsupportedCapabilityException("Level 1 feature");
250:            }
251:
252:            public void removeChildOrganizations(Collection collection)
253:                    throws JAXRException {
254:                throw new UnsupportedCapabilityException("Level 1 feature");
255:            }
256:
257:            public PostalAddress getPostalAddress() throws JAXRException {
258:                throw new UnsupportedCapabilityException("Level 1 feature");
259:            }
260:
261:            public void setPostalAddress(PostalAddress postalAddress)
262:                    throws JAXRException {
263:                throw new UnsupportedCapabilityException("Level 1 feature");
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.