use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class BaseSiteHandler method doCreatePortalRequest.
protected PortalRequest doCreatePortalRequest(final WebRequest webRequest, final String baseUri, final String baseSubPath) {
final RepositoryId repositoryId = findRepository(baseSubPath);
final Branch branch = findBranch(baseSubPath);
final ContentPath contentPath = findContentPath(baseSubPath);
final PortalRequest portalRequest = new PortalRequest(webRequest);
portalRequest.setBaseUri(baseUri);
portalRequest.setRepositoryId(repositoryId);
portalRequest.setBranch(branch);
portalRequest.setContentPath(contentPath);
return portalRequest;
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ControllerHandlerWorker method contentExists.
private boolean contentExists(final String contentSelector) {
final ContentId contentId = ContentId.from(contentSelector.substring(1));
final ContentPath contentPath = ContentPath.from(contentSelector).asAbsolute();
return this.contentService.contentExists(contentId) || (!ContentPath.ROOT.equals(contentPath) && this.contentService.contentExists(contentPath));
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ControllerHandlerWorker method getContentOrNull.
protected final Content getContentOrNull(final String contentSelector) {
if (request.getMode() == RenderMode.EDIT) {
final ContentId contentId = ContentId.from(contentSelector.substring(1));
final Content contentById = getContentById(contentId);
if (contentById != null) {
return contentById;
}
}
final ContentPath contentPath = ContentPath.from(contentSelector).asAbsolute();
return getContentByPath(contentPath);
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentIdResolver method resolveId.
private ContentId resolveId(final ContentPath path) {
final ContentPath resolved = resolvePath(path);
final Content content = this.contentService.getByPath(resolved);
return content != null ? content.getId() : null;
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class GenericEndpointUrlBuilder method removeContentPath.
private String removeContentPath(final String path) {
final String[] splitPreEndpointPath = path.split("/");
int preEndpointPathIndex = splitPreEndpointPath.length - 1;
final ContentPath normalizedContentPath = ContentPath.from(normalizePath(this.portalRequest.getContentPath().toString()));
int contentPathIndex = normalizedContentPath.elementCount() - 1;
while (preEndpointPathIndex >= 0 && contentPathIndex >= 0 && normalizedContentPath.getElement(contentPathIndex).equals(splitPreEndpointPath[preEndpointPathIndex])) {
preEndpointPathIndex--;
contentPathIndex--;
}
final String[] preEndpointPathWithoutContentPath = Arrays.copyOfRange(splitPreEndpointPath, 0, preEndpointPathIndex + 1);
return String.join(ELEMENT_DIVIDER, preEndpointPathWithoutContentPath);
}
Aggregations