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