public BUILDER path( final ContentPath path ) { this.parentPath = path.getParentPath() != null ? path.getParentPath().asAbsolute() : null; Preconditions.checkArgument( path.elementCount() > 0, "No content can be \"root content\": " + path.toString() ); this.name = ContentName.from( path.getElement( path.elementCount() - 1 ) ); return (BUILDER) this; }
@Override public ContentPath apply( final String value ) { return ContentPath.from( value ); } }
@Override public boolean equals( final Object o ) { if ( this == o ) { return true; } if ( !( o instanceof DeleteContentParams ) ) { return false; } final DeleteContentParams that = (DeleteContentParams) o; if ( !contentPath.equals( that.contentPath ) ) { return false; } return true; }
public boolean isChildOf( final ContentPath possibleParentPath ) { if ( elementCount() <= possibleParentPath.elementCount() ) { return false; } for ( int i = 0; i < possibleParentPath.elementCount(); i++ ) { if ( !elements.get( i ).equalsIgnoreCase( possibleParentPath.getElement( i ) ) ) { return false; } } return true; }
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 ); }
sourcePath = ContentPath.from( this.source ); final Content sourceContent = contentService.getByPath( sourcePath ); sourceId = sourceContent.getId(); return move( sourceId, ContentPath.from( target ).asAbsolute() ); final ContentPath targetPath = ContentPath.from( target ); final ContentPath targetParent = targetPath.getParentPath(); if ( targetParent.equals( sourcePath.getParentPath() ) ) return rename( sourceId, targetPath.getName() ); return rename( sourceId, targetPath.getName() );
private static ContentPath translateNodePathToContentPath( final NodePath nodePath ) { final String contentPath = StringUtils.substringAfter( nodePath.asAbsolute().toString(), CONTENT_ROOT_NODE_NAME + "/" ); return ContentPath.from( contentPath ).asAbsolute(); } }
public ContentAlreadyExistsException( final ContentPath path ) { super( MessageFormat.format( "Content at path [{0}] already exists", path.toString() ) ); this.path = path; }
public static ContentPath from( final ContentPath parent, final ContentPath relative ) { final Builder builder = create().elements( parent.elements ); builder.addElements( relative.elements ); builder.absolute( parent.isAbsolute() ); return builder.build(); }
public ContentPath getAncestorPath( final Integer deep ) { if ( this.elements.size() < 1 ) { return null; } final LinkedList<String> parentElements = newListOfParentElements( deep ); return parentElements != null ? create().absolute( absolute ).elements( parentElements ).build() : null; }
public boolean isRoot() { return this.path.elementCount() == 1; }
public ContentPath build() { return new ContentPath( this ); } }
public ContentPath getParentPath() { return getAncestorPath(1); }
public static ContentPath from( final String path ) { final Iterable<String> pathElements = Splitter.on( ELEMENT_DIVIDER ).omitEmptyStrings().split( path ); boolean absolute = path.startsWith( ELEMENT_DIVIDER ); return create().elements( pathElements ).absolute( absolute ).build(); }
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 ContentNotFoundException( final ContentPath path, final Branch branch ) { super( MessageFormat.format( "Content with path [{0}] was not found in branch [{1}]", path.toString(), branch ) ); this.path = path; }
public static ContentPath from( final ContentPath parent, final String name ) { return create().elements( parent.elements ).absolute( parent.isAbsolute() ).addElement( name ).build(); }
public PortalRequest( final WebRequest webRequest ) { super(webRequest); this.baseUri = ""; this.contentPath = ContentPath.from( "/" ); this.mode = RenderMode.LIVE; this.branch = DEFAULT_BRANCH; }
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 static String resolveSitePath( final String pathExpression, final Site site ) { return site != null ? pathExpression.replace( SITE_WILDCARD, site.getPath().toString() ) : pathExpression; }