| <?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>ValidateClientSubscriptionInfo.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 Services</a> > <a href="index.source.html" class="el_package">org.apache.juddi.validation</a> > <span class="el_source">ValidateClientSubscriptionInfo.java</span></div><h1>ValidateClientSubscriptionInfo.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.validation; |
| |
| import java.util.HashSet; |
| import java.util.List; |
| |
| import javax.persistence.EntityManager; |
| |
| import org.apache.juddi.api_v3.ClientSubscriptionInfo; |
| import org.apache.juddi.api_v3.DeleteClientSubscriptionInfo; |
| import org.apache.juddi.api_v3.GetAllClientSubscriptionInfoDetail; |
| import org.apache.juddi.api_v3.GetClientSubscriptionInfoDetail; |
| import org.apache.juddi.api_v3.SaveClientSubscriptionInfo; |
| import org.apache.juddi.model.UddiEntityPublisher; |
| 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.ValueNotAllowedException; |
| import org.uddi.v3_service.DispositionReportFaultMessage; |
| |
| |
| /** |
| * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a> |
| */ |
| public class ValidateClientSubscriptionInfo extends ValidateUDDIApi { |
| |
| public ValidateClientSubscriptionInfo(UddiEntityPublisher publisher) { |
| <span class="fc" id="L44"> super(publisher);</span> |
| <span class="fc" id="L45"> }</span> |
| |
| |
| |
| /*------------------------------------------------------------------- |
| ClientSubscriptionInf functions are specific to jUDDI. |
| --------------------------------------------------------------------*/ |
| |
| public void validateDeleteClientSubscriptionInfo(EntityManager em, DeleteClientSubscriptionInfo body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L56" title="1 of 2 branches missed."> if (body == null)</span> |
| <span class="nc" id="L57"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| |
| // No null or empty list |
| <span class="fc" id="L60"> List<String> entityKeyList = body.getSubscriptionKey();</span> |
| <span class="pc bpc" id="L61" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0)</span> |
| <span class="nc" id="L62"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| |
| <span class="fc" id="L64"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc bfc" id="L65" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L66"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L67" title="1 of 2 branches missed."> if (!inserted)</span> |
| <span class="nc" id="L68"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| |
| <span class="fc" id="L70"> Object obj = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, entityKey);</span> |
| <span class="pc bpc" id="L71" title="1 of 2 branches missed."> if (obj == null)</span> |
| <span class="nc" id="L72"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscriptionKeyNotFound", entityKey));</span> |
| |
| <span class="fc" id="L74"> }</span> |
| <span class="fc" id="L75"> }</span> |
| |
| public void validateSaveClientSubscriptionInfo(EntityManager em, SaveClientSubscriptionInfo body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L80" title="1 of 2 branches missed."> if (body == null)</span> |
| <span class="nc" id="L81"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| |
| // No null or empty list |
| <span class="fc" id="L84"> List<ClientSubscriptionInfo> clientSubscriptionInfos = body.getClientSubscriptionInfo();</span> |
| <span class="pc bpc" id="L85" title="1 of 2 branches missed."> if (clientSubscriptionInfos == null)</span> |
| <span class="nc" id="L86"> throw new ValueNotAllowedException(new ErrorMessage("errors.saveclientsubscriptioninfo.NoInput"));</span> |
| |
| <span class="fc bfc" id="L88" title="All 2 branches covered."> for (ClientSubscriptionInfo clientSubscriptionInfo : body.getClientSubscriptionInfo()) {</span> |
| <span class="pc bpc" id="L89" title="2 of 4 branches missed."> if (clientSubscriptionInfo.getSubscriptionKey()==null || clientSubscriptionInfo.getSubscriptionKey().equals("")) {</span> |
| <span class="nc" id="L90"> throw new ValueNotAllowedException(new ErrorMessage("errors.saveclientsubscriptionKey.NoInput"));</span> |
| } |
| <span class="fc" id="L92"> validateClerk(em, clientSubscriptionInfo.getFromClerk());</span> |
| <span class="fc" id="L93"> }</span> |
| <span class="fc" id="L94"> }</span> |
| |
| public void validateClerk(EntityManager em, org.apache.juddi.api_v3.Clerk clerk) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L99" title="1 of 2 branches missed."> if (clerk == null)</span> |
| <span class="nc" id="L100"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NullInput"));</span> |
| |
| <span class="fc" id="L102"> String name = clerk.getName();</span> |
| <span class="pc bpc" id="L103" title="2 of 4 branches missed."> if (name == null || name.length() == 0)</span> |
| <span class="nc" id="L104"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NoName"));</span> |
| |
| //make sure clerk exists |
| <span class="fc" id="L107"> Object obj = em.find(org.apache.juddi.model.Clerk.class, name);</span> |
| <span class="pc bpc" id="L108" title="1 of 2 branches missed."> if (obj == null)</span> |
| <span class="nc" id="L109"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ClerkNotFound", name));</span> |
| <span class="fc" id="L110"> }</span> |
| |
| public void validateGetClientSubscriptionInfoDetail(GetClientSubscriptionInfoDetail body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L115" title="1 of 2 branches missed."> if (body == null)</span> |
| <span class="nc" id="L116"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| |
| // No null or empty list |
| <span class="fc" id="L119"> List<String> clientSubscriptionKeyList = body.getClientSubscriptionKey();</span> |
| <span class="pc bpc" id="L120" title="2 of 4 branches missed."> if (clientSubscriptionKeyList == null || clientSubscriptionKeyList.size() == 0)</span> |
| <span class="nc" id="L121"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| |
| <span class="fc" id="L123"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc bfc" id="L124" title="All 2 branches covered."> for (String clientSubscriptionKey : clientSubscriptionKeyList) {</span> |
| <span class="fc" id="L125"> boolean inserted = dupCheck.add(clientSubscriptionKey);</span> |
| <span class="pc bpc" id="L126" title="1 of 2 branches missed."> if (!inserted)</span> |
| <span class="nc" id="L127"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", clientSubscriptionKey));</span> |
| <span class="fc" id="L128"> }</span> |
| <span class="fc" id="L129"> }</span> |
| |
| public void validateGetAllClientSubscriptionDetail(GetAllClientSubscriptionInfoDetail body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="nc bnc" id="L134" title="All 2 branches missed."> if (body == null)</span> |
| <span class="nc" id="L135"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| |
| <span class="nc" id="L137"> }</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> |