Return-Path: Delivered-To: apmail-ws-scout-dev-archive@www.apache.org Received: (qmail 72755 invoked from network); 10 Feb 2005 15:06:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Feb 2005 15:06:56 -0000 Received: (qmail 90157 invoked by uid 500); 10 Feb 2005 15:06:56 -0000 Delivered-To: apmail-ws-scout-dev-archive@ws.apache.org Received: (qmail 90133 invoked by uid 500); 10 Feb 2005 15:06:56 -0000 Mailing-List: contact scout-dev-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: scout-dev@ws.apache.org Delivered-To: mailing list scout-dev@ws.apache.org Received: (qmail 90115 invoked by uid 500); 10 Feb 2005 15:06:55 -0000 Delivered-To: apmail-ws-scout-cvs@ws.apache.org Received: (qmail 90112 invoked by uid 99); 10 Feb 2005 15:06:55 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 10 Feb 2005 07:06:55 -0800 Received: (qmail 72716 invoked by uid 65534); 10 Feb 2005 15:06:54 -0000 Message-ID: <20050210150653.72699.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Thu, 10 Feb 2005 15:06:53 -0000 Subject: svn commit: r153228 - webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/registry/infomodel/OrganizationImpl.java To: scout-cvs@ws.apache.org From: geirm@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: geirm Date: Thu Feb 10 07:06:49 2005 New Revision: 153228 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D153228 Log: first cut at solving the mythical primary contact problem The spec isn't quite clear about this, so trying to be as=20 clear and defensive as possible. =20 Modified: webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/regi= stry/infomodel/OrganizationImpl.java Modified: webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scou= t/registry/infomodel/OrganizationImpl.java URL: http://svn.apache.org/viewcvs/webservices/scout/trunk/modules/scout/sr= c/java/org/apache/ws/scout/registry/infomodel/OrganizationImpl.java?view=3D= diff&r1=3D153227&r2=3D153228 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/regi= stry/infomodel/OrganizationImpl.java (original) +++ webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/regi= stry/infomodel/OrganizationImpl.java Thu Feb 10 07:06:49 2005 @@ -16,7 +16,6 @@ =20 package org.apache.ws.scout.registry.infomodel; =20 -import javax.xml.registry.InvalidRequestException; import javax.xml.registry.JAXRException; import javax.xml.registry.LifeCycleManager; import javax.xml.registry.UnsupportedCapabilityException; @@ -35,7 +34,8 @@ * * Implements JAXR Interface. * For futher details, look into the JAXR API Javadoc. * - * @author Anil Saldhana + * @author Anil Saldhana + * @author Geir Magnusson Jr. */ public class OrganizationImpl extends RegistryObjectImpl implements Organi= zation { @@ -52,6 +52,9 @@ public User getPrimaryContact() throws JAXRException { //TODO: How do we fix this? Run JAXRQueryTest and you will hit thi= s problem. + // + // gmj : I think I fixed w/ primary contact hack... + // //if (primaryContact =3D=3D null) { // throw new IllegalStateException("primaryContact is null and = the spec says we cannot return a null value"); //} @@ -64,25 +67,47 @@ { throw new IllegalArgumentException("primaryContact must not be= null"); } - users.add(user); + + /* + * first check to see if user already exists in user set + */ + primaryContact =3D user; - ((UserImpl) user).setOrganization(this); + + if (!users.contains(user)) { + addUser(user); + } } =20 public void addUser(User user) throws JAXRException { + doPrimaryContactHack(user); + users.add(user); ((UserImpl) user).setOrganization(this); } =20 + /** + * + * to solve the getPrimaryContactProblem(), if we have no defined + * primaryContact, we'll designate the first user as such + * + * @param user + */ + private void doPrimaryContactHack(User user) { + + if (primaryContact =3D=3D null && users.size() =3D=3D 0) { + primaryContact =3D user; + } + } + public void addUsers(Collection collection) throws JAXRException { // do this by hand to ensure all members are actually instances of= User for (Iterator iterator =3D collection.iterator(); iterator.hasNext= ();) { User user =3D (User) iterator.next(); - users.add(user); - ((UserImpl) user).setOrganization(this); + addUser(user); } } =20 @@ -93,20 +118,35 @@ =20 public void removeUser(User user) throws JAXRException { - if (primaryContact.equals(user)) - { - throw new InvalidRequestException("Cannot remove primaryContac= t"); + if (user !=3D null) { + users.remove(user); + } + + /* + * more primaryContact hakiness - nothing says that you can't + * remove the user that is the PC... + */ + + if (!users.contains(primaryContact)) { + primaryContact =3D null; } - users.remove(user); } =20 public void removeUsers(Collection collection) throws JAXRException { - if (collection.contains(primaryContact)) - { - throw new InvalidRequestException("Cannot remove primaryContac= t"); + if (collection !=3D null) { + users.removeAll(collection); } - users.removeAll(collection); + + /* + * more primaryContact hakiness - nothing says that you can't + * remove the user that is the PC... + */ + + if (!users.contains(primaryContact)) { + primaryContact =3D null; + } + } =20 public Collection getTelephoneNumbers(String phoneType) throws JAXRExc= eption --------------------------------------------------------------------- To unsubscribe, e-mail: scout-dev-unsubscribe@ws.apache.org For additional commands, e-mail: scout-dev-help@ws.apache.org