use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloAdminController method renderReport.
public TrackedContentDTO renderReport(final String id, final String apiBaseUrl) throws IndyWorkflowException {
final TrackingKey tk = new TrackingKey(id);
logger.debug("Retrieving tracking record for: {}", tk);
final TrackedContentDTO record = constructContentDTO(recordManager.get(tk), apiBaseUrl);
logger.debug("Got: {}", record);
return record;
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class KafkaEventPublisher method transformFileEvent.
private void transformFileEvent(org.commonjava.maven.galley.event.FileEvent event, FileEvent fileEvent) {
Transfer transfer = event.getTransfer();
if (transfer == null) {
logger.trace("No transfer.");
return;
}
final Location location = transfer.getLocation();
if (!(location instanceof KeyedLocation)) {
logger.trace("Not in a keyed location: {}", transfer);
return;
}
try {
final KeyedLocation keyedLocation = (KeyedLocation) location;
final StoreKey affectedStore = keyedLocation.getKey();
final String path = transfer.getPath();
fileEvent.setTargetPath(path);
fileEvent.setNodeId(indyConfig.getNodeId());
EventMetadata metadata = event.getEventMetadata();
final TrackingKey trackingKey = (TrackingKey) metadata.get("tracking-id");
if (trackingKey != null) {
fileEvent.setSessionId(trackingKey.getId());
}
fileEvent.setTimestamp(new Date());
TransferMetadata artifactData = contentDigester.digest(affectedStore, path, metadata);
fileEvent.setMd5(artifactData.getDigests().get(ContentDigest.MD5));
fileEvent.setSha1(artifactData.getDigests().get(ContentDigest.SHA_1));
fileEvent.setChecksum(artifactData.getDigests().get(ContentDigest.SHA_256));
fileEvent.setSize(artifactData.getSize());
fileEvent.setStoreKey(affectedStore.toString());
if (StoreType.remote == affectedStore.getType()) {
final RemoteRepository repo = (RemoteRepository) storeManager.getArtifactStore(affectedStore);
if (repo != null) {
fileEvent.setSourceLocation(repo.getUrl());
fileEvent.setSourcePath(transfer.getPath());
}
}
} catch (final IndyWorkflowException | IndyDataException e) {
logger.error(String.format("Failed to transform file event. Reason: %s", e.getMessage()), e);
}
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class EventAuditListener method transformFileEvent.
private void transformFileEvent(org.commonjava.maven.galley.event.FileEvent event, FileEvent fileEvent) {
EventMetadata metadata = event.getEventMetadata();
final TrackingKey trackingKey = (TrackingKey) metadata.get(EventConstants.TRACKING_KEY);
if (trackingKey == null) {
logger.trace("No tracking key. Skip audit.");
return;
}
Transfer transfer = event.getTransfer();
if (transfer == null) {
logger.trace("No transfer. Skip audit.");
return;
}
final Location location = transfer.getLocation();
if (!(location instanceof KeyedLocation)) {
logger.trace("Not in a keyed location: {}", transfer);
return;
}
try {
final KeyedLocation keyedLocation = (KeyedLocation) location;
final StoreKey affectedStore = keyedLocation.getKey();
if (affectedStore.getType() == group) {
logger.trace("Not auditing content stored directly in group: {}. This content is generally aggregated metadata, and can be recalculated. Groups may not be stable in some build environments", affectedStore);
return;
}
final String path = transfer.getPath();
fileEvent.setTargetPath(path);
// TODO figure out what's the NodeId
fileEvent.setNodeId(indyConfig.getNodeId());
fileEvent.setSessionId(trackingKey.getId());
fileEvent.setTimestamp(new Date());
TransferMetadata artifactData = contentDigester.digest(affectedStore, path, metadata);
fileEvent.setMd5(artifactData.getDigests().get(ContentDigest.MD5));
fileEvent.setSha1(artifactData.getDigests().get(ContentDigest.SHA_1));
fileEvent.setChecksum(artifactData.getDigests().get(ContentDigest.SHA_256));
fileEvent.setSize(artifactData.getSize());
fileEvent.setStoreKey(affectedStore.toString());
Map<String, String> extra = new HashMap<>();
if (event instanceof FileStorageEvent) {
extra.put(EventConstants.STORE_EFFECT, ((FileStorageEvent) event).getType().name());
}
if (StoreType.remote == affectedStore.getType()) {
final RemoteRepository repo = (RemoteRepository) storeManager.getArtifactStore(affectedStore);
if (repo != null) {
fileEvent.setSourceLocation(repo.getUrl());
fileEvent.setSourcePath(transfer.getPath());
}
}
// TODO fix this, it should be the url of indy, or recalculate it in AuditQuery side.
fileEvent.setTargetLocation("");
fileEvent.setExtra(extra);
} catch (final IndyWorkflowException | IndyDataException e) {
logger.error(String.format("Failed to transform file event. Reason: %s", e.getMessage()), e);
}
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class DtxTrackingRecord method toTrackingContentEntry.
public static TrackedContentEntry toTrackingContentEntry(DtxTrackingRecord record) {
TrackedContentEntry trackedContentEntry = new TrackedContentEntry();
trackedContentEntry.setTrackingKey(new TrackingKey(record.getTrackingKey()));
if (record.getAccessChannel() == null || record.getAccessChannel().isEmpty()) {
trackedContentEntry.setAccessChannel(AccessChannel.NATIVE);
} else {
trackedContentEntry.setAccessChannel(AccessChannel.valueOf(record.getAccessChannel()));
}
trackedContentEntry.setEffect(StoreEffect.valueOf(record.getStoreEffect()));
trackedContentEntry.setMd5(record.getMd5());
trackedContentEntry.setSha1(record.getSha1());
trackedContentEntry.setSha256(record.getSha256());
trackedContentEntry.setSize(record.getSize());
trackedContentEntry.setStoreKey(StoreKey.fromString(record.getStoreKey()));
trackedContentEntry.setOriginUrl(record.getOriginUrl());
trackedContentEntry.setPath(record.getPath());
trackedContentEntry.setTimestamps(record.getTimestamps());
return trackedContentEntry;
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCassandra method getTrackingKeys.
private Set<TrackingKey> getTrackingKeys() {
BoundStatement statement = getTrackingKeys.bind();
ResultSet resultSet = session.execute(statement);
List<Row> all = resultSet.all();
Iterator<Row> iterator = all.iterator();
Set<TrackingKey> trackingKeys = new HashSet<>();
while (iterator.hasNext()) {
Row next = iterator.next();
String tracking_key = next.getString("tracking_key");
trackingKeys.add(new TrackingKey(tracking_key));
}
return trackingKeys.stream().collect(Collectors.toSet());
}
Aggregations