Skip to content

Commit 468a62d

Browse files
committed
working on bug fix (only first era is routed). Problem identified. Working on a stable solution - no workaround.
1 parent 3cde100 commit 468a62d

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ public interface ASAPStorage {
2626
*/
2727
ASAPStorage getExistingIncomingStorage(CharSequence sender) throws IOException, ASAPException;
2828

29+
/**
30+
* Get storage - parameter decides if to create a non-existing storage
31+
* @param sender
32+
* @param create
33+
* @return
34+
* @throws IOException
35+
* @throws ASAPException
36+
*/
37+
ASAPStorage getIncomingStorage(CharSequence sender, boolean create) throws IOException, ASAPException;
38+
39+
/**
40+
* Get storage - create of required
41+
* @param sender
42+
* @return
43+
* @throws IOException
44+
* @throws ASAPException
45+
*/
46+
ASAPStorage getIncomingStorage(CharSequence sender) throws IOException, ASAPException;
2947
/**
3048
*
3149
* @return storage format / app

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,9 @@ public void handleASAPAssimilate(ASAP_AssimilationPDU_1_0 asapAssimilationPDU, A
394394
//>>>>>>>>>>>>>>>>>>>debug
395395

396396
// get received storage
397-
/*
398-
ASAPStorage incomingStorage = this.getExistingIncomingStorage(senderE2E);
397+
ASAPStorage incomingStorage = this.getIncomingStorage(senderE2E, true);
399398
ASAPChunkStorage incomingChunkStorage = incomingStorage.getChunkStorage();
400-
*/
401-
ASAPChunkStorage incomingChunkStorage = this.getReceivedChunksStorage(senderE2E);
399+
//ASAPChunkStorage incomingChunkStorage = this.getReceivedChunksStorage(senderE2E);
402400
Log.writeLog(this, this.toString(), "got incoming chunk storage for senderE2E: " + senderE2E);
403401

404402
boolean changed = false;

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

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,31 @@ private void saveMemento() throws IOException {
105105
this.getMemento(this.rootDirectory).save(this);
106106
}
107107

108-
/**
109-
*
110-
* @param owner can be null - restored
111-
* @param rootDirectory must not be null
112-
* @param format can be null - restored
113-
* @return
114-
* @throws IOException
115-
* @throws ASAPException
116-
*/
117108
static ASAPEngineFS getASAPEngineFS(String owner, String rootDirectory, CharSequence format)
118109
throws IOException, ASAPException {
110+
return ASAPEngineFS.getASAPEngineFS(owner, rootDirectory, format, false);
111+
}
112+
113+
/**
114+
*
115+
* @param owner can be null - restored
116+
* @param rootDirectory must not be null
117+
* @param format can be null - restored
118+
* @return
119+
* @throws IOException
120+
* @throws ASAPException
121+
*/
122+
static ASAPEngineFS getASAPEngineFS(String owner, String rootDirectory, CharSequence format, boolean createFolder)
123+
throws IOException, ASAPException {
119124

120125
// root directory must exist when setting up an engine
121126
File root = new File(rootDirectory);
122127
if(!root.exists() || !root.isDirectory()) {
123-
throw new ASAPException("chunk root directory must exist when creating an ASAPEngine: " + rootDirectory);
128+
if(!createFolder) {
129+
throw new ASAPException("chunk root directory must exist when creating an ASAPEngine: " + rootDirectory);
130+
} else {
131+
root.mkdirs();
132+
}
124133
}
125134

126135
if(format == null || format.toString().equalsIgnoreCase(ASAP_1_0.ANY_FORMAT)) {
@@ -221,11 +230,16 @@ public ASAPChunkStorage getReceivedChunksStorage(CharSequence sender) {
221230
return new ASAPChunkStorageFS(dir, this.format, this.era);
222231
}
223232

224-
public ASAPInternalStorage getExistingIncomingStorage(CharSequence sender) throws IOException, ASAPException {
233+
public ASAPInternalStorage getIncomingStorage(CharSequence sender, boolean create) throws IOException, ASAPException {
225234
return ASAPEngineFS.getASAPEngineFS(
226235
sender.toString(), // becomes owner
227236
this.rootDirectory + "/" + sender, // folder
228-
this.getFormat()); // format taken from superior storage
237+
this.getFormat(), // format taken from superior storage
238+
create);
239+
}
240+
241+
public ASAPInternalStorage getExistingIncomingStorage(CharSequence sender) throws IOException, ASAPException {
242+
return this.getIncomingStorage(sender, true);
229243
}
230244

231245
/**
@@ -236,6 +250,8 @@ public ASAPInternalStorage getExistingIncomingStorage(CharSequence sender) throw
236250
* @throws ASAPException
237251
*/
238252
public ASAPInternalStorage getIncomingStorage(CharSequence sender) throws IOException, ASAPException {
253+
return this.getIncomingStorage(sender, true);
254+
/*
239255
String folderName = this.rootDirectory + "/" + sender;
240256
File folder = new File(folderName);
241257
if(!folder.exists()) {
@@ -246,6 +262,7 @@ public ASAPInternalStorage getIncomingStorage(CharSequence sender) throws IOExce
246262
sender.toString(), // becomes owner
247263
folderName, // folder
248264
this.getFormat()); // format taken from superior storage
265+
*/
249266
}
250267

251268
@Override

0 commit comments

Comments
 (0)