Search in sources :

Example 1 with BucketEntityAdapter

use of org.sonatype.nexus.repository.storage.BucketEntityAdapter in project nexus-public by sonatype.

the class RebuildBrowseNodesManagerTest method initializeDatabase.

private void initializeDatabase() throws Exception {
    bucketEntityAdapter = new BucketEntityAdapter();
    componentEntityAdapter = new ComponentEntityAdapter(bucketEntityAdapter, componentFactory, emptySet());
    assetEntityAdapter = new AssetEntityAdapter(bucketEntityAdapter, componentEntityAdapter);
    when(packageUrlService.getPackageUrl(anyString(), anyString(), anyString(), anyString())).thenReturn(Optional.empty());
    browseNodeEntityAdapter = new BrowseNodeEntityAdapter(componentEntityAdapter, assetEntityAdapter, packageUrlService);
    underTest = new RebuildBrowseNodesManager(databaseInstanceRule.getInstanceProvider(), taskScheduler, configuration, bucketEntityAdapter);
    bucketEntityAdapter.register(databaseInstanceRule.getInstance().acquire());
    componentEntityAdapter.register(databaseInstanceRule.getInstance().acquire());
    assetEntityAdapter.register(databaseInstanceRule.getInstance().acquire());
    browseNodeEntityAdapter.register(databaseInstanceRule.getInstance().acquire());
    bucketEntityAdapter.enableObfuscation(new HexRecordIdObfuscator());
    componentEntityAdapter.enableObfuscation(new HexRecordIdObfuscator());
    assetEntityAdapter.enableObfuscation(new HexRecordIdObfuscator());
    browseNodeEntityAdapter.enableObfuscation(new HexRecordIdObfuscator());
}
Also used : AssetEntityAdapter(org.sonatype.nexus.repository.storage.AssetEntityAdapter) BucketEntityAdapter(org.sonatype.nexus.repository.storage.BucketEntityAdapter) ComponentEntityAdapter(org.sonatype.nexus.repository.storage.ComponentEntityAdapter) HexRecordIdObfuscator(org.sonatype.nexus.orient.HexRecordIdObfuscator) BrowseNodeEntityAdapter(org.sonatype.nexus.repository.browse.internal.orient.BrowseNodeEntityAdapter)

Example 2 with BucketEntityAdapter

use of org.sonatype.nexus.repository.storage.BucketEntityAdapter in project nexus-public by sonatype.

the class OrientBrowseNodeStoreLoadTest method setUp.

@Before
public void setUp() throws Exception {
    BrowseNodeConfiguration configuration = new BrowseNodeConfiguration(true, 1000, DELETE_PAGE_SIZE, 10_000, 10_000);
    BucketEntityAdapter bucketEntityAdapter = new BucketEntityAdapter();
    ComponentFactory componentFactory = new ComponentFactory(emptySet());
    ComponentEntityAdapter componentEntityAdapter = new ComponentEntityAdapter(bucketEntityAdapter, componentFactory, emptySet());
    AssetEntityAdapter assetEntityAdapter = new AssetEntityAdapter(bucketEntityAdapter, componentEntityAdapter);
    when(packageUrlService.getPackageUrl(anyString(), anyString(), anyString(), anyString())).thenReturn(Optional.empty());
    BrowseNodeEntityAdapter browseNodeEntityAdapter = new BrowseNodeEntityAdapter(componentEntityAdapter, assetEntityAdapter, packageUrlService);
    try (ODatabaseDocumentTx db = database.getInstance().connect()) {
        bucketEntityAdapter.register(db);
        bucket = new Bucket();
        bucket.setRepositoryName(REPOSITORY_NAME);
        bucket.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>()));
        bucketEntityAdapter.addEntity(db, bucket);
        componentEntityAdapter.register(db);
        component = new DefaultComponent().bucketId(EntityHelper.id(bucket)).format("test").group("test-group").name("test-component").version("1.0").attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>()));
        componentEntityAdapter.addEntity(db, component);
        assetEntityAdapter.register(db);
        for (int i = 0; i < ASSET_COUNT; i++) {
            assets.add(new Asset().bucketId(EntityHelper.id(bucket)).format("test").name("test-asset-" + i).attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())));
            assetEntityAdapter.addEntity(db, assets.get(i));
        }
        // registration of the schema is now done outside of the store
        browseNodeEntityAdapter.register(db);
        bucketEntityAdapter.register(db);
    }
    underTest = new OrientBrowseNodeStore(database.getInstanceProvider(), browseNodeEntityAdapter, securityHelper, selectorManager, configuration, new HashMap<>(), new HashMap<>(), ImmutableMap.of(DefaultBrowseNodeComparator.NAME, new DefaultBrowseNodeComparator(new VersionComparator())));
    underTest.start();
}
Also used : HashMap(java.util.HashMap) ComponentFactory(org.sonatype.nexus.repository.storage.ComponentFactory) DefaultBrowseNodeComparator(org.sonatype.nexus.repository.browse.node.DefaultBrowseNodeComparator) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) BucketEntityAdapter(org.sonatype.nexus.repository.storage.BucketEntityAdapter) NestedAttributesMap(org.sonatype.nexus.common.collect.NestedAttributesMap) BrowseNodeConfiguration(org.sonatype.nexus.repository.browse.node.BrowseNodeConfiguration) AssetEntityAdapter(org.sonatype.nexus.repository.storage.AssetEntityAdapter) DefaultComponent(org.sonatype.nexus.repository.storage.DefaultComponent) Bucket(org.sonatype.nexus.repository.storage.Bucket) VersionComparator(org.sonatype.nexus.common.app.VersionComparator) Asset(org.sonatype.nexus.repository.storage.Asset) ComponentEntityAdapter(org.sonatype.nexus.repository.storage.ComponentEntityAdapter) Before(org.junit.Before)

Example 3 with BucketEntityAdapter

use of org.sonatype.nexus.repository.storage.BucketEntityAdapter in project nexus-public by sonatype.

the class BrowseNodeEntityAdapterTest method setUp.

@Before
public void setUp() throws Exception {
    bucketEntityAdapter = new BucketEntityAdapter();
    ComponentFactory componentFactory = new ComponentFactory(emptySet());
    componentEntityAdapter = new ComponentEntityAdapter(bucketEntityAdapter, componentFactory, emptySet());
    assetEntityAdapter = new AssetEntityAdapter(bucketEntityAdapter, componentEntityAdapter);
    packageUrlService = mock(PackageUrlService.class);
    when(packageUrlService.getPackageUrl(anyString(), anyString(), anyString(), anyString())).thenReturn(Optional.empty());
    underTest = new BrowseNodeEntityAdapter(componentEntityAdapter, assetEntityAdapter, packageUrlService);
    try (ODatabaseDocumentTx db = database.getInstance().acquire()) {
        bucketEntityAdapter.register(db);
        componentEntityAdapter.register(db);
        assetEntityAdapter.register(db);
        underTest.register(db);
        createEntities(db);
    }
}
Also used : AssetEntityAdapter(org.sonatype.nexus.repository.storage.AssetEntityAdapter) PackageUrlService(org.sonatype.nexus.repository.ossindex.PackageUrlService) ComponentFactory(org.sonatype.nexus.repository.storage.ComponentFactory) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) BucketEntityAdapter(org.sonatype.nexus.repository.storage.BucketEntityAdapter) ComponentEntityAdapter(org.sonatype.nexus.repository.storage.ComponentEntityAdapter) Before(org.junit.Before)

Aggregations

AssetEntityAdapter (org.sonatype.nexus.repository.storage.AssetEntityAdapter)3 BucketEntityAdapter (org.sonatype.nexus.repository.storage.BucketEntityAdapter)3 ComponentEntityAdapter (org.sonatype.nexus.repository.storage.ComponentEntityAdapter)3 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 Before (org.junit.Before)2 ComponentFactory (org.sonatype.nexus.repository.storage.ComponentFactory)2 HashMap (java.util.HashMap)1 VersionComparator (org.sonatype.nexus.common.app.VersionComparator)1 NestedAttributesMap (org.sonatype.nexus.common.collect.NestedAttributesMap)1 HexRecordIdObfuscator (org.sonatype.nexus.orient.HexRecordIdObfuscator)1 BrowseNodeEntityAdapter (org.sonatype.nexus.repository.browse.internal.orient.BrowseNodeEntityAdapter)1 BrowseNodeConfiguration (org.sonatype.nexus.repository.browse.node.BrowseNodeConfiguration)1 DefaultBrowseNodeComparator (org.sonatype.nexus.repository.browse.node.DefaultBrowseNodeComparator)1 PackageUrlService (org.sonatype.nexus.repository.ossindex.PackageUrlService)1 Asset (org.sonatype.nexus.repository.storage.Asset)1 Bucket (org.sonatype.nexus.repository.storage.Bucket)1 DefaultComponent (org.sonatype.nexus.repository.storage.DefaultComponent)1