public class MockAttachmentStorage extends SingletonSerializeAsToken implements AttachmentStorage
A mock implementation of interface AttachmentStorage
for use within tests
interface AttachmentStorage
public MockAttachmentStorage()
A mock implementation of interface AttachmentStorage
for use within tests
interface AttachmentStorage
@NotNull public java.util.Map<net.corda.core.crypto.SecureHash,kotlin.Pair> getFiles()
A map of the currently stored files by their class SecureHash
class SecureHash
@NotNull public SecureHash importAttachment(@NotNull java.io.InputStream jar)
Inserts the given attachment into the store, does not close the input stream. This can be an intensive operation due to the need to copy the bytes to disk and hash them along the way.
Note that you should not pass a java.util.jar.JarInputStream into this method and it will throw if you do, because access to the raw byte stream is required.
FileAlreadyExistsException
- if the given byte stream has already been inserted.IllegalArgumentException
- if the given byte stream is empty or a java.util.jar.JarInputStream.IOException
- if something went wrong.@NotNull public SecureHash importAttachment(@NotNull java.io.InputStream jar, @NotNull java.lang.String uploader, @Nullable java.lang.String filename)
Inserts the given attachment with additional metadata, see importAttachment
for input stream handling
Extra parameters:
uploader
- Uploader namefilename
- Name of the fileimportAttachment
@Nullable public Attachment openAttachment(@NotNull SecureHash id)
Returns a handle to a locally stored attachment, or null if it's not known. The handle can be used to open a stream for the data, which will be a zip/jar file.
@NotNull public java.util.List<net.corda.core.crypto.SecureHash> queryAttachments(@NotNull AttachmentQueryCriteria criteria, @Nullable AttachmentSort sorting)
Searches attachment using given criteria and optional sort rules
criteria
- Query criteria to use as a filtersorting
- Sorting definition, if not given, order is undefinedpublic boolean hasAttachment(@NotNull SecureHash attachmentId)
Searches for an attachment already in the store
attachmentId
- The attachment Id@NotNull public SecureHash importOrGetAttachment(@NotNull java.io.InputStream jar)
Inserts or returns Attachment Id of attachment. Does not throw an exception if already uploaded.
jar
- InputStream of Jar file@JvmOverloads @NotNull public SecureHash importContractAttachment(@NotNull java.util.List<java.lang.String> contractClassNames, @NotNull java.lang.String uploader, @NotNull java.io.InputStream jar, @Nullable SecureHash attachmentId, @NotNull java.util.List<? extends java.security.PublicKey> signers)
@JvmOverloads @NotNull public SecureHash importContractAttachment(@NotNull java.util.List<java.lang.String> contractClassNames, @NotNull java.lang.String uploader, @NotNull java.io.InputStream jar, @Nullable SecureHash attachmentId)
@JvmOverloads @NotNull public SecureHash importContractAttachment(@NotNull java.util.List<java.lang.String> contractClassNames, @NotNull java.lang.String uploader, @NotNull java.io.InputStream jar)
public void importContractAttachment(@NotNull SecureHash attachmentId, @NotNull ContractAttachment contractAttachment)
@NotNull public kotlin.Pair<net.corda.core.crypto.SecureHash,kotlin.Array[]> getAttachmentIdAndBytes(@NotNull java.io.InputStream jar)
@NotNull public java.util.List<net.corda.core.crypto.SecureHash> getLatestContractAttachments(@NotNull java.lang.String contractClassName, int minContractVersion)
Find the Attachment Id(s) of the contract attachments with the highest version for a given contract class name from trusted upload sources. Return highest version of both signed and unsigned attachment ids (signed first, unsigned second), otherwise return a single signed or unsigned version id, or an empty list if none meet the criteria.
contractClassName
- The fully qualified name of the contract class.minContractVersion
- The minimum contract version that should be returned.