This project has retired. For details please refer to its Attic page.
ArtifactCleanupFeature xref
View Javadoc
1   package org.apache.archiva.repository.features;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.time.Period;
23  
24  /**
25   *
26   * This feature provides settings for artifact cleanup. This is meant mainly for snapshot artifacts,
27   * that should be deleted after a time period.
28   *
29   */
30  public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanupFeature> {
31  
32      private boolean deleteReleasedSnapshots = false;
33      private Period retentionPeriod = Period.ofDays(100);
34      private int retentionCount = 2;
35  
36      public ArtifactCleanupFeature() {
37  
38      }
39  
40      public ArtifactCleanupFeature( boolean deleteReleasedSnapshots, Period retentionPeriod, int retentionCount) {
41          this.deleteReleasedSnapshots = deleteReleasedSnapshots;
42          this.retentionPeriod = retentionPeriod;
43          this.retentionCount = retentionCount;
44      }
45  
46      @Override
47      public ArtifactCleanupFeature get() {
48          return this;
49      }
50  
51      /**
52       * Returns true, if snapshot artifacts should be deleted, when artifacts with release version
53       * exist in one of the managed repositories.
54       * @return True, if artifacts should be deleted after release, otherwise false.
55       */
56      public boolean isDeleteReleasedSnapshots() {
57          return deleteReleasedSnapshots;
58      }
59  
60      /**
61       * Sets the flag for the deletion of released snapshot artifacts.
62       * @param deleteReleasedSnapshots
63       */
64      public void setDeleteReleasedSnapshots(boolean deleteReleasedSnapshots) {
65          this.deleteReleasedSnapshots = deleteReleasedSnapshots;
66      }
67  
68      /**
69       * Returns the amount of time after that, the (snapshot) artifacts can be deleted.
70       *
71       * @return The time period after that the artifacts can be deleted.
72       */
73      public Period getRetentionPeriod() {
74          return retentionPeriod;
75      }
76  
77      /**
78       * Sets time period, after that artifacts can be deleted.
79       * @param retentionPeriod
80       */
81      public void setRetentionPeriod( Period retentionPeriod ) {
82          this.retentionPeriod = retentionPeriod;
83      }
84  
85      /**
86       * Sets the number of (snapshot) artifacts that should be kept, even if they are older
87       * than the retention time.
88       * @return The number of artifacts for a version that should be kept
89       */
90      public int getRetentionCount() {
91          return retentionCount;
92      }
93  
94      /**
95       * Sets the number of artifacts that should be kept and not be deleted.
96       *
97       * @param retentionCount
98       */
99      public void setRetentionCount(int retentionCount) {
100         this.retentionCount = retentionCount;
101     }
102 }