|
1 | 1 | package com.dotcms.contenttype.transform.contenttype; |
2 | 2 |
|
3 | 3 | import com.dotcms.api.web.HttpServletRequestThreadLocal; |
| 4 | +import com.dotcms.contenttype.model.type.BaseContentType; |
4 | 5 | import com.dotcms.contenttype.model.type.ContentType; |
5 | 6 | import com.dotcms.rest.api.v1.contenttype.ContentTypeHelper; |
6 | 7 | import com.dotmarketing.beans.Host; |
|
20 | 21 |
|
21 | 22 | public class DetailPageTransformerImpl implements DetailPageTransformer { |
22 | 23 |
|
23 | | - private static final String PAGE_SUBTYPE = "htmlpageasset"; |
24 | 24 |
|
25 | 25 | private final ContentType contentType; |
26 | 26 | private final User user; |
@@ -123,25 +123,26 @@ public Optional<String> idToUri() throws DotDataException, DotSecurityException |
123 | 123 | * @throws IllegalArgumentException if the identifier is invalid. |
124 | 124 | */ |
125 | 125 | private Optional<String> validateIdentifier( |
126 | | - String detailPage, Identifier foundDetailPageIdentifier) { |
127 | | - |
128 | | - if (null != foundDetailPageIdentifier && |
129 | | - foundDetailPageIdentifier.exists() && |
130 | | - foundDetailPageIdentifier.getAssetSubType().equals(PAGE_SUBTYPE)) { |
131 | | - return Optional.of(foundDetailPageIdentifier.getId()); |
132 | | - } else { |
133 | | - if (null != foundDetailPageIdentifier && |
134 | | - foundDetailPageIdentifier.exists() && |
135 | | - !foundDetailPageIdentifier.getAssetSubType().equals(PAGE_SUBTYPE)) { |
136 | | - throw new IllegalArgumentException( |
137 | | - String.format("[%s] in Content Type [%s] is not a valid detail page.", |
138 | | - detailPage, contentType.name())); |
| 126 | + String detailPage, Identifier foundDetailPageIdentifier) |
| 127 | + throws DotDataException, DotSecurityException { |
| 128 | + |
| 129 | + if (null != foundDetailPageIdentifier && foundDetailPageIdentifier.exists()) { |
| 130 | + final String assetSubType = foundDetailPageIdentifier.getAssetSubType(); |
| 131 | + if (UtilMethods.isSet(assetSubType)) { |
| 132 | + final ContentType detailPageType = APILocator.getContentTypeAPI( |
| 133 | + APILocator.getUserAPI().getSystemUser()).find(assetSubType); |
| 134 | + if (null != detailPageType && BaseContentType.HTMLPAGE == detailPageType.baseType()) { |
| 135 | + return Optional.of(foundDetailPageIdentifier.getId()); |
| 136 | + } |
139 | 137 | } |
140 | | - |
141 | 138 | throw new IllegalArgumentException( |
142 | | - String.format("Detail page [%s] in Content Type [%s] does not exist.", |
| 139 | + String.format("[%s] in Content Type [%s] is not a valid detail page.", |
143 | 140 | detailPage, contentType.name())); |
144 | 141 | } |
| 142 | + |
| 143 | + throw new IllegalArgumentException( |
| 144 | + String.format("Detail page [%s] in Content Type [%s] does not exist.", |
| 145 | + detailPage, contentType.name())); |
145 | 146 | } |
146 | 147 |
|
147 | 148 | } |
0 commit comments