@Override public ContentPath apply( final String value ) { return ContentPath.from( value ); } }
public PortalRequest( final WebRequest webRequest ) { super(webRequest); this.baseUri = ""; this.contentPath = ContentPath.from( "/" ); this.mode = RenderMode.LIVE; this.branch = DEFAULT_BRANCH; }
public PortalRequest() { this.baseUri = ""; this.contentPath = ContentPath.from( "/" ); this.mode = RenderMode.LIVE; this.branch = DEFAULT_BRANCH; }
private ContentPath contentPath( final String value ) { return value != null ? ContentPath.from( value ) : null; }
@Override public ContentPath convert( final Object value ) { if ( value instanceof ContentPath ) { return (ContentPath) value; } return ContentPath.from( value.toString() ); } }
protected static ContentPath findContentPath( final String baseSubPath ) { final String branchSubPath = findPathAfterBranch( baseSubPath ); final int underscore = branchSubPath.indexOf( "/_/" ); final String result = branchSubPath.substring( 0, underscore > -1 ? underscore : branchSubPath.length() ); return ContentPath.from( result.startsWith( "/" ) ? result : ( "/" + result ) ); }
public BUILDER path( final String path ) { return (BUILDER) path( ContentPath.from( path ) ); }
private ContentPaths add( final ImmutableSet paths ) { final HashSet<ContentPath> tmp = Sets.newHashSet(); tmp.addAll( this.set ); tmp.addAll( (Set) paths.stream().map( ( item -> item instanceof ContentPath ? item : ContentPath.from( item.toString() ) ) ).collect( Collectors.toSet() ) ); return new ContentPaths( ImmutableSet.copyOf( tmp ) ); }
private ContentPaths remove( final ImmutableSet paths ) { final HashSet<ContentPath> tmp = Sets.newHashSet(); tmp.addAll( this.set ); tmp.removeAll( (Set) paths.stream().map( ( item -> item instanceof ContentPath ? item : ContentPath.from( item.toString() ) ) ).collect( Collectors.toSet() ) ); return new ContentPaths( ImmutableSet.copyOf( tmp ) ); }
@Override protected Object doExecute() { if ( this.key == null || this.key.isEmpty() ) { throw new IllegalArgumentException( "Parameter 'key' is required" ); } if ( this.key.startsWith( "/" ) ) { return getByPath( ContentPath.from( this.key ) ); } else { return getById( ContentId.from( this.key ) ); } }
private static ContentPath translateNodePathToContentPath( final NodePath nodePath ) { final String contentPath = StringUtils.substringAfter( nodePath.asAbsolute().toString(), CONTENT_ROOT_NODE_NAME + "/" ); return ContentPath.from( contentPath ).asAbsolute(); } }
@Override protected Object doExecute() { if ( isBlank( this.name ) && isNotBlank( this.displayName ) && isNotBlank( this.parentPath ) ) { this.name = generateUniqueContentName( ContentPath.from( this.parentPath ), this.displayName ); } if ( isBlank( this.displayName ) && isNotBlank( this.name ) ) { this.displayName = this.name; } final CreateContentParams params = createParams(); final Content result = this.contentService.create( params ); return new ContentMapper( result ); }
@Override protected Object doExecute() { if ( this.key.startsWith( "/" ) ) { return getByPath( ContentPath.from( this.key ) ); } else { return getById( ContentId.from( this.key ) ); } }
private String generateUniqueContentName( final ContentPath parent, final String displayName ) { final String baseName = NamePrettyfier.create( displayName ); String name = baseName; while ( this.contentService.contentExists( ContentPath.from( parent, name ) ) ) { final String randomId = this.idGenerator.get(); name = NamePrettyfier.create( baseName + "-" + randomId ); } return name; }
public ByteSource getStream() { if ( this.key.startsWith( "/" ) ) { return getByPath( ContentPath.from( this.key ) ); } else { return getById( ContentId.from( this.key ) ); } }
@Override protected Object doExecute() { if ( this.key.startsWith( "/" ) ) { return deleteByPath( ContentPath.from( this.key ) ); } else { return deleteById( ContentId.from( this.key ) ); } }
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 ) || this.contentService.contentExists( contentPath ); }
public void execute() { UpdateContentParams updateContent = new UpdateContentParams(); if ( !this.key.startsWith( "/" ) ) { updateContent.contentId( ContentId.from( this.key ) ); } else { final Content contentByPath = this.contentService.getByPath( ContentPath.from( key ) ); updateContent.contentId( contentByPath.getId() ); } BinaryReferences binaryRefs = BinaryReferences.from( Arrays.stream( this.names ).map( BinaryReference::from ).collect( toList() ) ); updateContent.removeAttachments( binaryRefs ); contentService.update( updateContent ); }
protected final Content getContentOrNull( final String contentSelector ) { final boolean inEditMode = ( this.request.getMode() == RenderMode.EDIT ); if ( inEditMode ) { 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 ); }
private CreateMediaParams createParams( final String name ) { final CreateMediaParams params = new CreateMediaParams(); params.name( name ); params.parent( this.parentPath != null ? ContentPath.from( this.parentPath ) : null ); params.mimeType( this.mimeType ); params.byteSource( this.data ); params.focalX( this.focalX ); params.focalY( this.focalY ); return params; }