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