public ValidationResponse validateModel(ValidationRequest request) {
ValidationResponse response = new ApplicationValidationResponse();
response.setContext(new ApplicationValidationContext());
Configuration model = (Configuration) request.getConfiguration();
ApplicationValidationContext context = (ApplicationValidationContext) response.getContext();
response.setContext(context);
// global conn settings
if (model.getGlobalConnectionSettings() != null) {
response.append(validateRemoteConnectionSettings(context, model.getGlobalConnectionSettings()));
}
else {
model.setGlobalConnectionSettings(new CRemoteConnectionSettings());
response
.addValidationWarning(
"Global connection settings block, which is mandatory, was missing. Reset with defaults.");
response.setModified(true);
}
// remote proxy settings (optional)
final CRemoteProxySettings rps = model.getRemoteProxySettings();
if (rps != null) {
if (rps.getHttpProxySettings() != null) {
response.append(validateRemoteHttpProxySettings(context, rps.getHttpProxySettings()));
}
if (rps.getHttpsProxySettings() != null) {
response.append(validateRemoteHttpProxySettings(context, rps.getHttpsProxySettings()));
}
}
// rest api
if (model.getRestApi() != null) {
response.append(validateRestApiSettings(context, model.getRestApi()));
}
// nexus built-in http proxy
if (model.getHttpProxy() != null) {
response.append(validateHttpProxySettings(context, model.getHttpProxy()));
}
else {
model.setHttpProxy(new CHttpProxySettings());
response.addValidationWarning("The HTTP Proxy section was missing from configuration, defaulted it.");
response.setModified(true);
}
// routing
if (model.getRouting() != null) {
response.append(validateRouting(context, model.getRouting()));
}
else {
model.setRouting(new CRouting());
response.addValidationWarning("The routing section was missing from configuration, defaulted it.");
response.setModified(true);
}
// check existing reposes and check their realms
context.addExistingRepositoryIds();
List<CRepository> reposes = model.getRepositories();
for (CRepository repo : reposes) {
response.append(validateRepository(context, repo));
}
// check groups (optional section)
if (model.getRepositoryGrouping() != null) {
response.append(validateRepositoryGrouping(context, model.getRepositoryGrouping()));
}
// check remote nexus instances (optional section)
if (model.getRemoteNexusInstances() != null) {
List<CRemoteNexusInstance> instances = model.getRemoteNexusInstances();
for (CRemoteNexusInstance instance : instances) {
response.append(validateRemoteNexusInstance(context, instance));
}
}
// check repo targets (optional section)
if (model.getRepositoryTargets() != null) {
List<CRepositoryTarget> targets = model.getRepositoryTargets();
for (CRepositoryTarget target : targets) {
response.append(validateRepositoryTarget(context, target));
}
}
// check tasks (optional section)
if (model.getTasks() != null) {
List<CScheduledTask> tasks = model.getTasks();
for (CScheduledTask task : tasks) {
response.append(validateScheduledTask(context, task));
}
}
response.append(validateSmtpConfiguration(context, model.getSmtpConfiguration()));
return response;
}