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