@Override public ContentId apply( final Content value ) { return value.getId(); } }
@Override public ContentPath apply( final Content value ) { return value.getPath(); } }
public EditableContent( final Content source ) { this.source = source; this.displayName = source.getDisplayName(); this.data = source.getData().copy(); this.extraDatas = source.getAllExtraData().copy(); this.page = source.hasPage() ? source.getPage().copy() : null; this.valid = source.isValid(); this.thumbnail = source.getThumbnail(); this.inheritPermissions = source.inheritsPermissions(); this.permissions = source.getPermissions(); this.owner = source.getOwner(); this.language = source.getLanguage(); this.creator = source.getCreator(); this.createdTime = source.getCreatedTime(); this.publishInfo = source.getPublishInfo(); }
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() ); }
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() ); }
if ( ID_PROPERTY.equals( this.id ) ) return valueMatches( val, content.getId().toString() ); return valueMatches( val, content.getName().toString() ); return valueMatches( val, content.getPath().toString() ); return valueMatches( val, content.getType().toString() ); return valueMatches( val, content.getDisplayName() ); return valueMatches( val, content.hasChildren() ); return valueMatches( val, content.getLanguage() == null ? "" : content.getLanguage().toLanguageTag() ); return valueMatches( val, content.isValid() ); final Property prop = content.getData().getProperty( dataPath ); if ( prop == null || prop.getValue() == null ) final String mixinName = substringBefore( dataPath, "." ); dataPath = substringAfter( dataPath, "." ); final PropertyTree xData = getXData( content.getAllExtraData(), appPrefix, mixinName ); if ( xData == null )
private static String resolveActualPath( final Content content, final String path ) { if ( "*".equals( path ) || "/".equals( path ) || "/*".equals( path ) ) { return "/*"; // any path } else if ( "./".equals( path ) || "./*".equals( path ) ) { return content.getPath() + "/*"; // all children of current item } else if ( "../".equals( path ) || "../*".equals( path ) ) { return content.getParentPath().isRoot() ? content.getParentPath() + "*" : content.getParentPath() + "/*"; // siblings and children of current item } else if ( path.startsWith( "../" ) ) { return makeEndWithStar( makeStartWithSlash( getPathStartedSomeLevelsHigher( content, path ) ) ); // path starting x levels higher } else if ( path.startsWith( "./" ) ) { return makeEndWithStar( makeStartWithSlash( getChildPath( content, path ) ) ); // child path for current item } else { return makeEndWithStar( makeStartWithSlash( path ) ); } }
protected final Site getSiteOrNull( final Content content ) { return content != null ? this.contentService.getNearestSite( content.getId() ) : null; }
public ContentPath getContentPath() { return ( this.content != null ) ? this.content.getPath() : this.contentPath; }
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 static String getChildPath( final Content content, final String path ) { return content.getPath() + path.substring( 1 ); }
private SiteMapper getByPath( final ContentPath contentPath ) { try { final Content content = this.contentService.getByPath( contentPath ); return getById( content.getId() ); } catch ( final ContentNotFoundException e ) { } return null; }
protected final Site getSite( final Content content ) { final Site site = getSiteOrNull( content ); if ( site != null ) { return site; } throw notFound( "Site for content [%s] not found", content.getPath() ); }
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 deleteById( final ContentId id ) { try { final Content content = this.contentService.getById( id ); return deleteByPath( content.getPath() ); } catch ( final ContentNotFoundException e ) { return false; } }
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 static String getPathStartedSomeLevelsHigher( final Content content, final String path ) { int levels = getNumberOfLevelsToAscend( path ); ContentPath contentPath = content.getPath(); for ( int level = 1; level <= levels; level++ ) { contentPath = contentPath.getParentPath(); if ( contentPath.isRoot() ) { return path.substring( levels * 3 ); } } return contentPath.toString() + "/" + path.substring( levels * 3 ); }
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 ); }
if ( content != null ) contentIds.add( content.getId() );