@Override public ContentId apply( final Content value ) { return value.getId(); } }
protected final Site getSiteOrNull( final Content content ) { return content != null ? this.contentService.getNearestSite( content.getId() ) : null; }
private PropertyTreeMapper getByPath( final ContentPath contentPath ) { try { final Content content = this.contentService.getByPath( contentPath ); return getById( content.getId() ); } catch ( final ContentNotFoundException e ) { return null; } }
private SiteMapper getByPath( final ContentPath contentPath ) { try { final Content content = this.contentService.getByPath( contentPath ); return getById( content.getId() ); } catch ( final ContentNotFoundException e ) { } return null; }
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 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; }
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 ); }
private ByteSource getAttachment( final Content content, final String attachmentName ) { final Attachment attachment = content.getAttachments().byName( attachmentName ); if ( attachment == null ) { return null; } return this.contentService.getBinary( content.getId(), attachment.getBinaryReference() ); }
if ( content != null ) contentIds.add( content.getId() );
@Override protected Object doExecute() { final Content existingContent = getExistingContent( this.key ); if ( existingContent == null ) { return null; } final UpdateContentParams params = new UpdateContentParams(); params.contentId( existingContent.getId() ); params.editor( newContentEditor( existingContent ) ); params.requireValid( this.requireValid ); final Content result = this.contentService.update( params ); return result != null ? new ContentMapper( result ) : null; }
if ( ID_PROPERTY.equals( this.id ) ) return valueMatches( val, content.getId().toString() );
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 = sourceContent.getId();
private static void serialize( final MapGenerator gen, final Content value ) { gen.value( "_id", value.getId() ); gen.value( "_name", value.getName() ); gen.value( "_path", value.getPath() ); gen.value( "creator", value.getCreator() ); gen.value( "modifier", value.getModifier() ); gen.value( "createdTime", value.getCreatedTime() ); gen.value( "modifiedTime", value.getModifiedTime() ); gen.value( "owner", value.getOwner() ); gen.value( "type", value.getType() ); gen.value( "displayName", value.getDisplayName() ); gen.value( "hasChildren", value.hasChildren() ); gen.value( "language", value.getLanguage() ); gen.value( "valid", value.isValid() ); if ( value.getChildOrder() != null ) { gen.value( "childOrder", value.getChildOrder().toString() ); } serializeData( gen, value.getData() ); serializeExtraData( gen, value.getAllExtraData() ); serializePage( gen, value.getPage() ); serializeAttachments( gen, value.getAttachments() ); serializePublishInfo( gen, value.getPublishInfo() ); }