]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.core/src/main/java/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java
Fix issues in deployment related to the move to Java 5
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / support / deploy / HttpdApplicationTargetData.java
1 package org.argeo.slc.support.deploy;
2
3 import java.io.File;
4 import java.net.MalformedURLException;
5 import java.net.URL;
6
7 import org.argeo.slc.core.SlcException;
8 import org.argeo.slc.core.deploy.TargetData;
9
10 public class HttpdApplicationTargetData implements TargetData {
11 private HttpdServer webServer;
12 private String relativePath;
13 private String targetRootPath;
14
15 public HttpdServer getWebServer() {
16 return webServer;
17 }
18
19 public void setWebServer(HttpdServer webServer) {
20 this.webServer = webServer;
21 }
22
23 public String getRelativePath() {
24 return relativePath;
25 }
26
27 /**
28 * If targetRootLocation not set, used to build the targetRootLocation,
29 * relative to the webserver base.
30 */
31 public void setRelativePath(String relativePath) {
32 this.relativePath = relativePath;
33 }
34
35 public String getTargetRootPath() {
36 return targetRootPath;
37 }
38
39 public void setTargetRootPath(String targetRootPath) {
40 this.targetRootPath = targetRootPath;
41 }
42
43 public URL getTargetBaseUrl() {
44 try {
45 URL wsUrl = getWebServer().getBaseUrl();
46 // TODO: use URI
47 return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);
48 } catch (MalformedURLException e) {
49 throw new SlcException("Cannot get base url for " + relativePath, e);
50 }
51 }
52
53 public File getTargetRootLocation() {
54 if (targetRootPath != null && !targetRootPath.equals("")) {
55 return new File(targetRootPath);
56 } else {
57 HttpdServerTargetData targetData = (HttpdServerTargetData) getWebServer()
58 .getTargetData();
59 String path = targetData.getServerRoot() + File.separator
60 + getRelativePath();
61 return new File(path);
62 }
63 }
64
65 }