1package org.apache.archiva.metadata.repository.jcr;
2/*3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 */2021import org.apache.jackrabbit.core.config.ConfigurationException;
22import org.apache.jackrabbit.core.config.RepositoryConfig;
23import org.slf4j.LoggerFactory;
2425import java.io.File;
2627/**28 * @author Olivier Lamy29 * @since 1.4-M130 */31publicclassArchivaJcrRepositoryConfig32 {
33publicstatic RepositoryConfig create( String file, String home )
34throws ConfigurationException
35 {
36 File homeFile = new File( home );
37if ( !homeFile.exists( ) )
38 {
39 homeFile.mkdirs( );
40 }
4142 File configurationFile = new File( file );
43if ( !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// use bundled repository.xml49return RepositoryConfig.create(
50 Thread.currentThread( ).getContextClassLoader( ).getResourceAsStream( resourcePath ), home );
51 }
5253return RepositoryConfig.create( file, home );
54 }
55 }