Skip to content

Commit 574c180

Browse files
committed
peer id and name ist bot the same.
1 parent 2fd835b commit 574c180

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

src/main/java/net/sharksystem/asap/ASAPPeer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package net.sharksystem.asap;
22

3+
import net.sharksystem.SharkException;
4+
import net.sharksystem.fs.ExtraData;
5+
36
import java.io.IOException;
47

58
public interface ASAPPeer extends
@@ -67,4 +70,6 @@ ASAPConnection handleConnection(InputStream is, OutputStream os, boolean encrypt
6770
* @throws ASAPException key never used in putExtra
6871
*/
6972
byte[] getExtra(CharSequence key) throws ASAPException, IOException;
73+
74+
ExtraData getExtraData() throws SharkException, IOException;
7075
}

src/main/java/net/sharksystem/asap/ASAPPeerFS.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package net.sharksystem.asap;
22

3+
import net.sharksystem.SharkException;
34
import net.sharksystem.asap.engine.*;
45
import net.sharksystem.asap.utils.ASAPLogHelper;
6+
import net.sharksystem.fs.ExtraData;
57
import net.sharksystem.utils.Log;
68

79
import javax.swing.*;
@@ -159,4 +161,9 @@ public void sendTransientASAPMessage(CharSequence nextHopPeerID,
159161
public String toString() {
160162
return this.getInternalPeer().getOwner().toString();
161163
}
164+
165+
@Override
166+
public ExtraData getExtraData() throws SharkException, IOException {
167+
return this.getInternalPeer().getExtraData();
168+
}
162169
}

src/main/java/net/sharksystem/asap/engine/ASAPInternalPeer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.engine;
22

3+
import net.sharksystem.SharkException;
34
import net.sharksystem.asap.ASAPConnectionHandler;
45
import net.sharksystem.asap.ASAPException;
56
import net.sharksystem.asap.ASAPSecurityException;
@@ -155,5 +156,7 @@ void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence urlTarget
155156

156157
ASAPKeyStore getASAPKeyStore() throws ASAPSecurityException;
157158

159+
ExtraData getExtraData() throws SharkException, IOException;
160+
158161
void setSecurityAdministrator(DefaultSecurityAdministrator securityAdministrator);
159162
}

src/main/java/net/sharksystem/asap/engine/ASAPInternalPeerFS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public ASAPKeyStore getASAPKeyStore() throws ASAPSecurityException {
700700
///////////////////////////////////////////////////////////////////////////////////////////////////////////
701701
private ExtraData extraData = null;
702702

703-
private ExtraData getExtraData() throws SharkException, IOException {
703+
public ExtraData getExtraData() throws SharkException, IOException {
704704
if(this.extraData == null) {
705705
this.extraData = new ExtraDataFS(this.rootFolderName);
706706
}

src/main/java/net/sharksystem/asap/utils/ASAPSerialization.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ public class ASAPSerialization {
1717
public static final short BLANK_LEFT_SHORT = 0x00FF;
1818
public static final short BLANK_RIGHT_SHORT = (short) 0xFF00;
1919

20+
public static String byteArray2String(byte[] serializedString) throws IOException, ASAPException {
21+
ByteArrayInputStream bais = new ByteArrayInputStream(serializedString);
22+
return readCharSequenceParameter(bais);
23+
}
24+
25+
public static byte[] string2byteArray(CharSequence charSequence2Serialize) throws IOException {
26+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
27+
writeCharSequenceParameter(charSequence2Serialize, baos);
28+
return baos.toByteArray();
29+
}
30+
2031
public static void writeByteArray(byte[] bytes2Write, OutputStream os) throws IOException {
2132
if(bytes2Write == null) {
2233
writeNonNegativeIntegerParameter(0, os);

src/main/java/net/sharksystem/utils/Utils.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,19 @@ public static String calendar2String(Calendar calendarObject) {
123123
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
124124
return dateFormat.format(calendarObject.getTime());
125125
}
126+
127+
public static String getStringByStringList(List<String> list) {
128+
if(list == null || list.isEmpty()) return "empty list";
129+
StringBuilder sb = new StringBuilder();
130+
int i = 0;
131+
boolean first = true;
132+
for(String o : list) {
133+
if(first) first = false;
134+
else sb.append(", ");
135+
sb.append(i++);
136+
sb.append(": ");
137+
sb.append(o);
138+
}
139+
return sb.toString();
140+
}
126141
}

0 commit comments

Comments
 (0)