Skip to content

Commit ca4005d

Browse files
committed
Add PublishFrom
1 parent 8623883 commit ca4005d

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

src/main/java/multichain/command/StreamCommand.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,58 @@ public String publish(String streamName, String key, String dataHex) throws Mult
537537

538538
return stringPublish;
539539
}
540+
541+
/**
542+
* {@link #publish(String, String, String)} with control over the from-address used to
543+
* used to publish
544+
*
545+
* @param addressFrom
546+
* (Address) The from-address used to publish
547+
* @param streamName
548+
* (String) The name of the stream
549+
* @param key
550+
* (String) The key of the item
551+
* @param dataHex
552+
* (String) Data in hexadecimal
553+
* @return (String) The transaction id
554+
* @throws MultichainException
555+
*/
556+
557+
public String publishFrom(Address addressFrom, String streamName, String key, String dataHex) throws MultichainException {
558+
String stringPublish = "";
559+
Object objectPublish = executePublishFrom(addressFrom.getAddress(), streamName, key, dataHex);
560+
if (verifyInstance(objectPublish, String.class)) {
561+
stringPublish = (String) objectPublish;
562+
}
563+
return stringPublish;
564+
}
565+
566+
/**
567+
* {@link #createFrom(Address, String, String, String)} with address in format string
568+
*
569+
* @param addressFrom
570+
* (String) The from-address used to publish
571+
* @param streamName
572+
* (String) The name of the stream
573+
* @param key
574+
* (String) The key of the item
575+
* @param dataHex
576+
* (String) Data in hexadecimal
577+
* @return (String) The transaction id
578+
* @throws MultichainException
579+
*/
580+
581+
public String publishFrom(String addressFrom, String streamName, String key, String dataHex) throws MultichainException {
582+
String stringPublish = "";
540583

584+
Object objectPublish = executePublishFrom(addressFrom, streamName, key, dataHex);
585+
if (verifyInstance(objectPublish, String.class)) {
586+
stringPublish = (String) objectPublish;
587+
}
588+
589+
return stringPublish;
590+
}
591+
541592
/**
542593
* subscribe entity-identifier(s) ( rescan )
543594
*

src/main/java/multichain/command/builders/QueryBuilderStream.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,30 @@ protected Object executePublish(String streamName, String key, String dataHex) t
271271
return execute(CommandEnum.PUBLISH, streamName, key, dataHex);
272272
}
273273

274+
/**
275+
* {@link #executePublish(String, String, String)} with control over the
276+
* from-address used to publish
277+
*
278+
* @param addressFrom
279+
* (String) The from-address used to publish
280+
* @param streamName
281+
* (String) The name of the stream
282+
* @param key
283+
* (String) The key of the item
284+
* @param dataHex
285+
* (String) Data in hexadecimal
286+
* @return (String) The transaction id
287+
* @throws MultichainException
288+
*/
289+
protected Object executePublishFrom(String addressFrom ,String streamName, String key, String dataHex) throws MultichainException {
290+
MultichainTestParameter.isNotNullOrEmpty("addressFrom", addressFrom);
291+
MultichainTestParameter.isNotNullOrEmpty("streamName", streamName);
292+
MultichainTestParameter.isNotNullOrEmpty("key", key);
293+
MultichainTestParameter.isNotNullOrEmpty("dataHex", dataHex);
294+
295+
return execute(CommandEnum.PUBLISHFROM, addressFrom, streamName, key, dataHex);
296+
}
297+
274298
/**
275299
* subscribe entity-identifier(s) ( rescan )
276300
*

0 commit comments

Comments
 (0)