Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Temporarily re-instated ConsoleAppResource getAppConfig to prevent breaking consoles (they don't follow redirects)

Rich Turner9bcee26a08f6
diff --git a/manager/src/main/java/org/openremote/manager/apps/ConsoleAppResourceImpl.java b/manager/src/main/java/org/openremote/manager/apps/ConsoleAppResourceImpl.java
index 258873656..8c3d69768 100644
--- a/manager/src/main/java/org/openremote/manager/apps/ConsoleAppResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/apps/ConsoleAppResourceImpl.java
@@ -21,6 +21,7 @@ package org.openremote.manager.apps;
import org.openremote.container.web.WebResource;
import org.openremote.model.Constants;
+import org.openremote.model.apps.ConsoleAppConfig;
import org.openremote.model.apps.ConsoleAppResource;
import org.openremote.model.http.RequestParams;
@@ -50,9 +51,11 @@ public class ConsoleAppResourceImpl extends WebResource implements ConsoleAppRes
}
}
+ // Left here as android console stops working once this is removed
@Override
- public Response getAppConfig(RequestParams requestParams) {
- String realm = getRequestRealm() != null ? getRequestRealm() : Constants.MASTER_REALM;
- return Response.seeOther(URI.create("../" + ConsoleAppService.CONSOLE_APP_CONFIG_PATH + "/" + realm + ".json")).build();
+ public ConsoleAppConfig getAppConfig(RequestParams requestParams) {
+ return consoleAppService.getAppConfig(getRequestRealm());
+// String realm = getRequestRealm() != null ? getRequestRealm() : Constants.MASTER_REALM;
+// return Response.seeOther(URI.create("../" + ConsoleAppService.CONSOLE_APP_CONFIG_PATH + "/" + realm + ".json")).build();
}
}
diff --git a/manager/src/main/java/org/openremote/manager/apps/ConsoleAppService.java b/manager/src/main/java/org/openremote/manager/apps/ConsoleAppService.java
index 1eb670a5e..0aee4f679 100644
--- a/manager/src/main/java/org/openremote/manager/apps/ConsoleAppService.java
+++ b/manager/src/main/java/org/openremote/manager/apps/ConsoleAppService.java
@@ -61,7 +61,6 @@ public class ConsoleAppService implements ContainerService {
@Override
public void init(Container container) throws Exception {
- boolean devMode = container.isDevMode();
this.timerService = container.getService(TimerService.class);
this.managerWebService = container.getService(ManagerWebService.class);
this.identityService = container.getService(ManagerIdentityService.class);
@@ -102,6 +101,28 @@ public class ConsoleAppService implements ContainerService {
.toArray(String[]::new);
}
+ @Deprecated
+ public ConsoleAppConfig getAppConfig(String realm) {
+ try {
+ if (!Files.isDirectory(consoleAppDocRoot)) {
+ return null;
+ }
+
+ return Files.list(consoleAppDocRoot)
+ .filter(dir -> dir.getFileName().toString().startsWith(realm))
+ .map(dir -> {
+ try {
+ return ValueUtil.JSON.readValue(dir.toFile(), ConsoleAppConfig.class);
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
+ })
+ .findFirst().orElseThrow(NotFoundException::new);
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
+ }
+
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
diff --git a/model/src/main/java/org/openremote/model/apps/ConsoleAppResource.java b/model/src/main/java/org/openremote/model/apps/ConsoleAppResource.java
index a53a8e0a9..d296df27f 100644
--- a/model/src/main/java/org/openremote/model/apps/ConsoleAppResource.java
+++ b/model/src/main/java/org/openremote/model/apps/ConsoleAppResource.java
@@ -24,8 +24,10 @@ import org.openremote.model.Constants;
import org.openremote.model.http.RequestParams;
import javax.annotation.security.RolesAllowed;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Response;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
@@ -43,9 +45,10 @@ public interface ConsoleAppResource {
String[] getInstalledApps(@BeanParam RequestParams requestParams);
// TODO: Remove this once console updated to use file path
+ // Left here as android console stops working once this is removed
@Deprecated
@GET
@Path("config")
@Produces(APPLICATION_JSON)
- Response getAppConfig(@BeanParam RequestParams requestParams);
+ ConsoleAppConfig getAppConfig(@BeanParam RequestParams requestParams);
}