|
1 | 1 | /*
|
2 |
| - * Copyright 2013, 2014, 2021 Deutsche Nationalbibliothek et al |
| 2 | + * Copyright 2022 hbz |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 the "License";
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
33 | 33 | import org.slf4j.Logger;
|
34 | 34 | import org.slf4j.LoggerFactory;
|
35 | 35 |
|
36 |
| -import java.io.FileInputStream; |
37 |
| -import java.io.FileNotFoundException; |
38 |
| -import java.io.IOException; |
39 |
| -import java.io.InputStream; |
40 |
| -import java.io.UncheckedIOException; |
41 |
| -import java.net.MalformedURLException; |
42 |
| -import java.net.URL; |
43 | 36 | import java.util.ArrayList;
|
44 | 37 | import java.util.Collections;
|
45 | 38 | import java.util.HashMap;
|
46 | 39 | import java.util.Map;
|
47 | 40 | import java.util.NoSuchElementException;
|
48 |
| -import java.util.Optional; |
49 | 41 | import java.util.Set;
|
50 | 42 |
|
51 | 43 | /**
|
@@ -82,9 +74,9 @@ private void init() {
|
82 | 74 | if (!map.containsKey(Maps.DEFAULT_MAP_KEY)) {
|
83 | 75 | setDefault(Maps.DEFAULT_MAP_KEY);
|
84 | 76 | }
|
85 |
| - final String[] nsPrefixAndProperty = target.split(":"); |
86 |
| - if (nsPrefixAndProperty.length == 2) { |
87 |
| - target = model.getNsPrefixURI(nsPrefixAndProperty[0]) + nsPrefixAndProperty[1]; |
| 77 | + if (!target.toLowerCase().startsWith("http")) { |
| 78 | + final String[] nsPrefixAndProperty = target.split(":"); |
| 79 | + target = nsPrefixAndProperty.length == 2 ? model.getNsPrefixURI(nsPrefixAndProperty[0]) + nsPrefixAndProperty[1] : nsPrefixAndProperty[0]; |
88 | 80 | }
|
89 | 81 | isUninitialized = false;
|
90 | 82 | }
|
@@ -125,39 +117,6 @@ private void loadFile(final String file) {
|
125 | 117 | }
|
126 | 118 | }
|
127 | 119 |
|
128 |
| - private InputStream openStream(final String file) { |
129 |
| - return openAsFile(file).orElseGet(() -> openAsResource(file).orElseGet(() -> openAsUrl(file).orElseThrow(() -> new FixExecutionException("File not found: " + file)))); |
130 |
| - } |
131 |
| - |
132 |
| - private Optional<InputStream> openAsFile(final String file) { |
133 |
| - try { |
134 |
| - return Optional.of(new FileInputStream(file)); |
135 |
| - } |
136 |
| - catch (final FileNotFoundException e) { |
137 |
| - return Optional.empty(); |
138 |
| - } |
139 |
| - } |
140 |
| - |
141 |
| - private Optional<InputStream> openAsResource(final String file) { |
142 |
| - return Optional.ofNullable(Thread.currentThread().getContextClassLoader().getResourceAsStream(file)); |
143 |
| - } |
144 |
| - |
145 |
| - private Optional<InputStream> openAsUrl(final String file) { |
146 |
| - final URL url; |
147 |
| - try { |
148 |
| - url = new URL(file); |
149 |
| - } |
150 |
| - catch (final MalformedURLException e) { |
151 |
| - return Optional.empty(); |
152 |
| - } |
153 |
| - try { |
154 |
| - return Optional.of(url.openStream()); |
155 |
| - } |
156 |
| - catch (final IOException e) { |
157 |
| - throw new UncheckedIOException(e); |
158 |
| - } |
159 |
| - } |
160 |
| - |
161 | 120 | /**
|
162 | 121 | * Builds a Map dynamically by querying an RDF model based on a key and a targeted Property
|
163 | 122 | * (to be set in {@link RdfMap#setTarget(String)}) and an optional language tag (to be set in
|
|
0 commit comments