1 package org.andromda.repositories.emf;
2
3 import org.andromda.core.repository.RepositoryFacadeException;
4 import org.apache.commons.lang.StringUtils;
5 import org.eclipse.emf.common.util.URI;
6
7
8
9
10
11
12
13 class EMFRepositoryFacadeUtils
14 {
15
16
17
18 private static final String FILE_PREFIX = "file:";
19
20
21
22
23 private static final String ARCHIVE_FILE_PREFIX = "jar:file:";
24
25
26
27
28
29
30
31 static URI createUri(String uri)
32 {
33 if (!uri.startsWith(ARCHIVE_FILE_PREFIX) && uri.startsWith(FILE_PREFIX))
34 {
35 final String filePrefixWithSlash = FILE_PREFIX + '/';
36 if (!uri.startsWith(filePrefixWithSlash))
37 {
38 uri = StringUtils.replaceOnce(
39 uri,
40 FILE_PREFIX,
41 filePrefixWithSlash);
42 }
43 }
44 final URI resourceUri = URI.createURI(uri);
45 if (resourceUri == null)
46 {
47 throw new RepositoryFacadeException("The path '" + uri + "' is not a valid URI");
48 }
49 return resourceUri;
50 }
51 }