Skip to content

Commit

Permalink
#26546 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Aug 14, 2024
1 parent 0adb9a2 commit 8aebc4e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ This maintenance release includes the following code fixes:
129. https://github.com/dotCMS/core/issues/27297 : Edit Page: Edit Contentlet Dialog Language Support #27297
130. https://github.com/dotCMS/core/issues/26413 : Template Builder: Container Layout Editing Issue #26413
131. https://github.com/dotCMS/core/issues/27816 : Content Displacement Bug when Editing Template #27816
132. https://github.com/dotCMS/core/issues/28163 : 'alive' and 'startup' healthcheck APIs return 503 on seemingly healthy app #28163
132. https://github.com/dotCMS/core/issues/28163 : 'alive' and 'startup' healthcheck APIs return 503 on seemingly healthy app #28163
133. https://github.com/dotCMS/core/issues/26546 : Enable better logging for getPageByPath in HTMLPageAssetAPIImpl.java #26546
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,8 @@ public ResponseEntityPageWorkflowActionsView findAvailableActions(@Context final
));
}

throw new DoesNotExistException("The page: " + findAvailableActionsForm.getPath() + " do not exist");
throw new DoesNotExistException(String.format("HTML Page path '%s' with language ID '%s' in Site " +
"'%s' does not exist", findAvailableActionsForm.getPath(),
findAvailableActionsForm.getLanguageId(), findAvailableActionsForm.getHostId()));
} // findAvailableActions.
} // E:O:F:PageResource
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CMSUrlUtil {
private static final String HTMLPAGE = "htmlpage";
private static final String FILE_ASSET = "file_asset";
private static final String FOLDER = "folder";
private static final String NOT_FOUND = "NOTFOUND";
public static final String NOT_FOUND = "NOTFOUND";
private static final String UNABLE_TO_FIND = "Unable to find ";

public static final Set<String> BACKEND_FILTERED_COLLECTION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;
import com.dotcms.contenttype.model.type.BaseContentType;
import com.dotcms.exception.ExceptionUtil;
import com.dotcms.mock.request.FakeHttpRequest;
import com.dotcms.mock.request.MockAttributeRequest;
import com.dotcms.mock.request.MockSessionRequest;
Expand Down Expand Up @@ -245,19 +246,21 @@ public HTMLPageAsset fromContentlet(Contentlet con) {

@CloseDBIfOpened
@Override
public IHTMLPage getPageByPath(String uri, Host host, Long languageId, Boolean live) throws DotDataException, DotSecurityException {
public IHTMLPage getPageByPath(final String uri, final Host site, final Long languageId, final Boolean live) {
Identifier id;
if(!UtilMethods.isSet(uri)){
return null;
}

if (CMSUrlUtil.getInstance().isFolder(uri, host)) {
id = this.getIndexPageIdentifier(uri, host);
final String errorMsg = "Unable to find '%s' HTML Page with URI '%s' in language '%s' in Site '%s' [%s]: %s";
if (CMSUrlUtil.getInstance().isFolder(uri, site)) {
id = this.getIndexPageIdentifier(uri, site);
} else {
try {
id = identifierAPI.find(host, uri);
} catch (Exception e) {
Logger.error(this.getClass(), "Unable to find URI: " + uri);
id = this.identifierAPI.find(site, uri);
} catch (final Exception e) {
Logger.error(this, String.format(errorMsg, live ? "live" : "working",
uri, languageId, site, site.getIdentifier(),
ExceptionUtil.getErrorMessage(e)), e);
return null;
}
}
Expand All @@ -266,30 +269,32 @@ public IHTMLPage getPageByPath(String uri, Host host, Long languageId, Boolean l
return null;
}

if ("contentlet".equals(id.getAssetType())) {
if (Identifier.ASSET_TYPE_CONTENTLET.equals(id.getAssetType())) {
try {
final String currentVariantId = WebAPILocator.getVariantWebAPI().currentVariantId();
Optional<ContentletVersionInfo> cinfo = versionableAPI
.getContentletVersionInfo( id.getId(), languageId, currentVariantId);

if (cinfo.isEmpty() || cinfo.get().getWorkingInode().equals( "NOTFOUND" )) {
if (cinfo.isEmpty() || cinfo.get().getWorkingInode().equals(CMSUrlUtil.NOT_FOUND)) {

cinfo = versionableAPI.getContentletVersionInfo( id.getId(), languageId);

if (cinfo.isEmpty() || cinfo.get().getWorkingInode().equals( "NOTFOUND" )) {
if (cinfo.isEmpty() || cinfo.get().getWorkingInode().equals(CMSUrlUtil.NOT_FOUND)) {
return null;
}
}

Contentlet contentlet = contentletAPI.find(live ? cinfo.get().getLiveInode()
: cinfo.get().getWorkingInode(), userAPI.getSystemUser(), false);
final Contentlet contentlet = this.contentletAPI.find(live ? cinfo.get().getLiveInode()
: cinfo.get().getWorkingInode(), this.userAPI.getSystemUser(), false);

if(contentlet.getStructure().getStructureType() == Structure.STRUCTURE_TYPE_HTMLPAGE) {
if (BaseContentType.HTMLPAGE.getType() == contentlet.getContentType().baseType().getType()) {
return fromContentlet(contentlet);
}

} catch (Exception e) {
Logger.error(this.getClass(), "Unable to find URI: " + uri);
} catch (final Exception e) {
Logger.error(this, String.format(errorMsg, live ? "live" : "working",
uri, languageId, site, site.getIdentifier(),
ExceptionUtil.getErrorMessage(e)));
return null;
}
}
Expand Down

0 comments on commit 8aebc4e

Please sign in to comment.