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 | 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 | |
} |