Coverage Report - org.kuali.rice.ken.util.ContentTypeResourceResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
ContentTypeResourceResolver
0%
0/12
0%
0/4
3
 
 1  
 /*
 2  
  * Copyright 2007-2008 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 org.apache.log4j.Logger;
 19  
 import org.kuali.rice.ken.bo.NotificationContentType;
 20  
 import org.kuali.rice.ken.service.NotificationContentTypeService;
 21  
 
 22  
 /**
 23  
  * Utility base class for Entity and LSResource Resolvers that should resolve
 24  
  * arguments to XSDs defined for NotificationContentTypes
 25  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 26  
  */
 27  
 public class ContentTypeResourceResolver {
 28  
     protected static final String CONTENT_TYPE_PREFIX = "resource:notification/ContentType";
 29  
 
 30  0
     protected final Logger LOG = Logger.getLogger(getClass());
 31  
     
 32  
     private NotificationContentTypeService notificationContentTypeService;
 33  
 
 34  
     /**
 35  
      * Constructs a ContentTypeResourceResolver.java.
 36  
      * @param notificationContentTypeService
 37  
      */
 38  0
     public ContentTypeResourceResolver(NotificationContentTypeService notificationContentTypeService) {
 39  0
         this.notificationContentTypeService = notificationContentTypeService;
 40  0
     }
 41  
 
 42  
     /**
 43  
      * This method resolves the NotificationContentType by id.
 44  
      * @param id
 45  
      * @return
 46  
      */
 47  
     public NotificationContentType resolveContentType(String id) {
 48  0
         if (!id.startsWith(CONTENT_TYPE_PREFIX)) return null;
 49  0
         String contentType = id.substring(CONTENT_TYPE_PREFIX.length());
 50  0
         NotificationContentType notificationContentType = notificationContentTypeService.getNotificationContentType(contentType);
 51  0
         if (contentType == null) {
 52  0
             LOG.warn("Content type '" + contentType + "' not found in notification database");
 53  0
             return null;
 54  
         }
 55  
 
 56  0
         LOG.info("Resolved '" + id + "' to notification content type: " + notificationContentType);
 57  0
         return notificationContentType;
 58  
     }
 59  
 }