1
22
23 package com.liferay.portal.verify;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.util.PropsUtil;
27 import com.liferay.portlet.journal.action.ExportAction;
28 import com.liferay.portlet.journal.model.JournalArticle;
29 import com.liferay.portlet.journal.model.JournalStructure;
30 import com.liferay.portlet.journal.model.JournalTemplate;
31 import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
32 import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
33 import com.liferay.portlet.journal.service.JournalTemplateLocalServiceUtil;
34
35 import java.util.List;
36
37 import org.apache.commons.logging.Log;
38 import org.apache.commons.logging.LogFactory;
39
40
46 public class VerifyOracle extends VerifyProcess {
47
48 public static final int NUM_OF_ARTICLES = GetterUtil.getInteger(
49 PropsUtil.get(VerifyOracle.class.getName()), 5);
50
51 public void verify() throws VerifyException {
52 _log.info("Verifying");
53
54 try {
55 verifyOracle();
56 }
57 catch (Exception e) {
58 throw new VerifyException(e);
59 }
60 }
61
62 protected void verifyOracle() throws Exception {
63
64
70 boolean checkNewLine = false;
71
72 List<JournalArticle> articles = null;
73
74 if (NUM_OF_ARTICLES <= 0) {
75 checkNewLine = true;
76
77 articles = JournalArticleLocalServiceUtil.getArticles(
78 ExportAction.DEFAULT_GROUP_ID);
79 }
80 else {
81 articles = JournalArticleLocalServiceUtil.getArticles(
82 ExportAction.DEFAULT_GROUP_ID, 0, NUM_OF_ARTICLES);
83 }
84
85 for (int i = 0; i < articles.size(); i++) {
86 JournalArticle article = articles.get(i);
87
88 String content = article.getContent();
89
90 if ((content != null) && (content.indexOf("\\n") != -1)) {
91 articles = JournalArticleLocalServiceUtil.getArticles(
92 ExportAction.DEFAULT_GROUP_ID);
93
94 for (int j = 0; j < articles.size(); j++) {
95 article = articles.get(j);
96
97 JournalArticleLocalServiceUtil.checkNewLine(
98 article.getGroupId(), article.getArticleId(),
99 article.getVersion());
100 }
101
102 checkNewLine = true;
103
104 break;
105 }
106 }
107
108
110 if (!checkNewLine) {
111 if (_log.isInfoEnabled()) {
112 _log.debug("Do not fix oracle new line");
113 }
114
115 return;
116 }
117 else {
118 if (_log.isInfoEnabled()) {
119 _log.info("Fix oracle new line");
120 }
121 }
122
123 List<JournalStructure> structures =
124 JournalStructureLocalServiceUtil.getStructures(
125 ExportAction.DEFAULT_GROUP_ID, 0, 1);
126
127 if (structures.size() == 1) {
128 JournalStructure structure = structures.get(0);
129
130 String xsd = structure.getXsd();
131
132 if ((xsd != null) && (xsd.indexOf("\\n") != -1)) {
133 structures = JournalStructureLocalServiceUtil.getStructures(
134 ExportAction.DEFAULT_GROUP_ID);
135
136 for (int i = 0; i < structures.size(); i++) {
137 structure = structures.get(i);
138
139 JournalStructureLocalServiceUtil.checkNewLine(
140 structure.getGroupId(), structure.getStructureId());
141 }
142 }
143 }
144
145 List<JournalTemplate> templates =
146 JournalTemplateLocalServiceUtil.getTemplates(
147 ExportAction.DEFAULT_GROUP_ID, 0, 1);
148
149 if (templates.size() == 1) {
150 JournalTemplate template = templates.get(0);
151
152 String xsl = template.getXsl();
153
154 if ((xsl != null) && (xsl.indexOf("\\n") != -1)) {
155 templates = JournalTemplateLocalServiceUtil.getTemplates(
156 ExportAction.DEFAULT_GROUP_ID);
157
158 for (int i = 0; i < templates.size(); i++) {
159 template = templates.get(i);
160
161 JournalTemplateLocalServiceUtil.checkNewLine(
162 template.getGroupId(), template.getTemplateId());
163 }
164 }
165 }
166 }
167
168 private static Log _log = LogFactory.getLog(VerifyOracle.class);
169
170 }