protected String buildLink(NexusArtifactEvent event) { return "content/repositories/" + event.getNexusItemInfo().getRepositoryId() + event.getNexusItemInfo().getPath(); }
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; }
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; } }
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; } }
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()); }