// ==
@Override
public RoutingStatus getStatusFor(final MavenRepository mavenRepository) {
final MavenProxyRepository mavenProxyRepository = mavenRepository.adaptToFacet(MavenProxyRepository.class);
final boolean remoteDiscoveryEnabled;
if (mavenProxyRepository != null) {
final DiscoveryConfig discoveryConfig = getRemoteDiscoveryConfig(mavenProxyRepository);
remoteDiscoveryEnabled = discoveryConfig.isEnabled();
}
else {
remoteDiscoveryEnabled = false;
}
PublishingStatus publishingStatus = null;
DiscoveryStatus discoveryStatus = null;
// publish status
final FilePrefixSource publishedEntrySource = getPrefixSourceFor(mavenRepository);
if (!publishedEntrySource.supported()) {
final String message;
if (isMavenRepositorySupported(mavenRepository)) {
if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenGroupRepository.class)) {
final MavenGroupRepository mavenGroupRepository =
mavenRepository.adaptToFacet(MavenGroupRepository.class);
final List<String> membersWithoutPrefixFiles = new ArrayList<String>();
for (Repository member : mavenGroupRepository.getMemberRepositories()) {
final MavenRepository memberMavenRepository = member.adaptToFacet(MavenRepository.class);
if (null != memberMavenRepository) {
final PrefixSource ps = getPrefixSourceFor(memberMavenRepository);
if (!ps.supported()) {
membersWithoutPrefixFiles.add(memberMavenRepository.getName());
}
}
}
message =
"Publishing not possible, following members have no published prefix file: "
+ Joiner.on(", ").join(membersWithoutPrefixFiles);
}
else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) {
if (remoteDiscoveryEnabled) {
message = "Discovery in progress or unable to discover remote content (see discovery status).";
}
else {
message = "Remote discovery not enabled.";
}
}
else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenHostedRepository.class)) {
message = "Check Nexus logs for more details."; // hosted reposes must be discovered always
}
else if (mavenRepository.getRepositoryKind().isFacetAvailable(ShadowRepository.class)) {
message = "Unsupported repository type (only hosted, proxy and groups are supported).";
}
else {
message = "Check Nexus logs for more details.";
}
}
else {
message = "Unsupported repository format (only Maven2 format is supported).";
}
publishingStatus = new PublishingStatus(PStatus.NOT_PUBLISHED, message, -1, null);
}
else {
publishingStatus =
new PublishingStatus(PStatus.PUBLISHED, "Prefix file published successfully.",
publishedEntrySource.getLostModifiedTimestamp(), publishedEntrySource.getFilePath());
}
if (mavenProxyRepository == null) {
discoveryStatus = new DiscoveryStatus(DStatus.NOT_A_PROXY);
}
else {
if (!remoteDiscoveryEnabled) {
discoveryStatus = new DiscoveryStatus(DStatus.DISABLED);
}
else if (constrainedExecutor.hasRunningWithKey(mavenProxyRepository.getId())) {
// still running or never run yet
discoveryStatus = new DiscoveryStatus(DStatus.ENABLED_IN_PROGRESS);
}
else {
final PropfileDiscoveryStatusSource discoveryStatusSource =
new PropfileDiscoveryStatusSource(mavenProxyRepository);
if (!discoveryStatusSource.exists()) {
if (!mavenProxyRepository.getLocalStatus().shouldServiceRequest()) {
// should run but not yet scheduled, or never run yet
// out of service prevents us to persist ending states, so this
// is the only place where we actually "calculate" it
discoveryStatus =
new DiscoveryStatus(DStatus.ENABLED_NOT_POSSIBLE, "none",