throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Local status must be defined");
}
LocalStatus localStatus = EnumUtil.valueOf(resource.getLocalStatus(), LocalStatus.class);
if (RepositoryBaseResourceConverter.REPO_TYPE_VIRTUAL.equals(resource.getRepoType())) {
ShadowRepository shadow =
getRepositoryRegistry().getRepositoryWithFacet(repoId, ShadowRepository.class);
shadow.setLocalStatus(localStatus);
getNexusConfiguration().saveConfiguration();
result = (RepositoryStatusResourceResponse) this.get(context, request, response, null);
}
else {
Repository repository = getRepositoryRegistry().getRepository(repoId);
repository.setLocalStatus(localStatus);
if (repository.getRepositoryKind().isFacetAvailable(ProxyRepository.class)
&& resource.getProxyMode() != null) {
ProxyMode proxyMode = EnumUtil.valueOf(resource.getProxyMode(), ProxyMode.class);
repository.adaptToFacet(ProxyRepository.class).setProxyMode(proxyMode);
}
// update dependant shadows too
for (ShadowRepository shadow : getRepositoryRegistry().getRepositoriesWithFacet(
ShadowRepository.class)) {
if (repository.getId().equals(shadow.getMasterRepository().getId())) {
shadow.setLocalStatus(localStatus);
}
}
getNexusConfiguration().saveConfiguration();
result = (RepositoryStatusResourceResponse) this.get(context, request, response, null);
for (ShadowRepository shadow : getRepositoryRegistry().getRepositoriesWithFacet(
ShadowRepository.class)) {
if (repository.getId().equals(shadow.getMasterRepository().getId())) {
RepositoryDependentStatusResource dependent = new RepositoryDependentStatusResource();
dependent.setId(shadow.getId());
dependent.setRepoType(getRestRepoType(shadow));
dependent.setFormat(shadow.getRepositoryContentClass().getId());
dependent.setLocalStatus(shadow.getLocalStatus().toString());
result.getData().addDependentRepo(dependent);
}
}
}