@Test public void testPrereleaseVersion() throws Exception { NpmPackageId packageId = new NpmPackageId(null, "query-string"); String version = "1.0.0-alpha." + System.currentTimeMillis() + ".500-beta"; String tarball = "query-string-" + version + ".tgz"; underTest.putTarball(packageId.id(), tarball, assetBlob, null); verifyTarballAndVersion(packageId, tarball, version); }
@Nullable @Override public Asset putTarball(final String packageId, final String tarballName, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) throws IOException { final Repository repository = getRepository(); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(repository); NpmPackageId npmPackageId = NpmPackageId.parse(packageId); Asset asset = NpmFacetUtils.findTarballAsset(tx, bucket, npmPackageId, tarballName); if (asset == null) { String version = extractVersion(tarballName); Component tarballComponent = getOrCreateTarballComponent(tx, repository, npmPackageId, version); asset = tx.firstAsset(tarballComponent); if (asset == null) { asset = tx.createAsset(bucket, tarballComponent).name(tarballAssetName(npmPackageId, tarballName)); } } maybeExtractFormatAttributes(tx, packageId, asset, assetBlob); saveAsset(tx, asset, assetBlob, TARBALL, contentAttributes); return asset; }
NpmFacetImpl extends FacetSupport implements NpmFacet { @Nullable @Override public Asset putTarball(final String packageId, final String tarballName, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) throws IOException { final Repository repository = getRepository(); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(repository); NpmPackageId npmPackageId = NpmPackageId.parse(packageId); Asset asset = NpmFacetUtils.findTarballAsset(tx, bucket, npmPackageId, tarballName); if (asset == null) { String version = extractVersion(tarballName); Component tarballComponent = getOrCreateTarballComponent(tx, repository, npmPackageId, version); asset = tx.firstAsset(tarballComponent); if (asset == null) { asset = tx.createAsset(bucket, tarballComponent).name(tarballAssetName(npmPackageId, tarballName)); } } maybeExtractFormatAttributes(tx, packageId, asset, assetBlob); saveAsset(tx, asset, assetBlob, TARBALL, contentAttributes); return asset; } }
NpmFacetImpl extends FacetSupport implements NpmFacet { @Nullable @Override public Asset putTarball(final String packageId, final String tarballName, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) throws IOException { final Repository repository = getRepository(); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(repository); NpmPackageId npmPackageId = NpmPackageId.parse(packageId); Asset asset = NpmFacetUtils.findTarballAsset(tx, bucket, npmPackageId, tarballName); if (asset == null) { String version = extractVersion(tarballName); Component tarballComponent = getOrCreateTarballComponent(tx, repository, npmPackageId, version); asset = tx.firstAsset(tarballComponent); if (asset == null) { asset = tx.createAsset(bucket, tarballComponent).name(tarballAssetName(npmPackageId, tarballName)); } } maybeExtractFormatAttributes(tx, packageId, asset, assetBlob); saveAsset(tx, asset, assetBlob, TARBALL, contentAttributes); return asset; } @Inject  NpmFacetImpl(final NpmPackageParser npmPackageParser); }
NpmFacetImpl extends FacetSupport implements NpmFacet { @Nullable @Override public Asset putTarball(final String packageId, final String tarballName, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) throws IOException { final Repository repository = getRepository(); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(repository); NpmPackageId npmPackageId = NpmPackageId.parse(packageId); Asset asset = NpmFacetUtils.findTarballAsset(tx, bucket, npmPackageId, tarballName); if (asset == null) { String version = extractVersion(tarballName); Component tarballComponent = getOrCreateTarballComponent(tx, repository, npmPackageId, version); asset = tx.firstAsset(tarballComponent); if (asset == null) { asset = tx.createAsset(bucket, tarballComponent).name(tarballAssetName(npmPackageId, tarballName)); } } maybeExtractFormatAttributes(tx, packageId, asset, assetBlob); saveAsset(tx, asset, assetBlob, TARBALL, contentAttributes); return asset; } @Inject  NpmFacetImpl(final NpmPackageParser npmPackageParser); @Nullable @Override Asset findRepositoryRootAsset(); @Nullable @Override Asset putRepositoryRoot(final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes); @Nullable @Override Asset findPackageRootAsset(final String packageId); @Nullable @Override Asset putPackageRoot(final String packageId,
                              final AssetBlob assetBlob,
                              @Nullable final AttributesMap contentAttributes); @Nullable @Override Asset findTarballAsset(final String packageId,
                                final String tarballName); @Nullable @Override Asset putTarball(final String packageId,
                          final String tarballName,
                          final AssetBlob assetBlob,
                          @Nullable final AttributesMap contentAttributes); }
NpmFacetImpl extends FacetSupport implements NpmFacet { @Nullable @Override public Asset putTarball(final String packageId, final String tarballName, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) throws IOException { final Repository repository = getRepository(); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(repository); NpmPackageId npmPackageId = NpmPackageId.parse(packageId); Asset asset = NpmFacetUtils.findTarballAsset(tx, bucket, npmPackageId, tarballName); if (asset == null) { String version = extractVersion(tarballName); Component tarballComponent = getOrCreateTarballComponent(tx, repository, npmPackageId, version); asset = tx.firstAsset(tarballComponent); if (asset == null) { asset = tx.createAsset(bucket, tarballComponent).name(tarballAssetName(npmPackageId, tarballName)); } } maybeExtractFormatAttributes(tx, packageId, asset, assetBlob); saveAsset(tx, asset, assetBlob, TARBALL, contentAttributes); return asset; } @Inject  NpmFacetImpl(final NpmPackageParser npmPackageParser); @Nullable @Override Asset findRepositoryRootAsset(); @Nullable @Override Asset putRepositoryRoot(final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes); @Nullable @Override Asset findPackageRootAsset(final String packageId); @Nullable @Override Asset putPackageRoot(final String packageId,
                              final AssetBlob assetBlob,
                              @Nullable final AttributesMap contentAttributes); @Nullable @Override Asset findTarballAsset(final String packageId,
                                final String tarballName); @Nullable @Override Asset putTarball(final String packageId,
                          final String tarballName,
                          final AssetBlob assetBlob,
                          @Nullable final AttributesMap contentAttributes);  }