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.

MockManagedRepositoryAdmin.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package org.apache.archiva.mock;
  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.admin.model.AuditInformation;
  21. import org.apache.archiva.admin.model.RepositoryAdminException;
  22. import org.apache.archiva.admin.model.beans.ManagedRepository;
  23. import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
  24. import org.apache.archiva.configuration.ArchivaConfiguration;
  25. import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
  26. import org.apache.commons.lang.StringUtils;
  27. import java.util.ArrayList;
  28. import java.util.List;
  29. import java.util.Locale;
  30. import java.util.Map;
  31. /**
  32. * @author Olivier Lamy
  33. */
  34. public class MockManagedRepositoryAdmin
  35. implements ManagedRepositoryAdmin
  36. {
  37. private ArchivaConfiguration archivaConfiguration;
  38. @Override
  39. public List<ManagedRepository> getManagedRepositories()
  40. throws RepositoryAdminException
  41. {
  42. List<ManagedRepositoryConfiguration> managedRepoConfigs =
  43. getArchivaConfiguration().getConfiguration().getManagedRepositories();
  44. List<ManagedRepository> managedRepos = new ArrayList<>( managedRepoConfigs.size() );
  45. for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
  46. {
  47. // TODO add staging repo information back too
  48. ManagedRepository repo =
  49. new ManagedRepository( Locale.getDefault( ), repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
  50. repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
  51. repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
  52. repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getRetentionPeriod(),
  53. repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), true );
  54. managedRepos.add( repo );
  55. }
  56. return managedRepos;
  57. }
  58. @Override
  59. public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
  60. throws RepositoryAdminException
  61. {
  62. return null;
  63. }
  64. @Override
  65. public ManagedRepository getManagedRepository( String repositoryId )
  66. throws RepositoryAdminException
  67. {
  68. List<ManagedRepository> repos = getManagedRepositories();
  69. for ( ManagedRepository repo : repos )
  70. {
  71. if ( StringUtils.equals( repo.getId(), repositoryId ) )
  72. {
  73. return repo;
  74. }
  75. }
  76. return null;
  77. }
  78. @Override
  79. public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
  80. boolean deleteContent )
  81. throws RepositoryAdminException
  82. {
  83. return null;
  84. }
  85. @Override
  86. public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
  87. AuditInformation auditInformation )
  88. throws RepositoryAdminException
  89. {
  90. return null;
  91. }
  92. @Override
  93. public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
  94. AuditInformation auditInformation, boolean resetStats )
  95. throws RepositoryAdminException
  96. {
  97. return null;
  98. }
  99. public ArchivaConfiguration getArchivaConfiguration()
  100. {
  101. return archivaConfiguration;
  102. }
  103. public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
  104. {
  105. this.archivaConfiguration = archivaConfiguration;
  106. }
  107. }