View Javadoc
1   /*
2    * Copyright 2001-2008 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  
18  package org.apache.juddi.api.impl;
19  
20  import java.io.File;
21  import java.io.FileOutputStream;
22  import java.util.List;
23  import java.util.logging.Level;
24  import java.util.logging.Logger;
25  import javax.jws.WebService;
26  import javax.persistence.EntityManager;
27  import javax.persistence.EntityTransaction;
28  import javax.xml.bind.JAXB;
29  import org.apache.commons.configuration.ConfigurationException;
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  import org.apache.juddi.api.util.InquiryQuery;
33  import org.apache.juddi.api.util.QueryStatus;
34  import org.apache.juddi.config.AppConfig;
35  import org.apache.juddi.config.PersistenceManager;
36  import org.apache.juddi.config.Property;
37  import org.apache.juddi.mapping.MappingModelToApi;
38  import org.apache.juddi.v3.error.ErrorMessage;
39  import org.apache.juddi.v3.error.InvalidKeyPassedException;
40  import org.apache.juddi.validation.ValidateInquiry;
41  import org.uddi.api_v3.BindingDetail;
42  import org.uddi.api_v3.BusinessDetail;
43  import org.uddi.api_v3.BusinessList;
44  import org.uddi.api_v3.FindBinding;
45  import org.uddi.api_v3.FindBusiness;
46  import org.uddi.api_v3.FindRelatedBusinesses;
47  import org.uddi.api_v3.FindService;
48  import org.uddi.api_v3.FindTModel;
49  import org.uddi.api_v3.GetBindingDetail;
50  import org.uddi.api_v3.GetBusinessDetail;
51  import org.uddi.api_v3.GetOperationalInfo;
52  import org.uddi.api_v3.GetServiceDetail;
53  import org.uddi.api_v3.GetTModelDetail;
54  import org.uddi.api_v3.OperationalInfos;
55  import org.uddi.api_v3.RelatedBusinessesList;
56  import org.uddi.api_v3.ServiceDetail;
57  import org.uddi.api_v3.ServiceList;
58  import org.uddi.api_v3.TModelDetail;
59  import org.uddi.api_v3.TModelList;
60  import org.uddi.v3_service.DispositionReportFaultMessage;
61  import org.uddi.v3_service.UDDIInquiryPortType;
62  
63  
64  /**
65   * This implements the UDDI v3 Inquiry API web service
66   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
67   */
68  @WebService(serviceName="UDDIInquiryService",   
69  			endpointInterface="org.uddi.v3_service.UDDIInquiryPortType",
70  			targetNamespace = "urn:uddi-org:api_v3_portType")
71  public class UDDIInquiryImpl extends AuthenticatedService implements UDDIInquiryPortType {
72  
73  
74      private static Log log = LogFactory.getLog(UDDIInquiryImpl.class);
75  
76          private static boolean isLogRequestPayloads() {
77                  boolean result = false;
78  		try {
79  			result = AppConfig.getConfiguration().getBoolean(Property.JUDDI_LOGGING_FindApiCalls, false);
80  		} catch (ConfigurationException e) {
81  			log.error("Configuration exception occurred retrieving: " + Property.JUDDI_LOGGING_FindApiCalls, e);
82  		}
83  		return result;
84          }
85      private UDDIServiceCounter serviceCounter;
86          
87      public UDDIInquiryImpl() {
88          super();
89          serviceCounter = ServiceCounterLifecycleResource.getServiceCounter(UDDIInquiryImpl.class);
90      }
91      
92      
93      private static void LogFindRelatedBusinessRequest(FindRelatedBusinesses request) {
94                   request.setAuthInfo(null);
95                   LogRequest(request);
96          }
97          private static void LogFindBindingRequest(FindBinding request) {
98                   request.setAuthInfo(null);
99                   LogRequest(request);
100         }
101         private static void LogFindTModelRequest(FindTModel request) {
102                  request.setAuthInfo(null);
103                  LogRequest(request);
104         }
105         private static void LogFindServiceRequest(FindService request) {
106                  request.setAuthInfo(null);
107                  LogRequest(request);
108         }
109         private static void LogFindBusinessRequest(FindBusiness request) {
110                  request.setAuthInfo(null);
111                  LogRequest(request);
112         }
113 	 private static synchronized void LogRequest(Object request) {
114                  if (isLogRequestPayloads())
115                   try {
116                         File f = new File(System.currentTimeMillis()+".xml");
117                         FileOutputStream fos = new FileOutputStream(f);
118                         JAXB.marshal(request, fos);
119                         fos.close();
120                         f = null;
121                 } catch (Exception ex) {
122                         logger.warn("Unable to log request payload", ex);
123                 }
124          }
125          
126          
127     public BindingDetail findBinding(FindBinding body)
128 			throws DispositionReportFaultMessage {
129                 long startTime = System.currentTimeMillis();
130                 try {
131                     new ValidateInquiry(null).validateFindBinding(body);
132                 } catch (DispositionReportFaultMessage drfm) {
133                     long procTime = System.currentTimeMillis() - startTime;
134                     serviceCounter.update(InquiryQuery.FIND_BINDING, QueryStatus.FAILED, procTime);                      
135                     throw drfm;
136                 }
137                 
138 		EntityManager em = PersistenceManager.getEntityManager();
139 		EntityTransaction tx = em.getTransaction();
140 		try {
141 			tx.begin();
142 
143 			if (isAuthenticated())
144 				this.getEntityPublisher(em, body.getAuthInfo());
145 
146                         LogFindBindingRequest(body);
147                         if (body.getServiceKey() != null && body.getServiceKey().length() > 0) {
148                             // Check that we were passed a valid serviceKey per
149                             // 5.1.12.4 of the UDDI v3 spec
150                             String serviceKey = body.getServiceKey();
151                             org.apache.juddi.model.BusinessService modelBusinessService = null;
152                             try {
153                                     modelBusinessService=em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
154                             } catch (Exception e) {
155                                     log.debug(e.getMessage(), e);
156                             }
157                             if (modelBusinessService == null)
158                                 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));
159                         }
160 
161 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
162 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
163 
164 			List<?> keysFound = InquiryHelper.findBinding(body, findQualifiers, em);
165 
166 			BindingDetail result = InquiryHelper.getBindingDetailFromKeys(body, findQualifiers, em, keysFound);
167 			tx.rollback();
168                         long procTime = System.currentTimeMillis() - startTime;
169                         serviceCounter.update(InquiryQuery.FIND_BINDING, QueryStatus.SUCCESS, procTime);                      
170 
171 			return result;
172 		} finally {
173 			if (tx.isActive()) {
174 				tx.rollback();
175 			}
176 			em.close();
177 		}
178 	}
179 
180 	
181     public BusinessList findBusiness(FindBusiness body)
182 			throws DispositionReportFaultMessage {
183                 long startTime = System.currentTimeMillis();
184                 try {
185                     new ValidateInquiry(null).validateFindBusiness(body);
186                 } catch (DispositionReportFaultMessage drfm) {
187                     long procTime = System.currentTimeMillis() - startTime;
188                     serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.FAILED, procTime);                      
189                     throw drfm;
190                 }
191 
192 		EntityManager em = PersistenceManager.getEntityManager();
193 		EntityTransaction tx = em.getTransaction();
194 		try {
195                         try {
196                                 //AppConfig.reloadConfig();
197                                 logger.info("FindBusiness with tModel bag filtering is enabled: " +
198                                         AppConfig.getConfiguration().getBoolean(Property.JUDDI_ENABLE_FIND_BUSINESS_TMODEL_BAG_FILTERING,true)
199                                 + " loaded from " + AppConfig.getConfigFileURL());
200                         } catch (ConfigurationException ex) {
201                                 ex.printStackTrace();
202                         }
203 			tx.begin();
204 
205 			if (isAuthenticated())
206 				this.getEntityPublisher(em, body.getAuthInfo());
207                         LogFindBusinessRequest(body);
208 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
209 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
210 
211 			List<?> keysFound = InquiryHelper.findBusiness(body, findQualifiers, em);
212 
213 			BusinessList result = InquiryHelper.getBusinessListFromKeys(body, findQualifiers, em, keysFound);
214 
215 			tx.rollback();
216                         long procTime = System.currentTimeMillis() - startTime;
217                         serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.SUCCESS, procTime);                      
218 
219 			return result;
220 		} finally {
221 			if (tx.isActive()) {
222 				tx.rollback();
223 			}
224 			em.close();
225 		}
226 	}
227 
228 	
229     public RelatedBusinessesList findRelatedBusinesses(FindRelatedBusinesses body)
230 			throws DispositionReportFaultMessage {
231                 long startTime = System.currentTimeMillis();
232                 try {
233                     new ValidateInquiry(null).validateFindRelatedBusinesses(body, false);
234                 } catch (DispositionReportFaultMessage drfm) {
235                     long procTime = System.currentTimeMillis() - startTime;
236                     serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.FAILED, procTime);                      
237                     throw drfm;
238                 }
239 
240 		EntityManager em = PersistenceManager.getEntityManager();
241 		EntityTransaction tx = em.getTransaction();
242 		try {
243 			tx.begin();
244 
245 			if (isAuthenticated())
246 				this.getEntityPublisher(em, body.getAuthInfo());
247                         LogFindRelatedBusinessRequest(body);
248 
249 			// TODO: findQualifiers aren't really used for this call, except maybe for sorting.  Sorting must be done in Java due to the retrieval method used.  Right now
250 			// no sorting is performed.
251 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
252 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
253 
254 			RelatedBusinessesList result = InquiryHelper.getRelatedBusinessesList(body, em);
255 
256 			tx.rollback();
257                         long procTime = System.currentTimeMillis() - startTime;
258                         serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.SUCCESS, procTime);                      
259 
260 			return result;
261 		} finally {
262 			if (tx.isActive()) {
263 				tx.rollback();
264 			}
265 			em.close();
266 		}
267 	}
268 
269 	
270     public ServiceList findService(FindService body)
271 			throws DispositionReportFaultMessage {
272                 long startTime = System.currentTimeMillis();
273                 try {
274                     new ValidateInquiry(null).validateFindService(body);
275                 } catch (DispositionReportFaultMessage drfm) {
276                     long procTime = System.currentTimeMillis() - startTime;
277                     serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.FAILED, procTime);                      
278                     throw drfm;
279                 }
280 
281 		EntityManager em = PersistenceManager.getEntityManager();
282 		EntityTransaction tx = em.getTransaction();
283 		try {
284 			tx.begin();
285 
286 			if (isAuthenticated())
287 				this.getEntityPublisher(em, body.getAuthInfo());
288                         LogFindServiceRequest(body);
289 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
290 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
291 
292 			List<?> keysFound = InquiryHelper.findService(body, findQualifiers, em);
293 
294 		        if (keysFound.size() == 0) {
295 		            if (body.getBusinessKey() != null) {
296 		                // Check that we were passed a valid businessKey per
297     	                // 5.1.12.4 of the UDDI v3 spec
298     	                String businessKey = body.getBusinessKey();
299     	                org.apache.juddi.model.BusinessEntity modelBusinessEntity = null;
300     	                try {
301     	                	modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey);
302     	                } catch (ClassCastException e) {}
303     	                if (modelBusinessEntity == null) {
304     	                    throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", businessKey));
305     	                }
306 		            }
307 		        }
308 
309 			ServiceList result = InquiryHelper.getServiceListFromKeys(body, findQualifiers, em, keysFound);
310 
311 			tx.rollback();
312                         long procTime = System.currentTimeMillis() - startTime;
313                         serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.SUCCESS, procTime);                      
314 
315 			return result;
316 		} finally {
317 			if (tx.isActive()) {
318 				tx.rollback();
319 			}
320 			em.close();
321 		}
322 	}
323 
324 	
325     public TModelList findTModel(FindTModel body)
326 			throws DispositionReportFaultMessage {
327                 long startTime = System.currentTimeMillis();
328                 try {
329                     new ValidateInquiry(null).validateFindTModel(body, false);
330                 } catch (DispositionReportFaultMessage drfm) {
331                     long procTime = System.currentTimeMillis() - startTime;
332                     serviceCounter.update(InquiryQuery.FIND_TMODEL, QueryStatus.FAILED, procTime);                      
333                     throw drfm;
334                 }
335                     
336 		EntityManager em = PersistenceManager.getEntityManager();
337 		EntityTransaction tx = em.getTransaction();
338 		try {
339 			tx.begin();
340 
341 			if (isAuthenticated())
342 				this.getEntityPublisher(em, body.getAuthInfo());
343                         LogFindTModelRequest(body);
344 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
345 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
346 
347 			List<?> keysFound = InquiryHelper.findTModel(body, findQualifiers, em);
348 
349 			TModelList result = InquiryHelper.getTModelListFromKeys(body, findQualifiers, em, keysFound);
350 
351 			tx.rollback();
352                         long procTime = System.currentTimeMillis() - startTime;
353                         serviceCounter.update(InquiryQuery.FIND_TMODEL, QueryStatus.SUCCESS, procTime);                      
354 
355 			return result;
356 		} finally {
357 			if (tx.isActive()) {
358 				tx.rollback();
359 			}
360 			em.close();
361 		}
362 	}
363 
364 	
365     public BindingDetail getBindingDetail(GetBindingDetail body)
366 			throws DispositionReportFaultMessage {
367                 long startTime = System.currentTimeMillis();
368                 try {
369                     new ValidateInquiry(null).validateGetBindingDetail(body);
370                 } catch (DispositionReportFaultMessage drfm) {
371                     long procTime = System.currentTimeMillis() - startTime;
372                     serviceCounter.update(InquiryQuery.FIND_TMODEL, QueryStatus.FAILED, procTime);                      
373                     throw drfm;
374                 }
375 
376 		EntityManager em = PersistenceManager.getEntityManager();
377 		EntityTransaction tx = em.getTransaction();
378 		try {
379 			tx.begin();
380 
381 			if (isAuthenticated())
382 				this.getEntityPublisher(em, body.getAuthInfo());
383 
384 			BindingDetail result = new BindingDetail();
385 
386 			List<String> bindingKeyList = body.getBindingKey();
387 			for (String bindingKey : bindingKeyList) {
388 				org.apache.juddi.model.BindingTemplate modelBindingTemplate = null;
389 				try {
390 					modelBindingTemplate = em.find(org.apache.juddi.model.BindingTemplate.class, bindingKey);
391 				} catch (ClassCastException e) {}
392 				if (modelBindingTemplate == null)
393 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BindingTemplateNotFound", bindingKey));
394 
395 				org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
396 
397 				MappingModelToApi.mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
398 
399 				result.getBindingTemplate().add(apiBindingTemplate);
400 			}
401 
402 			tx.commit();
403                         long procTime = System.currentTimeMillis() - startTime;
404                         serviceCounter.update(InquiryQuery.GET_BINDINGDETAIL, QueryStatus.SUCCESS, procTime);                      
405 
406 			return result;
407 		} finally {
408 			if (tx.isActive()) {
409 				tx.rollback();
410 			}
411 			em.close();
412 		}
413 	}
414 
415 	
416     public BusinessDetail getBusinessDetail(GetBusinessDetail body)
417 			throws DispositionReportFaultMessage {
418                 long startTime = System.currentTimeMillis();
419                 try {
420                     new ValidateInquiry(null).validateGetBusinessDetail(body);
421                 } catch (DispositionReportFaultMessage drfm) {
422                     long procTime = System.currentTimeMillis() - startTime;
423                     serviceCounter.update(InquiryQuery.GET_BUSINESSDETAIL, QueryStatus.FAILED, procTime);                      
424                     throw drfm;
425                 }
426 
427 		EntityManager em = PersistenceManager.getEntityManager();
428 		EntityTransaction tx = em.getTransaction();
429 		try {
430 			tx.begin();
431 
432 			if (isAuthenticated())
433 				this.getEntityPublisher(em, body.getAuthInfo());
434 
435 			BusinessDetail result = new BusinessDetail();
436 
437 			List<String> businessKeyList = body.getBusinessKey();
438 			for (String businessKey : businessKeyList) {
439 				org.apache.juddi.model.BusinessEntity modelBusinessEntity = null;
440 				try {
441 					modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey);
442 				} catch (ClassCastException e) {}
443 				if (modelBusinessEntity == null)
444 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", businessKey));
445 
446 				org.uddi.api_v3.BusinessEntity apiBusinessEntity = new org.uddi.api_v3.BusinessEntity();
447 
448 				MappingModelToApi.mapBusinessEntity(modelBusinessEntity, apiBusinessEntity);
449 
450 				result.getBusinessEntity().add(apiBusinessEntity);
451 			}
452 
453 			tx.commit();
454                         long procTime = System.currentTimeMillis() - startTime;
455                         serviceCounter.update(InquiryQuery.GET_BUSINESSDETAIL, QueryStatus.SUCCESS, procTime);                      
456 
457 			return result;
458 		} finally {
459 			if (tx.isActive()) {
460 				tx.rollback();
461 			}
462 			em.close();
463 		}
464 	}
465 
466 	
467     public OperationalInfos getOperationalInfo(GetOperationalInfo body)
468 			throws DispositionReportFaultMessage {
469                 long startTime = System.currentTimeMillis();
470                 try {
471                     new ValidateInquiry(null).validateGetOperationalInfo(body);
472                 } catch (DispositionReportFaultMessage drfm) {
473                     long procTime = System.currentTimeMillis() - startTime;
474                     serviceCounter.update(InquiryQuery.GET_OPERATIONALINFO, QueryStatus.FAILED, procTime);                      
475                     throw drfm;
476                 }
477 
478 		EntityManager em = PersistenceManager.getEntityManager();
479 		EntityTransaction tx = em.getTransaction();
480 		try {
481 			tx.begin();
482 
483 			if (isAuthenticated())
484 				this.getEntityPublisher(em, body.getAuthInfo());
485 
486 			OperationalInfos result = new OperationalInfos();
487 
488 			List<String> entityKeyList = body.getEntityKey();
489 			for (String entityKey : entityKeyList) {
490 				org.apache.juddi.model.UddiEntity modelUddiEntity = null;
491 				try {
492 					modelUddiEntity = em.find(org.apache.juddi.model.UddiEntity.class, entityKey);
493 				} catch (ClassCastException e) {}
494 				if (modelUddiEntity == null)
495 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.EntityNotFound", entityKey));
496 
497 				org.uddi.api_v3.OperationalInfo apiOperationalInfo = new org.uddi.api_v3.OperationalInfo();
498 
499 				MappingModelToApi.mapOperationalInfo(modelUddiEntity, apiOperationalInfo);
500 
501 				result.getOperationalInfo().add(apiOperationalInfo);
502 			}
503 
504 			tx.commit();
505                         long procTime = System.currentTimeMillis() - startTime;
506                         serviceCounter.update(InquiryQuery.GET_OPERATIONALINFO, QueryStatus.SUCCESS, procTime);                      
507 
508 			return result;
509 		} finally {
510 			if (tx.isActive()) {
511 				tx.rollback();
512 			}
513 			em.close();
514 		}
515 	}
516 
517 	
518     public ServiceDetail getServiceDetail(GetServiceDetail body)
519 			throws DispositionReportFaultMessage {
520         long startTime = System.currentTimeMillis();
521         try {
522             new ValidateInquiry(null).validateGetServiceDetail(body);
523         } catch (DispositionReportFaultMessage drfm) {
524             long procTime = System.currentTimeMillis() - startTime;
525             serviceCounter.update(InquiryQuery.GET_SERVICEDETAIL, QueryStatus.FAILED, procTime);                      
526             throw drfm;
527         }
528 
529 		EntityManager em = PersistenceManager.getEntityManager();
530 		EntityTransaction tx = em.getTransaction();
531 		try {
532 			tx.begin();
533 
534 			if (isAuthenticated())
535 				this.getEntityPublisher(em, body.getAuthInfo());
536 
537 			ServiceDetail result = new ServiceDetail();
538 
539 			List<String> serviceKeyList = body.getServiceKey();
540 			for (String serviceKey : serviceKeyList) {
541 				org.apache.juddi.model.BusinessService modelBusinessService = null;
542 				try {
543 					modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
544 				} catch (ClassCastException e){}
545 				if (modelBusinessService == null)
546 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));
547 
548 				org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();
549 
550 				MappingModelToApi.mapBusinessService(modelBusinessService, apiBusinessService);
551 
552 				result.getBusinessService().add(apiBusinessService);
553 			}
554 
555 			tx.commit();
556                         long procTime = System.currentTimeMillis() - startTime;
557                         serviceCounter.update(InquiryQuery.GET_SERVICEDETAIL, QueryStatus.SUCCESS, procTime);                      
558 
559 			return result;
560 
561 		} finally {
562 			if (tx.isActive()) {
563 				tx.rollback();
564 			}
565 			em.close();
566 		}
567 	}
568 
569 	
570     public TModelDetail getTModelDetail(GetTModelDetail body)
571 			throws DispositionReportFaultMessage {
572                 long startTime = System.currentTimeMillis();
573                 try {
574                     new ValidateInquiry(null).validateGetTModelDetail(body);
575                 } catch (DispositionReportFaultMessage drfm) {
576                     long procTime = System.currentTimeMillis() - startTime;
577                     serviceCounter.update(InquiryQuery.GET_TMODELDETAIL, QueryStatus.FAILED, procTime);                      
578                     throw drfm;
579                 }
580                     
581 		EntityManager em = PersistenceManager.getEntityManager();
582 		EntityTransaction tx = em.getTransaction();
583 		try {
584 			tx.begin();
585 
586 			if (isAuthenticated())
587 				this.getEntityPublisher(em, body.getAuthInfo());
588 
589 			TModelDetail result = new TModelDetail();
590 
591 			List<String> tmodelKeyList = body.getTModelKey();
592 			for (String tmodelKey : tmodelKeyList) {
593 				org.apache.juddi.model.Tmodel modelTModel = null;
594 				try {
595 					modelTModel = em.find(org.apache.juddi.model.Tmodel.class, tmodelKey);
596 				} catch (ClassCastException e) {}
597 				if (modelTModel == null)
598 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.TModelNotFound", tmodelKey));
599 
600 				org.uddi.api_v3.TModel apiTModel = new org.uddi.api_v3.TModel();
601 
602 				MappingModelToApi.mapTModel(modelTModel, apiTModel);
603 
604 				result.getTModel().add(apiTModel);
605 			}
606 
607 			tx.commit();
608                         long procTime = System.currentTimeMillis() - startTime;
609                         serviceCounter.update(InquiryQuery.GET_TMODELDETAIL, QueryStatus.SUCCESS, procTime);                      
610 
611 			return result;
612 		} finally {
613 			if (tx.isActive()) {
614 				tx.rollback();
615 			}
616 			em.close();
617 		}
618 	}
619 
620 	private boolean isAuthenticated() {
621 		boolean result = false;
622 		try {
623 			result = AppConfig.getConfiguration().getBoolean(Property.JUDDI_AUTHENTICATE_INQUIRY);
624 		} catch (ConfigurationException e) {
625 			log.error("Configuration exception occurred retrieving: " + Property.JUDDI_AUTHENTICATE_INQUIRY, e);
626 		}
627 		return result;
628 	}
629 
630 }