class NpmFacetImpl extends FacetSupport implements NpmFacet {

  @Nullable
  @Override
  public Asset putPackageRoot(final String packageId,
                              final AssetBlob assetBlob,
                              @Nullable final AttributesMap contentAttributes)
      throws IOException
  {
    final Repository repository = getRepository();
    final StorageTx tx = UnitOfWork.currentTx();
    final Bucket bucket = tx.findBucket(repository);
    Asset asset = NpmFacetUtils.findPackageRootAsset(tx, bucket, NpmPackageId.parse(packageId));

    if (asset == null) {
      asset = tx.createAsset(bucket, repository.getFormat()).name(packageId);
      saveAsset(tx, asset, assetBlob, PACKAGE_ROOT, contentAttributes);
    }

    return asset;
  }

  @Inject public  NpmFacetImpl(final NpmPackageParser npmPackageParser);

}