Coverage Report - org.kuali.rice.kew.engine.node.var.schemes.URLScheme
 
Classes in this File Line Coverage Branch Coverage Complexity
URLScheme
0%
0/12
0%
0/2
2.25
 
 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.kew.engine.node.var.schemes;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.io.InputStream;
 20  
 import java.net.URL;
 21  
 
 22  
 import org.apache.log4j.Logger;
 23  
 import org.kuali.rice.kew.engine.RouteContext;
 24  
 import org.kuali.rice.kew.engine.node.PropertiesUtil;
 25  
 import org.kuali.rice.kew.engine.node.var.Property;
 26  
 import org.kuali.rice.kew.engine.node.var.PropertyScheme;
 27  
 
 28  
 
 29  
 /**
 30  
  * A property scheme that interprets the locator as a URL.
 31  
  * 
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class URLScheme implements PropertyScheme {
 35  0
     private static final Logger LOG = Logger.getLogger(URLScheme.class);
 36  
 
 37  
     public String getName() {
 38  0
         return "url";
 39  
     }
 40  
     public String getShortName() {
 41  0
         return "url";
 42  
     }
 43  
 
 44  
     public Object load(Property property, RouteContext context) {
 45  0
         LOG.info("Reading url '" + property.locator + "'...");
 46  
         InputStream is;
 47  
         try {
 48  0
             is = new URL(property.locator).openStream();
 49  0
             if (is == null) {
 50  0
                 throw new RuntimeException("Unable to access URL: " + property.locator);
 51  
             }
 52  0
             return PropertiesUtil.readResource(is);
 53  0
         } catch (IOException ioe) {
 54  0
             throw new RuntimeException("Error loading resource: " + property.locator, ioe);
 55  
         }
 56  
     }
 57  
 
 58  
     public String toString() {
 59  0
         return "[URLScheme]";
 60  
     }
 61  
 }