]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java
Download process log
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / support / deploy / HttpdApplicationTargetData.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc.support.deploy;
18
19 import java.io.File;
20 import java.net.MalformedURLException;
21 import java.net.URL;
22
23 import org.argeo.slc.SlcException;
24 import org.argeo.slc.deploy.TargetData;
25
26 public class HttpdApplicationTargetData implements TargetData {
27 private HttpdServer webServer;
28 private String relativePath;
29 private String targetRootPath;
30
31 public HttpdServer getWebServer() {
32 return webServer;
33 }
34
35 public void setWebServer(HttpdServer webServer) {
36 this.webServer = webServer;
37 }
38
39 public String getRelativePath() {
40 return relativePath;
41 }
42
43 /**
44 * If targetRootLocation not set, used to build the targetRootLocation,
45 * relative to the webserver base.
46 */
47 public void setRelativePath(String relativePath) {
48 this.relativePath = relativePath;
49 }
50
51 public String getTargetRootPath() {
52 return targetRootPath;
53 }
54
55 public void setTargetRootPath(String targetRootPath) {
56 this.targetRootPath = targetRootPath;
57 }
58
59 public URL getTargetBaseUrl() {
60 try {
61 URL wsUrl = getWebServer().getBaseUrl();
62 // TODO: use URI
63 return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);
64 } catch (MalformedURLException e) {
65 throw new SlcException("Cannot get base url for " + relativePath, e);
66 }
67 }
68
69 public File getTargetRootLocation() {
70 if (targetRootPath != null && !targetRootPath.equals("")) {
71 return new File(targetRootPath);
72 } else {
73 HttpdServerTargetData targetData = (HttpdServerTargetData) getWebServer()
74 .getTargetData();
75 String path = targetData.getServerRoot() + File.separator
76 + getRelativePath();
77 return new File(path);
78 }
79 }
80
81 }