1
22
23 package com.liferay.portlet.journal.model.impl;
24
25 import com.liferay.portal.kernel.util.Validator;
26 import com.liferay.portal.kernel.xml.Document;
27 import com.liferay.portal.kernel.xml.Element;
28 import com.liferay.portal.kernel.xml.SAXReaderUtil;
29 import com.liferay.portlet.journal.model.JournalStructure;
30 import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
31
32 import java.util.Iterator;
33
34
39 public class JournalStructureImpl
40 extends JournalStructureModelImpl implements JournalStructure {
41
42 public static final String RESERVED = "reserved";
43
44 public static final String RESERVED_ARTICLE_AUTHOR_COMMENTS =
45 "reserved-article-author-comments";
46
47 public static final String RESERVED_ARTICLE_AUTHOR_EMAIL_ADDRESS =
48 "reserved-article-author-email-address";
49
50 public static final String RESERVED_ARTICLE_AUTHOR_ID =
51 "reserved-article-author-id";
52
53 public static final String RESERVED_ARTICLE_AUTHOR_JOB_TITLE =
54 "reserved-article-author-job-title";
55
56 public static final String RESERVED_ARTICLE_AUTHOR_LOCATION =
57 "reserved-article-author-location";
58
59 public static final String RESERVED_ARTICLE_AUTHOR_NAME =
60 "reserved-article-author-name";
61
62 public static final String RESERVED_ARTICLE_AUTHOR_ORGANIZATION =
63 "reserved-article-author-organization";
64
65 public static final String RESERVED_ARTICLE_CREATE_DATE =
66 "reserved-article-create-date";
67
68 public static final String RESERVED_ARTICLE_DESCRIPTION =
69 "reserved-article-description";
70
71 public static final String RESERVED_ARTICLE_DISPLAY_DATE =
72 "reserved-article-display-date";
73
74 public static final String RESERVED_ARTICLE_ID = "reserved-article-id";
75
76 public static final String RESERVED_ARTICLE_MODIFIED_DATE =
77 "reserved-article-modified-date";
78
79 public static final String RESERVED_ARTICLE_SMALL_IMAGE_URL =
80 "reserved-article-small-image-url";
81
82 public static final String RESERVED_ARTICLE_TITLE =
83 "reserved-article-title";
84
85 public static final String RESERVED_ARTICLE_TYPE =
86 "reserved-article-type";
87
88 public static final String RESERVED_ARTICLE_URL_TITLE =
89 "reserved-article-url-title";
90
91 public static final String RESERVED_ARTICLE_VERSION =
92 "reserved-article-version";
93
94 public JournalStructureImpl() {
95 }
96
97 public String getMergedXsd() {
98 String parentStructureId = getParentStructureId();
99
100 String xsd = getXsd();
101
102 if (Validator.isNull(parentStructureId)) {
103 return xsd;
104 }
105
106 try {
107 JournalStructure parentStructure =
108 JournalStructureLocalServiceUtil.getStructure(
109 getGroupId(), parentStructureId);
110
111 Document doc = SAXReaderUtil.read(getXsd());
112
113 Element root = doc.getRootElement();
114
115 Document parentDoc = SAXReaderUtil.read(
116 parentStructure.getMergedXsd());
117
118 Element parentRoot = parentDoc.getRootElement();
119
120 addParentStructureId(parentRoot, parentStructureId);
121
122 root.content().addAll(0, parentRoot.content());
123
124 xsd = root.asXML();
125 }
126 catch (Exception e) {
127 }
128
129 return xsd;
130 }
131
132 protected void addParentStructureId(
133 Element parentEl, String parentStructureId) {
134
135 Iterator<Element> itr = parentEl.elements(_DYNAMIC_ELEMENT).iterator();
136
137 while (itr.hasNext()) {
138 Element dynamicEl = itr.next();
139
140 dynamicEl.addAttribute(_PARENT_STRUCTURE_ID, parentStructureId);
141
142 addParentStructureId(dynamicEl, parentStructureId);
143 }
144 }
145
146 private static final String _DYNAMIC_ELEMENT = "dynamic-element";
147
148 private static final String _PARENT_STRUCTURE_ID = "parent-structure-id";
149
150 }