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.

ArtifactCleanupFeature.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package org.apache.archiva.repository.features;
  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 java.time.Period;
  21. /**
  22. *
  23. * This feature provides settings for artifact cleanup. This is meant mainly for snapshot artifacts,
  24. * that should be deleted after a time period.
  25. *
  26. */
  27. public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanupFeature> {
  28. private boolean deleteReleasedSnapshots = false;
  29. private Period retentionPeriod = Period.ofDays(100);
  30. private int retentionCount = 2;
  31. public ArtifactCleanupFeature() {
  32. }
  33. public ArtifactCleanupFeature( boolean deleteReleasedSnapshots, Period retentionPeriod, int retentionCount) {
  34. this.deleteReleasedSnapshots = deleteReleasedSnapshots;
  35. this.retentionPeriod = retentionPeriod;
  36. this.retentionCount = retentionCount;
  37. }
  38. /**
  39. * Returns true, if snapshot artifacts should be deleted, when artifacts with release version
  40. * exist in one of the managed repositories.
  41. * @return True, if artifacts should be deleted after release, otherwise false.
  42. */
  43. public boolean isDeleteReleasedSnapshots() {
  44. return deleteReleasedSnapshots;
  45. }
  46. /**
  47. * Sets the flag for the deletion of released snapshot artifacts.
  48. * @param deleteReleasedSnapshots
  49. */
  50. public void setDeleteReleasedSnapshots(boolean deleteReleasedSnapshots) {
  51. this.deleteReleasedSnapshots = deleteReleasedSnapshots;
  52. }
  53. /**
  54. * Returns the amount of time after that, the (snapshot) artifacts can be deleted.
  55. *
  56. * @return The time period after that the artifacts can be deleted.
  57. */
  58. public Period getRetentionPeriod() {
  59. return retentionPeriod;
  60. }
  61. /**
  62. * Sets time period, after that artifacts can be deleted.
  63. * @param retentionPeriod
  64. */
  65. public void setRetentionPeriod( Period retentionPeriod ) {
  66. this.retentionPeriod = retentionPeriod;
  67. }
  68. /**
  69. * Sets the number of (snapshot) artifacts that should be kept, even if they are older
  70. * than the retention time.
  71. * @return The number of artifacts for a version that should be kept
  72. */
  73. public int getRetentionCount() {
  74. return retentionCount;
  75. }
  76. /**
  77. * Sets the number of artifacts that should be kept and not be deleted.
  78. *
  79. * @param retentionCount
  80. */
  81. public void setRetentionCount(int retentionCount) {
  82. this.retentionCount = retentionCount;
  83. }
  84. }