-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imageUrl calls content API one time too many #10006
- Loading branch information
Showing
10 changed files
with
106 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
...les/portal/portal-impl/src/main/java/com/enonic/xp/portal/impl/url/ContentIdResolver.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
modules/portal/portal-impl/src/main/java/com/enonic/xp/portal/impl/url/ContentResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.enonic.xp.portal.impl.url; | ||
|
||
import com.enonic.xp.content.Content; | ||
import com.enonic.xp.content.ContentId; | ||
import com.enonic.xp.content.ContentPath; | ||
import com.enonic.xp.content.ContentService; | ||
import com.enonic.xp.portal.PortalRequest; | ||
|
||
final class ContentResolver | ||
{ | ||
private PortalRequest portalRequest; | ||
|
||
private ContentId id; | ||
|
||
private ContentPath path; | ||
|
||
private ContentService contentService; | ||
|
||
public ContentResolver portalRequest( final PortalRequest portalRequest ) | ||
{ | ||
this.portalRequest = portalRequest; | ||
return this; | ||
} | ||
|
||
public ContentResolver id( final String value ) | ||
{ | ||
this.id = value != null ? ContentId.from( value ) : null; | ||
return this; | ||
} | ||
|
||
public ContentResolver path( final String value ) | ||
{ | ||
this.path = value != null ? ContentPath.from( value ) : null; | ||
return this; | ||
} | ||
|
||
public ContentResolver contentService( final ContentService value ) | ||
{ | ||
this.contentService = value; | ||
return this; | ||
} | ||
|
||
public Content resolve() | ||
{ | ||
if ( this.id != null ) | ||
{ | ||
return this.contentService.getById( this.id ); | ||
} | ||
|
||
if ( path == null ) | ||
{ | ||
return this.portalRequest.getContent(); | ||
} | ||
|
||
final ContentPath contentPath; | ||
if ( path.isAbsolute() ) | ||
{ | ||
contentPath = path; | ||
} | ||
else | ||
{ | ||
contentPath = ContentPath.from( this.portalRequest.getContentPath(), this.path ); | ||
} | ||
|
||
return this.contentService.getByPath( contentPath ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.