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
42 public class ReverendFunBuilder {
43
44 public static void main(String[] args) {
45 InitUtil.initWithSpring();
46
47 new ReverendFunBuilder();
48 }
49
50 public ReverendFunBuilder() {
51 try {
52 File file = new File(
53 "../portal-impl/src/com/liferay/portlet/reverendfun/" +
54 "dependencies/dates.txt");
55
56 String[] dates = StringUtil.split(FileUtil.read(file), "\n");
57
58 WebCacheItem wci = new ReverendFunWebCacheItem(dates[0]);
59
60 Set<String> moreDates = (Set<String>)wci.convert(StringPool.BLANK);
61
62 if (moreDates.size() > 0) {
63 StringBuilder sb = new StringBuilder();
64
65 Set<String> datesSet = new HashSet<String>();
66
67 for (String date : moreDates) {
68 datesSet.add(date);
69
70 sb.append(date);
71 sb.append("\n");
72 }
73
74 for (int i = 0; i < dates.length; i++) {
75 String date = dates[i];
76
77 if (!datesSet.contains(date)) {
78 datesSet.add(date);
79
80 sb.append(date);
81
82 if ((i + 1) < dates.length) {
83 sb.append("\n");
84 }
85 }
86 }
87
88 FileUtil.write(file, sb.toString(), true);
89 }
90 }
91 catch (Exception e) {
92 }
93 }
94
95 }