public class MockAttachmentStorage extends SingletonSerializeAsToken implements AttachmentStorage
A mock implementation of interface AttachmentStorage
for use within tests
interface AttachmentStorage
AttachmentStorage.DefaultImpls
Constructor and Description |
---|
MockAttachmentStorage()
A mock implementation of
interface AttachmentStorage for use within tests |
Modifier and Type | Method and Description |
---|---|
NonExistentClass |
getAttachmentIdAndBytes(java.io.InputStream jar) |
java.util.Map<net.corda.core.crypto.SecureHash,NonExistentClass> |
getFiles()
A map of the currently stored files by their
class SecureHash |
java.util.List<net.corda.core.crypto.SecureHash> |
getLatestContractAttachments(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.
|
boolean |
hasAttachment(SecureHash attachmentId)
Searches for an attachment already in the store
|
SecureHash |
importAttachment(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.
|
SecureHash |
importAttachment(java.io.InputStream jar,
java.lang.String uploader,
java.lang.String filename)
Inserts the given attachment with additional metadata, see
AttachmentStorage.importAttachment for input stream handling
Extra parameters: |
SecureHash |
importContractAttachment(java.util.List<java.lang.String> contractClassNames,
java.lang.String uploader,
java.io.InputStream jar,
SecureHash attachmentId,
java.util.List<? extends java.security.PublicKey> signers) |
void |
importContractAttachment(SecureHash attachmentId,
ContractAttachment contractAttachment) |
SecureHash |
importOrGetAttachment(java.io.InputStream jar)
Inserts or returns Attachment Id of attachment. Does not throw an exception if already uploaded.
|
Attachment |
openAttachment(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.
|
java.util.List<net.corda.core.crypto.SecureHash> |
queryAttachments(AttachmentQueryCriteria criteria,
AttachmentSort sorting)
Searches attachment using given criteria and optional sort rules
|
toToken
getLatestContractAttachments, hasAttachment, importAttachment, importAttachment, importOrGetAttachment, openAttachment, queryAttachments, queryAttachments
toToken
public MockAttachmentStorage()
A mock implementation of interface AttachmentStorage
for use within tests
interface AttachmentStorage
public java.util.Map<net.corda.core.crypto.SecureHash,NonExistentClass> getFiles()
A map of the currently stored files by their class SecureHash
class SecureHash
public SecureHash importAttachment(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.
public SecureHash importAttachment(java.io.InputStream jar, java.lang.String uploader, java.lang.String filename)
Inserts the given attachment with additional metadata, see AttachmentStorage.importAttachment
for input stream handling
Extra parameters:
uploader
- Uploader namefilename
- Name of the fileAttachmentStorage.importAttachment
public Attachment openAttachment(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.
public java.util.List<net.corda.core.crypto.SecureHash> queryAttachments(AttachmentQueryCriteria criteria, 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(SecureHash attachmentId)
Searches for an attachment already in the store
attachmentId
- The attachment Idpublic SecureHash importOrGetAttachment(java.io.InputStream jar)
Inserts or returns Attachment Id of attachment. Does not throw an exception if already uploaded.
jar
- InputStream of Jar filepublic SecureHash importContractAttachment(java.util.List<java.lang.String> contractClassNames, java.lang.String uploader, java.io.InputStream jar, SecureHash attachmentId, java.util.List<? extends java.security.PublicKey> signers)
public void importContractAttachment(SecureHash attachmentId, ContractAttachment contractAttachment)
public NonExistentClass getAttachmentIdAndBytes(java.io.InputStream jar)
public java.util.List<net.corda.core.crypto.SecureHash> getLatestContractAttachments(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.