1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
31
32
33
34 public class URLScheme implements PropertyScheme {
35 private static final Logger LOG = Logger.getLogger(URLScheme.class);
36
37 public String getName() {
38 return "url";
39 }
40 public String getShortName() {
41 return "url";
42 }
43
44 public Object load(Property property, RouteContext context) {
45 LOG.info("Reading url '" + property.locator + "'...");
46 InputStream is;
47 try {
48 is = new URL(property.locator).openStream();
49 if (is == null) {
50 throw new RuntimeException("Unable to access URL: " + property.locator);
51 }
52 return PropertiesUtil.readResource(is);
53 } catch (IOException ioe) {
54 throw new RuntimeException("Error loading resource: " + property.locator, ioe);
55 }
56 }
57
58 public String toString() {
59 return "[URLScheme]";
60 }
61 }