1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.journal.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.portal.kernel.xml.Document;
28  import com.liferay.portal.kernel.xml.Element;
29  import com.liferay.portal.kernel.xml.SAXReaderUtil;
30  import com.liferay.portal.util.PortalUtil;
31  import com.liferay.portlet.journal.model.JournalStructure;
32  import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
33  
34  /**
35   * <a href="JournalStructureImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   *
39   */
40  public class JournalStructureImpl
41      extends JournalStructureModelImpl implements JournalStructure {
42  
43      public static final String RESERVED = "reserved";
44  
45      public static final String RESERVED_ARTICLE_ID = "reserved-article-id";
46  
47      public static final String RESERVED_ARTICLE_VERSION =
48          "reserved-article-version";
49  
50      public static final String RESERVED_ARTICLE_TITLE =
51          "reserved-article-title";
52  
53      public static final String RESERVED_ARTICLE_DESCRIPTION =
54          "reserved-article-description";
55  
56      public static final String RESERVED_ARTICLE_TYPE =
57          "reserved-article-type";
58  
59      public static final String RESERVED_ARTICLE_CREATE_DATE =
60          "reserved-article-create-date";
61  
62      public static final String RESERVED_ARTICLE_MODIFIED_DATE =
63          "reserved-article-modified-date";
64  
65      public static final String RESERVED_ARTICLE_DISPLAY_DATE =
66          "reserved-article-display-date";
67  
68      public static final String RESERVED_ARTICLE_SMALL_IMAGE_URL =
69          "reserved-article-small-image-url";
70  
71      public static final String RESERVED_ARTICLE_AUTHOR_ID =
72          "reserved-article-author-id";
73  
74      public static final String RESERVED_ARTICLE_AUTHOR_NAME =
75          "reserved-article-author-name";
76  
77      public static final String RESERVED_ARTICLE_AUTHOR_EMAIL_ADDRESS =
78          "reserved-article-author-email-address";
79  
80      public static final String RESERVED_ARTICLE_AUTHOR_COMMENTS =
81          "reserved-article-author-comments";
82  
83      public static final String RESERVED_ARTICLE_AUTHOR_ORGANIZATION =
84          "reserved-article-author-organization";
85  
86      public static final String RESERVED_ARTICLE_AUTHOR_LOCATION =
87          "reserved-article-author-location";
88  
89      public static final String RESERVED_ARTICLE_AUTHOR_JOB_TITLE =
90          "reserved-article-author-job-title";
91  
92      public JournalStructureImpl() {
93      }
94  
95      public String getUserUuid() throws SystemException {
96          return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
97      }
98  
99      public void setUserUuid(String userUuid) {
100         _userUuid = userUuid;
101     }
102 
103     public String getMergedXsd() {
104         String parentStructureId = getParentStructureId();
105 
106         String xsd = getXsd();
107 
108         if (Validator.isNull(parentStructureId)) {
109             return xsd;
110         }
111 
112         try {
113             JournalStructure parentStructure =
114                 JournalStructureLocalServiceUtil.getStructure(
115                     getGroupId(), parentStructureId);
116 
117             Document doc = SAXReaderUtil.read(getXsd());
118 
119             Element root = doc.getRootElement();
120 
121             Document parentDoc = SAXReaderUtil.read(
122                 parentStructure.getMergedXsd());
123 
124             Element parentRoot = parentDoc.getRootElement();
125 
126             root.content().addAll(0, parentRoot.content());
127 
128             xsd = root.asXML();
129         }
130         catch (Exception e) {
131         }
132 
133         return xsd;
134     }
135 
136     private String _userUuid;
137 
138 }