Map<String, String> map = record.getData(); NexusItemInfo ai = new NexusItemInfo(); ai.setRepositoryId(map.get(REPOSITORY)); ai.setPath(map.get(REPOSITORY_PATH)); ai.setRemoteUrl(map.get(REMOTE_URL));
protected String buildLink(NexusArtifactEvent event) { return "content/repositories/" + event.getNexusItemInfo().getRepositoryId() + event.getNexusItemInfo().getPath(); }
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()); }
private String buildFilePath(NexusArtifactEvent event) { return event.getNexusItemInfo().getPath(); }
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; } }
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 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); } }
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; }
@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; }
StorageFileItem pomItem = (StorageFileItem) ievt.getItem(); NexusItemInfo ai = new NexusItemInfo(); ai.setRepositoryId(pomItem.getRepositoryId()); ai.setPath(pomItem.getPath()); ai.setRemoteUrl(pomItem.getRemoteUrl());
protected Gav buildGAV(final NexusArtifactEvent event) { if (event.getNexusItemInfo() == null) { return null; } try { final Repository repo = getRepositoryRegistry().getRepository(event.getNexusItemInfo().getRepositoryId()); if (MavenRepository.class.isAssignableFrom(repo.getClass())) { return ((MavenRepository) repo).getGavCalculator().pathToGav(event.getNexusItemInfo().getPath()); } return null; } catch (NoSuchRepositoryException e) { log.debug( "Feed entry contained invalid repository id " + event.getNexusItemInfo().getRepositoryId(), e); return null; } }