@Override public ContentId apply( final String value ) { return ContentId.from( value ); } }
private static ContentId convertToContentId( final Object value ) { if ( value instanceof ContentId ) { return (ContentId) value; } else if ( value instanceof String ) { return ContentId.from( (String) value ); } else { return null; } }
@Override public ContentId convert( final Object value ) { if ( value instanceof ContentId ) { return (ContentId) value; } return ContentId.from( value.toString() ); } }
@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 ) ); } }
public static PageTemplateKey from( final String value ) { return from( ContentId.from( CharacterChecker.check( value, "Not a valid value for PageTemplateKey [" + value + "]" ) ) ); }
@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 ) ); } }
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 == 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 ) ); } }
@Override protected Object doExecute() { 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 List<ContentId> resolveContentIds() { final List<ContentId> contentIds = new ArrayList<>(); for ( final String key : this.keys ) { if ( key.startsWith( "/" ) ) { final ContentPath path = ContentPath.from( key ); final Content content = getByPath( path ); if ( content != null ) { contentIds.add( content.getId() ); } } else { contentIds.add( ContentId.from( key ) ); } } return contentIds; }
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 ); }
private ContentId getContentId() { try { if ( this.key.startsWith( "/" ) ) { final Content content = this.contentService.getByPath( ContentPath.from( this.key ) ); if ( content != null ) { return content.getId(); } } else { return ContentId.from( this.key ); } } catch ( final ContentNotFoundException e ) { LOG.warn( "Content not found: " + this.key ); } return null; }
private Content getExistingContent( final String key ) { try { if ( !key.startsWith( "/" ) ) { return this.contentService.getById( ContentId.from( key ) ); } else { return this.contentService.getByPath( ContentPath.from( key ) ); } } catch ( final ContentNotFoundException e ) { return null; } }
private Content getContent() { try { if ( this.key.startsWith( "/" ) ) { return this.contentService.getByPath( ContentPath.from( key ) ); } else { return this.contentService.getById( ContentId.from( key ) ); } } catch ( final ContentNotFoundException e ) { // Do nothing } return null; } }
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 ); }
@Override protected Object doExecute() { final int start = valueOrDefault( this.start, 0 ); final int count = valueOrDefault( this.count, DEFAULT_COUNT ); final String sortExpr = valueOrDefault( this.sort, "" ); final FindContentByParentParams.Builder findContentByParent = FindContentByParentParams.create(); if ( key.startsWith( "/" ) ) { findContentByParent.parentPath( ContentPath.from( key ) ); } else { findContentByParent.parentId( ContentId.from( key ) ); } return getChildren( findContentByParent, start, count, sortExpr ); }
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() ); } final CreateAttachment createAttachment = CreateAttachment.create(). name( this.name ). label( this.label ). mimeType( this.mimeType ). byteSource( getData() ). build(); updateContent.createAttachments( CreateAttachments.from( createAttachment ) ); contentService.update( updateContent ); }
sourceId = ContentId.from( this.source ); final Content sourceContent = contentService.getById( sourceId ); sourcePath = sourceContent.getPath();