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 2.9KB

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