001
014
015 package com.liferay.portlet.dynamicdatamapping.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.LocaleUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.xml.Document;
023 import com.liferay.portal.kernel.xml.Element;
024 import com.liferay.portal.kernel.xml.SAXReaderUtil;
025 import com.liferay.portal.model.Group;
026 import com.liferay.portal.model.Image;
027 import com.liferay.portal.service.ImageLocalServiceUtil;
028 import com.liferay.portal.theme.ThemeDisplay;
029 import com.liferay.portal.util.PortalUtil;
030 import com.liferay.portal.util.PropsValues;
031
032 import java.util.Locale;
033
034
037 public class DDMTemplateImpl extends DDMTemplateBaseImpl {
038
039 public DDMTemplateImpl() {
040 }
041
042 @Override
043 public String getDefaultLanguageId() {
044 Document document = null;
045
046 try {
047 document = SAXReaderUtil.read(getName());
048
049 if (document != null) {
050 Element rootElement = document.getRootElement();
051
052 return rootElement.attributeValue("default-locale");
053 }
054 }
055 catch (Exception e) {
056 }
057
058 Locale locale = LocaleUtil.getSiteDefault();
059
060 return locale.toString();
061 }
062
063 @Override
064 public String getSmallImageType() throws PortalException, SystemException {
065 if ((_smallImageType == null) && isSmallImage()) {
066 Image smallImage = ImageLocalServiceUtil.getImage(
067 getSmallImageId());
068
069 _smallImageType = smallImage.getType();
070 }
071
072 return _smallImageType;
073 }
074
075
084 @Override
085 public String getWebDavURL(ThemeDisplay themeDisplay, String webDAVToken) {
086 StringBundler sb = new StringBundler(11);
087
088 boolean secure = false;
089
090 if (themeDisplay.isSecure() ||
091 PropsValues.WEBDAV_SERVLET_HTTPS_REQUIRED) {
092
093 secure = true;
094 }
095
096 String portalURL = PortalUtil.getPortalURL(
097 themeDisplay.getServerName(), themeDisplay.getServerPort(), secure);
098
099 sb.append(portalURL);
100
101 sb.append(themeDisplay.getPathContext());
102 sb.append(StringPool.SLASH);
103 sb.append("webdav");
104
105 Group group = themeDisplay.getScopeGroup();
106
107 sb.append(group.getFriendlyURL());
108
109 sb.append(StringPool.SLASH);
110 sb.append(webDAVToken);
111 sb.append(StringPool.SLASH);
112 sb.append("Templates");
113 sb.append(StringPool.SLASH);
114 sb.append(getTemplateId());
115
116 return sb.toString();
117 }
118
119 @Override
120 public void setSmallImageType(String smallImageType) {
121 _smallImageType = smallImageType;
122 }
123
124 private String _smallImageType;
125
126 }