org.sonatype.nexus.repository.storage.AssetEntityAdapter Java Examples
The following examples show how to use
org.sonatype.nexus.repository.storage.AssetEntityAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelmRestoreBlobIT.java From nexus-repository-helm with Eclipse Public License 1.0 | 6 votes |
private void runBlobRestore(final boolean isDryRun) { Asset asset; Blob blob; try (StorageTx tx = getStorageTx(proxyRepository)) { tx.begin(); asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, MONGO_PATH_FULL_728_TARGZ, tx.findBucket(proxyRepository)); assertThat(asset, Matchers.notNullValue()); blob = tx.getBlob(asset.blobRef()); } testHelper.simulateAssetMetadataLoss(); Properties properties = new Properties(); properties.setProperty(HEADER_PREFIX + REPO_NAME_HEADER, proxyRepository.getName()); properties.setProperty(HEADER_PREFIX + BLOB_NAME_HEADER, asset.name()); properties.setProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER, asset.contentType()); helmRestoreBlobStrategy.restore(properties, blob, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, isDryRun); }
Example #2
Source File: RebuildBrowseNodesManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private void initializeDatabase() throws Exception { bucketEntityAdapter = new BucketEntityAdapter(); componentEntityAdapter = new ComponentEntityAdapter(bucketEntityAdapter, componentFactory, emptySet()); assetEntityAdapter = new AssetEntityAdapter(bucketEntityAdapter, componentEntityAdapter); browseNodeEntityAdapter = new BrowseNodeEntityAdapter(componentEntityAdapter, assetEntityAdapter); 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()); }
Example #3
Source File: BrowseNodeEntityAdapterTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@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); underTest = new BrowseNodeEntityAdapter(componentEntityAdapter, assetEntityAdapter); try (ODatabaseDocumentTx db = database.getInstance().acquire()) { bucketEntityAdapter.register(db); componentEntityAdapter.register(db); assetEntityAdapter.register(db); underTest.register(db); createEntities(db); } }
Example #4
Source File: BrowseServiceImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Inject public BrowseServiceImpl(@Named(GroupType.NAME) final Type groupType, final ComponentEntityAdapter componentEntityAdapter, final VariableResolverAdapterManager variableResolverAdapterManager, final ContentPermissionChecker contentPermissionChecker, final AssetEntityAdapter assetEntityAdapter, final BrowseAssetIterableFactory browseAssetIterableFactory, final BrowseAssetsSqlBuilder browseAssetsSqlBuilder, final BrowseComponentsSqlBuilder browseComponentsSqlBuilder, final BucketStore bucketStore, final RepositoryManager repositoryManager) { this.groupType = checkNotNull(groupType); this.componentEntityAdapter = checkNotNull(componentEntityAdapter); this.variableResolverAdapterManager = checkNotNull(variableResolverAdapterManager); this.contentPermissionChecker = checkNotNull(contentPermissionChecker); this.assetEntityAdapter = checkNotNull(assetEntityAdapter); this.browseAssetIterableFactory = checkNotNull(browseAssetIterableFactory); this.browseAssetsSqlBuilder = checkNotNull(browseAssetsSqlBuilder); this.browseComponentsSqlBuilder = checkNotNull(browseComponentsSqlBuilder); this.bucketStore = checkNotNull(bucketStore); this.repositoryManager = checkNotNull(repositoryManager); }
Example #5
Source File: IndexSyncService.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Inject public IndexSyncService(@Named(COMPONENT) final Provider<DatabaseInstance> componentDatabase, final ComponentEntityAdapter componentEntityAdapter, final AssetEntityAdapter assetEntityAdapter, final ApplicationDirectories directories, final NodeAccess nodeAccess, final IndexRequestProcessor indexRequestProcessor, final IndexRebuildManager indexRebuildManager) { this.componentDatabase = checkNotNull(componentDatabase); this.componentEntityAdapter = checkNotNull(componentEntityAdapter); this.nodeAccess = checkNotNull(nodeAccess); this.indexRequestProcessor = checkNotNull(indexRequestProcessor); this.indexRebuildManager = checkNotNull(indexRebuildManager); this.entityLog = new EntityLog(componentDatabase, componentEntityAdapter, assetEntityAdapter); this.checkpointFile = new File(directories.getWorkDirectory("elasticsearch"), "nexus.lsn"); }
Example #6
Source File: OrientBlobstoreRestoreTestHelper.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public void assertAssetMatchesBlob(final Repository repository, final String... names) { for (String name : names) { try (StorageTx tx = getStorageTx(repository)) { tx.begin(); Asset asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, name, tx.findBucket(repository)); Blob blob = tx.requireBlob(asset.blobRef()); assertThat(repository.getName(), equalTo(blob.getHeaders().get(Bucket.REPO_NAME_HEADER))); assertThat(asset.name(), equalTo(blob.getHeaders().get(BlobStore.BLOB_NAME_HEADER))); assertThat(asset.createdBy(), equalTo(blob.getHeaders().get(BlobStore.CREATED_BY_HEADER))); assertThat(asset.createdByIp(), equalTo(blob.getHeaders().get(BlobStore.CREATED_BY_IP_HEADER))); assertThat(asset.contentType(), equalTo(blob.getHeaders().get(BlobStore.CONTENT_TYPE_HEADER))); assertThat(asset.attributes().child("checksum").get("sha1"), equalTo(blob.getMetrics().getSha1Hash())); assertThat(asset.size(), equalTo(blob.getMetrics().getContentSize())); } } }
Example #7
Source File: P2RestoreBlobIT.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
private void runBlobRestore(final boolean isDryRun) { Asset asset; Blob blob; try (StorageTx tx = getStorageTx(proxyRepository)) { tx.begin(); asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, VALID_PACKAGE_URL, tx.findBucket(proxyRepository)); assertThat(asset, Matchers.notNullValue()); blob = tx.getBlob(asset.blobRef()); } testHelper.simulateAssetMetadataLoss(); Properties properties = new Properties(); properties.setProperty(HEADER_PREFIX + REPO_NAME_HEADER, proxyRepository.getName()); properties.setProperty(HEADER_PREFIX + BLOB_NAME_HEADER, asset.name()); properties.setProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER, asset.contentType()); p2RestoreBlobStrategy.restore(properties, blob, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, isDryRun); }
Example #8
Source File: RRestoreBlobIT.java From nexus-repository-r with Eclipse Public License 1.0 | 6 votes |
private void runBlobRestore(final boolean isDryRun) { Asset asset; Blob blob; try (StorageTx tx = getStorageTx(proxyRepository)) { tx.begin(); asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, AGRICOLAE_131_TARGZ.fullPath, tx.findBucket(proxyRepository)); assertThat(asset, Matchers.notNullValue()); blob = tx.getBlob(asset.blobRef()); } testHelper.simulateAssetMetadataLoss(); Properties properties = new Properties(); properties.setProperty(HEADER_PREFIX + REPO_NAME_HEADER, proxyRepository.getName()); properties.setProperty(HEADER_PREFIX + BLOB_NAME_HEADER, asset.name()); properties.setProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER, asset.contentType()); rRestoreBlobStrategy.restore(properties, blob, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, isDryRun); }
Example #9
Source File: OrientBlobstoreRestoreTestHelper.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public void assertAssetMatchesBlob(final Repository repository, final String name) { try (StorageTx tx = getStorageTx(repository)) { tx.begin(); Asset asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, name, tx.findBucket(repository)); Blob blob = tx.requireBlob(asset.blobRef()); assertThat(repository.getName(), equalTo(blob.getHeaders().get(Bucket.REPO_NAME_HEADER))); assertThat(asset.name(), equalTo(blob.getHeaders().get(BlobStore.BLOB_NAME_HEADER))); assertThat(asset.createdBy(), equalTo(blob.getHeaders().get(BlobStore.CREATED_BY_HEADER))); assertThat(asset.createdByIp(), equalTo(blob.getHeaders().get(BlobStore.CREATED_BY_IP_HEADER))); assertThat(asset.contentType(), equalTo(blob.getHeaders().get(BlobStore.CONTENT_TYPE_HEADER))); assertThat(asset.attributes().child("checksum").get("sha1"), equalTo(blob.getMetrics().getSha1Hash())); assertThat(asset.size(), equalTo(blob.getMetrics().getContentSize())); } }
Example #10
Source File: RawRestoreBlobIT.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private void runBlobRestore(final boolean isDryRun) { Asset asset; Blob blob; try (StorageTx tx = getStorageTx(proxyRepository)) { tx.begin(); asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, TEST_CONTENT, tx.findBucket(proxyRepository)); blob = tx.getBlob(asset.blobRef()); } testHelper.simulateComponentMetadataLoss(); Properties properties = new Properties(); properties.setProperty(HEADER_PREFIX + REPO_NAME_HEADER, proxyRepository.getName()); properties.setProperty(HEADER_PREFIX + BLOB_NAME_HEADER, asset.name()); restoreBlobStrategy.restore(properties, blob, HEADER_PREFIX + BLOB_NAME_HEADER, isDryRun); }
Example #11
Source File: RepairMetadataComponentTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public RepairMetadataComponentForTest(final RepositoryManager repositoryManager, final AssetEntityAdapter assetEntityAdapter, final Type type, final Format format) { super(repositoryManager, assetEntityAdapter, type, format); }
Example #12
Source File: ComponentSchemaRegistration.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public ComponentSchemaRegistration(@Named(ComponentDatabase.NAME) final Provider<DatabaseInstance> databaseInstance, final BucketEntityAdapter bucketEntityAdapter, final ComponentEntityAdapter componentEntityAdapter, final AssetEntityAdapter assetEntityAdapter, final BrowseNodeEntityAdapter browseNodeEntityAdapter) { this.databaseInstance = checkNotNull(databaseInstance); this.bucketEntityAdapter = checkNotNull(bucketEntityAdapter); this.componentEntityAdapter = checkNotNull(componentEntityAdapter); this.assetEntityAdapter = checkNotNull(assetEntityAdapter); this.browseNodeEntityAdapter = checkNotNull(browseNodeEntityAdapter); }
Example #13
Source File: BrowseNodeEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public BrowseNodeEntityAdapter(final ComponentEntityAdapter componentEntityAdapter, final AssetEntityAdapter assetEntityAdapter) { super(DB_CLASS); this.assetEntityAdapter = checkNotNull(assetEntityAdapter); this.componentEntityAdapter = checkNotNull(componentEntityAdapter); }
Example #14
Source File: RepairMetadataComponent.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public RepairMetadataComponent(final RepositoryManager repositoryManager, final AssetEntityAdapter assetEntityAdapter, final Type type, final Format format) { this.repositoryManager = checkNotNull(repositoryManager); this.assetEntityAdapter = checkNotNull(assetEntityAdapter); this.type = checkNotNull(type); this.format = checkNotNull(format); }
Example #15
Source File: AssetsResource.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public AssetsResource(final BrowseService browseService, final RepositoryManagerRESTAdapter repositoryManagerRESTAdapter, final AssetEntityAdapter assetEntityAdapter, final MaintenanceService maintenanceService, @Named("asset") final ContinuationTokenHelper continuationTokenHelper) { this.browseService = checkNotNull(browseService); this.repositoryManagerRESTAdapter = checkNotNull(repositoryManagerRESTAdapter); this.assetEntityAdapter = checkNotNull(assetEntityAdapter); this.maintenanceService = checkNotNull(maintenanceService); this.continuationTokenHelper = checkNotNull(continuationTokenHelper); }
Example #16
Source File: OrientBlobstoreRestoreTestHelper.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private void assertForComponentId(final Repository repository, final Component component, final String path) { EntityId compId = component.getEntityMetadata().getId(); assertThat(compId, notNullValue()); try (StorageTx tx = getStorageTx(repository)) { tx.begin(); Asset asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, path, tx.findBucket(repository)); assertThat(asset, notNullValue()); final EntityId assertEntityId = asset.componentId(); assertThat(assertEntityId, notNullValue()); assertEquals(assertEntityId, compId); } }
Example #17
Source File: ComponentDatabaseUpgrade_1_7.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public void apply() throws Exception { withDatabaseAndClass(componentDatabaseInstance, BROWSE_NODE, (db, table) -> { db.getMetadata().getSchema().dropClass(BROWSE_NODE); }); withDatabaseAndClass(componentDatabaseInstance, ASSET, (db, table) -> { if (!table.existsProperty(AssetEntityAdapter.P_CREATED_BY)) { table.createProperty(AssetEntityAdapter.P_CREATED_BY, OType.STRING); } if (!table.existsProperty(AssetEntityAdapter.P_CREATED_BY_IP)) { table.createProperty(AssetEntityAdapter.P_CREATED_BY_IP, OType.STRING); } }); }
Example #18
Source File: OrientPyPiRepairIndexComponent.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public OrientPyPiRepairIndexComponent(final RepositoryManager repositoryManager, final AssetEntityAdapter assetEntityAdapter, @Named(HostedType.NAME) final Type type, @Named(PyPiFormat.NAME) final Format format) { super(repositoryManager, assetEntityAdapter, type, format); }
Example #19
Source File: NpmRepairPackageRootComponent.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public NpmRepairPackageRootComponent(final RepositoryManager repositoryManager, final AssetEntityAdapter assetEntityAdapter, final NpmPackageParser npmPackageParser, @Named(HostedType.NAME) final Type hostedType, @Named(NpmFormat.NAME) final Format npmFormat) { super(repositoryManager, assetEntityAdapter, hostedType, npmFormat); this.npmPackageParser = checkNotNull(npmPackageParser); }
Example #20
Source File: ComponentDatabaseUpgrade_1_4.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private void createComponentIndex(final ODatabaseDocumentTx db, final OClass type) { if (db.getMetadata().getIndexManager().getIndex(I_COMPONENT) == null) { type.createIndex(I_COMPONENT, INDEX_TYPE.NOTUNIQUE, AssetEntityAdapter.P_COMPONENT); } }
Example #21
Source File: ContentExpressionFunction.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; //if a single repo was selected, we want to auth against that member if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } //if all repos (or all of format) was selected, use the repository the asset was in, as well as any groups //that may contain that repository else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; //find the repository that matches the asset String assetRepository = getAssetRepository(asset); //if can't find it, just back out, nothing more to see here if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); }
Example #22
Source File: ContentExpressionFunction.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Nullable private String getAssetRepository(ODocument asset) { OIdentifiable bucketId = asset.field(AssetEntityAdapter.P_BUCKET, OIdentifiable.class); ODocument bucket = bucketId.getRecord(); return bucket.field(BucketEntityAdapter.P_REPOSITORY_NAME, String.class); }
Example #23
Source File: ComponentDatabaseUpgrade_1_3.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private void createAssetBlobUpdatedField() { try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { maybeCreateProperty(getAssetDbClass(db), AssetEntityAdapter.P_BLOB_UPDATED, OType.DATETIME); } }
Example #24
Source File: BrowseAssetsSqlBuilder.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Inject BrowseAssetsSqlBuilder(final AssetEntityAdapter assetEntityAdapter) { this.assetEntityAdapter = checkNotNull(assetEntityAdapter); }
Example #25
Source File: BrowseAssetsSqlBuilder.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override protected String getBrowseIndex() { return AssetEntityAdapter.I_NAME_CASEINSENSITIVE; }
Example #26
Source File: ComponentDatabaseUpgrade_1_3.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private void createAssetBlobCreatedField() { try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { maybeCreateProperty(getAssetDbClass(db), AssetEntityAdapter.P_BLOB_CREATED, OType.DATETIME); } }
Example #27
Source File: OrientRebuildBrowseNodeService.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override public void rebuild(final Repository repo, final BooleanSupplier isCancelled) throws RebuildBrowseNodeFailedException { log.info("Deleting browse nodes for repository {}", repo.getName()); browseNodeManager.deleteByRepository(repo.getName()); log.info("Rebuilding browse nodes for repository {}", repo.getName()); Bucket bucket = bucketStore.read(repo.getName()); ORID bucketId = AttachedEntityHelper.id(bucket); try { long processed = 0; long total = assetStore.countAssets(ImmutableList.of(bucket)); if (total > 0) { ProgressLogIntervalHelper progressLogger = new ProgressLogIntervalHelper(log, 60); Stopwatch sw = Stopwatch.createStarted(); OIndexCursor cursor = assetStore.getIndex(AssetEntityAdapter.I_BUCKET_COMPONENT_NAME).cursor(); List<Entry<OCompositeKey, EntityId>> nextPage = assetStore.getNextPage(cursor, rebuildPageSize); while (!Iterables.isEmpty(nextPage)) { checkContinuation(isCancelled, repo.getName()); List<Asset> assets = new ArrayList<>(rebuildPageSize); for (Entry<OCompositeKey, EntityId> indexEntry : nextPage) { if (bucketId.equals(indexEntry.getKey().getKeys().get(BUCKET_KEY_ID))) { assets.add(assetStore.getById(indexEntry.getValue())); } } int assetsSize = Iterables.size(assets); browseNodeManager.createFromAssets(repo, assets); processed += assetsSize; long elapsed = sw.elapsed(TimeUnit.MILLISECONDS); progressLogger.info("Rebuilt browse nodes for {} / {} assets in {} ms", processed, total, elapsed); nextPage = assetStore.getNextPage(cursor, rebuildPageSize); } progressLogger.flush(); // ensure final rebuild message is flushed } } catch (Exception e) { throw new RebuildBrowseNodeFailedException("Could not re-create browse nodes", e); } }
Example #28
Source File: RawContentFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Inject public RawContentFacetImpl(final AssetEntityAdapter assetEntityAdapter) { this.assetEntityAdapter = checkNotNull(assetEntityAdapter); }
Example #29
Source File: OrientPyPiFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Inject public OrientPyPiFacetImpl(final AssetEntityAdapter assetEntityAdapter) { this.assetEntityAdapter = checkNotNull(assetEntityAdapter); }
Example #30
Source File: AssetContinuationTokenHelper.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Inject public AssetContinuationTokenHelper(AssetEntityAdapter entityAdapter) { super(entityAdapter); }