1 package org.apache.archiva.metadata.repository.jcr;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.jackrabbit.core.config.ConfigurationException;
22 import org.apache.jackrabbit.core.config.RepositoryConfig;
23 import org.slf4j.LoggerFactory;
24
25 import java.io.File;
26
27
28
29
30
31 public class ArchivaJcrRepositoryConfig
32 {
33 public static RepositoryConfig create( String file, String home )
34 throws ConfigurationException
35 {
36 File homeFile = new File( home );
37 if ( !homeFile.exists( ) )
38 {
39 homeFile.mkdirs( );
40 }
41
42 File configurationFile = new File( file );
43 if ( !configurationFile.exists( ) )
44 {
45 String resourcePath = "org/apache/archiva/metadata/repository/jcr/repository.xml";
46 LoggerFactory.getLogger( ArchivaJcrRepositoryConfig.class ).info(
47 "no repository.xml file in path {} so use default from resources path {}", file, resourcePath );
48
49 return RepositoryConfig.create(
50 Thread.currentThread( ).getContextClassLoader( ).getResourceAsStream( resourcePath ), home );
51 }
52
53 return RepositoryConfig.create( file, home );
54 }
55 }