| <?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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>RampartException.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="right"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Coverage Report</a> > <a href="index.html" class="el_package">org.apache.rampart</a> > <span class="el_source">RampartException.java</span></div><h1>RampartException.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2004,2005 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.rampart; |
| |
| import java.text.MessageFormat; |
| import java.util.MissingResourceException; |
| import java.util.ResourceBundle; |
| |
| public class RampartException extends Exception { |
| |
| private static final long serialVersionUID = 8674795537585339704L; |
| |
| private static ResourceBundle resources; |
| |
| private String faultCode; |
| private String faultString; |
| |
| static { |
| try { |
| <span class="fc" id="L34"> resources = ResourceBundle.getBundle("org.apache.rampart.errors");</span> |
| <span class="nc" id="L35"> } catch (MissingResourceException e) {</span> |
| <span class="nc" id="L36"> throw new RuntimeException(e.getMessage());</span> |
| <span class="fc" id="L37"> }</span> |
| <span class="fc" id="L38"> }</span> |
| |
| public RampartException(String faultCode, Object[] args) { |
| <span class="fc" id="L41"> super(getMessage(faultCode, args));</span> |
| <span class="fc" id="L42"> this.faultCode = getFaultCode(faultCode);</span> |
| <span class="fc" id="L43"> this.faultString = getMessage(faultCode, args);</span> |
| <span class="fc" id="L44"> }</span> |
| |
| /** |
| * Construct the fault properly code for the standard faults |
| * @param code code as definfed in property file under |
| * @return |
| */ |
| private String getFaultCode(String code) { |
| //TODO check for spec specific error codes |
| <span class="fc" id="L53"> return code;</span> |
| } |
| |
| public RampartException(String faultCode) { |
| <span class="fc" id="L57"> this(faultCode, (Object[])null);</span> |
| <span class="fc" id="L58"> }</span> |
| |
| public RampartException(String faultCode, Object[] args, Throwable e) { |
| <span class="nc" id="L61"> super(getMessage(faultCode, args),e);</span> |
| <span class="nc" id="L62"> this.faultCode = faultCode;</span> |
| <span class="nc" id="L63"> this.faultString = getMessage(faultCode, args);</span> |
| <span class="nc" id="L64"> }</span> |
| |
| public RampartException(String faultCode, Throwable e) { |
| <span class="nc" id="L67"> this(faultCode, null, e);</span> |
| <span class="nc" id="L68"> }</span> |
| |
| /** |
| * get the message from resource bundle. |
| * <p/> |
| * |
| * @return the message translated from the property (message) file. |
| */ |
| protected static String getMessage(String faultCode, Object[] args) { |
| <span class="fc" id="L77"> String msg = null;</span> |
| try { |
| <span class="fc" id="L79"> msg = MessageFormat.format(resources.getString(faultCode), args);</span> |
| <span class="nc" id="L80"> } catch (MissingResourceException e) {</span> |
| <span class="nc" id="L81"> throw new RuntimeException("Undefined '" + faultCode + "' resource property");</span> |
| <span class="fc" id="L82"> }</span> |
| <span class="fc" id="L83"> return msg;</span> |
| } |
| |
| /** |
| * @return Returns the faultCode. |
| */ |
| protected String getFaultCode() { |
| <span class="nc" id="L90"> return faultCode;</span> |
| } |
| |
| /** |
| * @return Returns the faultString. |
| */ |
| protected String getFaultString() { |
| <span class="nc" id="L97"> return faultString;</span> |
| } |
| |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.6.1.201212231917</span></div></body></html> |