org.sonatype.nexus.common.entity.EntityHelper Java Examples
The following examples show how to use
org.sonatype.nexus.common.entity.EntityHelper.
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: AssetStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void getNextPageReturnsEntriesByPages() { int limit = 2; Asset asset1 = createAsset(bucket, "asset1", component); Asset asset2 = createAsset(bucket, "asset2", component); Asset asset3 = createAsset(bucket, "asset3", component); try (ODatabaseDocumentTx db = database.getInstance().connect()) { assetEntityAdapter.addEntity(db, asset1); assetEntityAdapter.addEntity(db, asset2); assetEntityAdapter.addEntity(db, asset3); } OIndexCursor cursor = underTest.getIndex(AssetEntityAdapter.I_BUCKET_COMPONENT_NAME).cursor(); List<Entry<OCompositeKey, EntityId>> assetPage1 = underTest.getNextPage(cursor, limit); List<Entry<OCompositeKey, EntityId>> assetPage2 = underTest.getNextPage(cursor, limit); assertThat(assetPage1.size(), is(2)); assertThat(assetPage1.get(0).getValue(), is(EntityHelper.id(asset1))); assertThat(assetPage1.get(1).getValue(), is(EntityHelper.id(asset2))); assertThat(assetPage2.size(), is(1)); assertThat(assetPage2.get(0).getValue(), is(EntityHelper.id(asset3))); }
Example #2
Source File: OrientBrowseNodeManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void createFromAssetSavesNodesForFormatSpecificAssetWithComponent() { List<BrowsePaths> assetPath = toBrowsePaths(asList("component", "asset")); Component component = createComponent("component", null, null, "componentId"); Asset asset = createAsset("asset", "assetId", MAVEN_2, EntityHelper.id(component)); when(maven2BrowseNodeGenerator.computeAssetPaths(asset, component)).thenReturn(assetPath); when(maven2BrowseNodeGenerator.computeComponentPaths(asset, component)).thenReturn(assetPath.subList(0, 1)); manager.createFromAsset(REPOSITORY_NAME, asset); verify(browseNodeStore) .createComponentNode(REPOSITORY_NAME, MAVEN_2, toBrowsePaths(singletonList(component.name())), component); verify(browseNodeStore) .createAssetNode(REPOSITORY_NAME, MAVEN_2, toBrowsePaths(asList(component.name(), asset.name())), asset); verifyNoMoreInteractions(browseNodeStore); }
Example #3
Source File: OrientBrowseNodeManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Component createComponent(final String name, final String group, final String version, final String componentId) { EntityMetadata metadata = mock(EntityMetadata.class); when(metadata.getId()).thenReturn(new DetachedEntityId(componentId)); Component component = new DefaultComponent(); component.name(name); component.group(group); component.version(version); component.setEntityMetadata(metadata); when(componentStore.read(EntityHelper.id(component))).thenReturn(component); return component; }
Example #4
Source File: BrowseNodeEntityAdapterTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private void createEntities(final ODatabaseDocumentTx db) { bucket = new Bucket(); bucket.setRepositoryName(REPOSITORY_NAME); bucket.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); bucketEntityAdapter.addEntity(db, bucket); component = new DefaultComponent(); component.bucketId(EntityHelper.id(bucket)); component.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); component.format(FORMAT_NAME); component.group("org").name("foo").version("1.0"); componentEntityAdapter.addEntity(db, component); asset = new Asset(); asset.bucketId(EntityHelper.id(bucket)); asset.componentId(EntityHelper.id(component)); asset.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); asset.format(FORMAT_NAME); asset.name("/org/foo/1.0/foo-1.0.jar"); assetEntityAdapter.addEntity(db, asset); }
Example #5
Source File: StorageTxImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Deletes the existing blob for the asset if one exists, updating the blob updated field if necessary. The * write policy will be enforced for this operation and will throw an exception if updates are not supported. */ private void maybeDeleteBlob(final Asset asset, final WritePolicy effectiveWritePolicy) { DateTime now = DateTime.now(); if (asset.blobRef() != null) { // updating old blob if (!effectiveWritePolicy.checkUpdateAllowed()) { throw new IllegalOperationException("Repository does not allow updating assets: " + repositoryName); } asset.blobUpdated(now); deleteBlob(asset.blobRef(), effectiveWritePolicy, format("Updating asset %s", EntityHelper.id(asset))); } else { // creating new blob asset.blobCreated(now); asset.blobUpdated(now); } }
Example #6
Source File: RebuildBrowseNodesManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Asset createAsset(final String name, final String format, final Bucket bucket) throws Exception { Asset asset = new Asset(); asset.name(name); Method m = MetadataNode.class.getDeclaredMethod("format", String.class); m.setAccessible(true); m.invoke(asset, format); m = MetadataNode.class.getDeclaredMethod("bucketId", EntityId.class); m.setAccessible(true); m.invoke(asset, EntityHelper.id(bucket)); m = MetadataNode.class.getDeclaredMethod("attributes", NestedAttributesMap.class); m.setAccessible(true); m.invoke(asset, new NestedAttributesMap("attributes", new HashMap<>())); return asset; }
Example #7
Source File: AssetStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void getNextPageStopsAtNullEntry() { int limit = 2; Asset asset1 = createAsset(bucket, "asset1", component); try (ODatabaseDocumentTx db = database.getInstance().connect()) { assetEntityAdapter.addEntity(db, asset1); } OIndexCursor cursor = underTest.getIndex(AssetEntityAdapter.I_BUCKET_COMPONENT_NAME).cursor(); List<Entry<OCompositeKey, EntityId>> assetPage1 = underTest.getNextPage(cursor, limit); assertThat(assetPage1.size(), is(1)); assertThat(assetPage1.get(0).getValue(), is(EntityHelper.id(asset1))); }
Example #8
Source File: ComponentStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void getNextPageReturnsEntriesByPages() { int limit = 2; Component entity1 = createComponent(bucket, "group1", "name1", "version1"); Component entity2 = createComponent(bucket, "group2", "name2", "version2"); Component entity3 = createComponent(bucket, "group3", "name3", "version3"); try (ODatabaseDocumentTx db = database.getInstance().connect()) { entityAdapter.addEntity(db, entity1); entityAdapter.addEntity(db, entity2); entityAdapter.addEntity(db, entity3); } OIndexCursor cursor = underTest.getIndex(ComponentEntityAdapter.I_GROUP_NAME_VERSION_INSENSITIVE).cursor(); List<Entry<OCompositeKey, EntityId>> page1 = underTest.getNextPage(cursor, limit); List<Entry<OCompositeKey, EntityId>> page2 = underTest.getNextPage(cursor, limit); assertThat(page1.size(), is(2)); assertThat(page1.get(0).getValue(), is(EntityHelper.id(entity1))); assertThat(page1.get(1).getValue(), is(EntityHelper.id(entity2))); assertThat(page2.size(), is(1)); assertThat(page2.get(0).getValue(), is(EntityHelper.id(entity3))); }
Example #9
Source File: ComponentStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void getNextPageStopsAtNullEntry() { int limit = 2; Component entity1 = createComponent(bucket, "group1", "name1", "version1"); try (ODatabaseDocumentTx db = database.getInstance().connect()) { entityAdapter.addEntity(db, entity1); } OIndexCursor cursor = underTest.getIndex(ComponentEntityAdapter.I_GROUP_NAME_VERSION_INSENSITIVE).cursor(); List<Entry<OCompositeKey, EntityId>> page1 = underTest.getNextPage(cursor, limit); assertThat(page1.size(), is(1)); assertThat(page1.get(0).getValue(), is(EntityHelper.id(entity1))); }
Example #10
Source File: ComponentComponentTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void testDeleteComponent_success() { String repositoryName = "testRepositoryName"; String format = "testFormat"; Component component = makeTestComponent(format); Asset asset = mock(Asset.class); VariableSource variableSource = mock(VariableSource.class); when(assetVariableResolver.fromAsset(asset)).thenReturn(variableSource); when(storageTx.findComponent(any(EntityId.class))).thenReturn(component); when(storageTx.browseAssets(component)).thenReturn(Collections.singletonList(asset)); when(contentPermissionChecker.isPermitted(repositoryName, format, BreadActions.DELETE, variableSource)) .thenReturn(true); when(defaultComponentFinder.findMatchingComponents( eq(repository), eq(EntityHelper.id(component).getValue()), eq(component.group()), eq(component.name()), eq(component.version()) )).thenReturn(ImmutableList.of(component)); deleteComponent(component, repositoryName); }
Example #11
Source File: OrientRoutingRule.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AbstractEntity that = (AbstractEntity) o; if (hasMetadata(this) && hasMetadata(that)) { return Objects.equals(EntityHelper.id(this), EntityHelper.id(that)); } return super.equals(o); }
Example #12
Source File: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doPutPackage(final TempBlob tempBlob, final Payload content, final ConanCoords coords, final AssetKind assetKind) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Component component = getOrCreateComponent(tx, bucket, coords); String assetPath = getProxyAssetPath(coords, assetKind); Asset asset = findAsset(tx, bucket, assetPath); if (asset == null) { asset = tx.createAsset(bucket, component); asset.name(assetPath); asset.formatAttributes().set(P_ASSET_KIND, CONAN_PACKAGE.name()); } else if (!asset.componentId().equals(EntityHelper.id(component))) { asset.componentId(EntityHelper.id(component)); } return saveAsset(tx, asset, tempBlob, content, null); }
Example #13
Source File: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doSaveMetadata(final TempBlob metadataContent, final Payload payload, final AssetKind assetKind, final ConanCoords coords) throws IOException { HashCode hash = null; StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Component component = getOrCreateComponent(tx, bucket, coords); String assetPath = getProxyAssetPath(coords, assetKind); Asset asset = findAsset(tx, bucket, assetPath); if (asset == null) { asset = tx.createAsset(bucket, component); asset.name(assetPath); asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); hash = hashVerifier.lookupHashFromAsset(tx, bucket, assetPath); } else if (!asset.componentId().equals(EntityHelper.id(component))) { asset.componentId(EntityHelper.id(component)); } return saveAsset(tx, asset, metadataContent, payload, hash); }
Example #14
Source File: StorageTxImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private void deleteAsset(final Asset asset, @Nullable final WritePolicy effectiveWritePolicy, final boolean deleteBlob) { checkNotNull(asset); if (deleteBlob) { BlobRef blobRef = asset.blobRef(); if (blobRef != null) { deleteBlob(blobRef, effectiveWritePolicy, format("Deleting asset %s", EntityHelper.id(asset))); } } assetEntityAdapter.deleteEntity(db, asset); }
Example #15
Source File: OrientRoutingRule.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public int hashCode() { if (hasMetadata(this)) { return Objects.hash(EntityHelper.id(this)); } return super.hashCode(); }
Example #16
Source File: LastDownloadedHandler.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Transactional(swallow = { // silently skip if the record has been deleted, someone else updated it, or the system is in read-only mode ORecordNotFoundException.class, ONeedRetryException.class, OModificationOperationProhibitedException.class }) @VisibleForTesting protected void tryPersistLastDownloadedTime(final Asset asset) { StorageTx tx = UnitOfWork.currentTx(); // reload asset in case it's changed since it was stored in the response Asset latestAsset = tx.findAsset(EntityHelper.id(asset)); if (latestAsset != null && assetManager.maybeUpdateLastDownloaded(latestAsset)) { tx.saveAsset(latestAsset); } }
Example #17
Source File: MetadataNodeEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
Iterable<T> browseByBucket(final ODatabaseDocumentTx db, final Bucket bucket) { checkNotNull(bucket); checkState(EntityHelper.hasMetadata(bucket)); Map<String, Object> parameters = ImmutableMap.<String, Object>of( P_BUCKET, bucketEntityAdapter.recordIdentity(bucket) ); String query = String.format( "select from %s where %s = :bucket", getTypeName(), P_BUCKET ); Iterable<ODocument> docs = OrientAsyncHelper.asyncIterable(db, query, parameters); return transform(docs); }
Example #18
Source File: BrowseNodeEntityAdapterTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void assetExistsFindsAssetNode() throws Exception { List<String> path = Splitter.on('/').omitEmptyStrings().splitToList(asset.name()); try (ODatabaseDocumentTx db = database.getInstance().acquire()) { underTest.createComponentNode(db, REPOSITORY_NAME, FORMAT_NAME, toBrowsePaths(path.subList(0, 3)), component); underTest.createAssetNode(db, REPOSITORY_NAME, FORMAT_NAME, toBrowsePaths(path), asset); assertThat(underTest.assetNodeExists(db, EntityHelper.id(asset)), is(true)); } }
Example #19
Source File: OrientRebuildBrowseNodeServiceTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void executeWithOfflineRepository() throws Exception { ORID bucketId = AttachedEntityHelper.id(bucket); Asset asset1 = createMockAsset("#1:1"); Asset asset2 = createMockAsset("#1:2"); Asset asset3 = createMockAsset("#2:1"); List<Entry<Object, EntityId>> page = asList( createIndexEntry(bucketId, EntityHelper.id(asset1)), createIndexEntry(bucketId, EntityHelper.id(asset2)), createIndexEntry(bucketId, EntityHelper.id(asset3))); when(config.isOnline()).thenReturn(false); when(assetStore.countAssets(any())).thenReturn(3L); when(assetStore.getNextPage(any(), eq(REBUILD_PAGE_SIZE))).thenReturn(page, emptyList()); when(assetStore.getById(EntityHelper.id(asset1))).thenReturn(asset1); when(assetStore.getById(EntityHelper.id(asset2))).thenReturn(asset2); when(assetStore.getById(EntityHelper.id(asset3))).thenReturn(asset3); underTest.rebuild(repository, () -> false); verify(assetStore, times(2)).getNextPage(any(), eq(REBUILD_PAGE_SIZE)); verify(browseNodeManager).createFromAssets(eq(repository), eq(asList(asset1, asset2, asset3))); }
Example #20
Source File: OrientRebuildBrowseNodeServiceTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void executeProcessesAllAssetsInPages() throws RebuildBrowseNodeFailedException { ORID bucketId = AttachedEntityHelper.id(bucket); Asset asset1 = createMockAsset("#1:1"); Asset asset2 = createMockAsset("#1:2"); Asset asset3 = createMockAsset("#2:1"); List<Entry<Object, EntityId>> page1 = asList( createIndexEntry(bucketId, EntityHelper.id(asset1)), createIndexEntry(bucketId, EntityHelper.id(asset2))); List<Entry<Object, EntityId>> page2 = asList( createIndexEntry(bucketId, EntityHelper.id(asset3))); List<Entry<Object, EntityId>> page3 = emptyList(); when(assetStore.countAssets(any())).thenReturn(3L); when(assetStore.getNextPage(any(), eq(REBUILD_PAGE_SIZE))).thenReturn(page1, page2, page3); when(assetStore.getById(EntityHelper.id(asset1))).thenReturn(asset1); when(assetStore.getById(EntityHelper.id(asset2))).thenReturn(asset2); when(assetStore.getById(EntityHelper.id(asset3))).thenReturn(asset3); underTest.rebuild(repository, () -> false); verify(assetStore, times(3)).getNextPage(any(), eq(REBUILD_PAGE_SIZE)); verify(browseNodeManager).createFromAssets(eq(repository), eq(asList(asset1, asset2))); verify(browseNodeManager).createFromAssets(eq(repository), eq(asList(asset3))); }
Example #21
Source File: OrientRebuildBrowseNodeServiceTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void executionCanCancelDuringTheProcess() throws Exception { ORID bucketId = AttachedEntityHelper.id(bucket); Asset asset1 = createMockAsset("#1:1"); Asset asset2 = createMockAsset("#1:2"); Asset asset3 = createMockAsset("#2:1"); List<Entry<Object, EntityId>> page1 = asList( createIndexEntry(bucketId, EntityHelper.id(asset1)), createIndexEntry(bucketId, EntityHelper.id(asset2))); List<Entry<Object, EntityId>> page2 = asList( createIndexEntry(bucketId, EntityHelper.id(asset3))); List<Entry<Object, EntityId>> page3 = emptyList(); when(assetStore.countAssets(any())).thenReturn(3L); when(assetStore.getNextPage(any(), eq(REBUILD_PAGE_SIZE))).thenReturn(page1, page2, page3); when(assetStore.getById(EntityHelper.id(asset1))).thenReturn(asset1); when(assetStore.getById(EntityHelper.id(asset2))).thenReturn(asset2); when(assetStore.getById(EntityHelper.id(asset3))).thenReturn(asset3); BooleanSupplier mockCancel = mock(BooleanSupplier.class); when(mockCancel.getAsBoolean()).thenReturn(false).thenReturn(true); thrown.expect(RebuildBrowseNodeFailedException.class); thrown.expectCause(instanceOf(TaskInterruptedException.class)); underTest.rebuild(repository, mockCancel); verify(assetStore, times(1)).getNextPage(any(), eq(REBUILD_PAGE_SIZE)); }
Example #22
Source File: StorageTxImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @Guarded(by = ACTIVE) public void saveComponent(final Component component) { if (EntityHelper.hasMetadata(component)) { componentEntityAdapter.editEntity(db, component); } else { componentEntityAdapter.addEntity(db, component); } }
Example #23
Source File: AssetEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
Iterable<Asset> browseByComponent(final ODatabaseDocumentTx db, final Component component) { checkNotNull(component); checkState(EntityHelper.hasMetadata(component)); Map<String, Object> parameters = ImmutableMap.of( "bucket", bucketEntityAdapter.recordIdentity(component.bucketId()), "component", componentEntityAdapter.recordIdentity(component) ); String query = String.format( "select from %s where %s = :bucket and %s = :component", DB_CLASS, P_BUCKET, P_COMPONENT ); Iterable<ODocument> docs = db.command(new OCommandSQL(query)).execute(parameters); return transform(docs); }
Example #24
Source File: BrowseServiceImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public Map<EntityId, String> getRepositoryBucketNames(final Repository repository) { checkNotNull(repository); try (StorageTx storageTx = repository.facet(StorageFacet.class).txSupplier().get()) { storageTx.begin(); List<Bucket> buckets = getBuckets(storageTx, getRepositories(repository)); return buckets.stream().collect(toMap(EntityHelper::id, Bucket::getRepositoryName)); } }
Example #25
Source File: BrowseNodeEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Associates a {@link OrientBrowseNode} with the given {@link Asset}. */ public void createAssetNode(final ODatabaseDocumentTx db, final String repositoryName, final String format, final List<? extends BrowsePath> paths, final Asset asset) { //create any parent folder nodes for this asset if not already existing maybeCreateParentNodes(db, repositoryName, format, paths.subList(0, paths.size() - 1)); //now create the asset node OrientBrowseNode node = newNode(repositoryName, format, paths); ODocument document = findNodeRecord(db, node); if (document == null) { // complete the new entity before persisting node.setAssetId(EntityHelper.id(asset)); addEntity(db, node); } else { ORID oldAssetId = document.field(P_ASSET_ID, ORID.class); ORID newAssetId = assetEntityAdapter.recordIdentity(asset); if (oldAssetId == null) { // shortcut: merge new information directly into existing record document.field(P_ASSET_ID, newAssetId); String path = document.field(P_PATH, OType.STRING); //if this node is now an asset, we don't want a trailing slash if (!asset.name().endsWith("/") && path.endsWith("/")) { path = path.substring(0, path.length() - 1); document.field(P_PATH, path); } document.save(); } else if (!oldAssetId.equals(newAssetId)) { // retry in case this is due to an out-of-order delete event throw new BrowseNodeCollisionException("Node already has an asset"); } } }
Example #26
Source File: BrowseNodeEntityAdapter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Associates a {@link OrientBrowseNode} with the given {@link Component}. */ public void createComponentNode(final ODatabaseDocumentTx db, final String repositoryName, final String format, final List<? extends BrowsePath> paths, final Component component) { //create any parent folder nodes for this component if not already existing maybeCreateParentNodes(db, repositoryName, format, paths.subList(0, paths.size() - 1)); //now create the component node OrientBrowseNode node = newNode(repositoryName, format, paths); ODocument document = findNodeRecord(db, node); if (document == null) { // complete the new entity before persisting node.setComponentId(EntityHelper.id(component)); addEntity(db, node); } else { ORID oldComponentId = document.field(P_COMPONENT_ID, ORID.class); ORID newComponentId = componentEntityAdapter.recordIdentity(component); if (oldComponentId == null) { // shortcut: merge new information directly into existing record document.field(P_COMPONENT_ID, newComponentId); document.save(); } else if (!oldComponentId.equals(newComponentId)) { // retry in case this is due to an out-of-order delete event throw new BrowseNodeCollisionException("Node already has a component"); } } }
Example #27
Source File: StorageTxImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @Guarded(by = ACTIVE) public void saveAsset(final Asset asset) { if (EntityHelper.hasMetadata(asset)) { assetEntityAdapter.editEntity(db, asset); } else { assetEntityAdapter.addEntity(db, asset); } }
Example #28
Source File: ComponentComponentTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testDeleteComponent_success_multipleAssets() { String repositoryName = "testRepositoryName"; String format = "testFormat"; Component component = makeTestComponent(format); Asset asset = mock(Asset.class); VariableSource variableSource = mock(VariableSource.class); Asset asset2 = mock(Asset.class); VariableSource variableSource2 = mock(VariableSource.class); when(assetVariableResolver.fromAsset(asset)).thenReturn(variableSource); when(assetVariableResolver.fromAsset(asset2)).thenReturn(variableSource2); when(storageTx.findComponent(any(EntityId.class))).thenReturn(component); when(storageTx.browseAssets(component)).thenReturn(Arrays.asList(asset, asset2)); when(contentPermissionChecker.isPermitted(repositoryName, format, BreadActions.DELETE, variableSource)) .thenReturn(true); when(contentPermissionChecker.isPermitted(repositoryName, format, BreadActions.DELETE, variableSource2)) .thenReturn(true); when(defaultComponentFinder.findMatchingComponents( eq(repository), eq(EntityHelper.id(component).getValue()), eq(component.group()), eq(component.name()), eq(component.version()) )).thenReturn(ImmutableList.of(component)); deleteComponent(component, repositoryName); verify(maintenanceService).deleteComponent(repository, component); }
Example #29
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
protected String generateNewRevId(final Asset packageRootAsset) { String newRevision = EntityHelper.version(packageRootAsset).getValue(); // For NEXUS-18094 we gonna request to upgrade the actual asset getEventManager().post(new NpmRevisionUpgradeRequestEvent(packageRootAsset, newRevision)); return newRevision; }
Example #30
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private void updateRevision(final NestedAttributesMap packageRoot, final Asset packageRootAsset, final boolean createdPackageRoot) { String newRevision = "1"; if (!createdPackageRoot) { if (packageRoot.contains(META_REV)) { String rev = packageRoot.get(META_REV, String.class); newRevision = Integer.toString(Integer.parseInt(rev) + 1); } else { /* This is covering the edge case when a new package is uploaded to a repository where the packageRoot already exists. If that packageRoot was created using an earlier version of NXRM where we didn't store the rev then we need to add it in. We also add the rev in on download but it is possible that someone is uploading a package where the packageRoot has never been downloaded before. */ newRevision = EntityHelper.version(packageRootAsset).getValue(); } } packageRoot.set(META_ID, packageRootAsset.name()); packageRoot.set(META_REV, newRevision); }