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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package org.apache.archiva.repository;
  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.storage.FilesystemStorage;
  23. import org.apache.archiva.repository.storage.RepositoryStorage;
  24. import org.apache.archiva.repository.features.IndexCreationFeature;
  25. import org.apache.archiva.repository.features.RemoteIndexFeature;
  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. /**
  32. *
  33. * Just a helper class, mainly used for unit tests.
  34. *
  35. *
  36. */
  37. public class BasicRemoteRepository extends AbstractRemoteRepository
  38. {
  39. Logger log = LoggerFactory.getLogger(BasicRemoteRepository.class);
  40. RemoteIndexFeature remoteIndexFeature = new RemoteIndexFeature();
  41. IndexCreationFeature indexCreationFeature = new IndexCreationFeature(true);
  42. static final StandardCapabilities CAPABILITIES = new StandardCapabilities( new ReleaseScheme[] {
  43. ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT
  44. }, new String[] {"default"}, new String[0], new String[] {
  45. RemoteIndexFeature.class.toString(),
  46. IndexCreationFeature.class.toString()
  47. }, true, true, true, true, true );
  48. public BasicRemoteRepository( String id, String name, RepositoryStorage storage)
  49. {
  50. super( RepositoryType.MAVEN, id, name, storage);
  51. initFeatures();
  52. }
  53. public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
  54. {
  55. super( primaryLocale, type, id, name, storage );
  56. initFeatures();
  57. }
  58. private void initFeatures() {
  59. addFeature( remoteIndexFeature );
  60. addFeature( indexCreationFeature );
  61. }
  62. @Override
  63. public boolean hasIndex( )
  64. {
  65. return true;
  66. }
  67. @Override
  68. public RepositoryCapabilities getCapabilities( )
  69. {
  70. return CAPABILITIES;
  71. }
  72. public static BasicRemoteRepository newFilesystemInstance(String id, String name, Path basePath) throws IOException {
  73. FileLockManager lockManager = new DefaultFileLockManager();
  74. FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
  75. return new BasicRemoteRepository(id, name, storage);
  76. }
  77. }