]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java
Update license headers
[lgpl/argeo-commons.git] / eclipse / runtime / org.argeo.eclipse.ui.rap / src / main / java / org / argeo / eclipse / ui / specific / FileHandler.java
index f873f1a524cf0c078dfa73a120f929cde74916df..ad551b47939e657625c8622af6c8830040262ad5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.argeo.eclipse.ui.specific;
 
 import java.net.URL;
@@ -19,10 +34,9 @@ import org.eclipse.ui.PlatformUI;
  * Manages the process of forwarding the request to the handler at runtime to
  * open the dialog box
  * 
- * @author bsinou
- * 
  */
 public class FileHandler {
+       public final static String FORCED_DOWNLOAD_URL_BASE_PROPERTY = "argeo.rap.specific.forcedDownloadUrlBase";
 
        private final static Log log = LogFactory.getLog(FileHandler.class);
 
@@ -41,8 +55,8 @@ public class FileHandler {
                // http://www.eclipse.org/forums/index.php?t=msg&th=205487&start=0&S=43d85dacc88b505402420592109c7240
 
                try {
-                       if (log.isDebugEnabled())
-                               log.debug("URL : " + createFullDownloadUrl(fileName, fileId));
+                       if (log.isTraceEnabled())
+                               log.trace("URL : " + createFullDownloadUrl(fileName, fileId));
 
                        URL url = new URL(createFullDownloadUrl(fileName, fileId));
                        PlatformUI.getWorkbench().getBrowserSupport()
@@ -62,7 +76,14 @@ public class FileHandler {
 
        private String createFullDownloadUrl(String fileName, String fileId) {
                StringBuilder url = new StringBuilder();
-               url.append(RWT.getRequest().getRequestURL());
+               // in case RAP is proxied we need to specify the actual base URL
+               // TODO find a cleaner way
+               String forcedDownloadUrlBase = System
+                               .getProperty(FORCED_DOWNLOAD_URL_BASE_PROPERTY);
+               if (forcedDownloadUrlBase != null)
+                       url.append(forcedDownloadUrlBase);
+               else
+                       url.append(RWT.getRequest().getRequestURL());
                url.append(createParamUrl(fileName, fileId));
                return url.toString();
        }