Coverage Report - org.kuali.rice.ken.util.ContentTypeEntityResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
ContentTypeEntityResolver
0%
0/13
0%
0/4
2.333
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.ken.util;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.io.StringReader;
 20  
 
 21  
 import org.kuali.rice.ken.bo.NotificationContentType;
 22  
 import org.kuali.rice.ken.service.NotificationContentTypeService;
 23  
 import org.xml.sax.EntityResolver;
 24  
 import org.xml.sax.InputSource;
 25  
 import org.xml.sax.SAXException;
 26  
 
 27  
 /**
 28  
  * Entity resolver that resolves content type XSD resources to XSDs define in
 29  
  * the respective content type's NotificationContentType record
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  */
 32  
 public class ContentTypeEntityResolver extends ContentTypeResourceResolver implements EntityResolver {
 33  
     /**
 34  
      * Constructs a ContentTypeEntityResolver.java.
 35  
      * @param notificationContentTypeService
 36  
      */
 37  
     public ContentTypeEntityResolver(NotificationContentTypeService notificationContentTypeService) {
 38  0
         super(notificationContentTypeService);
 39  0
     }
 40  
 
 41  
     /**
 42  
      * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
 43  
      */
 44  
     public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
 45  0
         LOG.debug("Resolving '" + publicId + "' / '" + systemId + "'");
 46  0
         if (!systemId.startsWith(CONTENT_TYPE_PREFIX)) {
 47  0
             LOG.warn("Cannot resolve non-ContentType resources");
 48  0
             return null;
 49  
         }
 50  0
         NotificationContentType notificationContentType = resolveContentType(systemId);
 51  0
         if (notificationContentType == null) {
 52  0
             LOG.error("Unable to resolve system id '" + systemId + "' locally...delegating to default resolution strategy.");
 53  0
             return null;
 54  
         }
 55  0
         LOG.debug("Resolved '" + systemId + "' to " + notificationContentType.getXsd());
 56  0
         return new InputSource(new StringReader(notificationContentType.getXsd()));
 57  
     }
 58  
 
 59  
     /**
 60  
      * @see java.lang.Object#toString()
 61  
      */
 62  
     public String toString() {
 63  0
         return "[ContentTypeEntityResolver]";
 64  
     }
 65  
 }