use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultArchivaAdministration method addLegacyArtifactPath.
@Override
public void addLegacyArtifactPath(LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addLegacyArtifactPath(getModelMapper().map(legacyArtifactPath, org.apache.archiva.configuration.LegacyArtifactPath.class));
saveConfiguration(configuration);
triggerAuditEvent("", "", AuditEvent.ADD_LEGACY_PATH, auditInformation);
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultArchivaAdministration method addInvalidContentConsumer.
@Override
public void addInvalidContentConsumer(String invalidContentConsumer, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
if (configuration.getRepositoryScanning().getInvalidContentConsumers().contains(invalidContentConsumer)) {
log.warn("skip adding invalidContentConsumer {} as already here", invalidContentConsumer);
return;
}
configuration.getRepositoryScanning().addInvalidContentConsumer(invalidContentConsumer);
saveConfiguration(configuration);
triggerAuditEvent("", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation);
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultArchivaAdministration method removeFileTypePattern.
@Override
public void removeFileTypePattern(String fileTypeId, String pattern, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
org.apache.archiva.configuration.FileType fileType = getFileTypeById(fileTypeId, configuration);
if (fileType == null) {
return;
}
fileType.removePattern(pattern);
saveConfiguration(configuration);
triggerAuditEvent("", "", AuditEvent.REMOVE_PATTERN, auditInformation);
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRepositoryGroupAdmin method addRepositoryGroup.
@Override
public Boolean addRepositoryGroup(RepositoryGroup repositoryGroup, AuditInformation auditInformation) throws RepositoryAdminException {
validateRepositoryGroup(repositoryGroup, false);
validateManagedRepositoriesExists(repositoryGroup.getRepositories());
RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
repositoryGroupConfiguration.setId(repositoryGroup.getId());
repositoryGroupConfiguration.setRepositories(repositoryGroup.getRepositories());
repositoryGroupConfiguration.setMergedIndexPath(repositoryGroup.getMergedIndexPath());
repositoryGroupConfiguration.setMergedIndexTtl(repositoryGroup.getMergedIndexTtl());
repositoryGroupConfiguration.setCronExpression(repositoryGroup.getCronExpression());
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addRepositoryGroup(repositoryGroupConfiguration);
saveConfiguration(configuration);
triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation);
mergedRemoteIndexesScheduler.schedule(repositoryGroup, getMergedIndexDirectory(repositoryGroup.getId()));
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRepositoryGroupAdmin method validateRepositoryGroup.
public Boolean validateRepositoryGroup(RepositoryGroup repositoryGroup, boolean updateMode) throws RepositoryAdminException {
String repoGroupId = repositoryGroup.getId();
if (StringUtils.isBlank(repoGroupId)) {
throw new RepositoryAdminException("repositoryGroup id cannot be empty");
}
if (repoGroupId.length() > 100) {
throw new RepositoryAdminException("Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters");
}
Matcher matcher = REPO_GROUP_ID_PATTERN.matcher(repoGroupId);
if (!matcher.matches()) {
throw new RepositoryAdminException("Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'");
}
if (repositoryGroup.getMergedIndexTtl() <= 0) {
throw new RepositoryAdminException("Merged Index TTL must be greater than 0.");
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
if (configuration.getRepositoryGroupsAsMap().containsKey(repoGroupId)) {
if (!updateMode) {
throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a repository group.");
}
} else if (configuration.getManagedRepositoriesAsMap().containsKey(repoGroupId)) {
throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a managed repository.");
} else if (configuration.getRemoteRepositoriesAsMap().containsKey(repoGroupId)) {
throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a remote repository.");
}
return Boolean.TRUE;
}
Aggregations