use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultArchivaAdministration method addFileTypePattern.
@Override
public void addFileTypePattern(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;
}
if (fileType.getPatterns().contains(pattern)) {
throw new RepositoryAdminException("File type [" + fileTypeId + "] already contains pattern [" + pattern + "]");
}
fileType.addPattern(pattern);
saveConfiguration(configuration);
triggerAuditEvent("", "", AuditEvent.ADD_PATTERN, auditInformation);
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultRepositoryGroupAdmin method addRepositoryToGroup.
@Override
public Boolean addRepositoryToGroup(String repositoryGroupId, String repositoryId, AuditInformation auditInformation) throws RepositoryAdminException {
RepositoryGroup repositoryGroup = getRepositoryGroup(repositoryGroupId);
if (repositoryGroup == null) {
throw new RepositoryAdminException("repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot add repository to it");
}
if (repositoryGroup.getRepositories().contains(repositoryId)) {
throw new RepositoryAdminException("repositoryGroup with id " + repositoryGroupId + " already contain repository with id" + repositoryId);
}
validateManagedRepositoriesExists(Arrays.asList(repositoryId));
repositoryGroup.addRepository(repositoryId);
updateRepositoryGroup(repositoryGroup, auditInformation, false);
triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.ADD_REPO_TO_GROUP, auditInformation);
return Boolean.TRUE;
}
use of org.apache.archiva.admin.model.RepositoryAdminException 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;
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultNetworkProxyAdmin method addNetworkProxy.
@Override
public void addNetworkProxy(NetworkProxy networkProxy, AuditInformation auditInformation) throws RepositoryAdminException {
if (networkProxy == null) {
return;
}
if (getNetworkProxy(networkProxy.getId()) != null) {
throw new RepositoryAdminException("cannot add NetworkProxy with id " + networkProxy.getId() + " already exist");
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addNetworkProxy(getNetworkProxyConfiguration(networkProxy));
triggerAuditEvent(networkProxy.getId(), null, AuditEvent.ADD_NETWORK_PROXY, auditInformation);
saveConfiguration(configuration);
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultNetworkProxyAdmin method updateNetworkProxy.
@Override
public void updateNetworkProxy(NetworkProxy networkProxy, AuditInformation auditInformation) throws RepositoryAdminException {
if (networkProxy == null) {
return;
}
if (getNetworkProxy(networkProxy.getId()) == null) {
throw new RepositoryAdminException("cannot update NetworkProxy with id " + networkProxy.getId() + " as not exist");
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration(networkProxy);
configuration.removeNetworkProxy(networkProxyConfiguration);
configuration.addNetworkProxy(networkProxyConfiguration);
triggerAuditEvent(networkProxy.getId(), null, AuditEvent.MODIFY_NETWORK_PROXY, auditInformation);
saveConfiguration(configuration);
}
Aggregations