diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index 7a5672ee1838..89a40f2dfc22 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/page/PageResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/page/PageResource.java index 1d36cc2e664f..76e8f14b2d8e 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/page/PageResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/page/PageResource.java @@ -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 diff --git a/dotCMS/src/main/java/com/dotmarketing/filters/CMSUrlUtil.java b/dotCMS/src/main/java/com/dotmarketing/filters/CMSUrlUtil.java index 234cb80e1ec2..165c06d95475 100644 --- a/dotCMS/src/main/java/com/dotmarketing/filters/CMSUrlUtil.java +++ b/dotCMS/src/main/java/com/dotmarketing/filters/CMSUrlUtil.java @@ -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 BACKEND_FILTERED_COLLECTION = diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/HTMLPageAssetAPIImpl.java b/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/HTMLPageAssetAPIImpl.java index 37f63979e457..1aa6cf72e886 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/HTMLPageAssetAPIImpl.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/HTMLPageAssetAPIImpl.java @@ -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; @@ -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; } } @@ -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 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; } }