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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package org.apache.archiva.repository.maven;
  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.EditableRepositoryGroup;
  23. import org.apache.archiva.repository.ReleaseScheme;
  24. import org.apache.archiva.repository.RepositoryCapabilities;
  25. import org.apache.archiva.repository.RepositoryType;
  26. import org.apache.archiva.repository.StandardCapabilities;
  27. import org.apache.archiva.repository.base.group.AbstractRepositoryGroup;
  28. import org.apache.archiva.repository.features.IndexCreationFeature;
  29. import org.apache.archiva.repository.storage.fs.FilesystemStorage;
  30. import org.slf4j.Logger;
  31. import org.slf4j.LoggerFactory;
  32. import java.io.IOException;
  33. import java.nio.file.Path;
  34. import java.util.Locale;
  35. public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup {
  36. private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
  37. new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
  38. new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
  39. new String[] {},
  40. new String[] {IndexCreationFeature.class.getName()},
  41. false,
  42. false,
  43. false,
  44. false,
  45. false
  46. );
  47. private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
  48. private IndexCreationFeature indexCreationFeature;
  49. public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
  50. super(RepositoryType.MAVEN, id, name, storage);
  51. init();
  52. }
  53. public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
  54. super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
  55. init();
  56. }
  57. private Path getRepositoryPath() {
  58. return getStorage().getRoot().getFilePath();
  59. }
  60. private void init() {
  61. setCapabilities(CAPABILITIES);
  62. this.indexCreationFeature = new IndexCreationFeature(this, this);
  63. addFeature( this.indexCreationFeature );
  64. }
  65. public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
  66. FileLockManager lockManager = new DefaultFileLockManager();
  67. FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
  68. return new MavenRepositoryGroup(id, name, storage);
  69. }
  70. }