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


0001:        /**
0002:         *
0003:         * Copyright 2004 The Apache Software Foundation
0004:         *
0005:         *  Licensed under the Apache License, Version 2.0 (the "License");
0006:         *  you may not use this file except in compliance with the License.
0007:         *  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */package org.apache.ws.scout.registry;
0017:
0018:        import java.net.PasswordAuthentication;
0019:        import java.util.ArrayList;
0020:        import java.util.Collection;
0021:        import java.util.Iterator;
0022:        import java.util.LinkedHashSet;
0023:        import java.util.List;
0024:        import java.util.Set;
0025:
0026:        import javax.xml.registry.BulkResponse;
0027:        import javax.xml.registry.BusinessLifeCycleManager;
0028:        import javax.xml.registry.BusinessQueryManager;
0029:        import javax.xml.registry.InvalidRequestException;
0030:        import javax.xml.registry.JAXRException;
0031:        import javax.xml.registry.LifeCycleManager;
0032:        import javax.xml.registry.RegistryService;
0033:        import javax.xml.registry.UnsupportedCapabilityException;
0034:        import javax.xml.registry.infomodel.Association;
0035:        import javax.xml.registry.infomodel.ClassificationScheme;
0036:        import javax.xml.registry.infomodel.Concept;
0037:        import javax.xml.registry.infomodel.Key;
0038:        import javax.xml.registry.infomodel.LocalizedString;
0039:        import javax.xml.registry.infomodel.Organization;
0040:        import javax.xml.registry.infomodel.RegistryObject;
0041:        import javax.xml.registry.infomodel.Service;
0042:        import javax.xml.registry.infomodel.ServiceBinding;
0043:
0044:        import org.apache.ws.scout.registry.infomodel.AssociationImpl;
0045:        import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
0046:        import org.apache.ws.scout.registry.infomodel.ConceptImpl;
0047:        import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
0048:        import org.apache.ws.scout.registry.infomodel.KeyImpl;
0049:        import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl;
0050:        import org.apache.ws.scout.uddi.AssertionStatusItem;
0051:        import org.apache.ws.scout.uddi.AssertionStatusReport;
0052:        import org.apache.ws.scout.uddi.AuthToken;
0053:        import org.apache.ws.scout.uddi.BindingDetail;
0054:        import org.apache.ws.scout.uddi.BindingTemplate;
0055:        import org.apache.ws.scout.uddi.BusinessDetail;
0056:        import org.apache.ws.scout.uddi.BusinessEntity;
0057:        import org.apache.ws.scout.uddi.BusinessInfo;
0058:        import org.apache.ws.scout.uddi.BusinessList;
0059:        import org.apache.ws.scout.uddi.BusinessService;
0060:        import org.apache.ws.scout.uddi.FindQualifiers;
0061:        import org.apache.ws.scout.uddi.KeyedReference;
0062:        import org.apache.ws.scout.uddi.Name;
0063:        import org.apache.ws.scout.uddi.PublisherAssertion;
0064:        import org.apache.ws.scout.uddi.PublisherAssertions;
0065:        import org.apache.ws.scout.uddi.ServiceDetail;
0066:        import org.apache.ws.scout.uddi.ServiceInfo;
0067:        import org.apache.ws.scout.uddi.ServiceInfos;
0068:        import org.apache.ws.scout.uddi.ServiceList;
0069:        import org.apache.ws.scout.uddi.TModel;
0070:        import org.apache.ws.scout.uddi.TModelDetail;
0071:        import org.apache.ws.scout.uddi.TModelInfo;
0072:        import org.apache.ws.scout.uddi.TModelInfos;
0073:        import org.apache.ws.scout.uddi.TModelList;
0074:        import org.apache.ws.scout.util.EnumerationHelper;
0075:        import org.apache.ws.scout.util.ScoutJaxrUddiHelper;
0076:        import org.apache.ws.scout.util.ScoutUddiJaxrHelper;
0077:
0078:        /**
0079:         * Implements the JAXR BusinessQueryManager Interface
0080:         * For futher details, look into the JAXR API Javadoc.
0081:         *
0082:         * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
0083:         * @author <a href="mailto:jboynes@apache.org">Jeremy Boynes</a>
0084:         * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
0085:         */
0086:        public class BusinessQueryManagerImpl implements  BusinessQueryManager {
0087:            private final RegistryServiceImpl registryService;
0088:
0089:            public BusinessQueryManagerImpl(RegistryServiceImpl registry) {
0090:                this .registryService = registry;
0091:            }
0092:
0093:            public RegistryService getRegistryService() {
0094:                return registryService;
0095:            }
0096:
0097:            /**
0098:             * Finds organizations in the registry that match the specified parameters
0099:             *
0100:             * @param findQualifiers
0101:             * @param namePatterns
0102:             * @param classifications
0103:             * @param specifications
0104:             * @param externalIdentifiers
0105:             * @param externalLinks
0106:             * @return
0107:             * @throws JAXRException
0108:             */
0109:            public BulkResponse findOrganizations(Collection findQualifiers,
0110:                    Collection namePatterns, Collection classifications,
0111:                    Collection specifications, Collection externalIdentifiers,
0112:                    Collection externalLinks) throws JAXRException {
0113:                IRegistry registry = registryService.getRegistry();
0114:                try {
0115:                    FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
0116:                    Name[] nameArray = mapNamePatterns(namePatterns);
0117:                    BusinessList result = registry
0118:                            .findBusiness(
0119:                                    nameArray,
0120:                                    null,
0121:                                    ScoutJaxrUddiHelper
0122:                                            .getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
0123:                                    ScoutJaxrUddiHelper
0124:                                            .getCategoryBagFromClassifications(classifications),
0125:                                    null, juddiFindQualifiers, registryService
0126:                                            .getMaxRows());
0127:                    BusinessInfo[] a = result.getBusinessInfos() != null ? result
0128:                            .getBusinessInfos().getBusinessInfoArray()
0129:                            : null;
0130:
0131:                    LinkedHashSet<Organization> orgs = null;
0132:                    int len = 0;
0133:                    if (a != null) {
0134:                        len = a.length;
0135:                        orgs = new LinkedHashSet<Organization>();
0136:                    }
0137:                    for (int i = 0; i < len; i++) {
0138:                        BusinessInfo info = a[i];
0139:                        //Now get the details on the individual biz
0140:                        BusinessDetail detail = registry.getBusinessDetail(info
0141:                                .getBusinessKey());
0142:
0143:                        orgs.add(registryService.getLifeCycleManagerImpl()
0144:                                .createOrganization(detail));
0145:                    }
0146:                    return new BulkResponseImpl(orgs);
0147:                } catch (RegistryException e) {
0148:                    throw new JAXRException(e);
0149:                }
0150:            }
0151:
0152:            public BulkResponse findAssociations(Collection findQualifiers,
0153:                    String sourceObjectId, String targetObjectId,
0154:                    Collection associationTypes) throws JAXRException {
0155:                //TODO: Currently we just return all the Association objects owned by the caller
0156:                IRegistry registry = registryService.getRegistry();
0157:                try {
0158:                    ConnectionImpl con = ((RegistryServiceImpl) getRegistryService())
0159:                            .getConnection();
0160:                    AuthToken auth = this .getAuthToken(con, registry);
0161:                    PublisherAssertions result = registry
0162:                            .getPublisherAssertions(auth.getAuthInfo());
0163:                    PublisherAssertion[] a = result
0164:                            .getPublisherAssertionArray();
0165:
0166:                    LinkedHashSet<Association> col = null;
0167:                    int len = 0;
0168:                    if (a != null) {
0169:                        len = a.length;
0170:                        col = new LinkedHashSet<Association>();
0171:                    }
0172:                    for (int i = 0; i < len; i++) {
0173:                        PublisherAssertion pas = a[i];
0174:                        String sourceKey = pas.getFromKey();
0175:                        String targetKey = pas.getToKey();
0176:                        Collection<Key> orgcol = new ArrayList<Key>();
0177:                        orgcol.add(new KeyImpl(sourceKey));
0178:                        orgcol.add(new KeyImpl(targetKey));
0179:                        BulkResponse bl = getRegistryObjects(orgcol,
0180:                                LifeCycleManager.ORGANIZATION);
0181:                        Association asso = ScoutUddiJaxrHelper.getAssociation(
0182:                                bl.getCollection(), registryService
0183:                                        .getBusinessLifeCycleManager());
0184:                        KeyedReference keyr = pas.getKeyedReference();
0185:                        Concept c = new ConceptImpl(getRegistryService()
0186:                                .getBusinessLifeCycleManager());
0187:                        c
0188:                                .setName(new InternationalStringImpl(keyr
0189:                                        .getKeyName()));
0190:                        c.setKey(new KeyImpl(keyr.getTModelKey()));
0191:                        c.setValue(keyr.getKeyValue());
0192:                        asso.setAssociationType(c);
0193:                        col.add(asso);
0194:                    }
0195:                    return new BulkResponseImpl(col);
0196:                } catch (RegistryException e) {
0197:                    throw new JAXRException(e);
0198:                }
0199:            }
0200:
0201:            public BulkResponse findCallerAssociations(
0202:                    Collection findQualifiers, Boolean confirmedByCaller,
0203:                    Boolean confirmedByOtherParty, Collection associationTypes)
0204:                    throws JAXRException {
0205:                //TODO: Currently we just return all the Association objects owned by the caller
0206:                IRegistry registry = registryService.getRegistry();
0207:                try {
0208:                    ConnectionImpl con = ((RegistryServiceImpl) getRegistryService())
0209:                            .getConnection();
0210:                    AuthToken auth = this .getAuthToken(con, registry);
0211:
0212:                    AssertionStatusReport report = null;
0213:                    String confirm = "";
0214:                    boolean caller = confirmedByCaller.booleanValue();
0215:                    boolean other = confirmedByOtherParty.booleanValue();
0216:
0217:                    if (caller && other)
0218:                        confirm = Constants.COMPLETION_STATUS_COMPLETE;
0219:                    else if (!caller && other)
0220:                        confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
0221:                    else if (caller && !other)
0222:                        confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;
0223:
0224:                    report = registry.getAssertionStatusReport(auth
0225:                            .getAuthInfo(), confirm);
0226:                    AssertionStatusItem[] a = report
0227:                            .getAssertionStatusItemArray();
0228:                    LinkedHashSet<Association> col = null;
0229:                    int len = 0;
0230:                    if (a != null) {
0231:                        len = a.length;
0232:                        col = new LinkedHashSet<Association>();
0233:                    }
0234:                    for (int i = 0; i < len; i++) {
0235:                        AssertionStatusItem asi = a[i];
0236:                        String sourceKey = asi.getFromKey();
0237:                        String targetKey = asi.getToKey();
0238:                        Collection<Key> orgcol = new ArrayList<Key>();
0239:                        orgcol.add(new KeyImpl(sourceKey));
0240:                        orgcol.add(new KeyImpl(targetKey));
0241:                        BulkResponse bl = getRegistryObjects(orgcol,
0242:                                LifeCycleManager.ORGANIZATION);
0243:                        Association asso = ScoutUddiJaxrHelper.getAssociation(
0244:                                bl.getCollection(), registryService
0245:                                        .getBusinessLifeCycleManager());
0246:                        //Set Confirmation
0247:                        ((AssociationImpl) asso)
0248:                                .setConfirmedBySourceOwner(caller);
0249:                        ((AssociationImpl) asso)
0250:                                .setConfirmedByTargetOwner(other);
0251:
0252:                        if (confirm != Constants.COMPLETION_STATUS_COMPLETE)
0253:                            ((AssociationImpl) asso).setConfirmed(false);
0254:
0255:                        Concept c = new ConceptImpl(getRegistryService()
0256:                                .getBusinessLifeCycleManager());
0257:                        KeyedReference keyr = asi.getKeyedReference();
0258:                        c.setKey(new KeyImpl(keyr.getTModelKey()));
0259:                        c
0260:                                .setName(new InternationalStringImpl(keyr
0261:                                        .getKeyName()));
0262:                        c.setValue(keyr.getKeyValue());
0263:                        asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
0264:                        asso.setAssociationType(c);
0265:                        col.add(asso);
0266:                    }
0267:
0268:                    return new BulkResponseImpl(col);
0269:                } catch (RegistryException e) {
0270:                    throw new JAXRException(e);
0271:                }
0272:            }
0273:
0274:            /**
0275:             *  TODO - need to support the qualifiers
0276:             *
0277:             * @param findQualifiers
0278:             * @param namePatterns
0279:             * @return
0280:             * @throws JAXRException
0281:             */
0282:            public ClassificationScheme findClassificationSchemeByName(
0283:                    Collection findQualifiers, String namePatterns)
0284:                    throws JAXRException {
0285:                ClassificationScheme scheme = null;
0286:
0287:                if (namePatterns.indexOf("uddi-org:types") != -1) {
0288:
0289:                    scheme = new ClassificationSchemeImpl(registryService
0290:                            .getLifeCycleManagerImpl());
0291:                    scheme.setName(new InternationalStringImpl(namePatterns));
0292:                    scheme
0293:                            .setKey(new KeyImpl(
0294:                                    Constants.TMODEL_TYPES_TMODEL_KEY));
0295:                } else if (namePatterns.indexOf("dnb-com:D-U-N-S") != -1) {
0296:
0297:                    scheme = new ClassificationSchemeImpl(registryService
0298:                            .getLifeCycleManagerImpl());
0299:                    scheme.setName(new InternationalStringImpl(namePatterns));
0300:                    scheme.setKey(new KeyImpl(
0301:                            Constants.TMODEL_D_U_N_S_TMODEL_KEY));
0302:                } else if (namePatterns.indexOf("uddi-org:iso-ch:3166:1999") != -1) {
0303:                    scheme = new ClassificationSchemeImpl(registryService
0304:                            .getLifeCycleManagerImpl());
0305:                    scheme.setName(new InternationalStringImpl(namePatterns));
0306:                    scheme.setKey(new KeyImpl(
0307:                            Constants.TMODEL_ISO_CH_TMODEL_KEY));
0308:                } else if (namePatterns.indexOf("uddi-org:iso-ch:3166-1999") != -1) {
0309:                    scheme = new ClassificationSchemeImpl(registryService
0310:                            .getLifeCycleManagerImpl());
0311:                    scheme.setName(new InternationalStringImpl(namePatterns));
0312:                    scheme.setKey(new KeyImpl(
0313:                            Constants.TMODEL_ISO_CH_TMODEL_KEY));
0314:                } else if (namePatterns.indexOf("iso-ch:3166:1999") != -1) {
0315:                    scheme = new ClassificationSchemeImpl(registryService
0316:                            .getLifeCycleManagerImpl());
0317:                    scheme.setName(new InternationalStringImpl(namePatterns));
0318:                    scheme.setKey(new KeyImpl(
0319:                            Constants.TMODEL_ISO_CH_TMODEL_KEY));
0320:                } else if (namePatterns.indexOf("iso-ch:3166-1999") != -1) {
0321:                    scheme = new ClassificationSchemeImpl(registryService
0322:                            .getLifeCycleManagerImpl());
0323:                    scheme.setName(new InternationalStringImpl(namePatterns));
0324:                    scheme.setKey(new KeyImpl(
0325:                            Constants.TMODEL_ISO_CH_TMODEL_KEY));
0326:                } else if (namePatterns.indexOf("unspsc-org:unspsc") != -1) {
0327:
0328:                    scheme = new ClassificationSchemeImpl(registryService
0329:                            .getLifeCycleManagerImpl());
0330:                    scheme.setName(new InternationalStringImpl(namePatterns));
0331:                    scheme.setKey(new KeyImpl(
0332:                            Constants.TMODEL_UNSPSC_TMODEL_KEY));
0333:                } else if (namePatterns.indexOf("ntis-gov:naics") != -1) {
0334:
0335:                    scheme = new ClassificationSchemeImpl(registryService
0336:                            .getLifeCycleManagerImpl());
0337:                    scheme.setName(new InternationalStringImpl(namePatterns));
0338:                    scheme
0339:                            .setKey(new KeyImpl(
0340:                                    Constants.TMODEL_NAICS_TMODEL_KEY));
0341:                } else { //TODO:Before going to the registry, check if it a predefined Enumeration
0342:
0343:                    /*
0344:                     * predefined Enumerations
0345:                     */
0346:
0347:                    if ("AssociationType".equals(namePatterns)) {
0348:                        scheme = new ClassificationSchemeImpl(registryService
0349:                                .getLifeCycleManagerImpl());
0350:
0351:                        scheme
0352:                                .setName(new InternationalStringImpl(
0353:                                        namePatterns));
0354:
0355:                        scheme.setKey(new KeyImpl(
0356:                                Constants.TMODEL_UNSPSC_TMODEL_KEY));
0357:
0358:                        addChildConcept((ClassificationSchemeImpl) scheme,
0359:                                "RelatedTo");
0360:                        addChildConcept((ClassificationSchemeImpl) scheme,
0361:                                "HasChild");
0362:                        addChildConcept((ClassificationSchemeImpl) scheme,
0363:                                "HasMember");
0364:                        addChildConcept((ClassificationSchemeImpl) scheme,
0365:                                "HasParent");
0366:                        addChildConcept((ClassificationSchemeImpl) scheme,
0367:                                "ExternallyLinks");
0368:                        addChildConcept((ClassificationSchemeImpl) scheme,
0369:                                "Contains");
0370:                        addChildConcept((ClassificationSchemeImpl) scheme,
0371:                                "EquivalentTo");
0372:                        addChildConcept((ClassificationSchemeImpl) scheme,
0373:                                "Extends");
0374:                        addChildConcept((ClassificationSchemeImpl) scheme,
0375:                                "Implements");
0376:                        addChildConcept((ClassificationSchemeImpl) scheme,
0377:                                "InstanceOf");
0378:                        addChildConcept((ClassificationSchemeImpl) scheme,
0379:                                "Supersedes");
0380:                        addChildConcept((ClassificationSchemeImpl) scheme,
0381:                                "Uses");
0382:                        addChildConcept((ClassificationSchemeImpl) scheme,
0383:                                "Replaces");
0384:                        addChildConcept((ClassificationSchemeImpl) scheme,
0385:                                "ResponsibleFor");
0386:                        addChildConcept((ClassificationSchemeImpl) scheme,
0387:                                "SubmitterOf");
0388:                    } else if ("ObjectType".equals(namePatterns)) {
0389:                        scheme = new ClassificationSchemeImpl(registryService
0390:                                .getLifeCycleManagerImpl());
0391:
0392:                        scheme
0393:                                .setName(new InternationalStringImpl(
0394:                                        namePatterns));
0395:
0396:                        scheme.setKey(new KeyImpl(
0397:                                Constants.TMODEL_UNSPSC_TMODEL_KEY));
0398:
0399:                        addChildConcept((ClassificationSchemeImpl) scheme,
0400:                                "CPP");
0401:                        addChildConcept((ClassificationSchemeImpl) scheme,
0402:                                "CPA");
0403:                        addChildConcept((ClassificationSchemeImpl) scheme,
0404:                                "Process");
0405:                        addChildConcept((ClassificationSchemeImpl) scheme,
0406:                                "WSDL");
0407:                        addChildConcept((ClassificationSchemeImpl) scheme,
0408:                                "Association");
0409:                        addChildConcept((ClassificationSchemeImpl) scheme,
0410:                                "AuditableEvent");
0411:                        addChildConcept((ClassificationSchemeImpl) scheme,
0412:                                "Classification");
0413:                        addChildConcept((ClassificationSchemeImpl) scheme,
0414:                                "Concept");
0415:                        addChildConcept((ClassificationSchemeImpl) scheme,
0416:                                "ExternalIdentifier");
0417:                        addChildConcept((ClassificationSchemeImpl) scheme,
0418:                                "ExternalLink");
0419:                        addChildConcept((ClassificationSchemeImpl) scheme,
0420:                                "ExtrinsicObject");
0421:                        addChildConcept((ClassificationSchemeImpl) scheme,
0422:                                "Organization");
0423:                        addChildConcept((ClassificationSchemeImpl) scheme,
0424:                                "Package");
0425:                        addChildConcept((ClassificationSchemeImpl) scheme,
0426:                                "Service");
0427:                        addChildConcept((ClassificationSchemeImpl) scheme,
0428:                                "ServiceBinding");
0429:                        addChildConcept((ClassificationSchemeImpl) scheme,
0430:                                "User");
0431:                    } else if ("PhoneType".equals(namePatterns)) {
0432:                        scheme = new ClassificationSchemeImpl(registryService
0433:                                .getLifeCycleManagerImpl());
0434:
0435:                        scheme
0436:                                .setName(new InternationalStringImpl(
0437:                                        namePatterns));
0438:
0439:                        scheme.setKey(new KeyImpl(
0440:                                Constants.TMODEL_UNSPSC_TMODEL_KEY));
0441:
0442:                        addChildConcept((ClassificationSchemeImpl) scheme,
0443:                                "OfficePhone");
0444:                        addChildConcept((ClassificationSchemeImpl) scheme,
0445:                                "HomePhone");
0446:                        addChildConcept((ClassificationSchemeImpl) scheme,
0447:                                "MobilePhone");
0448:                        addChildConcept((ClassificationSchemeImpl) scheme,
0449:                                "Beeper");
0450:                        addChildConcept((ClassificationSchemeImpl) scheme,
0451:                                "FAX");
0452:                    } else if ("URLType".equals(namePatterns)) {
0453:                        scheme = new ClassificationSchemeImpl(registryService
0454:                                .getLifeCycleManagerImpl());
0455:
0456:                        scheme
0457:                                .setName(new InternationalStringImpl(
0458:                                        namePatterns));
0459:
0460:                        scheme.setKey(new KeyImpl(
0461:                                Constants.TMODEL_UNSPSC_TMODEL_KEY));
0462:
0463:                        addChildConcept((ClassificationSchemeImpl) scheme,
0464:                                "HTTP");
0465:                        addChildConcept((ClassificationSchemeImpl) scheme,
0466:                                "HTTPS");
0467:                        addChildConcept((ClassificationSchemeImpl) scheme,
0468:                                "SMTP");
0469:                        addChildConcept((ClassificationSchemeImpl) scheme,
0470:                                "PHONE");
0471:                        addChildConcept((ClassificationSchemeImpl) scheme,
0472:                                "FAX");
0473:                        addChildConcept((ClassificationSchemeImpl) scheme,
0474:                                "OTHER");
0475:                    } else if ("PostalAddressAttributes".equals(namePatterns)) {
0476:                        scheme = new ClassificationSchemeImpl(registryService
0477:                                .getLifeCycleManagerImpl());
0478:
0479:                        scheme
0480:                                .setName(new InternationalStringImpl(
0481:                                        namePatterns));
0482:
0483:                        scheme.setKey(new KeyImpl(
0484:                                Constants.TMODEL_UNSPSC_TMODEL_KEY));
0485:
0486:                        addChildConcept((ClassificationSchemeImpl) scheme,
0487:                                "StreetNumber");
0488:                        addChildConcept((ClassificationSchemeImpl) scheme,
0489:                                "Street");
0490:                        addChildConcept((ClassificationSchemeImpl) scheme,
0491:                                "City");
0492:                        addChildConcept((ClassificationSchemeImpl) scheme,
0493:                                "State");
0494:                        addChildConcept((ClassificationSchemeImpl) scheme,
0495:                                "PostalCode");
0496:                        addChildConcept((ClassificationSchemeImpl) scheme,
0497:                                "Country");
0498:                    } else {
0499:
0500:                        //Lets ask the uddi registry if it has the TModels
0501:                        IRegistry registry = registryService.getRegistry();
0502:                        FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
0503:                        try {
0504:                            //We are looking for one exact match, so getting upto 3 records is fine
0505:                            TModelList list = registry.findTModel(namePatterns,
0506:                                    null, null, juddiFindQualifiers, 3);
0507:                            TModelInfos infos = null;
0508:                            TModelInfo[] tmarr = null;
0509:                            if (list != null)
0510:                                infos = list.getTModelInfos();
0511:                            if (infos != null)
0512:                                tmarr = infos.getTModelInfoArray();
0513:                            if (tmarr != null && tmarr.length > 0) {
0514:                                if (tmarr.length > 1)
0515:                                    throw new InvalidRequestException(
0516:                                            "Multiple matches found");
0517:
0518:                                TModelInfo info = tmarr[0];
0519:                                scheme = new ClassificationSchemeImpl(
0520:                                        registryService
0521:                                                .getLifeCycleManagerImpl());
0522:                                scheme.setName(new InternationalStringImpl(info
0523:                                        .getName().getStringValue()));
0524:                                scheme.setKey(new KeyImpl(info.getTModelKey()));
0525:                            }
0526:
0527:                        } catch (RegistryException e) {
0528:                            e.printStackTrace();
0529:                            throw new JAXRException(e.getLocalizedMessage());
0530:                        }
0531:                    }
0532:                }
0533:                return scheme;
0534:            }
0535:
0536:            /**
0537:             * Creates a new Concept, associates w/ parent scheme, and then
0538:             * adds as decendent.
0539:             * @param scheme
0540:             * @param name
0541:             * @throws JAXRException
0542:             */
0543:            private void addChildConcept(ClassificationSchemeImpl scheme,
0544:                    String name) throws JAXRException {
0545:                Concept c = new ConceptImpl(registryService
0546:                        .getLifeCycleManagerImpl());
0547:
0548:                c.setName(new InternationalStringImpl(name));
0549:                c.setValue(name);
0550:                ((ConceptImpl) c).setScheme((ClassificationSchemeImpl) scheme);
0551:
0552:                scheme.addChildConcept(c);
0553:            }
0554:
0555:            public BulkResponse findClassificationSchemes(
0556:                    Collection findQualifiers, Collection namePatterns,
0557:                    Collection classifications, Collection externalLinks)
0558:                    throws JAXRException {
0559:                //TODO: Handle this better
0560:                LinkedHashSet<ClassificationScheme> col = new LinkedHashSet<ClassificationScheme>();
0561:                Iterator iter = namePatterns.iterator();
0562:                String name = "";
0563:                while (iter.hasNext()) {
0564:                    name = (String) iter.next();
0565:                    break;
0566:                }
0567:
0568:                ClassificationScheme classificationScheme = findClassificationSchemeByName(
0569:                        findQualifiers, name);
0570:                if (classificationScheme != null) {
0571:                    col.add(classificationScheme);
0572:                }
0573:                return new BulkResponseImpl(col);
0574:            }
0575:
0576:            public Concept findConceptByPath(String path) throws JAXRException {
0577:                //We will store the enumerations datastructure in the util package
0578:                /**
0579:                 * I am not clear about how this association type enumerations
0580:                 * are to be implemented.
0581:                 */
0582:                return EnumerationHelper.getConceptByPath(path);
0583:            }
0584:
0585:            public BulkResponse findConcepts(Collection findQualifiers,
0586:                    Collection namePatterns, Collection classifications,
0587:                    Collection externalIdentifiers, Collection externalLinks)
0588:                    throws JAXRException {
0589:                LinkedHashSet<Concept> col = new LinkedHashSet<Concept>();
0590:
0591:                //Lets ask the uddi registry if it has the TModels
0592:                IRegistry registry = registryService.getRegistry();
0593:                FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
0594:                Iterator iter = null;
0595:                if (namePatterns != null)
0596:                    iter = namePatterns.iterator();
0597:                while (iter.hasNext()) {
0598:                    String namestr = (String) iter.next();
0599:                    try {
0600:                        TModelList list = registry
0601:                                .findTModel(
0602:                                        namestr,
0603:                                        ScoutJaxrUddiHelper
0604:                                                .getCategoryBagFromClassifications(classifications),
0605:                                        ScoutJaxrUddiHelper
0606:                                                .getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
0607:                                        juddiFindQualifiers, 10);
0608:                        TModelInfos infos = null;
0609:                        TModelInfo[] tmarr = null;
0610:                        if (list != null)
0611:                            infos = list.getTModelInfos();
0612:                        if (infos != null)
0613:                            tmarr = infos.getTModelInfoArray();
0614:                        for (int i = 0; tmarr != null && i < tmarr.length; i++) {
0615:                            TModelInfo info = tmarr[i];
0616:                            col.add(ScoutUddiJaxrHelper.getConcept(info,
0617:                                    this .registryService
0618:                                            .getBusinessLifeCycleManager()));
0619:                        }
0620:
0621:                    } catch (RegistryException e) {
0622:                        e.printStackTrace();
0623:                        throw new JAXRException(e.getLocalizedMessage());
0624:                    }
0625:                }
0626:
0627:                return new BulkResponseImpl(col);
0628:            }
0629:
0630:            public BulkResponse findRegistryPackages(Collection findQualifiers,
0631:                    Collection namePatterns, Collection classifications,
0632:                    Collection externalLinks) throws JAXRException {
0633:                throw new UnsupportedCapabilityException();
0634:            }
0635:
0636:            public BulkResponse findServiceBindings(Key serviceKey,
0637:                    Collection findQualifiers, Collection classifications,
0638:                    Collection specifications) throws JAXRException {
0639:                BulkResponseImpl blkRes = new BulkResponseImpl();
0640:
0641:                IRegistry iRegistry = registryService.getRegistry();
0642:                FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
0643:
0644:                try {
0645:
0646:                    BindingDetail l = iRegistry
0647:                            .findBinding(
0648:                                    serviceKey.getId(),
0649:                                    ScoutJaxrUddiHelper
0650:                                            .getCategoryBagFromClassifications(classifications),
0651:                                    null, juddiFindQualifiers, registryService
0652:                                            .getMaxRows());
0653:
0654:                    /*
0655:                     * now convert  from jUDDI ServiceInfo objects to JAXR Services
0656:                     */
0657:                    if (l != null) {
0658:
0659:                        BindingTemplate[] bindarr = l.getBindingTemplateArray();
0660:                        LinkedHashSet<ServiceBinding> col = new LinkedHashSet<ServiceBinding>();
0661:
0662:                        for (int i = 0; bindarr != null && i < bindarr.length; i++) {
0663:                            BindingTemplate si = bindarr[i];
0664:                            ServiceBinding sb = ScoutUddiJaxrHelper
0665:                                    .getServiceBinding(si, registryService
0666:                                            .getBusinessLifeCycleManager());
0667:                            col.add(sb);
0668:                            //Fill the Service object by making a call to registry
0669:                            Service s = (Service) getRegistryObject(serviceKey
0670:                                    .getId(), LifeCycleManager.SERVICE);
0671:                            ((ServiceBindingImpl) sb).setService(s);
0672:                        }
0673:
0674:                        blkRes.setCollection(col);
0675:                    }
0676:                } catch (RegistryException e) {
0677:                    e.printStackTrace();
0678:                    throw new JAXRException(e.getLocalizedMessage());
0679:                }
0680:
0681:                return blkRes;
0682:            }
0683:
0684:            /**
0685:             * Finds all Service objects that match all of the criteria specified by
0686:             * the parameters of this call.  This is a logical AND operation between
0687:             * all non-null parameters
0688:             *
0689:             * TODO - support findQualifiers, classifications and specifications
0690:             *
0691:             * @param orgKey
0692:             * @param findQualifiers
0693:             * @param namePatterns
0694:             * @param classifications
0695:             * @param specificationa
0696:             * @return
0697:             * @throws JAXRException
0698:             */
0699:            public BulkResponse findServices(Key orgKey,
0700:                    Collection findQualifiers, Collection namePatterns,
0701:                    Collection classifications, Collection specificationa)
0702:                    throws JAXRException {
0703:                BulkResponseImpl blkRes = new BulkResponseImpl();
0704:
0705:                IRegistry iRegistry = registryService.getRegistry();
0706:                FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
0707:                Name[] juddiNames = mapNamePatterns(namePatterns);
0708:
0709:                try {
0710:                    /*
0711:                     * hit the registry.  The key is not required for UDDI2
0712:                     */
0713:
0714:                    String id = null;
0715:
0716:                    if (orgKey != null) {
0717:                        id = orgKey.getId();
0718:                    }
0719:
0720:                    ServiceList l = iRegistry
0721:                            .findService(
0722:                                    id,
0723:                                    juddiNames,
0724:                                    ScoutJaxrUddiHelper
0725:                                            .getCategoryBagFromClassifications(classifications),
0726:                                    null, juddiFindQualifiers, registryService
0727:                                            .getMaxRows());
0728:
0729:                    /*
0730:                     * now convert  from jUDDI ServiceInfo objects to JAXR Services
0731:                     */
0732:                    if (l != null) {
0733:
0734:                        ServiceInfos serviceInfos = l.getServiceInfos();
0735:
0736:                        ServiceInfo[] a = (serviceInfos != null ? serviceInfos
0737:                                .getServiceInfoArray() : null);
0738:
0739:                        LinkedHashSet<Service> col = new LinkedHashSet<Service>();
0740:
0741:                        for (int i = 0; a != null && i < a.length; i++) {
0742:                            ServiceInfo si = (ServiceInfo) a[i];
0743:                            Service srv = (Service) getRegistryObject(si
0744:                                    .getServiceKey(), LifeCycleManager.SERVICE);
0745:                            col.add(srv);
0746:                        }
0747:
0748:                        blkRes.setCollection(col);
0749:                    }
0750:                } catch (RegistryException e) {
0751:                    e.printStackTrace();
0752:                    throw new JAXRException(e.getLocalizedMessage());
0753:                }
0754:
0755:                return blkRes;
0756:            }
0757:
0758:            public RegistryObject getRegistryObject(String id)
0759:                    throws JAXRException {
0760:                throw new UnsupportedCapabilityException();
0761:            }
0762:
0763:            public RegistryObject getRegistryObject(String id, String objectType)
0764:                    throws JAXRException {
0765:                IRegistry registry = registryService.getRegistry();
0766:                BusinessLifeCycleManager lcm = registryService
0767:                        .getBusinessLifeCycleManager();
0768:
0769:                if (LifeCycleManager.CLASSIFICATION_SCHEME
0770:                        .equalsIgnoreCase(objectType)) {
0771:
0772:                    try {
0773:
0774:                        TModelDetail tmodeldetail = registry
0775:                                .getTModelDetail(id);
0776:                        Concept c = ScoutUddiJaxrHelper.getConcept(
0777:                                tmodeldetail, lcm);
0778:
0779:                        /*
0780:                         * now turn into a concrete ClassificationScheme
0781:                         */
0782:
0783:                        ClassificationScheme scheme = new ClassificationSchemeImpl(
0784:                                lcm);
0785:
0786:                        scheme.setName(c.getName());
0787:                        scheme.setDescription(c.getDescription());
0788:                        scheme.setKey(c.getKey());
0789:
0790:                        return scheme;
0791:                    } catch (RegistryException e) {
0792:                        e.printStackTrace();
0793:                        throw new JAXRException(e.getLocalizedMessage());
0794:                    }
0795:                } else if (LifeCycleManager.ORGANIZATION
0796:                        .equalsIgnoreCase(objectType)) {
0797:
0798:                    try {
0799:                        BusinessDetail orgdetail = registry
0800:                                .getBusinessDetail(id);
0801:                        return ScoutUddiJaxrHelper.getOrganization(orgdetail,
0802:                                lcm);
0803:                    } catch (RegistryException e) {
0804:                        e.printStackTrace();
0805:                        throw new JAXRException(e.getLocalizedMessage());
0806:                    }
0807:                } else if (LifeCycleManager.CONCEPT
0808:                        .equalsIgnoreCase(objectType)) {
0809:
0810:                    try {
0811:                        TModelDetail tmodeldetail = registry
0812:                                .getTModelDetail(id);
0813:                        return ScoutUddiJaxrHelper
0814:                                .getConcept(tmodeldetail, lcm);
0815:                    } catch (RegistryException e) {
0816:                        e.printStackTrace();
0817:                        throw new JAXRException(e.getLocalizedMessage());
0818:                    }
0819:                } else if (LifeCycleManager.SERVICE
0820:                        .equalsIgnoreCase(objectType)) {
0821:
0822:                    try {
0823:
0824:                        ServiceDetail sd = registry.getServiceDetail(id);
0825:
0826:                        if (sd != null) {
0827:
0828:                            BusinessService[] a = sd.getBusinessServiceArray();
0829:
0830:                            if (a != null && a.length != 0) {
0831:                                Service service = getServiceFromBusinessService(
0832:                                        a[0], lcm);
0833:
0834:                                return service;
0835:                            }
0836:                        }
0837:                    } catch (RegistryException e) {
0838:                        e.printStackTrace();
0839:                    }
0840:                }
0841:
0842:                return null;
0843:            }
0844:
0845:            /**
0846:             *  Helper routine to take a jUDDI business service and turn into a useful
0847:             *  Service.  Needs to go back to the registry to get the organization to
0848:             *  properly hydrate the Service
0849:             *
0850:             * @param bs  BusinessService object to turn in to a Service
0851:             * @param lcm manager to use
0852:             * @return new Service object
0853:             * @throws JAXRException
0854:             */
0855:            protected Service getServiceFromBusinessService(BusinessService bs,
0856:                    LifeCycleManager lcm) throws JAXRException {
0857:
0858:                Service service = ScoutUddiJaxrHelper.getService(bs, lcm);
0859:
0860:                /*
0861:                 * now get the Organization if we can
0862:                 */
0863:
0864:                String busKey = bs.getBusinessKey();
0865:
0866:                if (busKey != null) {
0867:                    Organization o = (Organization) getRegistryObject(busKey,
0868:                            LifeCycleManager.ORGANIZATION);
0869:                    service.setProvidingOrganization(o);
0870:                }
0871:
0872:                return service;
0873:            }
0874:
0875:            /**
0876:             * Gets the RegistryObjects owned by the caller. The objects
0877:             * are returned as their concrete type (e.g. Organization, User etc.)
0878:             *
0879:             *  TODO - need to figure out what the set are.  This is just to get some
0880:             *  basic functionality
0881:             *
0882:             * @return
0883:             * @throws JAXRException
0884:             */
0885:            public BulkResponse getRegistryObjects() throws JAXRException {
0886:                String types[] = { LifeCycleManager.ORGANIZATION,
0887:                        LifeCycleManager.SERVICE };
0888:
0889:                LinkedHashSet<Object> c = new LinkedHashSet<Object>();
0890:
0891:                for (int i = 0; i < types.length; i++) {
0892:                    try {
0893:                        BulkResponse bk = getRegistryObjects(types[i]);
0894:
0895:                        if (bk.getCollection() != null) {
0896:                            c.addAll(bk.getCollection());
0897:                        }
0898:                    } catch (JAXRException e) {
0899:                        // ignore - just a problem with that type?
0900:                    }
0901:                }
0902:
0903:                return new BulkResponseImpl(c);
0904:            }
0905:
0906:            public BulkResponse getRegistryObjects(Collection<Key> objectKeys)
0907:                    throws JAXRException {
0908:                throw new UnsupportedCapabilityException();
0909:            }
0910:
0911:            public BulkResponse getRegistryObjects(Collection<Key> objectKeys,
0912:                    String objectType) throws JAXRException {
0913:                IRegistry registry = registryService.getRegistry();
0914:                //Convert into a vector of strings
0915:                String[] keys = new String[objectKeys.size()];
0916:                int currLoc = 0;
0917:                Iterator iter = objectKeys.iterator();
0918:                while (iter.hasNext()) {
0919:                    Key key = (Key) iter.next();
0920:                    keys[currLoc] = key.getId();
0921:                    currLoc++;
0922:                }
0923:                LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
0924:                LifeCycleManager lcm = registryService
0925:                        .getLifeCycleManagerImpl();
0926:
0927:                if (LifeCycleManager.CLASSIFICATION_SCHEME
0928:                        .equalsIgnoreCase(objectType)) {
0929:                    try {
0930:                        TModelDetail tmodeldetail = registry
0931:                                .getTModelDetail(keys);
0932:                        TModel[] tmarray = tmodeldetail.getTModelArray();
0933:                        for (int i = 0; tmarray != null && i < tmarray.length; i++) {
0934:                            col.add(ScoutUddiJaxrHelper.getConcept(tmarray[i],
0935:                                    lcm));
0936:                        }
0937:
0938:                    } catch (RegistryException e) {
0939:                        e.printStackTrace();
0940:                        throw new JAXRException(e.getLocalizedMessage());
0941:                    }
0942:                } else if (LifeCycleManager.ORGANIZATION
0943:                        .equalsIgnoreCase(objectType)) {
0944:                    //Get the Organization from the uddi registry
0945:                    try {
0946:                        BusinessDetail orgdetail = registry
0947:                                .getBusinessDetail(keys);
0948:                        BusinessEntity[] bizarr = orgdetail
0949:                                .getBusinessEntityArray();
0950:                        for (int i = 0; bizarr != null && i < bizarr.length; i++) {
0951:                            col.add(ScoutUddiJaxrHelper.getOrganization(
0952:                                    bizarr[i], lcm));
0953:                        }
0954:                    } catch (RegistryException e) {
0955:                        throw new JAXRException(e.getLocalizedMessage());
0956:                    }
0957:                } else if (LifeCycleManager.CONCEPT
0958:                        .equalsIgnoreCase(objectType)) {
0959:                    try {
0960:                        TModelDetail tmodeldetail = registry
0961:                                .getTModelDetail(keys);
0962:                        TModel[] tmarr = tmodeldetail.getTModelArray();
0963:                        for (int i = 0; tmarr != null && i < tmarr.length; i++) {
0964:                            col.add(ScoutUddiJaxrHelper.getConcept(tmarr[i],
0965:                                    lcm));
0966:                        }
0967:
0968:                    } catch (RegistryException e) {
0969:                        e.printStackTrace();
0970:                        throw new JAXRException(e.getLocalizedMessage());
0971:                    }
0972:                } else if (LifeCycleManager.SERVICE
0973:                        .equalsIgnoreCase(objectType)) {
0974:
0975:                    try {
0976:                        ServiceDetail serviceDetail = registry
0977:                                .getServiceDetail(keys);
0978:
0979:                        if (serviceDetail != null) {
0980:
0981:                            BusinessService[] a = serviceDetail
0982:                                    .getBusinessServiceArray();
0983:
0984:                            for (int i = 0; a != null && i < a.length; i++) {
0985:
0986:                                Service service = getServiceFromBusinessService(
0987:                                        a[i], lcm);
0988:
0989:                                col.add(service);
0990:                            }
0991:                        }
0992:                    } catch (RegistryException e) {
0993:                        throw new JAXRException(e);
0994:                    }
0995:                } else {
0996:                    throw new JAXRException("Unsupported type " + objectType
0997:                            + " for getRegistryObjects() in Apache Scout");
0998:                }
0999:
1000:                return new BulkResponseImpl(col);
1001:
1002:            }
1003:
1004:            public BulkResponse getRegistryObjects(String id)
1005:                    throws JAXRException {
1006:                if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) {
1007:                    List<String> a = new ArrayList<String>();
1008:                    a.add("%");
1009:
1010:                    BulkResponse br = findOrganizations(null, a, null, null,
1011:                            null, null);
1012:
1013:                    return br;
1014:                } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(id)) {
1015:                    List<String> a = new ArrayList<String>();
1016:                    a.add("%");
1017:
1018:                    BulkResponse br = this .findServices(null, null, a, null,
1019:                            null);
1020:
1021:                    return br;
1022:                } else {
1023:                    throw new JAXRException(
1024:                            "Unsupported type for getRegistryObjects() :" + id);
1025:                }
1026:
1027:            }
1028:
1029:            static FindQualifiers mapFindQualifiers(Collection jaxrQualifiers)
1030:                    throws UnsupportedCapabilityException {
1031:                if (jaxrQualifiers == null) {
1032:                    return null;
1033:                }
1034:                FindQualifiers result = FindQualifiers.Factory.newInstance();
1035:                for (Iterator i = jaxrQualifiers.iterator(); i.hasNext();) {
1036:                    String jaxrQualifier = (String) i.next();
1037:                    String juddiQualifier = jaxrQualifier;
1038:                    if (juddiQualifier == null) {
1039:                        throw new UnsupportedCapabilityException(
1040:                                "jUDDI does not support FindQualifer: "
1041:                                        + jaxrQualifier);
1042:                    }
1043:                    result.addFindQualifier(juddiQualifier);
1044:                }
1045:                return result;
1046:            }
1047:
1048:            static Name[] mapNamePatterns(Collection namePatterns)
1049:                    throws JAXRException {
1050:                if (namePatterns == null)
1051:                    return null;
1052:                Name[] result = new Name[namePatterns.size()];
1053:                int currLoc = 0;
1054:                for (Iterator i = namePatterns.iterator(); i.hasNext();) {
1055:                    Object obj = i.next();
1056:                    Name n = Name.Factory.newInstance();
1057:                    if (obj instanceof  String) {
1058:                        n.setStringValue((String) obj);
1059:                    } else if (obj instanceof  LocalizedString) {
1060:                        LocalizedString ls = (LocalizedString) obj;
1061:                        n.setStringValue(ls.getValue());
1062:                        n.setLang(ls.getLocale().getLanguage());
1063:                    }
1064:                    result[currLoc] = n;
1065:                    currLoc++;
1066:                }
1067:                return result;
1068:            }
1069:
1070:            /**
1071:             * Get the Auth Token from the registry
1072:             *
1073:             * @param connection
1074:             * @param ireg
1075:             * @return auth token
1076:             * @throws JAXRException
1077:             */
1078:            private AuthToken getAuthToken(ConnectionImpl connection,
1079:                    IRegistry ireg) throws JAXRException {
1080:                Set creds = connection.getCredentials();
1081:                Iterator it = creds.iterator();
1082:                String username = "", pwd = "";
1083:                while (it.hasNext()) {
1084:                    PasswordAuthentication pass = (PasswordAuthentication) it
1085:                            .next();
1086:                    username = pass.getUserName();
1087:                    pwd = new String(pass.getPassword());
1088:                }
1089:                AuthToken token = null;
1090:                try {
1091:                    token = ireg.getAuthToken(username, pwd);
1092:                } catch (Exception e) {
1093:                    throw new JAXRException(e);
1094:                }
1095:                return token;
1096:            }
1097:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.