| <?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>ValidateClerk.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.validation</a> > <span class="el_source">ValidateClerk.java</span></div><h1>ValidateClerk.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.List; |
| |
| import javax.persistence.EntityManager; |
| |
| import org.apache.juddi.api_v3.Clerk; |
| import org.apache.juddi.api_v3.Node; |
| 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 ValidateClerk extends ValidateUDDIApi { |
| |
| public ValidateClerk(UddiEntityPublisher publisher) { |
| <span class="fc" id="L40"> super(publisher);</span> |
| <span class="fc" id="L41"> }</span> |
| |
| |
| |
| /*------------------------------------------------------------------- |
| ClientSubscriptionInf functions are specific to jUDDI. |
| --------------------------------------------------------------------*/ |
| |
| |
| public void validateSaveClerk(EntityManager em, org.apache.juddi.api_v3.SaveClerk body) throws DispositionReportFaultMessage { |
| |
| <span class="pc bpc" id="L52" title="1 of 2 branches missed."> if (body == null)</span> |
| <span class="nc" id="L53"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| |
| // No null or empty list |
| <span class="fc" id="L56"> List<Clerk> clerks = body.getClerk();</span> |
| <span class="pc bpc" id="L57" title="1 of 2 branches missed."> if (clerks == null)</span> |
| <span class="nc" id="L58"> throw new ValueNotAllowedException(new ErrorMessage("errors.saveClerk.NoInput"));</span> |
| |
| <span class="fc bfc" id="L60" title="All 2 branches covered."> for (Clerk clerk : body.getClerk()) {</span> |
| <span class="fc" id="L61"> validateClerk(em, clerk);</span> |
| <span class="fc" id="L62"> }</span> |
| |
| <span class="fc" id="L64"> }</span> |
| |
| public void validateClerk(EntityManager em, org.apache.juddi.api_v3.Clerk clerk) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L69" title="1 of 2 branches missed."> if (clerk == null)</span> |
| <span class="nc" id="L70"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NullInput"));</span> |
| |
| <span class="fc" id="L72"> String name = clerk.getName();</span> |
| <span class="pc bpc" id="L73" title="2 of 4 branches missed."> if (name == null || name.length() == 0)</span> |
| <span class="nc" id="L74"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NoName"));</span> |
| |
| <span class="fc" id="L76"> String publisherName = clerk.getPublisher();</span> |
| <span class="pc bpc" id="L77" title="2 of 4 branches missed."> if (publisherName == null || publisherName.length() == 0)</span> |
| <span class="nc" id="L78"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NoPublisherName"));</span> |
| |
| <span class="fc" id="L80"> Node node = clerk.getNode();</span> |
| <span class="pc bpc" id="L81" title="1 of 2 branches missed."> if (node == null) </span> |
| <span class="nc" id="L82"> throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NullNodeInput"));</span> |
| |
| <span class="fc" id="L84"> String nodeName = node.getName();</span> |
| <span class="pc bpc" id="L85" title="2 of 4 branches missed."> if (nodeName == null || nodeName.length() == 0)</span> |
| <span class="nc" id="L86"> throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));</span> |
| |
| //make sure node exists |
| //edit, doesn't matter if it doesn't exist, it'll be created on save of the clerk |
| /*Object obj = em.find(org.apache.juddi.model.Node.class, nodeName); |
| if (obj == null) |
| throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NodeNotFound", nodeName)); |
| */ |
| <span class="fc" id="L94"> }</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> |