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

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