Skip to content

Commit

Permalink
Rollback Page object resolving: inject empty regions to the page obje…
Browse files Browse the repository at this point in the history
…ct when returning content #10209
  • Loading branch information
ashklianko committed Jul 3, 2023
1 parent 05f8e0d commit 60c4d4c
Show file tree
Hide file tree
Showing 44 changed files with 846 additions and 979 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class ContentNodeTranslator

private final ContentDataSerializer contentDataSerializer;

public ContentNodeTranslator( final NodeService nodeService )
public ContentNodeTranslator( final NodeService nodeService, final ContentDataSerializer contentDataSerializer )
{
this.nodeService = nodeService;
this.contentDataSerializer = new ContentDataSerializer();
this.contentDataSerializer = contentDataSerializer;
}

public Contents fromNodes( final Nodes nodes, final boolean resolveHasChildren )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class ContentOutboundDependenciesIdsResolver

private final ContentDataSerializer contentDataSerializer;

ContentOutboundDependenciesIdsResolver( final ContentService contentService )
ContentOutboundDependenciesIdsResolver( final ContentService contentService, final ContentDataSerializer contentDataSerializer )
{
this.contentService = contentService;
this.contentDataSerializer = new ContentDataSerializer();
this.contentDataSerializer = contentDataSerializer;
}

public ContentIds resolve( final ContentId contentId )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import com.enonic.xp.content.processor.ContentProcessor;
import com.enonic.xp.context.ContextAccessor;
import com.enonic.xp.context.ContextBuilder;
import com.enonic.xp.core.impl.content.serializer.ContentDataSerializer;
import com.enonic.xp.data.PropertyTree;
import com.enonic.xp.event.EventPublisher;
import com.enonic.xp.form.FormDefaultValuesProcessor;
Expand Down Expand Up @@ -171,6 +172,8 @@ public class ContentServiceImpl

private final LayoutDescriptorService layoutDescriptorService;

private final ContentDataSerializer contentDataSerializer;

private ContentAuditLogSupport contentAuditLogSupport;

private volatile ContentConfig config;
Expand All @@ -184,7 +187,14 @@ public ContentServiceImpl( @Reference final NodeService nodeService, @Reference
this.pageDescriptorService = pageDescriptorService;
this.partDescriptorService = partDescriptorService;
this.layoutDescriptorService = layoutDescriptorService;
this.translator = new ContentNodeTranslator( nodeService );

this.contentDataSerializer = ContentDataSerializer.create().
layoutDescriptorService( layoutDescriptorService ).
pageDescriptorService( pageDescriptorService ).
partDescriptorService( partDescriptorService ).
build();

this.translator = new ContentNodeTranslator( nodeService, contentDataSerializer );
}

@Activate
Expand Down Expand Up @@ -226,6 +236,7 @@ public Site create( final CreateSiteParams params )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( config.attachments_allowUnsafeNames() ).
params( createContentParams ).
build().
Expand Down Expand Up @@ -265,6 +276,7 @@ public Content create( final CreateContentParams params )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( config.attachments_allowUnsafeNames() ).
params( params ).
build().
Expand Down Expand Up @@ -311,6 +323,7 @@ public Content create( final CreateMediaParams params )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( config.attachments_allowUnsafeNames() ).
build().
execute();
Expand All @@ -337,6 +350,7 @@ public Content update( final UpdateContentParams params )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( config.attachments_allowUnsafeNames() ).
build().
execute();
Expand Down Expand Up @@ -364,6 +378,7 @@ public Content update( final UpdateMediaParams params )
xDataService( this.xDataService ).
contentProcessors( this.contentProcessors ).
contentValidators( this.contentValidators ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( config.attachments_allowUnsafeNames() ).
build().
execute();
Expand Down Expand Up @@ -776,6 +791,7 @@ public Content rename( final RenameContentParams params )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
build().
execute();

Expand Down Expand Up @@ -1069,7 +1085,7 @@ public ContentDependencies getDependencies( final ContentId id )
@Override
public ContentIds getOutboundDependencies( final ContentId id )
{
return new ContentOutboundDependenciesIdsResolver( this ).resolve( id );
return new ContentOutboundDependenciesIdsResolver( this, contentDataSerializer ).resolve( id );
}

@Override
Expand Down Expand Up @@ -1169,6 +1185,7 @@ public Content reprocess( final ContentId contentId )
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
siteService( this.siteService ).
xDataService( this.xDataService ).
contentProcessors( this.contentProcessors ).
Expand Down Expand Up @@ -1227,6 +1244,7 @@ public ImportContentResult importContent( final ImportContentParams params )
params( params ).
nodeService( nodeService ).
contentTypeService( contentTypeService ).
contentDataSerializer( contentDataSerializer ).
eventPublisher( eventPublisher ).
translator( translator ).
build().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.enonic.xp.content.processor.ProcessCreateParams;
import com.enonic.xp.content.processor.ProcessCreateResult;
import com.enonic.xp.context.ContextAccessor;
import com.enonic.xp.core.impl.content.serializer.ContentDataSerializer;
import com.enonic.xp.core.impl.content.validate.InputValidator;
import com.enonic.xp.data.Property;
import com.enonic.xp.form.FormDefaultValuesProcessor;
Expand Down Expand Up @@ -62,6 +63,8 @@ final class CreateContentCommand

private final LayoutDescriptorService layoutDescriptorService;

private final ContentDataSerializer contentDataSerializer;

private CreateContentCommand( final Builder builder )
{
super( builder );
Expand All @@ -71,6 +74,7 @@ private CreateContentCommand( final Builder builder )
this.pageDescriptorService = builder.pageDescriptorService;
this.partDescriptorService = builder.partDescriptorService;
this.layoutDescriptorService = builder.layoutDescriptorService;
this.contentDataSerializer = builder.contentDataSerializer;
}

static Builder create()
Expand Down Expand Up @@ -108,6 +112,7 @@ private Content doExecute()
.xDataService( this.xDataService )
.partDescriptorService( this.partDescriptorService )
.layoutDescriptorService( this.layoutDescriptorService )
.contentDataSerializer( this.contentDataSerializer )
.siteService( this.siteService )
.build()
.produce().refresh( params.isRefresh() ? RefreshMode.ALL : RefreshMode.STORAGE ).build();
Expand Down Expand Up @@ -328,6 +333,8 @@ static class Builder

private LayoutDescriptorService layoutDescriptorService;

private ContentDataSerializer contentDataSerializer;

private Builder()
{
}
Expand Down Expand Up @@ -373,6 +380,12 @@ Builder layoutDescriptorService( final LayoutDescriptorService value )
return this;
}

Builder contentDataSerializer( final ContentDataSerializer value )
{
this.contentDataSerializer = value;
return this;
}

@Override
void validate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.enonic.xp.content.Content;
import com.enonic.xp.content.CreateContentParams;
import com.enonic.xp.content.CreateMediaParams;
import com.enonic.xp.core.impl.content.serializer.ContentDataSerializer;
import com.enonic.xp.data.PropertyTree;
import com.enonic.xp.form.FormDefaultValuesProcessor;
import com.enonic.xp.media.MediaInfo;
Expand All @@ -34,6 +35,8 @@ final class CreateMediaCommand

private final LayoutDescriptorService layoutDescriptorService;

private final ContentDataSerializer contentDataSerializer;

private CreateMediaCommand( final Builder builder )
{
super( builder );
Expand All @@ -43,6 +46,7 @@ private CreateMediaCommand( final Builder builder )
this.pageDescriptorService = builder.pageDescriptorService;
this.partDescriptorService = builder.partDescriptorService;
this.layoutDescriptorService = builder.layoutDescriptorService;
this.contentDataSerializer = builder.contentDataSerializer;
}

Content execute()
Expand Down Expand Up @@ -110,6 +114,7 @@ private Content doExecute()
pageDescriptorService( this.pageDescriptorService ).
partDescriptorService( this.partDescriptorService ).
layoutDescriptorService( this.layoutDescriptorService ).
contentDataSerializer( this.contentDataSerializer ).
allowUnsafeAttachmentNames( this.allowUnsafeAttachmentNames ).
build();

Expand Down Expand Up @@ -146,6 +151,8 @@ public static class Builder

private LayoutDescriptorService layoutDescriptorService;

private ContentDataSerializer contentDataSerializer;

public Builder params( final CreateMediaParams params )
{
this.params = params;
Expand Down Expand Up @@ -182,6 +189,13 @@ Builder layoutDescriptorService( final LayoutDescriptorService value )
return this;
}

Builder contentDataSerializer( final ContentDataSerializer value )
{
this.contentDataSerializer = value;
return this;
}


@Override
void validate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class CreateNodeParamsFactory

private final SiteService siteService;

private final ContentDataSerializer contentDataSerializer;

public CreateNodeParamsFactory( final Builder builder )
{
this.params = builder.params;
Expand All @@ -54,11 +56,11 @@ public CreateNodeParamsFactory( final Builder builder )
this.pageDescriptorService = builder.pageDescriptorService;
this.partDescriptorService = builder.partDescriptorService;
this.layoutDescriptorService = builder.layoutDescriptorService;
this.contentDataSerializer = builder.contentDataSerializer;
}

public CreateNodeParams.Builder produce()
{
final ContentDataSerializer contentDataSerializer = new ContentDataSerializer();
final PropertyTree contentAsData = contentDataSerializer.toCreateNodeData( params );

final PropertySet extraDataSet = contentAsData.getPropertySet( PropertyPath.from( ContentPropertyNames.EXTRA_DATA ) );
Expand Down Expand Up @@ -147,6 +149,8 @@ public static class Builder

private LayoutDescriptorService layoutDescriptorService;

private ContentDataSerializer contentDataSerializer;

private SiteService siteService;

Builder( final CreateContentTranslatorParams params )
Expand Down Expand Up @@ -190,13 +194,20 @@ Builder layoutDescriptorService( final LayoutDescriptorService value )
return this;
}

Builder contentDataSerializer( final ContentDataSerializer value )
{
this.contentDataSerializer = value;
return this;
}

void validate()
{
Preconditions.checkNotNull( params );
Preconditions.checkNotNull( contentTypeService );
Preconditions.checkNotNull( pageDescriptorService );
Preconditions.checkNotNull( siteService );
Preconditions.checkNotNull( xDataService );
Preconditions.checkNotNull( contentDataSerializer );
}

public CreateNodeParamsFactory build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.enonic.xp.content.ImportContentParams;
import com.enonic.xp.content.ImportContentResult;
import com.enonic.xp.core.impl.content.serializer.ContentDataSerializer;
import com.enonic.xp.node.ImportNodeParams;
import com.enonic.xp.node.ImportNodeResult;
import com.enonic.xp.node.Node;
Expand All @@ -14,10 +15,13 @@ final class ImportContentCommand
{
private final ImportContentParams params;

private final ContentDataSerializer contentDataSerializer;

private ImportContentCommand( final Builder builder )
{
super( builder );
this.params = builder.params;
this.contentDataSerializer = builder.contentDataSerializer;
}

static Builder create()
Expand All @@ -34,6 +38,7 @@ private ImportContentResult doExecute()
{
final Node importNode = ImportContentFactory.create().
params( params ).
contentDataSerializer( contentDataSerializer ).
build().execute();

final ImportNodeParams importNodeParams = ImportNodeParams.create().importNode( importNode )
Expand All @@ -55,6 +60,8 @@ static class Builder
{
private ImportContentParams params;

private ContentDataSerializer contentDataSerializer;

private Builder()
{
}
Expand All @@ -65,11 +72,18 @@ Builder params( final ImportContentParams params )
return this;
}

Builder contentDataSerializer( final ContentDataSerializer contentDataSerializer )
{
this.contentDataSerializer = contentDataSerializer;
return this;
}

@Override
void validate()
{
super.validate();
Preconditions.checkNotNull( params, "params must be given" );
Preconditions.checkNotNull( contentDataSerializer, "contentDataSerializer must be given" );
}

public ImportContentCommand build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ public class ImportContentFactory
{
private final ImportContentParams params;

private final ContentDataSerializer contentDataSerializer;

private ImportContentFactory( Builder builder )
{
this.params = builder.params;
this.contentDataSerializer = builder.contentDataSerializer;
}

public static Builder create()
Expand All @@ -32,7 +35,6 @@ public static Builder create()

public Node execute()
{
final ContentDataSerializer contentDataSerializer = new ContentDataSerializer();
final PropertyTree nodeData = contentDataSerializer.toNodeData( params.getContent() );

if ( params.getInherit() != null )
Expand Down Expand Up @@ -72,6 +74,8 @@ public static final class Builder
{
private ImportContentParams params;

private ContentDataSerializer contentDataSerializer;

private Builder()
{
}
Expand All @@ -82,6 +86,12 @@ public Builder params( final ImportContentParams params )
return this;
}

public Builder contentDataSerializer( final ContentDataSerializer contentDataSerializer )
{
this.contentDataSerializer = contentDataSerializer;
return this;
}

private void validate()
{
Preconditions.checkNotNull( this.params, "params cannot be null" );
Expand Down
Loading

0 comments on commit 60c4d4c

Please sign in to comment.