forked from uPortal-Project/uPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
1564 lines (1365 loc) · 55.4 KB
/
build.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
Licensed to Jasig under one or more contributor license
agreements. See the NOTICE file distributed with this work
for additional information regarding copyright ownership.
Jasig licenses this file to you 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.
-->
<!--
| Detailed help documentation lives in docs/antHelp.txt, please refer to this file or
| run 'ant help' for usage of this file.
|
| Comments in this file should be targeted to the maintenance of the build script.
+-->
<project name="uPortal" default="help" basedir="." xmlns:up="urn:up-util-ant" xmlns:artifact="urn:maven-artifact-ant">
<!--
| Determine if a named environment has been specified in the command.
| Examples: dev, test, prod, local, etc.
+-->
<condition property="environment.token" value="${env}">
<isset property="env" />
</condition>
<property name="environment.token" value="local" />
<fail message="filters/${environment.token}.properties does not exist, please copy local.properties and fill in your settings.">
<condition>
<not>
<available file="${basedir}/filters/${environment.token}.properties" />
</not>
</condition>
</fail>
<!--
| Load the build properties before the next fail tests since they check properties provided
| by the file.
+-->
<property environment="env" />
<property file="${basedir}/filters/${environment.token}.properties" />
<property file="${basedir}/build.properties" />
<property name="targetdir" value="${basedir}/target"/>
<!--
| Setup temp directories
+-->
<property name="jasig.tmpdir" value="${targetdir}/tmp" />
<mkdir dir="${jasig.tmpdir}" />
<tempfile property="parentPomInstallMarker.file" destdir="${jasig.tmpdir}" prefix="uportal-parent.pom-" suffix="-marker" deleteonexit="true" />
<!-- PortalShell Script File for run -->
<tempfile property="portal-shell-script" destdir="${jasig.tmpdir}" prefix="upshell_" suffix=".groovy" deleteonexit="true" />
<!--
| Define maven.home and maven.settings variables if they are not set
+-->
<condition property="maven.home" value="${env.M2_HOME}">
<and>
<not>
<isset property="maven.home" />
</not>
<available file="${env.M2_HOME}" />
</and>
</condition>
<fail message="maven.home=${maven.home} does not exist.${line.separator}Either set maven.home in build.properties or set the M2_HOME environment variable.">
<condition>
<not>
<available file="${maven.home}" />
</not>
</condition>
</fail>
<condition property="maven.settings" value="${user.home}/.ant/settings.xml">
<and>
<not>
<isset property="maven.settings" />
</not>
<available file="${user.home}/.ant/settings.xml" />
</and>
</condition>
<condition property="maven.settings" value="${user.home}/.m2/settings.xml">
<and>
<not>
<isset property="maven.settings" />
</not>
<available file="${user.home}/.m2/settings.xml" />
</and>
</condition>
<condition property="maven.settings" value="${maven.home}/conf/settings.xml">
<and>
<not>
<isset property="maven.settings" />
</not>
<available file="${maven.home}/conf/settings.xml" />
</and>
</condition>
<fail message="maven.settings=${maven.settings} does not exist.${line.separator}Either set maven.settings in build.properties or ensure one of the following files exist:${line.separator} - ${user.home}/.ant/settings.xml${line.separator} - ${user.home}/.m2/settings.xml${line.separator} - ${maven.home}/conf/settings.xml">
<condition>
<not>
<available file="${maven.settings}" />
</not>
</condition>
</fail>
<!--
| Properties that describe the maven project
+-->
<property name="bootstrap.dir" value="${basedir}/bootstrap" />
<property name="uportal-search-api.dir" value="${basedir}/uportal-search-api" />
<property name="uportal-war.dir" value="${basedir}/uportal-war" />
<property name="uportal-portlets-overlay.dir" value="${basedir}/uportal-portlets-overlay" />
<property name="uportal-ear.dir" value="${basedir}/uportal-ear" />
<import file="${bootstrap.dir}/build_includes.xml" />
<!-- ============================== Public Targets ============================== -->
<target name="help" description="Prints information about using this ant build file.">
<loadfile property="helpMessage" srcFile="docs/antHelp.txt" />
<echo message="${helpMessage}" />
</target>
<target name="initportal" depends="prodPrompt" description="Runs all the targets necessary to deploy the portal and prepare the portal database">
<echo message="Initializing uPortal" />
<antcall target="deploy-ear">
<param name="removeExisting" value="true" />
</antcall>
<antcall target="initdb" />
<echo message="Finished initializing uPortal" />
</target>
<target name="initdb" depends="prodPrompt" description="Drops all tables, then runs all the targets necessary prepare the portal database">
<echo message="Initializing database" />
<up-shell-batch>
<antcall target="db" />
<antcall target="db-hibernate" />
<antcall target="db-import" />
</up-shell-batch>
<echo message="Finished initializing database" />
</target>
<target name="db-ddl" depends="prodPrompt" description="Create a SQL script of commands to drop and create the uPortal database">
<fail unless="ddlFile">
You must specify a 'ddlFile' parameter (-DddlFile={uPortal.ddl})
</fail>
<tempfile property="db-ddl-file" destdir="${targetdir}" prefix="db-ddl." suffix=".sql" />
<tempfile property="db-hibernate-portal-ddl-file" destdir="${targetdir}" prefix="db-hibernate-portal-ddl." suffix=".sql" />
<tempfile property="db-hibernate-aggr-events-ddl-file" destdir="${targetdir}" prefix="db-hibernate-aggr-events-ddl." suffix=".sql" />
<tempfile property="db-hibernate-raw-events-ddl-file" destdir="${targetdir}" prefix="db-hibernate-raw-events-ddl." suffix=".sql" />
<echo message="Creating database DDL and writing to ${ddlFile}" />
<up-shell-batch>
<mkdir dir="${targetdir}" />
<antcall target="db">
<param name="scriptfile" value="${db-ddl-file}" />
</antcall>
<antcall target="db-hibernate-portal">
<param name="export" value="false" />
<param name="outputFile" value="${db-hibernate-portal-ddl-file}" />
</antcall>
<antcall target="db-hibernate-raw-events">
<param name="export" value="false" />
<param name="outputFile" value="${db-hibernate-raw-events-ddl-file}" />
</antcall>
<antcall target="db-hibernate-aggr-events">
<param name="export" value="false" />
<param name="outputFile" value="${db-hibernate-aggr-events-ddl-file}" />
</antcall>
</up-shell-batch>
<concat destfile="${ddlFile}" fixlastline="yes">
<fileset file="${db-ddl-file}" />
<fileset file="${db-hibernate-portal-ddl-file}" />
<fileset file="${db-hibernate-raw-events-ddl-file}" />
<fileset file="${db-hibernate-aggr-events-ddl-file}" />
</concat>
<echo message="Finished creating database DDL: ${ddlFile}" />
</target>
<target name="db-hibernate" depends="prodPrompt" description="Drops then creates Hibernate managed tables">
<up-shell-batch>
<antcall target="db-hibernate-portal" />
<antcall target="db-hibernate-raw-events" />
<antcall target="db-hibernate-aggr-events" />
</up-shell-batch>
</target>
<target name="db-hibernate-update" depends="prodPrompt" description="Makes required changes to the portal database for patch upgrades for both the portal and event schemas">
<up-shell-batch>
<antcall target="db-hibernate-portal-update" />
<antcall target="db-hibernate-raw-events-update" />
<antcall target="db-hibernate-aggr-events-update" />
</up-shell-batch>
</target>
<target name="db-hibernate-portal" depends="prodPrompt" description="Drops then creates Hibernate managed tables for the portal">
<property name="schemaExportBean" value="portalDbHibernateExport" />
<property name="export" value="true" />
<property name="drop" value="true" />
<property name="create" value="true" />
<property name="outputFile" value="null" />
<property name="haltOnError" value="true" />
<groovy-safe-path property="outputFileEscaped" input="${outputFile}" />
<echo>Creating HBM2DDL Script</echo>
<echo file="${portal-shell-script}" append="true">
//HBM2DDL Script
try {
schemaExportBean = '${schemaExportBean}';
logger.info('');
logger.info('');
logger.info('HBM2DDL: ' + schemaExportBean);
export = '${export}'.toBoolean();
create = '${create}'.toBoolean();
drop = '${drop}'.toBoolean();
outputFile = /${outputFileEscaped}/;
haltOnError = '${haltOnError}'.toBoolean();
${schemaExportBean}.hbm2ddl(export, create, drop, outputFile == 'null' ? null : outputFile , haltOnError);
}
catch (Exception e) {
throw new RuntimeException("db-hibernate for ' + schemaExportBean + ' failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="db-hibernate-portal-update" depends="prodPrompt" description="Makes required changes to the portal database for patch upgrades for the portal schema">
<property name="schemaExportBean" value="portalDbHibernateExport" />
<property name="export" value="true" />
<property name="outputFile" value="null" />
<property name="haltOnError" value="true" />
<groovy-safe-path property="outputFileEscaped" input="${outputFile}" />
<echo>Creating HBM2DDL Update Script</echo>
<echo file="${portal-shell-script}" append="true">
//HBM2DDL Update Script
try {
schemaExportBean = '${schemaExportBean}';
logger.info('');
logger.info('');
logger.info('HBM2DDL Schema Update: ' + schemaExportBean);
export = '${export}'.toBoolean();
outputFile = /${outputFileEscaped}/;
haltOnError = '${haltOnError}'.toBoolean();
${schemaExportBean}.update(export, outputFile == 'null' ? null : outputFile , haltOnError);
}
catch (Exception e) {
throw new RuntimeException("db-hibernate-update for ' + schemaExportBean + ' failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="db-hibernate-stats" depends="prodPrompt">
<echo level="warning">DEPRECATED: Use db-hibernate-raw-events and db-hibernate-aggr-events instead</echo>
<up-shell-batch>
<antcall target="db-hibernate-raw-events" />
<antcall target="db-hibernate-aggr-events" />
</up-shell-batch>
</target>
<target name="db-hibernate-stats-update" depends="prodPrompt">
<echo level="warning">DEPRECATED: Use db-hibernate-raw-events-update and db-hibernate-aggr-events-update instead</echo>
<up-shell-batch>
<antcall target="db-hibernate-raw-events-update" />
<antcall target="db-hibernate-aggr-events-update" />
</up-shell-batch>
</target>
<target name="db-hibernate-raw-events" depends="prodPrompt" description="Drops then creates Hibernate managed tables used for raw portal event storage">
<antcall target="db-hibernate-portal">
<param name="schemaExportBean" value="rawEventsDbHibernateExport" />
<param name="haltOnError" value="false" />
</antcall>
</target>
<target name="db-hibernate-raw-events-update" depends="prodPrompt" description="Makes required changes to the portal database for patch upgrades for raw portal event storage">
<antcall target="db-hibernate-portal-update">
<param name="schemaExportBean" value="rawEventsDbHibernateExport" />
<param name="haltOnError" value="false" />
</antcall>
</target>
<target name="db-hibernate-aggr-events" depends="prodPrompt" description="Drops then creates Hibernate managed tables used for aggregate portal event storage">
<antcall target="db-hibernate-portal">
<param name="schemaExportBean" value="aggrEventsDbHibernateExport" />
<param name="haltOnError" value="false" />
</antcall>
</target>
<target name="db-hibernate-aggr-events-update" depends="prodPrompt" description="Makes required changes to the portal database for patch upgrades for aggregate portal event storage">
<antcall target="db-hibernate-portal-update">
<param name="schemaExportBean" value="aggrEventsDbHibernateExport" />
<param name="haltOnError" value="false" />
</antcall>
</target>
<target name="db" depends="prodPrompt" description="Loads legacy database tables and data. See: initdb">
<property name="tablefile" value="/properties/db/tables.xml" />
<property name="datafile" value="/properties/db/data.xml" />
<property name="scriptfile" value="null" />
<property name="droptables" value="true" />
<property name="createtables" value="true" />
<property name="populatetables" value="true" />
<groovy-safe-path property="tablefileEscaped" input="${tablefile}" />
<groovy-safe-path property="datafileEscaped" input="${datafile}" />
<groovy-safe-path property="scriptfileEscaped" input="${scriptfile}" />
<echo>Creating DBLoader Script</echo>
<echo file="${portal-shell-script}" append="true">
try {
//DbLoader Script
logger.info('');
logger.info('');
tablesFile = /${tablefileEscaped}/;
dataFile = /${datafileEscaped}/;
scriptFile = /${scriptfileEscaped}/;
droptables = '${droptables}'.toBoolean();
createtables = '${createtables}'.toBoolean();
populatetables = '${populatetables}'.toBoolean();
dbLoaderConfig = new org.jasig.portal.tools.dbloader.DbLoaderConfigBuilder();
dbLoaderConfig.setTablesFile(tablesFile);
dbLoaderConfig.setDataFile(dataFile);
if (scriptFile != 'null') {
dbLoaderConfig.setScriptFile(scriptFile);
}
dbLoaderConfig.setDropTables(droptables);
dbLoaderConfig.setCreateTables(createtables);
dbLoaderConfig.setPopulateTables(populatetables);
logger.info('Running DbLoader with: ' + dbLoaderConfig);
dbLoader.process(dbLoaderConfig);
}
catch (Exception e) {
throw new RuntimeException("db for ${tablefile} and ${datafile} failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="db-import-required" depends="prodPrompt" description="Imports the required data files to the database">
<up-shell-batch>
<antcall target="data-import">
<param name="dir" value="${basedir}/uportal-war/src/main/data/required_entities" />
</antcall>
</up-shell-batch>
</target>
<target name="db-import-default" depends="prodPrompt" description="Imports the default data files to the database">
<!-- Use build.properties to override the entities.location setting -->
<property name="default_entities.location" value="uportal-war/src/main/data/default_entities" />
<up-shell-batch>
<antcall target="data-import">
<param name="dir" value="${basedir}/${default_entities.location}" />
</antcall>
</up-shell-batch>
</target>
<target name="db-import-quickstart" depends="prodPrompt" description="Imports the quickstart data files to the database">
<!-- Use build.properties to override the entities.location setting -->
<property name="quickstart_entities.location" value="uportal-war/src/main/data/quickstart_entities" />
<up-shell-batch>
<antcall target="data-import">
<param name="dir" value="${basedir}/${quickstart_entities.location}" />
</antcall>
</up-shell-batch>
</target>
<target name="db-import" depends="prodPrompt" description="Imports the default XML files to the database">
<up-shell-batch>
<antcall target="db-import-required" />
<if>
<not>
<isset property="noDefaultData" />
</not>
<then>
<antcall target="db-import-default" />
</then>
</if>
<if>
<not>
<isset property="noQuickstartData" />
</not>
<then>
<antcall target="db-import-quickstart" />
</then>
</if>
</up-shell-batch>
</target>
<target name="dbtest" description="Displays information about the database defined in rdbm.properties">
<uportal-war-macro>
<echo message="Invoking DbTest" />
<java fork="true" failonerror="true" dir="${basedir}" classname="org.jasig.portal.tools.DbTest">
<sysproperty key="log4j.configuration" value="command-line.log4j.properties" />
<classpath refid="uportal-war-full.classpath" />
</java>
</uportal-war-macro>
</target>
<target name="regchantype" depends="prodPrompt" description="Registers a new channel type">
<uportal-war-macro>
<property name="class" value=" " />
<property name="name" value=" " />
<property name="description" value=" " />
<property name="uri" value=" " />
<echo message="Invoking RegisterChannelType" />
<java dir="${basedir}" classname="org.jasig.portal.tools.RegisterChannelType">
<classpath refid="uportal-war-full.classpath" />
<arg value="${class}" />
<arg value="${name}" />
<arg value="${description}" />
<arg value="${uri}" />
</java>
</uportal-war-macro>
</target>
<target name="up-shell" description="Run a uPortal Groovy Shell. Interactive or scripted using -Dscript=">
<if>
<not>
<istrue value="${skip-up-shell-execution}" />
</not>
<then>
<uportal-war-macro>
<if>
<and>
<isset property="script" />
</and>
<then>
<trycatch>
<try>
<!-- Invoke import/export tool -->
<java fork="true" failonerror="true" dir="${basedir}" classname="org.jasig.portal.shell.PortalShell">
<sysproperty key="log4j.configuration" value="command-line.log4j.properties" />
<classpath refid="uportal-war-full.classpath" />
<arg value="-s" />
<arg value="${script}" />
</java>
</try>
<finally>
<tempfile property="executed-portal-shell-script" destdir="${targetdir}" prefix="upshell_" suffix=".groovy" />
<copy file="${script}" tofile="${executed-portal-shell-script}" />
</finally>
</trycatch>
</then>
<else>
<echo>No Script</echo>
<!-- Invoke import/export tool -->
<java fork="true" failonerror="true" dir="${basedir}" classname="org.jasig.portal.shell.PortalShell">
<sysproperty key="log4j.configuration" value="command-line.log4j.properties" />
<classpath refid="uportal-war-full.classpath" />
</java>
</else>
</if>
</uportal-war-macro>
</then>
</if>
</target>
<target name="data-list" description="Lists portal data types and portal data for a type. Use the -Dtype parameter to specify a specific type">
<property name="type" value="null" />
<echo file="${portal-shell-script}" append="true">
try {
type = '${type}';
if (type == 'null') {
dhs = portalDataHandlerService;
//List Data Types Script
logger.info('');
logger.info('');
logger.info('Export and Delete Support by Data Type');
org.jasig.portal.io.xml.PortalDataHandlerServiceUtils.format(dhs, logger);
logger.info('Add -Dtype=dataType To get a list of data keys for the type');
}
else {
//List Data Script
data = portalDataHandlerService.getPortalData(type);
logger.info('');
logger.info('');
logger.info('All ' + type + ' data');
data.each() {
dataId = it.getDataId();
dataTitle = it.getDataTitle();
if (dataTitle != null && dataId != dataTitle) {
logger.info(' ' + it.getDataId() + " - " + it.getDataTitle());
}
else {
logger.info(' ' + it.getDataId());
}
};
}
}
catch (Exception e) {
throw new RuntimeException("data-list failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="data-export" description="Exports the specified entity or entities to XML on the file system">
<fail unless="dir">
You must specify a 'dir' parameter (-Ddir={some/directory})
</fail>
<property name="type" value="null" />
<property name="sysid" value="null" />
<groovy-safe-path property="dirFullEscaped" input="${dir}" />
<groovy-safe-path property="targetDirEscaped" input="${targetdir}" />
<echo>Creating Data Export Script</echo>
<echo file="${portal-shell-script}" append="true">
//Data Export Script
logger.info('');
logger.info('');
dataDir = /${dirFullEscaped}/;
logDir = /${targetDirEscaped}/;
type = '${type}';
sysid = '${sysid}';
if (type != 'null' && sysid != 'null') {
try {
logger.info('Exporting Data ' + sysid + ' of type ' + type + ' to: ' + dataDir);
portalDataHandlerService.exportData(type, sysid, new File(dataDir));
}
catch (Exception e) {
throw new RuntimeException("data-export to " + dataDir + " of " + type + " " + sysid + " failed", e);
}
}
else if (type != 'null') {
try {
logger.info('Exporting All Data of type ' + type + ' to: ' + dataDir);
portalDataHandlerService.exportAllDataOfType(
[type] as Set,
new File(dataDir),
new org.jasig.portal.io.xml.IPortalDataHandlerService.BatchExportOptions().setLogDirectoryParent(logDir));
}
catch (Exception e) {
throw new RuntimeException("data-export to " + dataDir + " of " + type + " failed", e);
}
}
else {
try {
logger.info('Exporting All Data to: ' + dataDir);
portalDataHandlerService.exportAllData(
new File(dataDir),
new org.jasig.portal.io.xml.IPortalDataHandlerService.BatchExportOptions().setLogDirectoryParent(logDir));
}
catch (Exception e) {
throw new RuntimeException("data-export to " + dataDir + " failed", e);
}
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="data-import" depends="prodPrompt" description="Imports the specified XML file or files">
<if>
<not>
<or>
<isset property="dir" />
<isset property="file" />
</or>
</not>
<then>
<fail>Either '-Ddir' or '-Dfile' must be specified for data import</fail>
</then>
</if>
<property name="pattern" value="null" />
<property name="file" value="null" />
<property name="dir" value="null" />
<groovy-safe-path property="dirFullEscaped" input="${dir}" />
<groovy-safe-path property="fileFullEscaped" input="${file}" />
<groovy-safe-path property="targetDirEscaped" input="${targetdir}" />
<echo>Creating Data Import Script</echo>
<echo file="${portal-shell-script}" append="true">
//Data Import Script
logger.info('');
logger.info('');
dataDir = /${dirFullEscaped}/;
logDir = /${targetDirEscaped}/;
if (dataDir == 'null') {
file = /${fileFullEscaped}/;
logger.info('Importing Data from: ' + file);
try {
portalDataHandlerService.importData(new org.springframework.core.io.FileSystemResource(file));
}
catch (Exception e) {
throw new RuntimeException("data-import for " + file + " failed", e);
}
}
else {
pattern = /${pattern}/;
logger.info('Importing Data from: ' + dataDir);
try {
portalDataHandlerService.importData(
new File(dataDir),
pattern == 'null' ? null : pattern,
new org.jasig.portal.io.xml.IPortalDataHandlerService.BatchImportOptions().setLogDirectoryParent(logDir));
}
catch (Exception e) {
if (pattern != null) {
throw new RuntimeException("data-import from " + dataDir + " matching " + pattern + " failed", e);
}
else {
throw new RuntimeException("data-import from " + dataDir + " failed", e);
}
}
} </echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="data-delete" depends="prodPrompt" description="Deletes the specified entity">
<if>
<not>
<and>
<isset property="type" />
<isset property="sysid" />
</and>
</not>
<then>
<fail>Both '-Dtype' and '-Dsysid' must be specified for data delete. Use 'ant data-list' to determine available data types</fail>
</then>
</if>
<groovy-safe-path property="dirFullEscaped" input="${dir}" />
<echo>Creating Data Delete Script</echo>
<echo file="${portal-shell-script}" append="true">
try {
//Data Delete Script
logger.info('');
logger.info('');
type = '${type}';
sysid = '${sysid}';
logger.info('Deleting Data ' + sysid + ' of type ' + type);
portalDataHandlerService.deleteData(type, sysid);
}
catch (Exception e) {
throw new RuntimeException("data-delete for " + type + " and " + sysid + " failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="clean-shared" depends="checkForTomcat" description="Removes ALL shared libraries from the servlet container.">
<mkdir dir="${server.base}/shared/lib" />
<delete>
<fileset dir="${server.base}/shared/lib">
<include name="*" />
</fileset>
</delete>
</target>
<target name="clean-tomcat" depends="checkForTomcat" description="Removes the deployed uPortal from the servlet container">
<uportal-parent-macro>
<!-- Clean out uPortal from Tomcat -->
<artifact:pom file="${uportal-war.dir}/pom.xml" id="uportal-war.pom" settingsFile="${maven.settings}" inheritAllProperties="false" />
<property name="destDir" value="${server.base}/webapps/${uportal-war.pom.build.finalName}" />
<echo>Deleting '${destDir}'</echo>
<delete dir="${destDir}" />
</uportal-parent-macro>
</target>
<target name="clean" description="Runs 'mvn clean'">
<!-- Execute the mvn clean lifecycle -->
<antcall target="mvn">
<param name="pomDir" value="${basedir}" />
<param name="goal" value="clean" />
</antcall>
</target>
<target name="deploy-ear" depends="checkForTomcat" description="Deploy uPortal and dependent libraries and portlets to the servlet container">
<uportal-ear-macro>
<echo message=" extractWars=${extractWars}" />
<echo message="removeExisting=${removeExisting}" />
<echo message=" cleanShared=${cleanShared}" />
<if>
<equals arg1="${cleanShared}" arg2="true" />
<then>
<antcall target="clean-shared" />
</then>
</if>
<artifact:dependencies pathid="uportal-ant" settingsFile="${maven.settings}">
<pom file="${bootstrap.dir}/uportal-ant-tasks/pom.xml" />
</artifact:dependencies>
<typedef resource="org/jasig/portal/ant/antlib.xml" uri="urn:up-util-ant">
<classpath>
<path refid="uportal-ant" />
</classpath>
</typedef>
<mkdir dir="${server.base}/shared/lib" />
<up:tomcatEarDeploy ear="${uportal-ear.artifact}" catalinaBase="${server.base}" webAppsDir="${server.webapps}" extractWars="${extractWars}" removeExistingDirectories="${removeExisting}" />
</uportal-ear-macro>
</target>
<target name="deploy-war" depends="checkForTomcat" description="Deploy the uPortal web application to the servlet container">
<uportal-war-macro>
<antcall target="fastWarDeploy">
<param name="warPath" value="${uportal-war.artifact}" />
</antcall>
</uportal-war-macro>
</target>
<target name="deployPortletApp" depends="checkForTomcat" description="Deploys a portlet application">
<!-- Check arguments -->
<fail message="'-DportletApp=[WAR File]' must be specified">
<condition>
<not>
<isset property="portletApp" />
</not>
</condition>
</fail>
<if>
<available file="${user.dir}/${portletApp}" />
<then>
<property name="portletAppPath" location="${user.dir}/${portletApp}" />
</then>
<else>
<property name="portletAppPath" location="${portletApp}" />
</else>
</if>
<fail message="portletApp '${portletAppPath}' does not exist">
<condition>
<not>
<available file="${portletAppPath}" />
</not>
</condition>
</fail>
<basename property="war.filename" file="${portletAppPath}" />
<uportal-parent-macro>
<artifact:dependencies pathid="pluto-ant" settingsFile="${maven.settings}">
<artifact:pom file="${bootstrap.dir}/pluto-assembler/pom.xml" settingsFile="${maven.settings}" inheritAllProperties="false" />
</artifact:dependencies>
<taskdef classname="org.apache.pluto.ant.AssembleTask" name="assemblePortlet">
<classpath>
<path refid="pluto-ant" />
</classpath>
</taskdef>
</uportal-parent-macro>
<assemblePortlet destdir="${jasig.tmpdir}" war="${portletAppPath}" />
<antcall target="fastWarDeploy">
<param name="warPath" value="${jasig.tmpdir}/${war.filename}" />
</antcall>
<delete file="${jasig.tmpdir}/${war.filename}" />
</target>
<target name="md5passwd" depends="prodPrompt" description="Creates a user in the UP_PERSON_DIR table">
<fail unless="username">
You must specify a 'username' parameter (-Dusername={juser})
</fail>
<uportal-war-macro>
<echo message="Invoking creating/updating password for: ${username}" />
<java dir="${basedir}" classname="org.jasig.portal.security.Md5Passwd">
<classpath refid="uportal-war-full.classpath" />
<arg value="-c" />
<arg value="${username}" />
</java>
</uportal-war-macro>
</target>
<target name="deluser" depends="prodPrompt" description="Delete traces of a user from the portal database">
<fail unless="user">
You must specify a 'user' parameter (-Duser={jdoe})
</fail>
<echo>Deleting user ${user}</echo>
<echo file="${portal-shell-script}" append="true">
try {
//Delete USer Script
logger.info('');
logger.info('');
user = '${user}';
userIdentityStore.removePortalUID(user);
}
catch (Exception e) {
throw new RuntimeException("deluser for " + user + " failed", e);
}
</echo>
<antcall target="up-shell">
<param name="script" value="${portal-shell-script}" />
</antcall>
</target>
<target name="addstylesheet" depends="prodPrompt" description="Registers a new theme or structure">
<uportal-war-macro>
<property name="stylesheetType" value=" " />
<property name="stylesheetUri" value=" " />
<property name="descriptionUri" value=" " />
<echo message="Invoking RegisterStylesheet (add)" />
<java dir="${basedir}" fork="true" classname="org.jasig.portal.tools.RegisterStylesheet">
<classpath refid="uportal-war-full.classpath" />
<arg value="${stylesheetType}" />
<arg value="${stylesheetUri}" />
<arg value="${descriptionUri}" />
</java>
</uportal-war-macro>
</target>
<target name="modstylesheet" depends="prodPrompt" description="Modifies an existing theme or structure">
<uportal-war-macro>
<property name="stylesheetType" value=" " />
<property name="stylesheetUri" value=" " />
<property name="descriptionUri" value=" " />
<property name="stylesheetId" value=" " />
<echo message="Invoking RegisterStylesheet (modify)" />
<java dir="${basedir}" fork="true" classname="org.jasig.portal.tools.RegisterStylesheet">
<classpath refid="uportal-war-full.classpath" />
<arg value="${stylesheetType}" />
<arg value="-u" />
<arg value="${stylesheetUri}" />
<arg value="${descriptionUri}" />
<arg value="${stylesheetId}" />
</java>
</uportal-war-macro>
</target>
<target name="delstylesheet" depends="prodPrompt" description="Deletes an existing theme or structure">
<uportal-war-macro>
<property name="stylesheetType" value=" " />
<property name="stylesheetId" value=" " />
<echo message="Invoking RegisterStylesheet (delete)" />
<java dir="${basedir}" classname="org.jasig.portal.tools.RegisterStylesheet">
<classpath refid="uportal-war-full.classpath" />
<arg value="${stylesheetType}" />
<arg value="-d" />
<arg value="${stylesheetId}" />
</java>
</uportal-war-macro>
</target>
<target name="hsql" description="Start a HSQLDB instance consistent with the default RDBMS requirements of uPortal">
<property name="spawn" value="false" />
<condition property="failonerror" value="false">
<equals arg1="${spawn}" arg2="true" />
</condition>
<property name="failonerror" value="true" />
<uportal-parent-macro>
<artifact:dependencies pathid="hsql.classpath" settingsFile="${maven.settings}">
<artifact:pom file="${bootstrap.dir}/hsqldb/pom.xml" settingsFile="${maven.settings}" inheritAllProperties="false" />
</artifact:dependencies>
<property name="database" value="file:${basedir}/data/uPortal;hsqldb.tx=mvcc" />
<property name="port" value="${environment.build.hsql.port}" />
<echo message="Starting HSQL on ${port}" />
<echo message="Using: ${database}" />
<java fork="true" spawn="${spawn}" maxmemory="32M" dir="${basedir}" classname="org.hsqldb.server.Server" failonerror="${failonerror}">
<classpath refid="hsql.classpath" />
<arg value="--database.0" />
<arg value="${database}" />
<arg value="--dbname.0" />
<arg value="uPortal" />
<arg value="--address" />
<arg value="localhost" />
<arg value="--port" />
<arg value="${port}" />
</java>
</uportal-parent-macro>
</target>
<target name="hsql-shutdown" description="Compacts then cleanly shuts down hsql, useful if the 'hsql' task was run with '-Dspawn=true'">
<uportal-parent-macro>
<artifact:dependencies pathid="hsql.classpath" settingsFile="${maven.settings}">
<artifact:pom file="${bootstrap.dir}/hsqldb/pom.xml" settingsFile="${maven.settings}" inheritAllProperties="false" />
</artifact:dependencies>
<copy file="${bootstrap.dir}/hsqldb.sqltool.rc.sample" tofile="${bootstrap.dir}/hsqldb.sqltool.rc" overwrite="true">
<filterset>
<filter token="environment.build.hibernate.connection.url" value="${environment.build.hibernate.connection.url}" />
</filterset>
</copy>
<echo message="Stopping HSQL" />
<trycatch reference="hsql-shutdown.exceptionId">
<try>
<java fork="true" maxmemory="8M" dir="${basedir}" classname="org.hsqldb.cmdline.SqlTool" timeout="5000" errorproperty="hsql-shutdown.err.out" failonerror="true">
<classpath refid="hsql.classpath" />
<arg value="--rcFile" />
<arg value="${bootstrap.dir}/hsqldb.sqltool.rc" />
<arg value="--sql" />
<arg value="shutdown compact;" />
<arg value="uPortalDb" />
</java>
</try>
<catch>
<if>
<contains string="${hsql-shutdown.err.out}" substring="java.net.ConnectException" />
<then>
<echo>HSQL is not running</echo>
</then>
<else>
<echo>${hsql-shutdown.err.out}</echo>
<throw refid="hsql-shutdown.exceptionId" />
</else>
</if>
</catch>
</trycatch>
</uportal-parent-macro>
</target>
<!-- ============================== Utility Targets ============================== -->
<target name="sync-schemas">
<fail unless="schemaDir">
You must specify a 'schemaDir' parameter (-DschemaDir={/path/to/jasig/schemas/uportal/})
NOTE THE TRAILING SLASH IS IMPORTANT
</fail>