Search in sources :

Example 11 with AttachedEntityMetadata

use of org.sonatype.nexus.orient.entity.AttachedEntityMetadata in project nexus-public by sonatype.

the class ComponentEntityAdapter method newEvent.

@Override
public EntityEvent newEvent(final ODocument document, final EventKind eventKind) {
    EntityMetadata metadata = new AttachedEntityMetadata(this, document);
    String repositoryName = ((ODocument) document.field(P_BUCKET)).field(P_REPOSITORY_NAME);
    // prefetch any lazy/linked fields that the extensions want to capture
    componentEntityAdapterExtensions.forEach(d -> d.prefetchFields(document));
    switch(eventKind) {
        case CREATE:
            return new ComponentCreatedEvent(metadata, repositoryName);
        case UPDATE:
            return new ComponentUpdatedEvent(metadata, repositoryName);
        case DELETE:
            return new ComponentDeletedEvent(metadata, repositoryName);
        default:
            return null;
    }
}
Also used : EntityMetadata(org.sonatype.nexus.common.entity.EntityMetadata) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 12 with AttachedEntityMetadata

use of org.sonatype.nexus.orient.entity.AttachedEntityMetadata in project nexus-public by sonatype.

the class OrientKeyStoreDataEntityAdapter method newEvent.

@Nullable
@Override
public EntityEvent newEvent(final ODocument document, final EventKind eventKind) {
    EntityMetadata metadata = new AttachedEntityMetadata(this, document);
    String name = document.field(P_NAME);
    EntityEvent event;
    switch(eventKind) {
        case CREATE:
            event = new OrientKeyStoreDataCreatedEvent(metadata, name);
            break;
        case UPDATE:
            event = new OrientKeyStoreDataUpdatedEvent(metadata, name);
            break;
        default:
            event = null;
    }
    if (event != null) {
        log.debug("Emitted {} event for key store {} with metadata {}", eventKind, name, metadata);
    }
    return event;
}
Also used : EntityMetadata(org.sonatype.nexus.common.entity.EntityMetadata) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) EntityEvent(org.sonatype.nexus.common.entity.EntityEvent) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) Nullable(javax.annotation.Nullable)

Example 13 with AttachedEntityMetadata

use of org.sonatype.nexus.orient.entity.AttachedEntityMetadata in project nexus-public by sonatype.

the class PurgeUnusedFacetImplTest method mockBucket.

private Bucket mockBucket() {
    EntityAdapter owner = mock(EntityAdapter.class);
    ODocument document = mock(ODocument.class);
    ORID orID = new ORecordId(1, 1);
    when(document.getIdentity()).thenReturn(orID);
    EntityMetadata entityMetadata = new AttachedEntityMetadata(owner, document);
    Bucket bucket = mock(Bucket.class);
    when(bucket.getEntityMetadata()).thenReturn(entityMetadata);
    return bucket;
}
Also used : EntityMetadata(org.sonatype.nexus.common.entity.EntityMetadata) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) Bucket(org.sonatype.nexus.repository.storage.Bucket) EntityAdapter(org.sonatype.nexus.orient.entity.EntityAdapter) ComponentEntityAdapter(org.sonatype.nexus.repository.storage.ComponentEntityAdapter) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) ORID(com.orientechnologies.orient.core.id.ORID) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 14 with AttachedEntityMetadata

use of org.sonatype.nexus.orient.entity.AttachedEntityMetadata in project nexus-public by sonatype.

the class OrientMetadataRebuilderTest method mockBucketEntityMetadata.

private static EntityMetadata mockBucketEntityMetadata() {
    EntityAdapter owner = mock(EntityAdapter.class);
    ODocument document = mock(ODocument.class);
    when(document.getIdentity()).thenReturn(new ORecordId(1, 1));
    return new AttachedEntityMetadata(owner, document);
}
Also used : EntityAdapter(org.sonatype.nexus.orient.entity.EntityAdapter) AttachedEntityMetadata(org.sonatype.nexus.orient.entity.AttachedEntityMetadata) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

AttachedEntityMetadata (org.sonatype.nexus.orient.entity.AttachedEntityMetadata)14 EntityMetadata (org.sonatype.nexus.common.entity.EntityMetadata)12 Nullable (javax.annotation.Nullable)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)5 ORID (com.orientechnologies.orient.core.id.ORID)3 ORecordId (com.orientechnologies.orient.core.id.ORecordId)3 EntityAdapter (org.sonatype.nexus.orient.entity.EntityAdapter)3 ComponentEntityAdapter (org.sonatype.nexus.repository.storage.ComponentEntityAdapter)2 EntityEvent (org.sonatype.nexus.common.entity.EntityEvent)1 EntityId (org.sonatype.nexus.common.entity.EntityId)1 AttachedEntityId (org.sonatype.nexus.orient.entity.AttachedEntityId)1 Bucket (org.sonatype.nexus.repository.storage.Bucket)1 BucketEntityAdapter (org.sonatype.nexus.repository.storage.BucketEntityAdapter)1 BucketCreatedEvent (org.sonatype.nexus.repository.storage.internal.BucketCreatedEvent)1 BucketDeletedEvent (org.sonatype.nexus.repository.storage.internal.BucketDeletedEvent)1 BucketUpdatedEvent (org.sonatype.nexus.repository.storage.internal.BucketUpdatedEvent)1