-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfileserver.xml
105 lines (100 loc) · 3.45 KB
/
fileserver.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<project name="fileserver" default="fileserver.servlet.install"
basedir="./" xmlns:antcontrib="antlib:net.sf.antcontrib">
<target name="fileserver.servlet.install">
<javac srcdir="${cfdistro.basedir}/java/fileserver/src/servlet" destdir="${war.target.dir}/WEB-INF/classes" classpath="${cfdistro.lib.dir}/${jetty-runner.jar}" />
<xmltask source="${war.target.dir}/WEB-INF/web.xml" dest="${war.target.dir}/WEB-INF/web.xml">
<insert path="web-app/servlet[1]" position="before">
<![CDATA[
<servlet>>
<servlet-name>File Servler Servlet</servlet-name>
<servlet-class>servlet.FileServer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>File Servler Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
]]>
<!--
#fileserver.properties
files.dir=/movies/m1;/movies/m2;/home/m3;/home/m4;
callback.server=http://dev.maryno.net/video/command
callback.user=someuser
callback.password=somepassword
callback=ru.freecode.video.VideoServerCallback
#threads count on client
max.threads=5
#speed in byte/s on 1 thread
max.speed=448576
#max.speed=2048576
# users not threads
max.users=20
-->
</insert>
</xmltask>
<antcall target="fileserver.mappings.update"/>
</target>
<target name="fileserver.mappings.update">
<xmltask source="${mappings.file}">
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<actions>
<antcontrib:var name="rule.exists" unset="true"/>
<echo message="@{virtual}" />
<xmltask source="${war.target.dir}/WEB-INF/urlrewrite.xml"
dest="${war.target.dir}/WEB-INF/urlrewrite.xml">
<xmlcatalog refId="commonDTDs"/>
<copy path="urlrewrite/rule[from='@{virtual}']" attrValue="true" property="rule.exists"/>
<print path="urlrewrite/rule[from='@{virtual}']"/>
<replace path="urlrewrite/rule[from='@{virtual}']" if="rule.exists">
<![CDATA[
<rule>
<from casesensitive="false">@{virtual}(.*)</from>
<to>@{physical}$1</to>
</rule>
]]>
</replace>
<insert path="urlrewrite" position="under" unless="rule.exists">
<![CDATA[
<rule>
<from casesensitive="false">@{virtual}(.*)</from>
<to>@{physical}$1</to>
</rule>
]]>
</insert>
</xmltask>
</actions>
</call>
</xmltask>
</target>
<macrodef name="urlrewrite">
<attribute name="from" />
<attribute name="to" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="@{from}" />
<xmltask source="${war.target.dir}/WEB-INF/urlrewrite.xml"
dest="${war.target.dir}/WEB-INF/urlrewrite.xml">
<xmlcatalog refId="commonDTDs"/>
<copy path="urlrewrite/rule[from='@{from}']" attrValue="true" property="rule.exists"/>
<print path="urlrewrite/rule[from='@{from}']"/>
<replace path="urlrewrite/rule[from='@{from}']" if="rule.exists">
<![CDATA[
<rule>
<from casesensitive="false">@{from}</from>
<to>@{to}</to>
</rule>
]]>
</replace>
<insert path="urlrewrite" position="under" unless="rule.exists">
<![CDATA[
<rule>
<from casesensitive="false">@{from}</from>
<to>@{to}</to>
</rule>
]]>
</insert>
</xmltask>
</sequential>
</macrodef>
</project>