Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 066bcf2

Browse files
committed
Updates to Notification Handling
1 parent 97b6ecc commit 066bcf2

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/main/java/org/energyos/espi/thirdparty/web/NotificationController.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,11 @@ public class NotificationController extends BaseController {
7575
public void notification(HttpServletResponse response, InputStream inputStream) throws IOException {
7676

7777
BatchList batchList = (BatchList) marshaller.unmarshal(new StreamSource(inputStream));
78-
batchListService.persist(batchList);
79-
Iterator<String> it = batchList.getResources().iterator();
80-
while (it.hasNext()) {
81-
String resourceUri = (String) it.next();
82-
doImportAsynchronously(resourceUri);
78+
79+
for (String resourceUri : batchList.getResources() ) {
80+
doImportAsynchronously(resourceUri);
8381
}
82+
8483
response.setStatus(HttpServletResponse.SC_OK);
8584
}
8685

@@ -126,13 +125,22 @@ private void doImportAsynchronously(String subscriptionUri) {
126125
resourceUri = (resourceUri.substring(0, resourceUri.indexOf("/resource/") + "/resource/".length()).concat("Batch/Bulk"));
127126

128127
} else {
129-
// mutate the resourceUri for the form /Subscription/{subscriptionId}/**
130-
String temp = resourceUri.substring(resourceUri.indexOf("/Subscription/") + "/Subscription/".length());
131-
if (temp.contains("/")) {
132-
resourceUri = resourceUri.substring(0, resourceUri.indexOf("/Subscription") + "/Subscription".length()).concat(temp.substring(0, temp.indexOf("/")));
128+
if (resourceUri.contains("/Subscription")) {
129+
// mutate the resourceUri for the form /Subscription/{subscriptionId}/**
130+
String temp = resourceUri.substring(resourceUri.indexOf("/Subscription/") + "/Subscription/".length());
131+
if (temp.contains("/")) {
132+
resourceUri = resourceUri.substring(0, resourceUri.indexOf("/Subscription") + "/Subscription".length()).concat(temp.substring(0, temp.indexOf("/")));
133+
}
133134
}
134135
}
135136

137+
Authorization x = resourceService.findById(2L, Authorization.class);
138+
139+
if (x.getResourceURI().equals(resourceUri)) {
140+
System.out.println("ResourceURIs Equal:" + resourceUri);
141+
} else {
142+
System.out.println("ResourceURIs Not - Equal:" + resourceUri);
143+
}
136144
authorization = resourceService.findByResourceUri(resourceUri, Authorization.class);
137145
retailCustomer = authorization.getRetailCustomer();
138146
accessToken = authorization.getAccessToken();

0 commit comments

Comments
 (0)