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.

BasicRemoteRepository.java 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package org.apache.archiva.repository.base.remote;
  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. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.common.filelock.DefaultFileLockManager;
  20. import org.apache.archiva.common.filelock.FileLockManager;
  21. import org.apache.archiva.repository.ReleaseScheme;
  22. import org.apache.archiva.repository.RepositoryCapabilities;
  23. import org.apache.archiva.repository.RepositoryType;
  24. import org.apache.archiva.repository.StandardCapabilities;
  25. import org.apache.archiva.repository.storage.fs.FilesystemStorage;
  26. import org.apache.archiva.repository.storage.RepositoryStorage;
  27. import org.apache.archiva.repository.features.IndexCreationFeature;
  28. import org.apache.archiva.repository.features.RemoteIndexFeature;
  29. import org.slf4j.Logger;
  30. import org.slf4j.LoggerFactory;
  31. import java.io.IOException;
  32. import java.nio.file.Path;
  33. import java.util.Locale;
  34. /**
  35. *
  36. * Just a helper class, mainly used for unit tests.
  37. *
  38. *
  39. */
  40. public class BasicRemoteRepository extends AbstractRemoteRepository
  41. {
  42. Logger log = LoggerFactory.getLogger(BasicRemoteRepository.class);
  43. RemoteIndexFeature remoteIndexFeature = new RemoteIndexFeature();
  44. IndexCreationFeature indexCreationFeature = new IndexCreationFeature(true);
  45. static final StandardCapabilities CAPABILITIES = new StandardCapabilities( new ReleaseScheme[] {
  46. ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT
  47. }, new String[] {"default"}, new String[0], new String[] {
  48. RemoteIndexFeature.class.toString(),
  49. IndexCreationFeature.class.toString()
  50. }, true, true, true, true, true );
  51. public BasicRemoteRepository( String id, String name, RepositoryStorage storage)
  52. {
  53. super( RepositoryType.MAVEN, id, name, storage);
  54. initFeatures();
  55. }
  56. public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
  57. {
  58. super( primaryLocale, type, id, name, storage );
  59. initFeatures();
  60. }
  61. private void initFeatures() {
  62. addFeature( remoteIndexFeature );
  63. addFeature( indexCreationFeature );
  64. }
  65. @Override
  66. public boolean hasIndex( )
  67. {
  68. return true;
  69. }
  70. @Override
  71. public RepositoryCapabilities getCapabilities( )
  72. {
  73. return CAPABILITIES;
  74. }
  75. public static BasicRemoteRepository newFilesystemInstance(String id, String name, Path basePath) throws IOException {
  76. FileLockManager lockManager = new DefaultFileLockManager();
  77. FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
  78. return new BasicRemoteRepository(id, name, storage);
  79. }
  80. }