Adding interfaces for managed and remote repositories. Features that may not be common for repository implementations use the RepositoryFeature interface.pull/46/head
@@ -0,0 +1,40 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* Represents a managed repository, that is readable and writable. | |||
*/ | |||
public interface ManagedRepository extends Repository { | |||
/** | |||
* Returns the interface to access the contents of this repository. | |||
* | |||
* @return The repository content. | |||
*/ | |||
ManagedRepositoryContent getContent(); | |||
/** | |||
* Returns true, if repeated deployments of the same artifact with the same version throws exceptions. | |||
* @return | |||
*/ | |||
boolean blocksRedeployments(); | |||
} |
@@ -0,0 +1,27 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* Repository release schemes that change the handling of artifacts | |||
*/ | |||
public enum ReleaseScheme { | |||
RELEASE,SNAPSHOT | |||
} |
@@ -0,0 +1,141 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.time.Duration; | |||
import java.util.Map; | |||
/** | |||
* This represents a repository that is not fully managed by archiva. Its some kind of proxy that | |||
* forwards requests to the remote repository and is able to cache artifacts locally. | |||
*/ | |||
public interface RemoteRepository extends Repository { | |||
/** | |||
* Returns the interface to access the content of the repository. | |||
* @return | |||
*/ | |||
RemoteRepositoryContent getContent(); | |||
/** | |||
* Returns the credentials used to login to the remote repository. | |||
* @return the credentials, null if not set. | |||
*/ | |||
RepositoryCredentials getLoginCredentials(); | |||
/** | |||
* Sets the login credentials for login to the remote repository. | |||
* @param credentials | |||
*/ | |||
void setCredentials(RepositoryCredentials credentials); | |||
/** | |||
* Returns the path relative to the root url of the repository that should be used | |||
* to check the availability of the repository. | |||
* @return The check path, null if not set. | |||
*/ | |||
String getCheckPath(); | |||
/** | |||
* Sets the path relative to the root url of the repository that should be used to check | |||
* the availability of the repository. | |||
* | |||
* @param path The path string. | |||
*/ | |||
void setCheckPath(String path); | |||
/** | |||
* Returns additional parameters, that are used for accessing the remote repository. | |||
* @return A map of key, value pairs. | |||
*/ | |||
Map<String,String> getExtraParameters(); | |||
/** | |||
* Sets additional parameters to be used to access the remote repository. | |||
* @param params A map of parameters, may not be null. | |||
*/ | |||
void setExtraParameters(Map<String,String> params); | |||
/** | |||
* Adds an additional parameter. | |||
* @param key The key of the parameter | |||
* @param value The value of the parameter | |||
*/ | |||
void addExtraParameter(String key, String value); | |||
/** | |||
* Returns extra headers that are added to the request to the remote repository. | |||
* @return | |||
*/ | |||
Map<String,String> getExtraHeaders(); | |||
/** | |||
* Sets the extra headers, that are added to the requests to the remote repository. | |||
*/ | |||
void setExtraHeaders(Map<String,String> headers); | |||
/** | |||
* Adds an extra header. | |||
* @param header The header name | |||
* @param value The header value | |||
*/ | |||
void addExtraHeader(String header, String value); | |||
/** | |||
* Returns the time duration, after that the request is aborted and a error is returned, if the remote repository | |||
* does not respond. | |||
* @return The timeout. | |||
*/ | |||
Duration getTimeout(); | |||
/** | |||
* Sets the timeout for requests to the remote repository. | |||
* | |||
* @param duration The amount of time, after that the request is aborted. | |||
*/ | |||
void setTimeout(Duration duration); | |||
/** | |||
* Returns the time duration after that downloads from the remote repository are aborted. | |||
* @return | |||
*/ | |||
Duration getDownloadTimeout(); | |||
/** | |||
* Sets the maximum duration for downloads from the remote repository. | |||
* | |||
* @param duration The amount of time after that a download is aborted. | |||
*/ | |||
void setDownloadTimeout(Duration duration); | |||
/** | |||
* Returns the id of the proxy, that is used for accessing the remote repository. | |||
* @return The proxy id. | |||
*/ | |||
String getProxyId(); | |||
/** | |||
* Sets the proxy id that is used for requests to the remote repository. | |||
* | |||
* @param proxyId The id of the proxy. | |||
*/ | |||
void setProxyId(String proxyId); | |||
} |
@@ -0,0 +1,163 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.repository.features.RepositoryFeature; | |||
import java.net.URI; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.Set; | |||
/** | |||
* | |||
* Base interface for repositories. | |||
* | |||
* Created by Martin Stockhammer on 21.09.17. | |||
*/ | |||
public interface Repository { | |||
/** | |||
* Return the identifier of the repository. Repository identifier should be unique at least | |||
* for the same type. | |||
* @return The identifier. | |||
*/ | |||
String getId(); | |||
/** | |||
* This is the display name of the repository. This string is presented in the user interface. | |||
* | |||
* @return The display name of the repository | |||
*/ | |||
String getName(); | |||
/** | |||
* Returns the name in the given locale. | |||
* @param locale | |||
* @return | |||
*/ | |||
String getName(Locale locale); | |||
/** | |||
* Returns a description of this repository. | |||
* @return The description. | |||
*/ | |||
String getDescription(); | |||
/** | |||
* Returns the description for the given locale. | |||
* @param locale | |||
* @return | |||
*/ | |||
String getDescription(Locale locale); | |||
/** | |||
* This identifies the type of repository. Archiva does only support certain types of repositories. | |||
* | |||
* @return A unique identifier for the repository type. | |||
*/ | |||
RepositoryType getType(); | |||
/** | |||
* Returns the location of this repository. For local repositories this might be a file URI, for | |||
* remote repositories a http URL or some very repository specific schemes. | |||
* Each repository has only one unique location. | |||
* | |||
* @return The repository location. | |||
*/ | |||
URI getLocation(); | |||
/** | |||
* A repository may allow additional locations that can be used, if the primary location is not available. | |||
* @return | |||
*/ | |||
Set<URI> getFailoverLocations(); | |||
/** | |||
* True, if this repository is scanned regularly. | |||
*/ | |||
boolean isScanned(); | |||
/** | |||
* The definition when the scheduler should run to scan this repository. | |||
* @return | |||
*/ | |||
List<ScheduleDefinition> getSchedulingTimes(); | |||
/** | |||
* Returns true, if this repository has a index available | |||
* @return | |||
*/ | |||
boolean hasIndex(); | |||
/** | |||
* Returns the path to the index parent folder. May be a HTTP URL or a file path. | |||
* @return | |||
*/ | |||
URI getIndexPath(); | |||
/** | |||
* Returns a layout definition. The returned string may be implementation specific and is not | |||
* standardized. | |||
* | |||
* @return | |||
*/ | |||
String getLayout(); | |||
/** | |||
* Returns the release schemes that are active by this repository. E.g. for maven repositories | |||
* this may either be a release repository, a snapshot repository or a combined repository. | |||
* @return | |||
*/ | |||
Set<ReleaseScheme> getActiveReleaseSchemes(); | |||
/** | |||
* Returns the capabilities of the repository implementation. | |||
* @return | |||
*/ | |||
RepositoryCapabilities getCapabilities(); | |||
/** | |||
* Extension method that allows to provide different features that are not supported by all | |||
* repository types. | |||
* | |||
* @param clazz The feature class that is requested | |||
* @param <T> This is the class of the feature | |||
* @return The feature implementation for this repository instance, if it is supported | |||
* @throws UnsupportedFeatureException if the feature is not supported by this repository type | |||
*/ | |||
<T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature(Class<T> clazz) throws UnsupportedFeatureException; | |||
/** | |||
* Returns true, if the requested feature is supported by this repository. | |||
* | |||
* @param clazz The requested feature class | |||
* @param <T> The requested feature class | |||
* @return True, if the feature is supported, otherwise false. | |||
*/ | |||
<T extends RepositoryFeature<T>> boolean supportsFeature(Class<T> clazz); | |||
} |
@@ -0,0 +1,99 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Set; | |||
/** | |||
* Describe the capabilities a repository implementation supports. | |||
*/ | |||
public interface RepositoryCapabilities { | |||
/** | |||
* Returns true, if this repository has a mechanism for indexes | |||
* @return true, if this repository is indexable, otherwise false. | |||
*/ | |||
default boolean isIndexable() { | |||
return true; | |||
} | |||
/** | |||
* Returns true, if this repository type is storing its artifacts on the filesystem. | |||
* @return true, if this is a file based repository, otherwise false. | |||
*/ | |||
default boolean isFileBased() { | |||
return true; | |||
} | |||
/** | |||
* Returns true, if this repository allows to block redeployments to prevent overriding | |||
* released artifacts | |||
* @return true, if this repo can block redeployments, otherwise false. | |||
*/ | |||
default boolean canBlockRedeployments() { | |||
return true; | |||
} | |||
/** | |||
* Returns true, if the artifacts can be scanned for metadata retrieval or maintenance tasks | |||
* @return true, if this repository can be scanned regularily, otherwise false. | |||
*/ | |||
default boolean isScannable() { | |||
return true; | |||
} | |||
/** | |||
* Returns true, if this repository can use failover repository urls | |||
* @return true, if there is a failover mechanism for repository access, otherwise false. | |||
*/ | |||
default boolean allowsFailover() { | |||
return false; | |||
} | |||
/** | |||
* Returns the release schemes this repository type can handle | |||
*/ | |||
Set<ReleaseScheme> supportedReleaseSchemes(); | |||
/** | |||
* Returns the layouts this repository type can provide | |||
* @return The list of layouts supported by this repository. | |||
*/ | |||
Set<String> supportedLayouts(); | |||
/** | |||
* Returns additional capabilities, that this repository type implements. | |||
* @return A list of custom capabilities. | |||
*/ | |||
Set<String> customCapabilities(); | |||
/** | |||
* Returns the supported features this repository type supports. This method returns | |||
* string that corresponds to fully qualified class names. | |||
* We use string representation to allow implementations provide their own feature | |||
* implementations if necessary and to avoid class errors. | |||
* | |||
* @return The list of supported features as string values. | |||
*/ | |||
Set<String> supportedFeatures(); | |||
} |
@@ -0,0 +1,27 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* Credentials used to login to a remote repository. | |||
*/ | |||
public interface RepositoryCredentials { | |||
} |
@@ -0,0 +1,29 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* The repository types that are known to the system. | |||
*/ | |||
public enum RepositoryType { | |||
MAVEN, NPM | |||
} |
@@ -0,0 +1,109 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.time.*; | |||
import java.util.Collection; | |||
import java.util.SortedSet; | |||
import java.util.TreeSet; | |||
/** | |||
* A definition of schedule times. | |||
*/ | |||
public class ScheduleDefinition { | |||
final SortedSet<DayOfWeek> daysOfWeek = new TreeSet<>(); | |||
final SortedSet<MonthDay> daysOfMonth = new TreeSet<>(); | |||
final SortedSet<LocalTime> scheduleTimes = new TreeSet<>(); | |||
final LocalTime startTime; | |||
final Duration timeInterval; | |||
boolean fixedTimes = false; | |||
public ScheduleDefinition(Collection<DayOfWeek> daysOfWeek, | |||
Collection<MonthDay> daysOfMonth, | |||
Collection<LocalTime> scheduleTimes, | |||
LocalTime startTime, Duration timeInterval) { | |||
if (daysOfWeek!=null) | |||
this.daysOfWeek.addAll(daysOfWeek); | |||
if (daysOfMonth!=null) | |||
this.daysOfMonth.addAll(daysOfMonth); | |||
if (scheduleTimes!=null) | |||
this.scheduleTimes.addAll(scheduleTimes); | |||
this.startTime = startTime; | |||
this.timeInterval = timeInterval; | |||
} | |||
/** | |||
* Returns the days of the week on which the action should be run. | |||
* @return The set of week days. | |||
*/ | |||
public SortedSet<DayOfWeek> getDaysOfWeek() { | |||
return daysOfWeek; | |||
} | |||
/** | |||
* Returns the days in the month on which the action should be run. | |||
* @return The set of days. | |||
*/ | |||
public SortedSet<MonthDay> getDaysOfMonth() { | |||
return daysOfMonth; | |||
} | |||
/** | |||
* Returns the time on each day on which the action should be run. | |||
* @return a set of times on which the action should be run. | |||
*/ | |||
public SortedSet<LocalTime> getScheduleTimes() { | |||
return scheduleTimes; | |||
} | |||
/** | |||
* Returns the start time each day on which the action should be run. | |||
* @return the start time. | |||
*/ | |||
public LocalTime getStartTime() { | |||
return startTime; | |||
} | |||
/** | |||
* The interval after that the next run should be scheduled. | |||
* @return The interval between runs. | |||
*/ | |||
public Duration getTimeInterval() { | |||
return timeInterval; | |||
} | |||
/** | |||
* Returns true, if the task should be run on fixed times. Otherwise | |||
* the tasks are scheduled repeatedly with the time interval. | |||
* @return true, if the schedule times are fixed. | |||
*/ | |||
public boolean isFixedTimes() { | |||
return fixedTimes; | |||
}; | |||
} |
@@ -0,0 +1,46 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* This exception is thrown if a given feature is not supported by the repository. | |||
* | |||
*/ | |||
public class UnsupportedFeatureException extends Exception { | |||
public UnsupportedFeatureException() { | |||
} | |||
public UnsupportedFeatureException(String message) { | |||
super(message); | |||
} | |||
public UnsupportedFeatureException(String message, Throwable cause) { | |||
super(message, cause); | |||
} | |||
public UnsupportedFeatureException(Throwable cause) { | |||
super(cause); | |||
} | |||
public UnsupportedFeatureException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | |||
super(message, cause, enableSuppression, writableStackTrace); | |||
} | |||
} |
@@ -0,0 +1,98 @@ | |||
package org.apache.archiva.repository.features; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.time.Period; | |||
/** | |||
* | |||
* This feature provides settings for artifact cleanup. This is meant mainly for snapshot artifacts, | |||
* that should be deleted after a time period. | |||
* | |||
*/ | |||
public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanupFeature> { | |||
private boolean deleteReleasedSnapshots = false; | |||
private Period retentionTime = Period.ofDays(100); | |||
private int retentionCount = 2; | |||
public ArtifactCleanupFeature(boolean deleteReleasedSnapshots, Period retentionTime, int retentionCount) { | |||
this.deleteReleasedSnapshots = deleteReleasedSnapshots; | |||
this.retentionTime = retentionTime; | |||
this.retentionCount = retentionCount; | |||
} | |||
@Override | |||
public ArtifactCleanupFeature getFeature() { | |||
return this; | |||
} | |||
/** | |||
* Returns true, if snapshot artifacts should be deleted, when artifacts with release version | |||
* exist in one of the managed repositories. | |||
* @return True, if artifacts should be deleted after release, otherwise false. | |||
*/ | |||
public boolean isDeleteReleasedSnapshots() { | |||
return deleteReleasedSnapshots; | |||
} | |||
/** | |||
* Sets the flag for the deletion of released snapshot artifacts. | |||
* @param deleteReleasedSnapshots | |||
*/ | |||
public void setDeleteReleasedSnapshots(boolean deleteReleasedSnapshots) { | |||
this.deleteReleasedSnapshots = deleteReleasedSnapshots; | |||
} | |||
/** | |||
* Returns the amount of time after that, the (snapshot) artifacts can be deleted. | |||
* | |||
* @return The time period after that the artifacts can be deleted. | |||
*/ | |||
public Period getRetentionTime() { | |||
return retentionTime; | |||
} | |||
/** | |||
* Sets time period, after that artifacts can be deleted. | |||
* @param retentionTime | |||
*/ | |||
public void setRetentionTime(Period retentionTime) { | |||
this.retentionTime = retentionTime; | |||
} | |||
/** | |||
* Sets the number of (snapshot) artifacts that should be kept, even if they are older | |||
* than the retention time. | |||
* @return The number of artifacts for a version that should be kept | |||
*/ | |||
public int getRetentionCount() { | |||
return retentionCount; | |||
} | |||
/** | |||
* Sets the number of artifacts that should be kept and not be deleted. | |||
* | |||
* @param retentionCount | |||
*/ | |||
public void setRetentionCount(int retentionCount) { | |||
this.retentionCount = retentionCount; | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
package org.apache.archiva.repository.features; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* | |||
* This feature provides some information about index creation. | |||
* | |||
*/ | |||
public class IndexCreationFeature implements RepositoryFeature<IndexCreationFeature> { | |||
private boolean skipPackedIndexCreation = false; | |||
public IndexCreationFeature(boolean skipPackedIndexCreation) { | |||
this.skipPackedIndexCreation = skipPackedIndexCreation; | |||
} | |||
@Override | |||
public IndexCreationFeature getFeature() { | |||
return this; | |||
} | |||
/** | |||
* Returns true, if no packed index files should be created. | |||
* @return True, if no packed index files are created, otherwise false. | |||
*/ | |||
public boolean isSkipPackedIndexCreation() { | |||
return skipPackedIndexCreation; | |||
} | |||
/** | |||
* Sets the flag for packed index creation. | |||
* | |||
* @param skipPackedIndexCreation | |||
*/ | |||
public void setSkipPackedIndexCreation(boolean skipPackedIndexCreation) { | |||
this.skipPackedIndexCreation = skipPackedIndexCreation; | |||
} | |||
} |
@@ -0,0 +1,88 @@ | |||
package org.apache.archiva.repository.features; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.net.URI; | |||
/** | |||
* Feature for remote index download. | |||
*/ | |||
public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature> { | |||
private boolean downloadRemoteIndex = false; | |||
private URI indexUri; | |||
private boolean downloadRemoteIndexOnStartup = false; | |||
@Override | |||
public RemoteIndexFeature getFeature() { | |||
return this; | |||
} | |||
/** | |||
* True, if the remote index should be downloaded. | |||
* @return True if download, otherwise false. | |||
*/ | |||
public boolean isDownloadRemoteIndex() { | |||
return downloadRemoteIndex; | |||
} | |||
public void setDownloadRemoteIndex(boolean downloadRemoteIndex) { | |||
this.downloadRemoteIndex = downloadRemoteIndex; | |||
} | |||
/** | |||
* The URI to access the remote index. May be a relative URI that is relative to the | |||
* repository URI. | |||
* | |||
* @return | |||
*/ | |||
public URI getIndexUri() { | |||
return indexUri; | |||
} | |||
/** | |||
* Sets the URI to access the remote index. May be a relative URI that is relative to the | |||
* repository URI. The allowed URI schemes are dependent on the repository type. | |||
* | |||
* @param indexUri The URI of the index | |||
*/ | |||
public void setIndexUri(URI indexUri) { | |||
this.indexUri = indexUri; | |||
} | |||
/** | |||
* Returns true, if the remote index should be downloaded on startup of the repository. | |||
* @return true, if the index should be downloaded during startup, otherwise false. | |||
*/ | |||
public boolean isDownloadRemoteIndexOnStartup() { | |||
return downloadRemoteIndexOnStartup; | |||
} | |||
/** | |||
* Sets the flag for download of the remote repository index. | |||
* | |||
* @param downloadRemoteIndexOnStartup | |||
*/ | |||
public void setDownloadRemoteIndexOnStartup(boolean downloadRemoteIndexOnStartup) { | |||
this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup; | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
package org.apache.archiva.repository.features; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* Created by martin on 30.09.17. | |||
*/ | |||
public interface RepositoryFeature<T extends RepositoryFeature<T>> { | |||
default String getId() { | |||
return this.getClass().getName(); | |||
} | |||
default boolean isFeature(String featureId) { | |||
return this.getClass().getName().equals(featureId); | |||
} | |||
default <K extends RepositoryFeature<K>> boolean isFeature(Class<K> clazz) { | |||
return this.getClass().equals(clazz); | |||
} | |||
T getFeature(); | |||
} |
@@ -0,0 +1,79 @@ | |||
package org.apache.archiva.repository.features; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.repository.ManagedRepository; | |||
/** | |||
* This feature provides some information about staging repositories. | |||
* | |||
*/ | |||
public class StagingRepositoryFeature implements RepositoryFeature<StagingRepositoryFeature> { | |||
private ManagedRepository stagingRepository = null; | |||
private boolean stageRepoNeeded = false; | |||
public StagingRepositoryFeature(ManagedRepository stagingRepository, boolean stageRepoNeeded) { | |||
this.stagingRepository = stagingRepository; | |||
this.stageRepoNeeded = stageRepoNeeded; | |||
} | |||
@Override | |||
public StagingRepositoryFeature getFeature() { | |||
return this; | |||
} | |||
/** | |||
* Returns the staging repository, if it exists. | |||
* | |||
* @return The staging repository, null if not set. | |||
* | |||
*/ | |||
public ManagedRepository getStagingRepository() { | |||
return stagingRepository; | |||
} | |||
/** | |||
* Sets the staging repository. | |||
* | |||
* @param stagingRepository | |||
*/ | |||
public void setStagingRepository(ManagedRepository stagingRepository) { | |||
this.stagingRepository = stagingRepository; | |||
} | |||
/** | |||
* Returns true, if a staging repository is needed by this repository. | |||
* @return True, if staging repository is needed, otherwise false. | |||
*/ | |||
public boolean isStageRepoNeeded() { | |||
return stageRepoNeeded; | |||
} | |||
/** | |||
* Sets the flag for needed staging repository. | |||
* | |||
* @param stageRepoNeeded | |||
*/ | |||
public void setStageRepoNeeded(boolean stageRepoNeeded) { | |||
this.stageRepoNeeded = stageRepoNeeded; | |||
} | |||
} |