Adapt to changes in Argeo Commons
[gpl/argeo-slc.git] / swt / rcp / org.argeo.cms.e4.rcp / src / org / argeo / cms / e4 / rcp / CmsE4Application.java
index 3861597aad00baa1b232366cc923d22e9fb45a60..2ad8760d2ee76d3a796790d39c61623cbf2e8a65 100644 (file)
@@ -1,5 +1,7 @@
 package org.argeo.cms.e4.rcp;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.security.PrivilegedExceptionAction;
 import java.util.UUID;
 import java.util.concurrent.Callable;
@@ -29,6 +31,8 @@ public class CmsE4Application implements IApplication, CmsView {
        private UxContext uxContext;
        private String uid;
 
+       private String httpServerBase;
+
        @Override
        public Object start(IApplicationContext context) throws Exception {
                // TODO wait for CMS to be ready
@@ -209,4 +213,22 @@ public class CmsE4Application implements IApplication, CmsView {
                throw new UnsupportedOperationException();
        }
 
+       @Override
+       public URI toBackendUri(String url) {
+               try {
+                       URI u = new URI(url);
+                       if (u.getHost() == null) {
+                               // TODO make it more robust
+                               u = new URI(httpServerBase + url);
+                       }
+                       return u;
+               } catch (URISyntaxException e) {
+                       throw new IllegalArgumentException("Cannot convert " + url, e);
+               }
+       }
+
+       public void setHttpServerBase(String httpServerBase) {
+               this.httpServerBase = httpServerBase;
+       }
+
 }