Skip to content

Commit

Permalink
feat(pp) if ct site does not exist, move ct to the system_host
Browse files Browse the repository at this point in the history
ref: #29255
  • Loading branch information
wezell committed Jul 24, 2024
1 parent 6aef49c commit 4db9fb9
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,21 @@ private ContentType saveOrUpdateContentType(final ContentTypeWrapper contentType
final List<Field> fields,
final List<FieldVariable> fieldVariables,
final ContentType localContentType) throws DotDataException, DotSecurityException {
final Host trySite = this.siteAPI.find(contentTypeIn.host(), APILocator.getUserAPI().getSystemUser(), false);

final String hostId = UtilMethods.isSet(()-> trySite.getIdentifier()) ? trySite.getIdentifier() : Host.SYSTEM_HOST;
final String hostId = UtilMethods.isSet(()-> localContentType.inode())
? localContentType.host()
: Try.of(()->this.siteAPI.find(contentTypeIn.host(), APILocator.systemUser(), false).getIdentifier())
.toJavaOptional()
.orElse(Host.SYSTEM_HOST);


// update host so that it works locally
final ContentType typeToSave = hostId.equals(contentTypeIn.host())
? contentTypeIn
: ContentTypeBuilder.builder(contentTypeIn).from(contentTypeIn).host(hostId).build();


final List<Field> deferredFields = fields.stream()
final List<Field> deferredFields = fields.stream()
.map(field -> {
if (field instanceof RelationshipField) {
return RelationshipFieldBuilder.builder(field).skipRelationshipCreation(true).build();
Expand All @@ -309,15 +317,6 @@ private ContentType saveOrUpdateContentType(final ContentTypeWrapper contentType
}).collect(Collectors.toList());


// update host so that it works locally
final ContentType typeToSave = hostId.equals(contentTypeIn.host())
? contentTypeIn
: UtilMethods.isSet(()->localContentType.inode())
? ContentTypeBuilder.builder(contentTypeIn).from(contentTypeIn).host(localContentType.host()).build()
: ContentTypeBuilder.builder(contentTypeIn).from(contentTypeIn).host(hostId).build();



typeToSave.constructWithFields(deferredFields);

if(UtilMethods.isEmpty(()->localContentType.inode())) {
Expand Down Expand Up @@ -366,6 +365,7 @@ private ContentType saveOrUpdateContentType(final ContentTypeWrapper contentType
return returnType;
}


private void setWorkflowScheme(final ContentTypeWrapper contentTypeWrapper,
final ContentType contentType,
final ContentType localContentType) throws DotDataException, DotSecurityException {
Expand Down

0 comments on commit 4db9fb9

Please sign in to comment.