@Subscribe public void on(final NexusStoppedEvent e) { inspect(e); }
protected String buildLink(NexusArtifactEvent event) { return "content/repositories/" + event.getNexusItemInfo().getRepositoryId() + event.getNexusItemInfo().getPath(); }
private String buildFilePath(NexusArtifactEvent event) { return event.getNexusItemInfo().getPath(); }
@Subscribe @AllowConcurrentEvents public void inspect(final RepositoryItemValidationEventFailed ievt) { final NexusItemInfo ai = new NexusItemInfo(); ai.setRepositoryId(ievt.getItem().getRepositoryId()); ai.setPath(ievt.getItem().getPath()); ai.setRemoteUrl(ievt.getItem().getRemoteUrl()); String action = NexusArtifactEvent.ACTION_BROKEN; if (ievt instanceof RepositoryItemValidationEventFailedChecksum) { action = NexusArtifactEvent.ACTION_BROKEN_WRONG_REMOTE_CHECKSUM; } else if (ievt instanceof RepositoryItemValidationEventFailedFileType) { action = NexusArtifactEvent.ACTION_BROKEN_INVALID_CONTENT; } final NexusArtifactEvent nae = new NexusArtifactEvent(ievt.getEventDate(), action, ievt.getMessage(), ai); getFeedRecorder().addNexusArtifactEvent(nae); } }
public void addNexusArtifactEvent(NexusArtifactEvent nae) { Map<String, String> map = new HashMap<String, String>(); map.put(REPOSITORY, nae.getNexusItemInfo().getRepositoryId()); map.put(REPOSITORY_PATH, nae.getNexusItemInfo().getPath()); if (nae.getNexusItemInfo().getRemoteUrl() != null) { map.put(REMOTE_URL, nae.getNexusItemInfo().getRemoteUrl()); } putContext(map, CTX_PREFIX, nae.getEventContext()); putContext(map, ATR_PREFIX, nae.getItemAttributes()); if (nae.getMessage() != null) { map.put(MESSAGE, nae.getMessage()); } map.put(DATE, getDateFormat().format(nae.getEventDate())); map.put(ACTION, nae.getAction()); addToTimeline(map, REPO_EVENT_TYPE, nae.getAction()); }
protected void inspect(Event<?> evt) { if (evt instanceof NexusStartedEvent) { getFeedRecorder().addSystemEvent( FeedRecorder.SYSTEM_BOOT_ACTION, "Started Nexus (version " + getApplicationStatusSource().getSystemStatus().getVersion() + " " + getApplicationStatusSource().getSystemStatus().getEditionShort() + ")"); } else if (evt instanceof NexusStoppedEvent) { getFeedRecorder().addSystemEvent( FeedRecorder.SYSTEM_BOOT_ACTION, "Stopping Nexus (version " + getApplicationStatusSource().getSystemStatus().getVersion() + " " + getApplicationStatusSource().getSystemStatus().getEditionShort() + ")"); getFeedRecorder().shutdown(); } }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryItemEventStore evt) { inspectForNexus(evt); }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryRegistryRepositoryEvent e) { inspect(e); }
protected boolean isNexusStarted() { return getApplicationStatusSource().getSystemStatus().isNexusStarted(); } }
msg.append("cached from remote URL ").append(event.getNexusItemInfo().getRemoteUrl()).append(".");
protected String getRepositoryName(NexusArtifactEvent event) { String repoId = event.getNexusItemInfo().getRepositoryId(); try { Repository repository = getRepositoryRegistry().getRepository(repoId); return repository.getName(); } catch (NoSuchRepositoryException e) { // that's fine, no need to yell, old timeline entries might correspond to long-time removed reposes return repoId; } }
protected boolean isRecordedEvent(final NexusAuthenticationEvent nae) { // we record everything except anonymous related ones if (StringUtils.equals(nexusConfiguration.getAnonymousUsername(), nae.getClientInfo().getUserid())) { return false; } // if here, we record the event if not similar to previous one return !isSimilarEvent(nae); }
protected boolean isRecordedEvent(final NexusAuthorizationEvent nae) { // we record only authz failures if (nae.isSuccessful()) { return false; } // we record everything except anonymous related ones if (StringUtils.equals(nexusConfiguration.getAnonymousUsername(), nae.getClientInfo().getUserid())) { return false; } // if here, we record the event if not similar to previous one return !isSimilarEvent(nae); }
private boolean filterEvent(NexusArtifactEvent event) { try { Repository repo = this.repositoryRegistry.getRepository(event.getNexusItemInfo().getRepositoryId()); ResourceStoreRequest req = new ResourceStoreRequest(event.getNexusItemInfo().getPath()); if (!this.nexusItemAuthorizer.authorizePath(repo, req, Action.read)) { return false; } } catch (NoSuchRepositoryException e) { // Can't get repository for artifact, therefore we can't authorize access, therefore you don't see it log.debug( "Feed entry contained invalid repository id " + event.getNexusItemInfo().getRepositoryId(), e); return false; } return true; }
private String getGAVString(NexusArtifactEvent event) { if (event.getNexusItemInfo() == null) { return "unknown:unknown:unknown"; } Gav gav = buildGAV(event); if (gav == null) { return event.getNexusItemInfo().getPath(); } StringBuilder result = new StringBuilder(gav.getGroupId()) .append(":").append(gav.getArtifactId()).append(":").append( gav.getVersion() != null ? gav.getVersion() : "unknown"); if (gav.getClassifier() != null) { result.append(":").append(gav.getClassifier()); } return result.toString(); }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryItemEventDelete evt) { inspectForNexus(evt); }
@Subscribe public void on(final NexusStartedEvent e) { inspect(e); }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryConfigurationUpdatedEvent e) { inspect(e); }
@Override public boolean shouldBuildEntry(final NexusArtifactEvent event) { if (!super.shouldBuildEntry(event)) { return false; } final Gav gav = buildGAV(event); if (gav != null) { if (gav.isHash() || gav.isSignature()) { return false; } } final String path = event.getNexusItemInfo().getPath(); if (path.contains("maven-metadata.xml")) { return false; } return true; }
@Subscribe @AllowConcurrentEvents public void on(final RepositoryItemEventCache evt) { inspectForNexus(evt); }