| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>JUDDIApiImpl.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Core - OpenJPA</a> > <a href="index.source.html" class="el_package">org.apache.juddi.api.impl</a> > <span class="el_source">JUDDIApiImpl.java</span></div><h1>JUDDIApiImpl.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2001-2008 The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| */ |
| package org.apache.juddi.api.impl; |
| |
| import java.io.StringWriter; |
| import java.math.BigInteger; |
| import java.rmi.RemoteException; |
| import java.text.SimpleDateFormat; |
| import java.util.ArrayList; |
| import java.util.Date; |
| import java.util.HashMap; |
| import java.util.Iterator; |
| import java.util.List; |
| import java.util.Map; |
| |
| import javax.jws.WebService; |
| import javax.persistence.EntityManager; |
| import javax.persistence.EntityTransaction; |
| import javax.persistence.Query; |
| import javax.xml.bind.JAXBContext; |
| import javax.xml.bind.Marshaller; |
| import javax.xml.ws.Holder; |
| |
| import org.apache.commons.logging.Log; |
| import org.apache.commons.logging.LogFactory; |
| import org.apache.juddi.ClassUtil; |
| import static org.apache.juddi.api.impl.JUDDIApiImpl.sub; |
| import org.apache.juddi.api.util.JUDDIQuery; |
| import org.apache.juddi.api.util.QueryStatus; |
| import org.apache.juddi.api_v3.AdminSaveBusinessWrapper; |
| import org.apache.juddi.api_v3.AdminSaveTModelWrapper; |
| import org.apache.juddi.api_v3.Clerk; |
| import org.apache.juddi.api_v3.ClerkDetail; |
| import org.apache.juddi.api_v3.ClerkList; |
| import org.apache.juddi.api_v3.ClientSubscriptionInfoDetail; |
| import org.apache.juddi.api_v3.DeleteClerk; |
| import org.apache.juddi.api_v3.DeleteClientSubscriptionInfo; |
| import org.apache.juddi.api_v3.DeleteNode; |
| import org.apache.juddi.api_v3.DeletePublisher; |
| import org.apache.juddi.api_v3.GetAllClientSubscriptionInfoDetail; |
| import org.apache.juddi.api_v3.GetAllPublisherDetail; |
| import org.apache.juddi.api_v3.GetClientSubscriptionInfoDetail; |
| import org.apache.juddi.api_v3.GetEntityHistoryMessageRequest; |
| import org.apache.juddi.api_v3.GetEntityHistoryMessageResponse; |
| import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageRequest; |
| import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageResponse; |
| import org.apache.juddi.api_v3.GetPublisherDetail; |
| import org.apache.juddi.api_v3.NodeDetail; |
| import org.apache.juddi.api_v3.NodeList; |
| import org.apache.juddi.api_v3.PublisherDetail; |
| import org.apache.juddi.api_v3.SaveClerk; |
| import org.apache.juddi.api_v3.SaveClientSubscriptionInfo; |
| import org.apache.juddi.api_v3.SaveNode; |
| import org.apache.juddi.api_v3.SavePublisher; |
| import org.apache.juddi.api_v3.SubscriptionWrapper; |
| import org.apache.juddi.api_v3.SyncSubscription; |
| import org.apache.juddi.api_v3.SyncSubscriptionDetail; |
| import org.apache.juddi.config.AppConfig; |
| import org.apache.juddi.config.PersistenceManager; |
| import org.apache.juddi.config.Property; |
| import org.apache.juddi.mapping.MappingApiToModel; |
| import org.apache.juddi.mapping.MappingModelToApi; |
| import org.apache.juddi.model.BusinessEntity; |
| import org.apache.juddi.model.ChangeRecord; |
| import org.apache.juddi.model.ClientSubscriptionInfo; |
| import org.apache.juddi.model.Node; |
| import org.apache.juddi.model.Publisher; |
| import org.apache.juddi.model.ReplicationConfiguration; |
| import org.apache.juddi.model.Tmodel; |
| import org.apache.juddi.model.UddiEntityPublisher; |
| import org.apache.juddi.replication.ReplicationNotifier; |
| import org.apache.juddi.subscription.NotificationList; |
| import org.apache.juddi.subscription.notify.TemporaryMailContainer; |
| import org.apache.juddi.subscription.notify.USERFRIENDLYSMTPNotifier; |
| import org.apache.juddi.v3.client.transport.Transport; |
| import org.apache.juddi.v3.error.ErrorMessage; |
| import org.apache.juddi.v3.error.FatalErrorException; |
| import org.apache.juddi.v3.error.InvalidKeyPassedException; |
| import org.apache.juddi.v3.error.InvalidValueException; |
| import org.apache.juddi.v3.error.UserMismatchException; |
| import org.apache.juddi.v3_service.JUDDIApiPortType; |
| import org.apache.juddi.validation.ValidateClerk; |
| import org.apache.juddi.validation.ValidateClientSubscriptionInfo; |
| import org.apache.juddi.validation.ValidateNode; |
| import org.apache.juddi.validation.ValidatePublish; |
| import org.apache.juddi.validation.ValidatePublisher; |
| import org.apache.juddi.validation.ValidateReplication; |
| import org.uddi.api_v3.AuthToken; |
| import org.uddi.api_v3.BusinessInfo; |
| import org.uddi.api_v3.BusinessInfos; |
| import org.uddi.api_v3.Contact; |
| import org.uddi.api_v3.DeleteTModel; |
| import org.uddi.api_v3.DispositionReport; |
| import org.uddi.api_v3.GetRegisteredInfo; |
| import org.uddi.api_v3.InfoSelection; |
| import org.uddi.api_v3.PersonName; |
| import org.uddi.api_v3.RegisteredInfo; |
| import org.uddi.api_v3.Result; |
| import org.uddi.api_v3.SaveBusiness; |
| import org.uddi.api_v3.SaveTModel; |
| import org.uddi.api_v3.TModelInfo; |
| import org.uddi.api_v3.TModelInfos; |
| import org.uddi.repl_v3.ChangeRecords; |
| import org.uddi.repl_v3.CommunicationGraph; |
| import org.uddi.repl_v3.Operator; |
| import org.uddi.repl_v3.OperatorStatusType; |
| import org.uddi.sub_v3.GetSubscriptionResults; |
| import org.uddi.sub_v3.Subscription; |
| import org.uddi.sub_v3.SubscriptionResultsList; |
| import org.uddi.v3_service.DispositionReportFaultMessage; |
| import org.uddi.v3_service.UDDISubscriptionPortType; |
| |
| /** |
| * Implements the jUDDI API service. These methods are outside of the UDDI spec |
| * and are specific to jUDDI. They are primarily used for administrative |
| * functions. |
| * |
| * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a> |
| * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a> |
| * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a> |
| */ |
| @WebService(serviceName = "JUDDIApiService", |
| endpointInterface = "org.apache.juddi.v3_service.JUDDIApiPortType", |
| targetNamespace = "urn:juddi-apache-org:v3_service" |
| //, wsdlLocation = "classpath:/juddi_api_v1.wsdl" |
| ) |
| <span class="fc" id="L141">public class JUDDIApiImpl extends AuthenticatedService implements JUDDIApiPortType {</span> |
| |
| <span class="fc" id="L143"> private Log log = LogFactory.getLog(this.getClass());</span> |
| <span class="fc" id="L144"> private UDDIServiceCounter serviceCounter = ServiceCounterLifecycleResource.getServiceCounter(this.getClass());</span> |
| |
| /** |
| * Saves publisher(s) to the persistence layer. This method is specific |
| * to jUDDI. Administrative privilege required. |
| * |
| * @param body |
| * @return PublisherDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| public PublisherDetail savePublisher(SavePublisher body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L156"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L157"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L158"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L160"> tx.begin();</span> |
| |
| <span class="fc" id="L162"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L164"> new ValidatePublish(publisher).validateSavePublisher(em, body);</span> |
| |
| <span class="fc" id="L166"> PublisherDetail result = new PublisherDetail();</span> |
| |
| <span class="fc" id="L168"> List<org.apache.juddi.api_v3.Publisher> apiPublisherList = body.getPublisher();</span> |
| <span class="fc bfc" id="L169" title="All 2 branches covered."> for (org.apache.juddi.api_v3.Publisher apiPublisher : apiPublisherList) {</span> |
| |
| <span class="fc" id="L171"> org.apache.juddi.model.Publisher modelPublisher = new org.apache.juddi.model.Publisher();</span> |
| |
| <span class="fc" id="L173"> MappingApiToModel.mapPublisher(apiPublisher, modelPublisher);</span> |
| |
| <span class="fc" id="L175"> Object existingUddiEntity = em.find(modelPublisher.getClass(), modelPublisher.getAuthorizedName());</span> |
| <span class="fc bfc" id="L176" title="All 2 branches covered."> if (existingUddiEntity != null) {</span> |
| <span class="fc" id="L177"> em.remove(existingUddiEntity);</span> |
| } |
| |
| <span class="fc" id="L180"> em.persist(modelPublisher);</span> |
| |
| <span class="fc" id="L182"> result.getPublisher().add(apiPublisher);</span> |
| <span class="fc" id="L183"> }</span> |
| |
| <span class="fc" id="L185"> tx.commit();</span> |
| <span class="fc" id="L186"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L187"> serviceCounter.update(JUDDIQuery.SAVE_PUBLISHER,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L189"> return result;</span> |
| <span class="nc" id="L190"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L191"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L192"> serviceCounter.update(JUDDIQuery.SAVE_PUBLISHER,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L194"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L196" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L197"> tx.rollback();</span> |
| } |
| <span class="pc" id="L199"> em.close();</span> |
| } |
| } |
| |
| /** |
| * Deletes publisher(s) from the persistence layer. This method is |
| * specific to jUDDI. Administrative privilege required. Also removes |
| * all registered business entities of the user and marks all created |
| * tModels as "deleted" but not does not remove the tModel from |
| * persistence. All subscriptions are also destroyed |
| * |
| * @param body |
| * @throws DispositionReportFaultMessage |
| */ |
| @Override |
| public void deletePublisher(DeletePublisher body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L216"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L217"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L218"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L220"> tx.begin();</span> |
| |
| <span class="fc" id="L222"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L224"> new ValidatePublish(publisher).validateDeletePublisher(em, body);</span> |
| |
| <span class="fc" id="L226"> List<String> entityKeyList = body.getPublisherId();</span> |
| <span class="fc" id="L227"> List<Publisher> deletedPubs = new ArrayList<Publisher>();</span> |
| <span class="fc bfc" id="L228" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L229"> Publisher obj = em.find(org.apache.juddi.model.Publisher.class, entityKey);</span> |
| <span class="fc" id="L230"> deletedPubs.add(obj);</span> |
| //get an authtoken for this publisher so that we can get its registeredInfo |
| <span class="fc" id="L232"> UDDISecurityImpl security = new UDDISecurityImpl();</span> |
| <span class="fc" id="L233"> AuthToken authToken = security.getAuthToken(entityKey);</span> |
| |
| <span class="fc" id="L235"> GetRegisteredInfo r = new GetRegisteredInfo();</span> |
| <span class="fc" id="L236"> r.setAuthInfo(authToken.getAuthInfo());</span> |
| <span class="fc" id="L237"> r.setInfoSelection(InfoSelection.ALL);</span> |
| |
| <span class="fc" id="L239"> log.info("removing all businesses owned by publisher " + entityKey + ".");</span> |
| <span class="fc" id="L240"> UDDIPublicationImpl publish = new UDDIPublicationImpl();</span> |
| <span class="fc" id="L241"> RegisteredInfo registeredInfo = publish.getRegisteredInfo(r);</span> |
| <span class="fc" id="L242"> BusinessInfos businessInfos = registeredInfo.getBusinessInfos();</span> |
| <span class="pc bpc" id="L243" title="3 of 4 branches missed."> if (businessInfos != null && businessInfos.getBusinessInfo() != null) {</span> |
| <span class="nc" id="L244"> Iterator<BusinessInfo> iter = businessInfos.getBusinessInfo().iterator();</span> |
| <span class="nc bnc" id="L245" title="All 2 branches missed."> while (iter.hasNext()) {</span> |
| <span class="nc" id="L246"> BusinessInfo businessInfo = iter.next();</span> |
| <span class="nc" id="L247"> Object business = em.find(org.apache.juddi.model.BusinessEntity.class, businessInfo.getBusinessKey());</span> |
| <span class="nc" id="L248"> em.remove(business);</span> |
| <span class="nc" id="L249"> }</span> |
| } |
| |
| <span class="fc" id="L252"> log.info("mark all tmodels for publisher " + entityKey + " as deleted.");</span> |
| <span class="fc" id="L253"> TModelInfos tmodelInfos = registeredInfo.getTModelInfos();</span> |
| <span class="pc bpc" id="L254" title="3 of 4 branches missed."> if (tmodelInfos != null && tmodelInfos.getTModelInfo() != null) {</span> |
| <span class="nc" id="L255"> Iterator<TModelInfo> iter = tmodelInfos.getTModelInfo().iterator();</span> |
| <span class="nc bnc" id="L256" title="All 2 branches missed."> while (iter.hasNext()) {</span> |
| <span class="nc" id="L257"> TModelInfo tModelInfo = iter.next();</span> |
| <span class="nc" id="L258"> Tmodel tmodel = (Tmodel) em.find(org.apache.juddi.model.Tmodel.class, tModelInfo.getTModelKey());</span> |
| <span class="nc" id="L259"> tmodel.setDeleted(true);</span> |
| <span class="nc" id="L260"> em.persist(tmodel);</span> |
| <span class="nc" id="L261"> }</span> |
| } |
| <span class="fc" id="L263"> log.info("remove all persisted AuthTokens for publisher " + entityKey + ".");</span> |
| <span class="fc" id="L264"> Query q1 = em.createQuery("DELETE FROM AuthToken auth WHERE auth.authorizedName = ?1");</span> |
| <span class="fc" id="L265"> q1.setParameter(1, entityKey);</span> |
| <span class="fc" id="L266"> q1.executeUpdate();</span> |
| <span class="fc" id="L267"> log.info("remove all subscriptions for publisher " + entityKey + ".");</span> |
| <span class="fc" id="L268"> q1 = em.createQuery("DELETE FROM Subscription s WHERE s.authorizedName = ?1");</span> |
| <span class="fc" id="L269"> q1.setParameter(1, entityKey);</span> |
| <span class="fc" id="L270"> q1.executeUpdate();</span> |
| |
| <span class="fc" id="L272"> log.info("removing publisher " + entityKey + ".");</span> |
| //delete the publisher |
| <span class="fc" id="L274"> em.remove(obj);</span> |
| <span class="fc" id="L275"> }</span> |
| |
| <span class="fc" id="L277"> tx.commit();</span> |
| <span class="fc bfc" id="L278" title="All 2 branches covered."> for (Publisher p: deletedPubs){</span> |
| <span class="fc" id="L279"> USERFRIENDLYSMTPNotifier.notifyAccountDeleted(new TemporaryMailContainer(null, p, (Publisher) publisher));</span> |
| <span class="fc" id="L280"> }</span> |
| <span class="fc" id="L281"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L282"> serviceCounter.update(JUDDIQuery.DELETE_PUBLISHER,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L284"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L285"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L286"> serviceCounter.update(JUDDIQuery.DELETE_PUBLISHER,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L288"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L290" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L291"> tx.rollback();</span> |
| } |
| <span class="pc" id="L293"> em.close();</span> |
| <span class="fc" id="L294"> }</span> |
| <span class="fc" id="L295"> }</span> |
| |
| /** |
| * Retrieves publisher(s) from the persistence layer. This method is |
| * specific to jUDDI. Administrative privilege required. |
| * |
| * @param body |
| * @return PublisherDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| public PublisherDetail getPublisherDetail(GetPublisherDetail body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L307"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L308"> new ValidatePublisher(null).validateGetPublisherDetail(body);</span> |
| |
| <span class="fc" id="L310"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L311"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L313"> tx.begin();</span> |
| |
| <span class="fc" id="L315"> this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L317"> PublisherDetail result = new PublisherDetail();</span> |
| |
| <span class="fc" id="L319"> List<String> publisherIdList = body.getPublisherId();</span> |
| <span class="fc bfc" id="L320" title="All 2 branches covered."> for (String publisherId : publisherIdList) {</span> |
| <span class="fc" id="L321"> org.apache.juddi.model.Publisher modelPublisher = null;</span> |
| try { |
| <span class="fc" id="L323"> modelPublisher = em.find(org.apache.juddi.model.Publisher.class, publisherId);</span> |
| <span class="nc" id="L324"> } catch (ClassCastException e) {</span> |
| <span class="fc" id="L325"> }</span> |
| <span class="fc bfc" id="L326" title="All 2 branches covered."> if (modelPublisher == null) {</span> |
| <span class="fc" id="L327"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.PublisherNotFound", publisherId));</span> |
| } |
| |
| <span class="fc" id="L330"> org.apache.juddi.api_v3.Publisher apiPublisher = new org.apache.juddi.api_v3.Publisher();</span> |
| |
| <span class="fc" id="L332"> MappingModelToApi.mapPublisher(modelPublisher, apiPublisher);</span> |
| |
| <span class="fc" id="L334"> result.getPublisher().add(apiPublisher);</span> |
| <span class="fc" id="L335"> }</span> |
| |
| <span class="fc" id="L337"> tx.commit();</span> |
| <span class="fc" id="L338"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L339"> serviceCounter.update(JUDDIQuery.GET_PUBLISHER_DETAIL,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L341"> return result;</span> |
| <span class="fc" id="L342"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="fc" id="L343"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L344"> serviceCounter.update(JUDDIQuery.GET_PUBLISHER_DETAIL,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="fc" id="L346"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L348" title="2 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="pc" id="L349"> tx.rollback();</span> |
| } |
| <span class="fc" id="L351"> em.close();</span> |
| } |
| |
| } |
| |
| /** |
| * Retrieves all publisher from the persistence layer. This method is |
| * specific to jUDDI. Administrative privilege required. Use caution |
| * when calling, result set is not bound. If there are many publishers, |
| * it is possible to have a result set that is too large |
| * |
| * @param body |
| * @return PublisherDetail |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| @SuppressWarnings("unchecked") |
| public PublisherDetail getAllPublisherDetail(GetAllPublisherDetail body) |
| throws DispositionReportFaultMessage, RemoteException { |
| <span class="nc" id="L370"> long startTime = System.currentTimeMillis();</span> |
| <span class="nc" id="L371"> new ValidatePublisher(null).validateGetAllPublisherDetail(body);</span> |
| |
| <span class="nc" id="L373"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L374"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L376"> tx.begin();</span> |
| |
| <span class="nc" id="L378"> this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="nc" id="L380"> PublisherDetail result = new PublisherDetail();</span> |
| |
| <span class="nc" id="L382"> Query query = em.createQuery("SELECT p from Publisher as p");</span> |
| <span class="nc" id="L383"> List<Publisher> modelPublisherList = query.getResultList();</span> |
| |
| <span class="nc bnc" id="L385" title="All 2 branches missed."> for (Publisher modelPublisher : modelPublisherList) {</span> |
| |
| <span class="nc" id="L387"> org.apache.juddi.api_v3.Publisher apiPublisher = new org.apache.juddi.api_v3.Publisher();</span> |
| |
| <span class="nc" id="L389"> MappingModelToApi.mapPublisher(modelPublisher, apiPublisher);</span> |
| |
| <span class="nc" id="L391"> result.getPublisher().add(apiPublisher);</span> |
| <span class="nc" id="L392"> }</span> |
| |
| <span class="nc" id="L394"> tx.commit();</span> |
| <span class="nc" id="L395"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L396"> serviceCounter.update(JUDDIQuery.GET_ALL_PUBLISHER_DETAIL,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L398"> return result;</span> |
| <span class="nc" id="L399"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L400"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L401"> serviceCounter.update(JUDDIQuery.GET_ALL_PUBLISHER_DETAIL,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L403"> throw drfm;</span> |
| } finally { |
| <span class="nc bnc" id="L405" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L406"> tx.rollback();</span> |
| } |
| <span class="nc" id="L408"> em.close();</span> |
| } |
| } |
| |
| /** |
| * Completely deletes a tModel from the persistence layer. |
| * Administrative privilege required. All entities that reference this |
| * tModel will no longer be able to use the tModel if jUDDI Option |
| * Enforce referential Integrity is enabled.<br> |
| * Required permission, you must be am administrator |
| * {@link Property#JUDDI_ENFORCE_REFERENTIAL_INTEGRITY}. In addition, |
| * tModels that are owned by another node via replication cannot be |
| * deleted using this method and will throw an exception |
| * |
| * |
| * @param body |
| * @throws DispositionReportFaultMessage |
| */ |
| @Override |
| public void adminDeleteTModel(DeleteTModel body) |
| throws DispositionReportFaultMessage { |
| <span class="nc" id="L429"> long startTime = System.currentTimeMillis();</span> |
| <span class="nc" id="L430"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L431"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L433"> tx.begin();</span> |
| |
| <span class="nc" id="L435"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="nc" id="L437"> new ValidatePublish(publisher).validateAdminDeleteTModel(em, body);</span> |
| |
| //TODO if referiental integrity is turned on, check to see if this is referenced anywhere and prevent the delete |
| <span class="nc" id="L440"> List<ChangeRecord> changes = new ArrayList<ChangeRecord>();</span> |
| <span class="nc" id="L441"> List<String> entityKeyList = body.getTModelKey();</span> |
| <span class="nc bnc" id="L442" title="All 2 branches missed."> for (String entityKey : entityKeyList) {</span> |
| <span class="nc" id="L443"> org.apache.juddi.model.Tmodel obj = em.find(org.apache.juddi.model.Tmodel.class, entityKey);</span> |
| |
| <span class="nc bnc" id="L445" title="All 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L446"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.TModelNotFound", entityKey));</span> |
| } |
| <span class="nc bnc" id="L448" title="All 2 branches missed."> if (!obj.getNodeId().equals(getNode())) {</span> |
| <span class="nc" id="L449"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.TModelNodeOwner", entityKey + " this node " + getNode() + " owning node " + obj.getNodeId()));</span> |
| } |
| <span class="nc" id="L451"> em.remove(obj);</span> |
| <span class="nc" id="L452"> changes.add(UDDIPublicationImpl.getChangeRecord_deleteTModelDelete(entityKey, getNode(), df));</span> |
| |
| <span class="nc" id="L454"> }</span> |
| |
| <span class="nc" id="L456"> tx.commit();</span> |
| <span class="nc bnc" id="L457" title="All 2 branches missed."> for (ChangeRecord cr : changes) {</span> |
| <span class="nc" id="L458"> ReplicationNotifier.enqueue(cr);</span> |
| <span class="nc" id="L459"> }</span> |
| <span class="nc" id="L460"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L461"> serviceCounter.update(JUDDIQuery.ADMIN_DELETE_TMODEL,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L463"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L464"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L465"> serviceCounter.update(JUDDIQuery.ADMIN_DELETE_TMODEL,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L467"> throw drfm;</span> |
| } finally { |
| <span class="nc bnc" id="L469" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L470"> tx.rollback();</span> |
| } |
| <span class="nc" id="L472"> em.close();</span> |
| <span class="nc" id="L473"> }</span> |
| <span class="nc" id="L474"> }</span> |
| |
| /** |
| * Delete's a client's subscription information. This is typically used |
| * for server to server subscriptions Administrative privilege required. |
| * |
| * @param body |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| public void deleteClientSubscriptionInfo(DeleteClientSubscriptionInfo body) |
| throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L486"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L487"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L488"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L490"> tx.begin();</span> |
| |
| <span class="fc" id="L492"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L494"> new ValidateClientSubscriptionInfo(publisher).validateDeleteClientSubscriptionInfo(em, body);</span> |
| |
| <span class="fc" id="L496"> List<String> entityKeyList = body.getSubscriptionKey();</span> |
| <span class="fc bfc" id="L497" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L498"> Object obj = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, entityKey);</span> |
| <span class="fc" id="L499"> em.remove(obj);</span> |
| <span class="fc" id="L500"> }</span> |
| |
| <span class="fc" id="L502"> tx.commit();</span> |
| <span class="fc" id="L503"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L504"> serviceCounter.update(JUDDIQuery.DELETE_CLIENT_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L506"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L507"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L508"> serviceCounter.update(JUDDIQuery.DELETE_CLIENT_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L510"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L513" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L514"> tx.rollback();</span> |
| } |
| <span class="pc" id="L516"> em.close();</span> |
| <span class="fc" id="L517"> }</span> |
| |
| <span class="fc" id="L519"> }</span> |
| |
| /** |
| * Adds client subscription information. This effectively links a server |
| * to serverr subscription to clerk Administrative privilege required. |
| * |
| * @param body |
| * @return ClientSubscriptionInfoDetail |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| public ClientSubscriptionInfoDetail saveClientSubscriptionInfo(SaveClientSubscriptionInfo body) |
| throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L532"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L533"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L534"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L536"> tx.begin();</span> |
| |
| <span class="fc" id="L538"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L540"> new ValidateClientSubscriptionInfo(publisher).validateSaveClientSubscriptionInfo(em, body);</span> |
| |
| <span class="fc" id="L542"> ClientSubscriptionInfoDetail result = new ClientSubscriptionInfoDetail();</span> |
| |
| <span class="fc" id="L544"> List<org.apache.juddi.api_v3.ClientSubscriptionInfo> apiClientSubscriptionInfoList = body.getClientSubscriptionInfo();</span> |
| <span class="fc bfc" id="L545" title="All 2 branches covered."> for (org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo : apiClientSubscriptionInfoList) {</span> |
| |
| <span class="fc" id="L547"> org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo = new org.apache.juddi.model.ClientSubscriptionInfo();</span> |
| |
| <span class="fc" id="L549"> MappingApiToModel.mapClientSubscriptionInfo(apiClientSubscriptionInfo, modelClientSubscriptionInfo);</span> |
| |
| <span class="fc" id="L551"> Object existingUddiEntity = em.find(modelClientSubscriptionInfo.getClass(), modelClientSubscriptionInfo.getSubscriptionKey());</span> |
| <span class="pc bpc" id="L552" title="1 of 2 branches missed."> if (existingUddiEntity != null) {</span> |
| <span class="nc" id="L553"> em.remove(existingUddiEntity);</span> |
| } |
| |
| <span class="fc" id="L556"> em.persist(modelClientSubscriptionInfo);</span> |
| |
| <span class="fc" id="L558"> result.getClientSubscriptionInfo().add(apiClientSubscriptionInfo);</span> |
| <span class="fc" id="L559"> }</span> |
| |
| <span class="fc" id="L561"> tx.commit();</span> |
| |
| <span class="fc" id="L563"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L564"> serviceCounter.update(JUDDIQuery.SAVE_CLIENT_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L566"> return result;</span> |
| <span class="nc" id="L567"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L568"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L569"> serviceCounter.update(JUDDIQuery.SAVE_CLIENT_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L571"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L574" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L575"> tx.rollback();</span> |
| } |
| <span class="pc" id="L577"> em.close();</span> |
| } |
| } |
| |
| /** |
| * Gets all client subscription information. This is used for server to |
| * server subscriptions Administrative privilege required. |
| * |
| * @param body |
| * @return ClientSubscriptionInfoDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| @SuppressWarnings("unchecked") |
| public ClientSubscriptionInfoDetail getAllClientSubscriptionInfoDetail(GetAllClientSubscriptionInfoDetail body) |
| throws DispositionReportFaultMessage { |
| <span class="nc" id="L592"> long startTime = System.currentTimeMillis();</span> |
| <span class="nc" id="L593"> new ValidateClientSubscriptionInfo(null).validateGetAllClientSubscriptionDetail(body);</span> |
| |
| <span class="nc" id="L595"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L596"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L598"> tx.begin();</span> |
| |
| <span class="nc" id="L600"> this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="nc" id="L602"> ClientSubscriptionInfoDetail result = new ClientSubscriptionInfoDetail();</span> |
| |
| <span class="nc" id="L604"> Query query = em.createQuery("SELECT cs from ClientSubscriptionInfo as cs");</span> |
| <span class="nc" id="L605"> List<org.apache.juddi.model.ClientSubscriptionInfo> modelClientSubscriptionInfoList = query.getResultList();</span> |
| |
| <span class="nc bnc" id="L607" title="All 2 branches missed."> for (ClientSubscriptionInfo modelClientSubscriptionInfo : modelClientSubscriptionInfoList) {</span> |
| |
| <span class="nc" id="L609"> org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo = new org.apache.juddi.api_v3.ClientSubscriptionInfo();</span> |
| |
| <span class="nc" id="L611"> MappingModelToApi.mapClientSubscriptionInfo(modelClientSubscriptionInfo, apiClientSubscriptionInfo, em);</span> |
| |
| <span class="nc" id="L613"> result.getClientSubscriptionInfo().add(apiClientSubscriptionInfo);</span> |
| <span class="nc" id="L614"> }</span> |
| |
| <span class="nc" id="L616"> tx.commit();</span> |
| <span class="nc" id="L617"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L618"> serviceCounter.update(JUDDIQuery.GET_ALL_CLIENT_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L620"> return result;</span> |
| <span class="nc" id="L621"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L622"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L623"> serviceCounter.update(JUDDIQuery.GET_ALL_CLIENT_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L625"> throw drfm;</span> |
| |
| } finally { |
| <span class="nc bnc" id="L628" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L629"> tx.rollback();</span> |
| } |
| <span class="nc" id="L631"> em.close();</span> |
| } |
| |
| } |
| |
| /** |
| * Retrieves clientSubscriptionKey(s) from the persistence layer. This |
| * method is specific to jUDDI. Used for server to server subscriptions |
| * Administrative privilege required. |
| * |
| * @param body |
| * @return ClientSubscriptionInfoDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| public ClientSubscriptionInfoDetail getClientSubscriptionInfoDetail(GetClientSubscriptionInfoDetail body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L647"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L648"> new ValidateClientSubscriptionInfo(null).validateGetClientSubscriptionInfoDetail(body);</span> |
| |
| <span class="fc" id="L650"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L651"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L653"> tx.begin();</span> |
| |
| <span class="fc" id="L655"> this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L657"> ClientSubscriptionInfoDetail result = new ClientSubscriptionInfoDetail();</span> |
| |
| <span class="fc" id="L659"> List<String> subscriptionKeyList = body.getClientSubscriptionKey();</span> |
| <span class="fc bfc" id="L660" title="All 2 branches covered."> for (String subscriptionKey : subscriptionKeyList) {</span> |
| |
| <span class="fc" id="L662"> org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo = null;</span> |
| |
| try { |
| <span class="fc" id="L665"> modelClientSubscriptionInfo = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, subscriptionKey);</span> |
| <span class="nc" id="L666"> } catch (ClassCastException e) {</span> |
| <span class="fc" id="L667"> }</span> |
| <span class="fc bfc" id="L668" title="All 2 branches covered."> if (modelClientSubscriptionInfo == null) {</span> |
| <span class="fc" id="L669"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscripKeyNotFound", subscriptionKey));</span> |
| } |
| |
| <span class="fc" id="L672"> org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo = new org.apache.juddi.api_v3.ClientSubscriptionInfo();</span> |
| |
| <span class="fc" id="L674"> MappingModelToApi.mapClientSubscriptionInfo(modelClientSubscriptionInfo, apiClientSubscriptionInfo, em);</span> |
| |
| <span class="fc" id="L676"> result.getClientSubscriptionInfo().add(apiClientSubscriptionInfo);</span> |
| <span class="fc" id="L677"> }</span> |
| |
| <span class="fc" id="L679"> tx.commit();</span> |
| |
| <span class="fc" id="L681"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L682"> serviceCounter.update(JUDDIQuery.GET_CLIENT_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L684"> return result;</span> |
| <span class="fc" id="L685"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="fc" id="L686"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L687"> serviceCounter.update(JUDDIQuery.GET_CLIENT_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="fc" id="L689"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L691" title="2 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="pc" id="L692"> tx.rollback();</span> |
| } |
| <span class="fc" id="L694"> em.close();</span> |
| } |
| |
| } |
| |
| /** |
| * Saves clerk(s) to the persistence layer. This method is specific to |
| * jUDDI. This is used for server to server subscriptions and for future |
| * use with replication. Administrative privilege required. |
| * |
| * @param body |
| * @return ClerkDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| @Override |
| public ClerkDetail saveClerk(SaveClerk body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L711"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L712"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L713"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L715"> tx.begin();</span> |
| |
| <span class="fc" id="L717"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L719"> new ValidateClerk(publisher).validateSaveClerk(em, body);</span> |
| |
| <span class="fc" id="L721"> ClerkDetail result = new ClerkDetail();</span> |
| |
| <span class="fc" id="L723"> List<org.apache.juddi.api_v3.Clerk> apiClerkList = body.getClerk();;</span> |
| <span class="fc bfc" id="L724" title="All 2 branches covered."> for (org.apache.juddi.api_v3.Clerk apiClerk : apiClerkList) {</span> |
| |
| <span class="fc" id="L726"> org.apache.juddi.model.Clerk modelClerk = new org.apache.juddi.model.Clerk();</span> |
| |
| <span class="fc" id="L728"> MappingApiToModel.mapClerk(apiClerk, modelClerk);</span> |
| <span class="fc" id="L729"> org.apache.juddi.model.Node node2 = em.find(org.apache.juddi.model.Node.class, apiClerk.getNode().getName());</span> |
| <span class="fc bfc" id="L730" title="All 2 branches covered."> if (node2 == null) {</span> |
| //it doesn't exist yet |
| <span class="fc" id="L732"> node2 = new Node();</span> |
| <span class="fc" id="L733"> MappingApiToModel.mapNode(apiClerk.getNode(), node2);</span> |
| <span class="fc" id="L734"> em.persist(node2);</span> |
| } |
| |
| <span class="fc" id="L737"> modelClerk.setNode(node2.getName());</span> |
| <span class="fc" id="L738"> Object existingUddiEntity = em.find(modelClerk.getClass(), modelClerk.getClerkName());</span> |
| <span class="pc bpc" id="L739" title="1 of 2 branches missed."> if (existingUddiEntity != null) {</span> |
| |
| <span class="nc" id="L741"> em.merge(modelClerk);</span> |
| } else { |
| <span class="fc" id="L743"> em.persist(modelClerk);</span> |
| } |
| |
| <span class="fc" id="L746"> result.getClerk().add(apiClerk);</span> |
| <span class="fc" id="L747"> }</span> |
| |
| <span class="fc" id="L749"> tx.commit();</span> |
| <span class="fc" id="L750"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L751"> serviceCounter.update(JUDDIQuery.SAVE_CLERK,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L753"> return result;</span> |
| <span class="nc" id="L754"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L755"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L756"> serviceCounter.update(JUDDIQuery.SAVE_CLERK,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L758"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L761" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L762"> tx.rollback();</span> |
| } |
| <span class="pc" id="L764"> em.close();</span> |
| } |
| } |
| |
| /** |
| * Saves nodes(s) to the persistence layer. This method is specific to |
| * jUDDI. Administrative privilege required. This is used for server to |
| * server subscriptions and for future use with replication. |
| * Administrative privilege required. |
| * |
| * @param body |
| * @return NodeDetail |
| * @throws DispositionReportFaultMessage |
| */ |
| public NodeDetail saveNode(SaveNode body) |
| throws DispositionReportFaultMessage { |
| <span class="fc" id="L780"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L781"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L782"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L784"> tx.begin();</span> |
| |
| <span class="fc" id="L786"> UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| |
| <span class="fc" id="L788"> new ValidateNode(publisher).validateSaveNode(em, body);</span> |
| |
| <span class="fc" id="L790"> NodeDetail result = new NodeDetail();</span> |
| |
| <span class="fc" id="L792"> List<org.apache.juddi.api_v3.Node> apiNodeList = body.getNode();</span> |
| <span class="fc bfc" id="L793" title="All 2 branches covered."> for (org.apache.juddi.api_v3.Node apiNode : apiNodeList) {</span> |
| |
| <span class="fc" id="L795"> org.apache.juddi.model.Node modelNode = new org.apache.juddi.model.Node();</span> |
| |
| <span class="fc" id="L797"> MappingApiToModel.mapNode(apiNode, modelNode);</span> |
| |
| <span class="fc" id="L799"> Object existingUddiEntity = em.find(modelNode.getClass(), modelNode.getName());</span> |
| <span class="pc bpc" id="L800" title="1 of 2 branches missed."> if (existingUddiEntity != null) {</span> |
| <span class="nc" id="L801"> em.merge(modelNode);</span> |
| } else { |
| <span class="fc" id="L803"> em.persist(modelNode);</span> |
| } |
| |
| <span class="fc" id="L806"> result.getNode().add(apiNode);</span> |
| <span class="fc" id="L807"> }</span> |
| |
| <span class="fc" id="L809"> tx.commit();</span> |
| <span class="fc" id="L810"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L811"> serviceCounter.update(JUDDIQuery.SAVE_NODE,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L813"> return result;</span> |
| <span class="fc" id="L814"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="fc" id="L815"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L816"> serviceCounter.update(JUDDIQuery.SAVE_NODE,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="fc" id="L818"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L821" title="2 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="pc" id="L822"> tx.rollback();</span> |
| } |
| <span class="fc" id="L824"> em.close();</span> |
| } |
| } |
| |
| /** |
| * Instructs the registry to perform a synchronous subscription |
| * response. |
| * |
| * @param body |
| * @return SyncSubscriptionDetail |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public SyncSubscriptionDetail invokeSyncSubscription( |
| SyncSubscription body) throws DispositionReportFaultMessage, |
| RemoteException { |
| <span class="nc" id="L842"> long startTime = System.currentTimeMillis();</span> |
| //validate |
| <span class="nc" id="L844"> SyncSubscriptionDetail syncSubscriptionDetail = new SyncSubscriptionDetail();</span> |
| |
| <span class="nc" id="L846"> Map<String, org.apache.juddi.api_v3.ClientSubscriptionInfo> clientSubscriptionInfoMap</span> |
| = new HashMap<String, org.apache.juddi.api_v3.ClientSubscriptionInfo>(); |
| //find the clerks to go with these subscriptions |
| <span class="nc" id="L849"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L850"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L852"> tx.begin();</span> |
| |
| <span class="nc" id="L854"> this.getEntityPublisher(em, body.getAuthInfo());</span> |
| <span class="nc bnc" id="L855" title="All 2 branches missed."> for (GetSubscriptionResults getSubscriptionResult : body.getGetSubscriptionResultsList()) {</span> |
| <span class="nc" id="L856"> String subscriptionKey = getSubscriptionResult.getSubscriptionKey();</span> |
| <span class="nc" id="L857"> org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo = null;</span> |
| |
| try { |
| <span class="nc" id="L860"> modelClientSubscriptionInfo = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, subscriptionKey);</span> |
| <span class="nc" id="L861"> } catch (ClassCastException e) {</span> |
| <span class="nc" id="L862"> }</span> |
| <span class="nc bnc" id="L863" title="All 2 branches missed."> if (modelClientSubscriptionInfo == null) {</span> |
| <span class="nc" id="L864"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscripKeyNotFound", subscriptionKey));</span> |
| } |
| <span class="nc" id="L866"> org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo = new org.apache.juddi.api_v3.ClientSubscriptionInfo();</span> |
| <span class="nc" id="L867"> MappingModelToApi.mapClientSubscriptionInfo(modelClientSubscriptionInfo, apiClientSubscriptionInfo, em);</span> |
| <span class="nc" id="L868"> clientSubscriptionInfoMap.put(apiClientSubscriptionInfo.getSubscriptionKey(), apiClientSubscriptionInfo);</span> |
| <span class="nc" id="L869"> }</span> |
| |
| <span class="nc" id="L871"> tx.commit();</span> |
| <span class="nc" id="L872"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L873"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L874"> serviceCounter.update(JUDDIQuery.INVOKE_SYNCSUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L876"> throw drfm;</span> |
| |
| } finally { |
| <span class="nc bnc" id="L879" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L880"> tx.rollback();</span> |
| } |
| <span class="nc" id="L882"> em.close();</span> |
| <span class="nc" id="L883"> }</span> |
| |
| <span class="nc bnc" id="L885" title="All 2 branches missed."> for (GetSubscriptionResults getSubscriptionResult : body.getGetSubscriptionResultsList()) {</span> |
| try { |
| <span class="nc" id="L887"> String subscriptionKey = getSubscriptionResult.getSubscriptionKey();</span> |
| <span class="nc" id="L888"> Clerk fromClerk = clientSubscriptionInfoMap.get(subscriptionKey).getFromClerk();</span> |
| <span class="nc" id="L889"> Clerk toClerk = clientSubscriptionInfoMap.get(subscriptionKey).getToClerk();</span> |
| <span class="nc" id="L890"> String clazz = fromClerk.getNode().getProxyTransport();</span> |
| <span class="nc" id="L891"> Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());</span> |
| <span class="nc" id="L892"> Transport transport = (Transport) transportClass.getConstructor(String.class</span> |
| <span class="nc" id="L893"> ).newInstance(fromClerk.getNode().getName());</span> |
| <span class="nc" id="L894"> UDDISubscriptionPortType subscriptionService = transport.getUDDISubscriptionService(fromClerk.getNode().getSubscriptionUrl());</span> |
| <span class="nc" id="L895"> SubscriptionResultsList list = subscriptionService.getSubscriptionResults(getSubscriptionResult);</span> |
| |
| <span class="nc" id="L897"> JAXBContext context = JAXBContext.newInstance(list.getClass());</span> |
| <span class="nc" id="L898"> Marshaller marshaller = context.createMarshaller();</span> |
| <span class="nc" id="L899"> StringWriter sw = new StringWriter();</span> |
| |
| <span class="nc" id="L901"> marshaller.marshal(list, sw);</span> |
| |
| <span class="nc" id="L903"> log.info(</span> |
| <span class="nc" id="L904"> "Notification received by UDDISubscriptionListenerService : " + sw.toString());</span> |
| |
| <span class="nc" id="L906"> NotificationList<String> nl = NotificationList.getInstance();</span> |
| |
| <span class="nc" id="L908"> nl.getNotifications()</span> |
| <span class="nc" id="L909"> .add(sw.toString());</span> |
| |
| //update the registry with the notification list. |
| <span class="nc" id="L912"> XRegisterHelper.handle(fromClerk, toClerk, list);</span> |
| |
| <span class="nc" id="L914"> syncSubscriptionDetail.getSubscriptionResultsList()</span> |
| <span class="nc" id="L915"> .add(list);</span> |
| <span class="nc" id="L916"> } catch (Exception ce) {</span> |
| <span class="nc" id="L917"> log.error(ce.getMessage(), ce);</span> |
| <span class="nc" id="L918"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L919"> serviceCounter.update(JUDDIQuery.SAVE_NODE,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc bnc" id="L921" title="All 2 branches missed."> if (ce instanceof DispositionReportFaultMessage) {</span> |
| <span class="nc" id="L922"> throw (DispositionReportFaultMessage) ce;</span> |
| } |
| <span class="nc bnc" id="L924" title="All 2 branches missed."> if (ce instanceof RemoteException) {</span> |
| <span class="nc" id="L925"> DispositionReportFaultMessage x = new FatalErrorException(new ErrorMessage("errors.subscriptionnotifier.client", ce.getMessage()));</span> |
| <span class="nc" id="L926"> throw x;</span> |
| } |
| <span class="nc" id="L928"> }</span> |
| <span class="nc" id="L929"> }</span> |
| //for now sending a clean object back |
| |
| <span class="nc" id="L932"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L933"> serviceCounter.update(JUDDIQuery.INVOKE_SYNCSUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L935"> return syncSubscriptionDetail;</span> |
| } |
| |
| @Override |
| public NodeList getAllNodes(String authInfo) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L940"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L941"> NodeList r = new NodeList();</span> |
| |
| <span class="fc" id="L943"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L944"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L946"> tx.begin();</span> |
| |
| <span class="fc" id="L948"> UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);</span> |
| |
| <span class="fc" id="L950"> new ValidatePublish(publisher).validateGetAllNodes();</span> |
| |
| <span class="fc" id="L952"> StringBuilder sql = new StringBuilder();</span> |
| <span class="fc" id="L953"> sql.append("select distinct c from Node c ");</span> |
| <span class="fc" id="L954"> sql.toString();</span> |
| <span class="fc" id="L955"> Query qry = em.createQuery(sql.toString());</span> |
| <span class="fc" id="L956"> List<org.apache.juddi.model.Node> resultList = qry.getResultList();</span> |
| <span class="fc bfc" id="L957" title="All 2 branches covered."> for (int i = 0; i < resultList.size(); i++) {</span> |
| <span class="fc" id="L958"> org.apache.juddi.api_v3.Node api = new org.apache.juddi.api_v3.Node();</span> |
| <span class="fc" id="L959"> MappingModelToApi.mapNode(resultList.get(i), api);</span> |
| <span class="fc" id="L960"> r.getNode().add(api);</span> |
| |
| } |
| |
| <span class="fc" id="L964"> tx.commit();</span> |
| <span class="fc" id="L965"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L966"> serviceCounter.update(JUDDIQuery.GET_ALL_NODES,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L968"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L969"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L970"> serviceCounter.update(JUDDIQuery.GET_ALL_NODES,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L972"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L974" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L975"> tx.rollback();</span> |
| } |
| <span class="pc" id="L977"> em.close();</span> |
| <span class="fc" id="L978"> }</span> |
| |
| <span class="fc" id="L980"> return r;</span> |
| } |
| |
| @Override |
| public ClerkList getAllClerks(String authInfo) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L985"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L986"> ClerkList ret = new ClerkList();</span> |
| <span class="fc" id="L987"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L988"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L990"> tx.begin();</span> |
| |
| <span class="fc" id="L992"> UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);</span> |
| |
| <span class="fc" id="L994"> new ValidatePublish(publisher).validateGetAllNodes();</span> |
| |
| <span class="fc" id="L996"> StringBuilder sql = new StringBuilder();</span> |
| <span class="fc" id="L997"> sql.append("select distinct c from Clerk c ");</span> |
| <span class="fc" id="L998"> sql.toString();</span> |
| <span class="fc" id="L999"> Query qry = em.createQuery(sql.toString());</span> |
| <span class="fc" id="L1000"> List<org.apache.juddi.model.Clerk> resultList = qry.getResultList();</span> |
| <span class="fc bfc" id="L1001" title="All 2 branches covered."> for (int i = 0; i < resultList.size(); i++) {</span> |
| <span class="fc" id="L1002"> Clerk api = new Clerk();</span> |
| <span class="fc" id="L1003"> MappingModelToApi.mapClerk(resultList.get(i), api, em);</span> |
| <span class="fc" id="L1004"> ret.getClerk().add(api);</span> |
| |
| } |
| <span class="fc" id="L1007"> tx.commit();</span> |
| <span class="fc" id="L1008"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1009"> serviceCounter.update(JUDDIQuery.GET_ALL_CLERKS,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1011"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1012"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1013"> serviceCounter.update(JUDDIQuery.GET_ALL_CLERKS,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1015"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1018" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1019"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1021"> em.close();</span> |
| <span class="fc" id="L1022"> }</span> |
| |
| <span class="fc" id="L1024"> return ret;</span> |
| |
| } |
| |
| @Override |
| public void deleteNode(DeleteNode req) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1030"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L1031"> boolean found = false;</span> |
| <span class="fc" id="L1032"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1033"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1035"> tx.begin();</span> |
| //TODO if the given node is in the replication config, prevent deletion |
| <span class="fc" id="L1037"> UddiEntityPublisher publisher = this.getEntityPublisher(em, req.getAuthInfo());</span> |
| <span class="fc" id="L1038"> new ValidatePublish(publisher).validateDeleteNode(em, req, getReplicationNodes(req.getAuthInfo()));</span> |
| |
| <span class="fc" id="L1040"> org.apache.juddi.model.Node existingUddiEntity = em.find(org.apache.juddi.model.Node.class, req.getNodeID());</span> |
| <span class="pc bpc" id="L1041" title="1 of 2 branches missed."> if (existingUddiEntity != null) {</span> |
| |
| //cascade delete all clerks tied to this node, confirm that it works |
| <span class="fc" id="L1044"> Query createQuery = em.createQuery("delete from Clerk c where c.node = :nodename");</span> |
| <span class="fc" id="L1045"> createQuery.setParameter("nodename", req.getNodeID());</span> |
| <span class="fc" id="L1046"> createQuery.executeUpdate();</span> |
| |
| <span class="fc" id="L1048"> em.remove(existingUddiEntity);</span> |
| <span class="fc" id="L1049"> found = true;</span> |
| <span class="fc" id="L1050"> } else {</span> |
| <span class="nc" id="L1051"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.NotFound"));</span> |
| } |
| |
| <span class="fc" id="L1054"> tx.commit();</span> |
| <span class="fc" id="L1055"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1056"> serviceCounter.update(JUDDIQuery.DELETE_NODE,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1058"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1059"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1060"> serviceCounter.update(JUDDIQuery.DELETE_NODE,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1062"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1065" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1066"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1068"> em.close();</span> |
| <span class="fc" id="L1069"> }</span> |
| |
| <span class="pc bpc" id="L1071" title="1 of 2 branches missed."> if (!found) {</span> |
| |
| <span class="nc" id="L1073"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.NotFound", req.getNodeID()));</span> |
| } |
| <span class="fc" id="L1075"> }</span> |
| |
| @Override |
| public void deleteClerk(DeleteClerk req) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1079"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L1080"> boolean found = false;</span> |
| <span class="fc" id="L1081"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1082"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1084"> tx.begin();</span> |
| |
| <span class="fc" id="L1086"> UddiEntityPublisher publisher = this.getEntityPublisher(em, req.getAuthInfo());</span> |
| |
| <span class="fc" id="L1088"> new ValidatePublish(publisher).validateDeleteClerk(em, req);</span> |
| |
| <span class="fc" id="L1090"> org.apache.juddi.model.Clerk existingUddiEntity = em.find(org.apache.juddi.model.Clerk.class, req.getClerkID());</span> |
| <span class="pc bpc" id="L1091" title="1 of 2 branches missed."> if (existingUddiEntity</span> |
| != null) { |
| <span class="fc" id="L1093"> em.remove(existingUddiEntity);</span> |
| <span class="fc" id="L1094"> found = true;</span> |
| } |
| |
| <span class="fc" id="L1097"> tx.commit();</span> |
| <span class="fc" id="L1098"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1099"> serviceCounter.update(JUDDIQuery.DELETE_CLERK,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1101"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1102"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1103"> serviceCounter.update(JUDDIQuery.DELETE_CLERK,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1105"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1108" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1109"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1111"> em.close();</span> |
| <span class="fc" id="L1112"> }</span> |
| |
| <span class="pc bpc" id="L1114" title="1 of 2 branches missed."> if (!found) {</span> |
| <span class="nc" id="L1115"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteClerk.NotFound"));</span> |
| } |
| |
| <span class="fc" id="L1118"> }</span> |
| |
| /* |
| * enables tmodel owners to setup valid values for tmodel instance infos |
| * to use? |
| * |
| * @param authInfo |
| * @param values |
| * @return |
| * @throws DispositionReportFaultMessage |
| |
| @Override |
| public DispositionReport setAllValidValues(String authInfo, List<ValidValues> values) throws DispositionReportFaultMessage, RemoteException { |
| throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
| /* EntityManager em = PersistenceManager.getEntityManager(); |
| UddiEntityPublisher entityPublisher = getEntityPublisher(em, authInfo); |
| |
| new ValidateValueSetValidation(entityPublisher).validateSetAllValidValues(values); |
| |
| EntityTransaction tx = em.getTransaction(); |
| try { |
| |
| // is this tModel used anywhere?, if so, validate all instances against the new rule? |
| tx.begin(); |
| |
| //each tmodel/value set |
| for (int i = 0; i < values.size(); i++) { |
| //remove any existing references to the key |
| ValueSetValues find = em.find(ValueSetValues.class, values.get(i).getTModekKey()); |
| |
| if (find != null) { |
| find.setValidatorClass(values.get(i).getValidationClass()); |
| em.persist(find); |
| |
| } else { |
| org.apache.juddi.model.ValueSetValues vv = new ValueSetValues(); |
| vv.setTModelKey(values.get(i).getTModekKey()); |
| vv.setValidatorClass(values.get(i).getValidationClass()); |
| em.persist(vv); |
| } |
| } |
| |
| tx.commit(); |
| } finally { |
| if (tx.isActive()) { |
| tx.rollback(); |
| } |
| em.close(); |
| } |
| DispositionReport r = new DispositionReport(); |
| r.getResult().add(new Result()); |
| return r; |
| }*/ |
| @Override |
| public void adminDeleteSubscription(String authInfo, List<String> subscriptionKey) throws DispositionReportFaultMessage, RemoteException { |
| |
| <span class="nc" id="L1174"> long startTime = System.currentTimeMillis();</span> |
| |
| <span class="nc" id="L1176"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L1177"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L1179"> tx.begin();</span> |
| |
| <span class="nc" id="L1181"> UddiEntityPublisher requestor = this.getEntityPublisher(em, authInfo);</span> |
| <span class="nc bnc" id="L1182" title="All 2 branches missed."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="nc" id="L1183"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| //new ValidateSubscription(publisher).validateDeleteSubscription(em, body); |
| <span class="nc" id="L1186"> List<TemporaryMailContainer> notifications = new ArrayList<TemporaryMailContainer>();</span> |
| <span class="nc" id="L1187"> List<String> subscriptionKeyList = subscriptionKey;</span> |
| <span class="nc bnc" id="L1188" title="All 2 branches missed."> for (String key : subscriptionKeyList) {</span> |
| <span class="nc bnc" id="L1189" title="All 4 branches missed."> if (key != null && key.length() > 0) {</span> |
| <span class="nc" id="L1190"> org.apache.juddi.model.Subscription obj = em.find(org.apache.juddi.model.Subscription.class, key);</span> |
| <span class="nc" id="L1191"> Publisher publisher = em.find(Publisher.class, obj.getAuthorizedName());</span> |
| <span class="nc" id="L1192"> notifications.add(new TemporaryMailContainer(obj, publisher, (Publisher) requestor));</span> |
| <span class="nc" id="L1193"> em.remove(obj);</span> |
| } |
| <span class="nc" id="L1195"> }</span> |
| |
| <span class="nc" id="L1197"> tx.commit();</span> |
| <span class="nc bnc" id="L1198" title="All 2 branches missed."> for (TemporaryMailContainer t : notifications) {</span> |
| <span class="nc" id="L1199"> USERFRIENDLYSMTPNotifier.notifySubscriptionDeleted(t);</span> |
| <span class="nc" id="L1200"> }</span> |
| <span class="nc" id="L1201"> notifications.clear();</span> |
| <span class="nc" id="L1202"> notifications = null;</span> |
| <span class="nc" id="L1203"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1204"> serviceCounter.update(JUDDIQuery.ADMIN_DELETE_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1206"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1207"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1208"> serviceCounter.update(JUDDIQuery.ADMIN_DELETE_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1210"> throw drfm;</span> |
| } finally { |
| <span class="nc bnc" id="L1212" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1213"> tx.rollback();</span> |
| } |
| <span class="nc" id="L1215"> em.close();</span> |
| <span class="nc" id="L1216"> }</span> |
| |
| <span class="nc" id="L1218"> }</span> |
| |
| @Override |
| public DispositionReport adminSaveBusiness(String authInfo, List<AdminSaveBusinessWrapper> values) throws DispositionReportFaultMessage, RemoteException { |
| <span class="nc" id="L1222"> long startTime = System.currentTimeMillis();</span> |
| <span class="nc" id="L1223"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L1224"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L1226"> tx.begin();</span> |
| <span class="nc" id="L1227"> UddiEntityPublisher requestor = this.getEntityPublisher(em, authInfo);</span> |
| <span class="nc bnc" id="L1228" title="All 2 branches missed."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="nc" id="L1229"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| |
| <span class="nc bnc" id="L1232" title="All 2 branches missed."> for (int i = 0; i < values.size(); i++) {</span> |
| //impersonate the user |
| <span class="nc" id="L1234"> AuthToken authToken = sec.getAuthToken(values.get(i).getPublisherID());</span> |
| |
| <span class="nc" id="L1236"> SaveBusiness stm = new SaveBusiness();</span> |
| |
| <span class="nc" id="L1238"> stm.setAuthInfo(authToken.getAuthInfo());</span> |
| <span class="nc" id="L1239"> stm.getBusinessEntity().addAll(values.get(i).getBusinessEntity());</span> |
| <span class="nc" id="L1240"> pub.saveBusiness(stm);</span> |
| } |
| |
| <span class="nc" id="L1243"> tx.commit();</span> |
| <span class="nc" id="L1244"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1245"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_BUSINESS,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1247"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1248"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1249"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_BUSINESS,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1251"> throw drfm;</span> |
| |
| } finally { |
| <span class="nc bnc" id="L1254" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1255"> tx.rollback();</span> |
| } |
| <span class="nc" id="L1257"> em.close();</span> |
| <span class="nc" id="L1258"> }</span> |
| |
| <span class="nc" id="L1260"> DispositionReport r = new DispositionReport();</span> |
| <span class="nc" id="L1261"> return r;</span> |
| |
| } |
| |
| @Override |
| public DispositionReport adminSaveTModel(String authInfo, List<AdminSaveTModelWrapper> values) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1267"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L1268"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1269"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1271"> tx.begin();</span> |
| <span class="fc" id="L1272"> UddiEntityPublisher requestor = this.getEntityPublisher(em, authInfo);</span> |
| <span class="pc bpc" id="L1273" title="1 of 2 branches missed."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="nc" id="L1274"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| |
| <span class="pc bpc" id="L1277" title="1 of 2 branches missed."> for (int i = 0; i < values.size(); i++) {</span> |
| //impersonate the user |
| <span class="nc" id="L1279"> AuthToken authToken = sec.getAuthToken(values.get(i).getPublisherID());</span> |
| <span class="nc" id="L1280"> SaveTModel stm = new SaveTModel();</span> |
| <span class="nc" id="L1281"> stm.setAuthInfo(authToken.getAuthInfo());</span> |
| <span class="nc" id="L1282"> stm.getTModel().addAll(values.get(i).getTModel());</span> |
| <span class="nc" id="L1283"> pub.saveTModel(stm);</span> |
| } |
| <span class="fc" id="L1285"> tx.commit();</span> |
| <span class="fc" id="L1286"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1287"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_TMODEL,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1289"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1290"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1291"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_TMODEL,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1293"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1296" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1297"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1299"> em.close();</span> |
| <span class="fc" id="L1300"> }</span> |
| |
| <span class="fc" id="L1302"> DispositionReport r = new DispositionReport();</span> |
| <span class="fc" id="L1303"> return r;</span> |
| } |
| |
| @Override |
| public List<SubscriptionWrapper> getAllClientSubscriptionInfo(String authInfo) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1308"> long startTime = System.currentTimeMillis();</span> |
| |
| <span class="fc" id="L1310"> List<SubscriptionWrapper> r = new ArrayList<SubscriptionWrapper>();</span> |
| |
| <span class="fc" id="L1312"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1313"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1315"> tx.begin();</span> |
| |
| <span class="fc" id="L1317"> UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);</span> |
| <span class="pc bpc" id="L1318" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1319"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| |
| <span class="fc" id="L1322"> StringBuilder sql = new StringBuilder();</span> |
| <span class="fc" id="L1323"> sql.append("select distinct c from Subscription c ");</span> |
| <span class="fc" id="L1324"> Query qry = em.createQuery(sql.toString());</span> |
| <span class="fc" id="L1325"> List<org.apache.juddi.model.Subscription> resultList = qry.getResultList();</span> |
| <span class="pc bpc" id="L1326" title="1 of 2 branches missed."> for (int i = 0; i < resultList.size(); i++) {</span> |
| <span class="nc" id="L1327"> Subscription sub = new Subscription();</span> |
| <span class="nc" id="L1328"> MappingModelToApi.mapSubscription(resultList.get(i), sub);</span> |
| <span class="nc" id="L1329"> SubscriptionWrapper x = new SubscriptionWrapper();</span> |
| <span class="nc" id="L1330"> x.getSubscription().add(sub);</span> |
| <span class="nc" id="L1331"> x.setPublisherIdOrUsername(resultList.get(i).getAuthorizedName());</span> |
| <span class="nc" id="L1332"> r.add(x);</span> |
| } |
| |
| <span class="fc" id="L1335"> tx.commit();</span> |
| <span class="fc" id="L1336"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1337"> serviceCounter.update(JUDDIQuery.GET_ALL_CLIENT_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1339"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1340"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1341"> serviceCounter.update(JUDDIQuery.GET_ALL_CLIENT_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1343"> throw drfm;</span> |
| } finally { |
| <span class="pc bpc" id="L1345" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1346"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1348"> em.close();</span> |
| <span class="fc" id="L1349"> }</span> |
| |
| <span class="fc" id="L1351"> return r;</span> |
| } |
| |
| @Override |
| public synchronized DispositionReport setReplicationNodes(String authInfo, org.uddi.repl_v3.ReplicationConfiguration replicationConfiguration) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1356"> long startTime = System.currentTimeMillis();</span> |
| |
| <span class="fc" id="L1358"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1359"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1361"> tx.begin();</span> |
| |
| <span class="fc" id="L1363"> org.uddi.repl_v3.ReplicationConfiguration oldConfig = null;</span> |
| <span class="fc" id="L1364"> UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);</span> |
| <span class="pc bpc" id="L1365" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1366"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| <span class="fc" id="L1368"> new ValidateReplication(publisher).validateSetReplicationNodes(replicationConfiguration, em, getNode(), AppConfig.getConfiguration());</span> |
| |
| <span class="fc" id="L1370"> org.apache.juddi.model.ReplicationConfiguration model = null;</span> |
| <span class="fc" id="L1371"> logger.info(publisher.getAuthorizedName() + " is setting the replication config from " + getRequestorsIPAddress());// + " " + sw.toString());</span> |
| try { |
| <span class="fc" id="L1373"> model = (ReplicationConfiguration) em.createQuery("select c FROM ReplicationConfiguration c order by c.serialNumber desc").getSingleResult();</span> |
| <span class="fc" id="L1374"> } catch (Exception ex) {</span> |
| <span class="fc" id="L1375"> }</span> |
| <span class="fc" id="L1376"> SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmZ");</span> |
| <span class="fc bfc" id="L1377" title="All 2 branches covered."> if (model == null) {</span> |
| //this is a brand new configuration and we didn't have one before |
| <span class="fc" id="L1379"> model = new ReplicationConfiguration();</span> |
| <span class="fc" id="L1380"> MappingApiToModel.mapReplicationConfiguration(replicationConfiguration, model, em);</span> |
| <span class="fc" id="L1381"> model.setSerialNumber(System.currentTimeMillis());</span> |
| <span class="fc" id="L1382"> model.setTimeOfConfigurationUpdate(sdf.format(new Date()));</span> |
| <span class="fc" id="L1383"> em.persist(model);</span> |
| //if (newReplicationNode(model)){ |
| //tell the replication notifier to start transfering with |
| //the first change record |
| //} |
| |
| } else { |
| //a config exists, remove it, add the new one |
| //spec doesn't appear to mention if recording a change history on the config is required |
| //assuming we'll keep it for now, might be useful later. |
| //em.remove(model); |
| <span class="fc" id="L1394"> oldConfig = new org.uddi.repl_v3.ReplicationConfiguration();</span> |
| <span class="fc" id="L1395"> MappingModelToApi.mapReplicationConfiguration(model, oldConfig);</span> |
| |
| <span class="fc" id="L1397"> ReplicationConfiguration model2 = new ReplicationConfiguration();</span> |
| <span class="fc" id="L1398"> MappingApiToModel.mapReplicationConfiguration(replicationConfiguration, model2, em);</span> |
| <span class="fc" id="L1399"> model2.setSerialNumber(System.currentTimeMillis());</span> |
| |
| <span class="fc" id="L1401"> model2.setTimeOfConfigurationUpdate(sdf.format(new Date()));</span> |
| <span class="fc" id="L1402"> em.persist(model2);</span> |
| |
| } |
| |
| <span class="fc" id="L1406"> tx.commit();</span> |
| <span class="fc" id="L1407"> UDDIReplicationImpl.notifyConfigurationChange(oldConfig, replicationConfiguration, this);</span> |
| <span class="fc" id="L1408"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1409"> serviceCounter.update(JUDDIQuery.SET_REPLICATION_NODES,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1411"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1412"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1413"> serviceCounter.update(JUDDIQuery.SET_REPLICATION_NODES,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1415"> throw drfm;</span> |
| <span class="nc" id="L1416"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1417"> logger.error(ex, ex);</span> |
| <span class="nc" id="L1418"> throw new FatalErrorException(new ErrorMessage("E_fatalError", ex.getMessage()));</span> |
| } finally { |
| <span class="pc bpc" id="L1420" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1421"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1423"> em.close();</span> |
| <span class="fc" id="L1424"> }</span> |
| <span class="fc" id="L1425"> DispositionReport d = new DispositionReport();</span> |
| <span class="fc" id="L1426"> Result res = new Result();</span> |
| |
| <span class="fc" id="L1428"> d.getResult().add(res);</span> |
| <span class="fc" id="L1429"> return d;</span> |
| } |
| |
| @Override |
| public synchronized org.uddi.repl_v3.ReplicationConfiguration getReplicationNodes(String authInfo) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1434"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L1435"> org.uddi.repl_v3.ReplicationConfiguration r = new org.uddi.repl_v3.ReplicationConfiguration();</span> |
| |
| <span class="fc" id="L1437"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1438"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1440"> tx.begin();</span> |
| |
| <span class="fc" id="L1442"> UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);</span> |
| <span class="pc bpc" id="L1443" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1444"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| |
| <span class="fc" id="L1447"> StringBuilder sql = new StringBuilder();</span> |
| <span class="fc" id="L1448"> sql.append("select c from ReplicationConfiguration c order by c.serialNumber desc");</span> |
| //sql.toString(); |
| <span class="fc" id="L1450"> Query qry = em.createQuery(sql.toString());</span> |
| <span class="fc" id="L1451"> qry.setMaxResults(1);</span> |
| |
| <span class="fc" id="L1453"> org.apache.juddi.model.ReplicationConfiguration resultList = (org.apache.juddi.model.ReplicationConfiguration) qry.getSingleResult();</span> |
| <span class="fc" id="L1454"> MappingModelToApi.mapReplicationConfiguration(resultList, r);</span> |
| <span class="fc" id="L1455"> tx.commit();</span> |
| <span class="fc" id="L1456"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1457"> serviceCounter.update(JUDDIQuery.GET_ALL_NODES,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1459"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1460"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1461"> serviceCounter.update(JUDDIQuery.GET_ALL_NODES,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1463"> throw drfm;</span> |
| <span class="nc" id="L1464"> } catch (Exception ex) {</span> |
| //possible that there is no config to return |
| <span class="nc" id="L1466"> logger.debug("Error caught, is there a replication config is avaiable? Returning a default config (no replication): ", ex);</span> |
| |
| <span class="nc" id="L1468"> r.setCommunicationGraph(new CommunicationGraph());</span> |
| <span class="nc" id="L1469"> Operator op = new Operator();</span> |
| <span class="nc" id="L1470"> op.setOperatorNodeID(getNode());</span> |
| <span class="nc" id="L1471"> op.setSoapReplicationURL(baseUrlSSL + "replication/services/replication");</span> |
| |
| <span class="nc" id="L1473"> op.getContact().add(new Contact());</span> |
| <span class="nc" id="L1474"> op.getContact().get(0).getPersonName().add(new PersonName("Unknown", null));</span> |
| <span class="nc" id="L1475"> op.setOperatorStatus(OperatorStatusType.NORMAL);</span> |
| |
| <span class="nc" id="L1477"> r.getOperator().add(op);</span> |
| <span class="nc" id="L1478"> r.getCommunicationGraph().getNode().add(getNode());</span> |
| <span class="nc" id="L1479"> r.getCommunicationGraph().getControlledMessage().add("*");</span> |
| <span class="nc" id="L1480"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1481"> r.setSerialNumber(0);</span> |
| <span class="nc" id="L1482"> SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmZ");</span> |
| <span class="nc" id="L1483"> r.setTimeOfConfigurationUpdate(sdf.format(new Date()));</span> |
| <span class="nc" id="L1484"> r.setRegistryContact(new org.uddi.repl_v3.ReplicationConfiguration.RegistryContact());</span> |
| try { |
| // pull from root business |
| <span class="nc bnc" id="L1487" title="All 2 branches missed."> if (!tx.isActive()) {</span> |
| <span class="nc" id="L1488"> tx = em.getTransaction();</span> |
| } |
| |
| <span class="nc" id="L1491"> BusinessEntity rootbiz = em.find(BusinessEntity.class, AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ROOT_BUSINESS));</span> |
| <span class="nc bnc" id="L1492" title="All 2 branches missed."> if (rootbiz != null) {</span> |
| |
| <span class="nc bnc" id="L1494" title="All 2 branches missed."> for (int i = 0; i < rootbiz.getContacts().size(); i++) {</span> |
| <span class="nc" id="L1495"> Contact c = new Contact();</span> |
| <span class="nc" id="L1496"> MappingModelToApi.mapContact(rootbiz.getContacts().get(i), c);</span> |
| <span class="nc" id="L1497"> r.getRegistryContact().setContact(c);</span> |
| <span class="nc" id="L1498"> break;</span> |
| } |
| |
| } |
| <span class="nc" id="L1502"> tx.rollback();</span> |
| |
| <span class="nc" id="L1504"> } catch (Exception ex1) {</span> |
| <span class="nc" id="L1505"> logger.warn("unexpected error", ex1);</span> |
| <span class="nc" id="L1506"> }</span> |
| <span class="nc bnc" id="L1507" title="All 2 branches missed."> if (r.getRegistryContact().getContact() == null) {</span> |
| <span class="nc" id="L1508"> r.getRegistryContact().setContact(new Contact());</span> |
| <span class="nc" id="L1509"> r.getRegistryContact().getContact().getPersonName().add(new PersonName("Unknown", null));</span> |
| } |
| <span class="nc" id="L1511"> serviceCounter.update(JUDDIQuery.GET_REPLICATION_NODES,</span> |
| QueryStatus.SUCCESS, procTime); |
| |
| } finally { |
| <span class="pc bpc" id="L1515" title="5 of 6 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1516"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1518"> em.close();</span> |
| <span class="pc" id="L1519"> }</span> |
| |
| <span class="fc" id="L1521"> r.setMaximumTimeToGetChanges(BigInteger.ONE);</span> |
| <span class="fc" id="L1522"> r.setMaximumTimeToSyncRegistry(BigInteger.ONE);</span> |
| //StringWriter sw = new StringWriter(); |
| //JAXB.marshal(r, sw); |
| //logger.info("dumping returned replication config " + sw.toString()); |
| <span class="fc" id="L1526"> return r;</span> |
| } |
| |
| <span class="fc" id="L1529"> static UDDISubscriptionImpl sub = new UDDISubscriptionImpl();</span> |
| <span class="fc" id="L1530"> static UDDISecurityImpl sec = new UDDISecurityImpl();</span> |
| <span class="fc" id="L1531"> static UDDIPublicationImpl pub = new UDDIPublicationImpl();</span> |
| |
| @Override |
| public void adminSaveSubscription(String authInfo, String publisherOrUsername, Holder<List<Subscription>> subscriptions) throws DispositionReportFaultMessage { |
| <span class="fc" id="L1535"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc" id="L1536"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1537"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1539"> tx.begin();</span> |
| <span class="fc" id="L1540"> UddiEntityPublisher requestor = this.getEntityPublisher(em, authInfo);</span> |
| <span class="fc bfc" id="L1541" title="All 2 branches covered."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="fc" id="L1542"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| //impersonate the user |
| <span class="fc" id="L1545"> AuthToken authToken = sec.getAuthToken(publisherOrUsername);</span> |
| <span class="fc" id="L1546"> sub.saveSubscription(authToken.getAuthInfo(), subscriptions);</span> |
| <span class="fc" id="L1547"> tx.commit();</span> |
| <span class="fc" id="L1548"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1549"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_SUB,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L1551"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="fc" id="L1552"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1553"> serviceCounter.update(JUDDIQuery.ADMIN_SAVE_SUB,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="fc" id="L1555"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1558" title="2 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="pc" id="L1559"> tx.rollback();</span> |
| } |
| <span class="fc" id="L1561"> em.close();</span> |
| <span class="fc" id="L1562"> }</span> |
| |
| <span class="fc" id="L1564"> }</span> |
| |
| /** |
| * {@inheritDoc } |
| * |
| * @param body |
| * @return item history or null if not found |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| @Override |
| public GetEntityHistoryMessageResponse getEntityHistory(GetEntityHistoryMessageRequest body) throws DispositionReportFaultMessage, RemoteException { |
| <span class="fc" id="L1576"> long startTime = System.currentTimeMillis();</span> |
| <span class="fc bfc" id="L1577" title="All 2 branches covered."> if (body == null) {</span> |
| <span class="fc" id="L1578"> throw new InvalidValueException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| <span class="fc" id="L1580"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L1581"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="fc" id="L1583"> tx.begin();</span> |
| <span class="fc" id="L1584"> UddiEntityPublisher requestor = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| <span class="pc bpc" id="L1585" title="1 of 2 branches missed."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="nc" id="L1586"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| <span class="pc bpc" id="L1588" title="1 of 2 branches missed."> if (body.getMaxRecords() <= 0) {</span> |
| <span class="fc" id="L1589"> body.setMaxRecords(20);</span> |
| } |
| <span class="pc bpc" id="L1591" title="1 of 2 branches missed."> if (body.getOffset() < 0) {</span> |
| <span class="nc" id="L1592"> body.setOffset(0);</span> |
| } |
| <span class="fc" id="L1594"> Query createQuery = em.createQuery("select m from ChangeRecord m where m.entityKey = :key order by m.id DESC");</span> |
| <span class="fc" id="L1595"> createQuery.setMaxResults((int) body.getMaxRecords());</span> |
| <span class="fc" id="L1596"> createQuery.setParameter("key", body.getEntityKey());</span> |
| <span class="fc" id="L1597"> createQuery.setFirstResult((int) body.getOffset());</span> |
| <span class="fc" id="L1598"> List<ChangeRecord> resultList = createQuery.getResultList();</span> |
| <span class="fc" id="L1599"> GetEntityHistoryMessageResponse res = new GetEntityHistoryMessageResponse();</span> |
| <span class="fc" id="L1600"> res.setChangeRecords(new ChangeRecords());</span> |
| <span class="fc bfc" id="L1601" title="All 2 branches covered."> for (ChangeRecord cr : resultList) {</span> |
| <span class="fc" id="L1602"> res.getChangeRecords().getChangeRecord().add(MappingModelToApi.mapChangeRecord(cr));</span> |
| <span class="fc" id="L1603"> }</span> |
| |
| <span class="fc" id="L1605"> tx.rollback();</span> |
| <span class="fc" id="L1606"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1607"> serviceCounter.update(JUDDIQuery.ADMIN_GET_HISTORY,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="fc" id="L1609"> return res;</span> |
| <span class="fc" id="L1610"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="fc" id="L1611"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="fc" id="L1612"> serviceCounter.update(JUDDIQuery.ADMIN_GET_HISTORY,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="fc" id="L1614"> throw drfm;</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1617" title="2 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="pc" id="L1618"> tx.rollback();</span> |
| } |
| <span class="fc" id="L1620"> em.close();</span> |
| } |
| } |
| |
| /** |
| * {@inheritDoc } |
| * |
| * @param body |
| * @return |
| * @throws DispositionReportFaultMessage |
| * @throws RemoteException |
| */ |
| @Override |
| public GetFailedReplicationChangeRecordsMessageResponse getFailedReplicationChangeRecords( |
| GetFailedReplicationChangeRecordsMessageRequest body) |
| throws DispositionReportFaultMessage, RemoteException { |
| //public GetFailedReplicationChangeRecordsMessageResponse getFailedReplicationChangeRecords(GetFailedReplicationChangeRecordsMessageRequest body) throws DispositionReportFaultMessage, RemoteException { |
| <span class="nc" id="L1637"> long startTime = System.currentTimeMillis();</span> |
| <span class="nc bnc" id="L1638" title="All 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L1639"> throw new InvalidValueException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| <span class="nc" id="L1641"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L1642"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| <span class="nc" id="L1644"> tx.begin();</span> |
| <span class="nc" id="L1645"> UddiEntityPublisher requestor = this.getEntityPublisher(em, body.getAuthInfo());</span> |
| <span class="nc bnc" id="L1646" title="All 2 branches missed."> if (!((Publisher) requestor).isAdmin()) {</span> |
| <span class="nc" id="L1647"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| <span class="nc bnc" id="L1649" title="All 2 branches missed."> if (body.getMaxRecords() <= 0) {</span> |
| <span class="nc" id="L1650"> body.setMaxRecords(20);</span> |
| } |
| <span class="nc bnc" id="L1652" title="All 2 branches missed."> if (body.getOffset() < 0) {</span> |
| <span class="nc" id="L1653"> body.setOffset(0);</span> |
| } |
| <span class="nc" id="L1655"> Query createQuery = em.createQuery("select m from ChangeRecord m where m.isAppliedLocally=false order by m.id DESC ");</span> |
| <span class="nc" id="L1656"> createQuery.setMaxResults((int) body.getMaxRecords());</span> |
| <span class="nc" id="L1657"> createQuery.setFirstResult((int) body.getOffset());</span> |
| <span class="nc" id="L1658"> List<ChangeRecord> resultList = createQuery.getResultList();</span> |
| <span class="nc" id="L1659"> GetFailedReplicationChangeRecordsMessageResponse res = new GetFailedReplicationChangeRecordsMessageResponse();</span> |
| <span class="nc" id="L1660"> res.setChangeRecords(new ChangeRecords());</span> |
| <span class="nc bnc" id="L1661" title="All 2 branches missed."> for (ChangeRecord cr : resultList) {</span> |
| <span class="nc" id="L1662"> res.getChangeRecords().getChangeRecord().add(MappingModelToApi.mapChangeRecord(cr));</span> |
| <span class="nc" id="L1663"> }</span> |
| |
| <span class="nc" id="L1665"> tx.rollback();</span> |
| <span class="nc" id="L1666"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1667"> serviceCounter.update(JUDDIQuery.ADMIN_GET_FAILED_CRS,</span> |
| QueryStatus.SUCCESS, procTime); |
| <span class="nc" id="L1669"> return res;</span> |
| <span class="nc" id="L1670"> } catch (DispositionReportFaultMessage drfm) {</span> |
| <span class="nc" id="L1671"> long procTime = System.currentTimeMillis() - startTime;</span> |
| <span class="nc" id="L1672"> serviceCounter.update(JUDDIQuery.ADMIN_GET_FAILED_CRS,</span> |
| QueryStatus.FAILED, procTime); |
| <span class="nc" id="L1674"> throw drfm;</span> |
| |
| } finally { |
| <span class="nc bnc" id="L1677" title="All 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1678"> tx.rollback();</span> |
| } |
| <span class="nc" id="L1680"> em.close();</span> |
| } |
| } |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html> |