1
19
20 package com.liferay.portlet.reverendfun.tools;
21
22 import com.liferay.portal.kernel.util.FileUtil;
23 import com.liferay.portal.kernel.util.StringPool;
24 import com.liferay.portal.kernel.util.StringUtil;
25 import com.liferay.portal.kernel.webcache.WebCacheItem;
26 import com.liferay.portal.util.InitUtil;
27 import com.liferay.portlet.reverendfun.util.ReverendFunWebCacheItem;
28
29 import java.io.File;
30
31 import java.util.HashSet;
32 import java.util.Set;
33
34
40 public class ReverendFunBuilder {
41
42 public static void main(String[] args) {
43 InitUtil.initWithSpring();
44
45 new ReverendFunBuilder();
46 }
47
48 public ReverendFunBuilder() {
49 try {
50 File file = new File(
51 "../portal-impl/src/com/liferay/portlet/reverendfun/" +
52 "dependencies/dates.txt");
53
54 String[] dates = StringUtil.split(FileUtil.read(file), "\n");
55
56 WebCacheItem wci = new ReverendFunWebCacheItem(dates[0]);
57
58 Set<String> moreDates = (Set<String>)wci.convert(StringPool.BLANK);
59
60 if (moreDates.size() > 0) {
61 StringBuilder sb = new StringBuilder();
62
63 Set<String> datesSet = new HashSet<String>();
64
65 for (String date : moreDates) {
66 datesSet.add(date);
67
68 sb.append(date);
69 sb.append("\n");
70 }
71
72 for (int i = 0; i < dates.length; i++) {
73 String date = dates[i];
74
75 if (!datesSet.contains(date)) {
76 datesSet.add(date);
77
78 sb.append(date);
79
80 if ((i + 1) < dates.length) {
81 sb.append("\n");
82 }
83 }
84 }
85
86 FileUtil.write(file, sb.toString(), true);
87 }
88 }
89 catch (Exception e) {
90 }
91 }
92
93 }