Skip to content

Commit ba0424f

Browse files
authored
0.25.0
SysCertManager DSAction changes Pathing fixes
2 parents 64554de + dde5671 commit ba0424f

File tree

78 files changed

+1446
-1286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1446
-1286
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
**/.DS_Store
2323

2424
# Runtime files
25+
**/dslink.jks
2526
**/.key
2627
**/db
2728
**/nodes.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ the DSA architecture, please visit
1616
## Sub Projects
1717

1818
- **/dslink-core** - The APIs used to build new links.
19-
- **/dslink-java-v2-test** - For proof of concept and testing.
19+
- **/dslink-java-v2-poc** - For proof of concept and testing.
2020
- **/dslink-websocket-standalone** - Used by links that run in their own process, rather
2121
than in an environment which provides another websocket implementation.
2222

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'java'
22
apply plugin: 'maven'
33

44
group 'org.iot.dsa'
5-
version '0.24.0'
5+
version '0.25.0'
66

77
sourceCompatibility = 1.6
88
targetCompatibility = 1.6

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/io/DSByteBuffer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ public DSByteBuffer putU32(long v, boolean bigEndian) {
425425
(byte) (v >>> 16),
426426
(byte) (v >>> 24));
427427
}
428+
428429
/**
429430
* Returns the next byte in the buffer, or -1 when nothing is available.
430431
*/

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/message/RequestPath.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public DSInfo getInfo() {
5252
if (target == null) {
5353
getTarget();
5454
}
55+
if ((info == null) && (root == target)) {
56+
info = new RootInfo(root);
57+
}
5558
return info;
5659
}
5760

@@ -73,10 +76,10 @@ public String getPath() {
7376
return path;
7477
}
7578

76-
public DSIObject getTarget() {
77-
if (parent == null) {
78-
parent = root.getParent();
79+
public synchronized DSIObject getTarget() {
80+
if (target == null) {
7981
target = root;
82+
parent = root.getParent();
8083
info = root.getInfo();
8184
int len = names.length;
8285
if (len == 0) {
@@ -116,4 +119,10 @@ public boolean isResponder() {
116119
return target instanceof DSIResponder;
117120
}
118121

122+
private static class RootInfo extends DSInfo {
123+
RootInfo(DSNode root) {
124+
super(null, root);
125+
}
126+
}
127+
119128
}

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/requester/DSOutboundSubscribeStub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
/**
1010
* Manages the lifecycle of a single subscription and is also the outbound stream passed to the
1111
* requester.
12-
*
1312
* <p>
14-
*
13+
* <p>
14+
* <p>
1515
* There can be multiple subscriptions to a single path. They are all contained in a
1616
* DSOutboundSubscribeStubs object.
1717
*

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundInvoke.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
import org.iot.dsa.node.DSInfo;
1616
import org.iot.dsa.node.DSList;
1717
import org.iot.dsa.node.DSMap;
18-
import org.iot.dsa.node.action.ActionResult;
19-
import org.iot.dsa.node.action.ActionSpec;
20-
import org.iot.dsa.node.action.ActionTable;
21-
import org.iot.dsa.node.action.ActionValues;
22-
import org.iot.dsa.node.action.DSAction;
18+
import org.iot.dsa.node.action.*;
2319
import org.iot.dsa.security.DSPermission;
2420

2521
/**
@@ -233,7 +229,7 @@ public void run() {
233229
setPath(path.getPath());
234230
result = responder.onInvoke(this);
235231
}
236-
DSInfo info = path.getInfo();
232+
DSInfo info = path.getInfo(); //action must be child of a node
237233
if (!info.isAction()) {
238234
throw new DSRequestException("Not an action " + path.getPath());
239235
}
@@ -250,7 +246,7 @@ public void run() {
250246
throw new DSPermissionException("Read permission required");
251247
}
252248
}
253-
DSAction action = info.getAction();
249+
DSAbstractAction action = info.getAction();
254250
result = action.invoke(info, this);
255251
} catch (Exception x) {
256252
error(getPath(), x);

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundList.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,10 @@
1010
import org.iot.dsa.dslink.responder.ApiObject;
1111
import org.iot.dsa.dslink.responder.InboundListRequest;
1212
import org.iot.dsa.dslink.responder.OutboundListResponse;
13-
import org.iot.dsa.node.DSElement;
14-
import org.iot.dsa.node.DSIEnum;
15-
import org.iot.dsa.node.DSIValue;
16-
import org.iot.dsa.node.DSInfo;
17-
import org.iot.dsa.node.DSList;
18-
import org.iot.dsa.node.DSMap;
13+
import org.iot.dsa.node.*;
1914
import org.iot.dsa.node.DSMap.Entry;
20-
import org.iot.dsa.node.DSMetadata;
21-
import org.iot.dsa.node.DSNode;
22-
import org.iot.dsa.node.DSPath;
23-
import org.iot.dsa.node.DSValueType;
2415
import org.iot.dsa.node.action.ActionSpec;
25-
import org.iot.dsa.node.action.DSAction;
16+
import org.iot.dsa.node.action.DSAbstractAction;
2617
import org.iot.dsa.node.event.DSIEvent;
2718
import org.iot.dsa.node.event.DSISubscriber;
2819
import org.iot.dsa.node.event.DSInfoTopic;
@@ -301,9 +292,9 @@ private void encodeTargetAction(ApiObject object, MessageWriter writer) {
301292
info = (DSInfo) object;
302293
}
303294
ActionSpec action = object.getAction();
304-
DSAction dsAction = null;
305-
if (action instanceof DSAction) {
306-
dsAction = (DSAction) action;
295+
DSAbstractAction dsAction = null;
296+
if (action instanceof DSAbstractAction) {
297+
dsAction = (DSAbstractAction) action;
307298
}
308299
DSElement e = cacheMap.remove("$invokable");
309300
if (e == null) {
@@ -599,6 +590,9 @@ public void run() {
599590
response = responder.onList(this);
600591
} else {
601592
info = path.getInfo();
593+
if (info == null) {
594+
info = new RootInfo((DSNode) path.getTarget());
595+
}
602596
if (info.isNode()) {
603597
node = info.getNode();
604598
node.subscribe(DSNode.INFO_TOPIC, null, this);
@@ -726,6 +720,12 @@ private void writeUpdates(MessageWriter writer) {
726720
// Inner Classes
727721
///////////////////////////////////////////////////////////////////////////
728722

723+
private static class RootInfo extends DSInfo {
724+
RootInfo(DSNode node) {
725+
super(null, node);
726+
}
727+
}
728+
729729
protected static class Update {
730730

731731
public boolean added;

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundSet.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import org.iot.dsa.dslink.DSPermissionException;
66
import org.iot.dsa.dslink.DSRequestException;
77
import org.iot.dsa.dslink.responder.InboundSetRequest;
8-
import org.iot.dsa.node.DSElement;
9-
import org.iot.dsa.node.DSIValue;
10-
import org.iot.dsa.node.DSInfo;
11-
import org.iot.dsa.node.DSNode;
8+
import org.iot.dsa.node.*;
129
import org.iot.dsa.security.DSPermission;
1310

1411
public class DSInboundSet extends DSInboundRequest implements InboundSetRequest, Runnable {
@@ -42,19 +39,21 @@ public void run() {
4239
} else {
4340
DSNode parent = path.getParent();
4441
DSInfo info = path.getInfo();
45-
if (info.isReadOnly()) {
42+
if ((info != null) && info.isReadOnly()) {
4643
throw new DSRequestException("Not writable: " + getPath());
4744
}
4845
if (!permission.isConfig()) {
49-
if (info.isAdmin()) {
46+
if ((info != null) && info.isAdmin()) {
5047
throw new DSPermissionException("Config permission required");
5148
} else if (DSPermission.WRITE.isGreaterThan(permission)) {
5249
throw new DSPermissionException("Write permission required");
5350
}
5451
}
55-
if (info.isNode()) {
56-
info.getNode().onSet(value);
52+
DSIObject obj = path.getTarget();
53+
if (obj instanceof DSNode) {
54+
((DSNode) obj).onSet(value);
5755
} else {
56+
//since not a node, there must be a parent
5857
DSIValue current = info.getValue();
5958
if (current == null) {
6059
if (info.getDefaultObject() instanceof DSIValue) {

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundSubscription.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import org.iot.dsa.dslink.responder.InboundSubscribeRequest;
77
import org.iot.dsa.dslink.responder.SubscriptionCloseHandler;
88
import org.iot.dsa.io.DSIWriter;
9-
import org.iot.dsa.node.DSIStatus;
10-
import org.iot.dsa.node.DSIValue;
11-
import org.iot.dsa.node.DSInfo;
12-
import org.iot.dsa.node.DSNode;
13-
import org.iot.dsa.node.DSStatus;
9+
import org.iot.dsa.node.*;
1410
import org.iot.dsa.node.event.DSIEvent;
1511
import org.iot.dsa.node.event.DSISubscriber;
1612
import org.iot.dsa.node.event.DSTopic;
@@ -97,13 +93,14 @@ protected void init() {
9793
setPath(path.getPath());
9894
closeHandler = responder.onSubscribe(this);
9995
} else {
100-
DSInfo info = path.getInfo();
101-
if (info.isNode()) {
102-
node = info.getNode();
96+
DSIObject obj = path.getTarget();
97+
if (obj instanceof DSNode) {
98+
node = (DSNode) obj;
10399
node.subscribe(DSNode.VALUE_TOPIC, null, this);
104-
onEvent(DSNode.VALUE_TOPIC, Event.NODE_CHANGED, info.getNode(), null,
100+
onEvent(DSNode.VALUE_TOPIC, Event.NODE_CHANGED, node, null,
105101
(Object[]) null);
106102
} else {
103+
DSInfo info = path.getInfo();
107104
node = path.getParent();
108105
child = info;
109106
node.subscribe(DSNode.VALUE_TOPIC, info, this);

0 commit comments

Comments
 (0)