11package net .sharksystem .asap ;
22
3- import net .sharksystem .asap .management .ASAPManagementMessage ;
43import net .sharksystem .asap .management .ASAPManagementStorage ;
4+ import net .sharksystem .asap .management .ASAPManagementStorageImpl ;
55import net .sharksystem .asap .protocol .*;
66import net .sharksystem .asap .util .Log ;
77
88import java .io .IOException ;
99import java .io .InputStream ;
1010import java .io .OutputStream ;
11- import java .util .ArrayList ;
12- import java .util .HashMap ;
13- import java .util .List ;
14- import java .util .Set ;
11+ import java .util .*;
1512
1613/**
1714 * That ASAPEngine manages exchange of stored messages with peers.
@@ -94,12 +91,12 @@ public CharSequence getExtra(CharSequence uri, String key) throws IOException {
9491 }
9592
9693 @ Override
97- public void createChannel (CharSequence uri , List <CharSequence > recipients ) throws IOException , ASAPException {
94+ public void createChannel (CharSequence uri , Set <CharSequence > recipients ) throws IOException , ASAPException {
9895 this .createChannel (this .getOwner (), uri , recipients );
9996 }
10097
10198 @ Override
102- public void createChannel (CharSequence owner , CharSequence uri , List <CharSequence > recipients )
99+ public void createChannel (CharSequence owner , CharSequence uri , Set <CharSequence > recipients )
103100 throws IOException , ASAPException {
104101
105102 this .setRecipients (uri , recipients );
@@ -116,7 +113,7 @@ public void createChannel(CharSequence owner, CharSequence uri, List<CharSequenc
116113
117114 @ Override
118115 public void createChannel (CharSequence urlTarget , CharSequence recipient ) throws IOException , ASAPException {
119- ArrayList <CharSequence > recipients = new ArrayList <>();
116+ Set <CharSequence > recipients = new HashSet <>();
120117 recipients .add (recipient );
121118 this .createChannel (urlTarget , recipients );
122119 }
@@ -139,23 +136,17 @@ public boolean isASAPManagementStorageSet() {
139136 }
140137
141138 public void notifyChannelCreated (CharSequence appName , CharSequence owner ,
142- CharSequence uri , List <CharSequence > recipients )
139+ CharSequence uri , Set <CharSequence > recipients )
143140 throws ASAPException , IOException {
144141
145- byte [] createClosedASAPChannelMessage =
146- ASAPManagementMessage .getCreateClosedASAPChannelMessage (
147- owner , appName , uri , recipients );
148-
149- // put into create channel
150- this .add (ASAPManagementStorage .ASAP_CREATE_CHANNEL , createClosedASAPChannelMessage );
151-
142+ new ASAPManagementStorageImpl (this ).notifyChannelCreated (appName , owner , uri , recipients );
152143 }
153144
154145 public void addRecipient (CharSequence urlTarget , CharSequence recipient ) throws IOException {
155146 this .chunkStorage .getChunk (urlTarget , this .era ).addRecipient (recipient );
156147 }
157148
158- public void setRecipients (CharSequence urlTarget , List <CharSequence > recipients ) throws IOException {
149+ public void setRecipients (CharSequence urlTarget , Set <CharSequence > recipients ) throws IOException {
159150 this .chunkStorage .getChunk (urlTarget , this .era ).setRecipients (recipients );
160151 }
161152
@@ -234,19 +225,19 @@ public void removeChannel(CharSequence uri) throws IOException {
234225 chunk .drop ();
235226 }
236227
237- public ASAPChunkChain getChunkChain (int position ) throws IOException , ASAPException {
228+ public ASAPChannelMessages getChunkChain (int position ) throws IOException , ASAPException {
238229 return this .getChunkChain (position , this .era );
239230 }
240231
241- public ASAPChunkChain getChunkChain (CharSequence uri , int toEra ) throws IOException {
232+ public ASAPChannelMessages getChunkChain (CharSequence uri , int toEra ) throws IOException {
242233 return this .chunkStorage .getASAPChunkCache (uri , toEra );
243234 }
244235
245- public ASAPChunkChain getChunkChain (CharSequence uri ) throws IOException {
236+ public ASAPChannelMessages getChunkChain (CharSequence uri ) throws IOException {
246237 return this .getChunkChain (uri , this .getEra ());
247238 }
248239
249- public ASAPChunkChain getChunkChain (int position , int toEra )
240+ public ASAPChannelMessages getChunkChain (int position , int toEra )
250241 throws IOException , ASAPException {
251242
252243 List <CharSequence > channelURIs = this .getChannelURIs ();
0 commit comments