You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MavenRepositoryGroup.java 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package org.apache.archiva.repository.maven2;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.common.filelock.DefaultFileLockManager;
  21. import org.apache.archiva.common.filelock.FileLockManager;
  22. import org.apache.archiva.repository.*;
  23. import org.apache.archiva.repository.base.AbstractRepositoryGroup;
  24. import org.apache.archiva.repository.storage.FilesystemStorage;
  25. import org.apache.archiva.repository.features.IndexCreationFeature;
  26. import org.slf4j.Logger;
  27. import org.slf4j.LoggerFactory;
  28. import java.io.IOException;
  29. import java.nio.file.Path;
  30. import java.util.Locale;
  31. public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup {
  32. private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
  33. new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
  34. new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
  35. new String[] {},
  36. new String[] {IndexCreationFeature.class.getName()},
  37. false,
  38. false,
  39. false,
  40. false,
  41. false
  42. );
  43. private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
  44. private IndexCreationFeature indexCreationFeature;
  45. public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
  46. super(RepositoryType.MAVEN, id, name, storage);
  47. init();
  48. }
  49. public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
  50. super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
  51. init();
  52. }
  53. private Path getRepositoryPath() {
  54. return getStorage().getAsset("").getFilePath();
  55. }
  56. private void init() {
  57. setCapabilities(CAPABILITIES);
  58. this.indexCreationFeature = new IndexCreationFeature(this, this);
  59. addFeature( this.indexCreationFeature );
  60. }
  61. public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
  62. FileLockManager lockManager = new DefaultFileLockManager();
  63. FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
  64. return new MavenRepositoryGroup(id, name, storage);
  65. }
  66. }