Studio Developer Manual / Version 2207
Table Of ContentsTo convert an existing LinkList property (Doctype property: LinkListProperty) to a new Annotated LinkList property (Doctype property: XmlProperty), functionality for migration is provided and can to be adapted to migrate custom properties.
The migration is performed on demand, that is, when the Annotated LinkList is edited. This migration approach does not migrate data as a preparation step, but is performed ongoing during write requests in normal operation mode.
Data migration from a legacy linkList property linkList to a struct linkList property
structList is performed as follows:
- The new XMLProperty needs to be added in the doctype definition. Then the doctype definition contains
the legacy and the new property.
<LinkListProperty Name="linkList" Max="1" LinkType="CMLinkable"/> <XmlProperty Name="structList" Grammar="coremedia-struct-2008" extensions:translatable="true"/>
- Configure a Spring bean for CoreMedia Studio of type
LegacyToAnnotatedLinkListAdapterwith appropriate properties.@Bean LegacyToAnnotatedLinkListAdapter customAnnotatedLinkListAdapter(ContentRepository contentRepository, CapConnection connection) { ContentType cmTeaser = contentRepository.getContentType("CMTeaser"); LegacyToAnnotatedLinkListAdapter customAdapter = new LegacyToAnnotatedLinkListAdapter(); customAdapter.setType(cmTeaser); customAdapter.setProperty("structList"); customAdapter.setLegacyProperty("linkList"); customAdapter.setPriority(0); customAdapter.setInterceptingSubtypes(true); customAdapter.setConnection(connection); return customAdapter; } -
If custom properties need to be adapted, extend the
LegacyToAnnotatedLinkListAdapterand configure this bean instead.public class CustomAnnotatedLinkListAdapter extends LegacyToAnnotatedLinkListAdapter { @Override protected void populateTargetStruct(Content target, int index, StructBuilder builder, CapObject capObject) { super.populateTargetStruct(target, index, builder, capObject); //custom code } @Override protected void cleanupLegacyData(ContentWriteRequest request) { super.cleanupLegacyData(request); //custom code } } -
Override
LegacyToAnnotatedLinkListAdapter#populateTargetStructto apply custom data to the struct list. For example, retrieve a setting from localSettings and apply it to the struct:@Override protected void populateTargetStruct(Content target, int index, StructBuilder builder, CapObject capObject) { super.populateTargetStruct(target, index, builder, capObject); Struct localSettings = capObject.getStruct("localSettings"); if (!isEmpty(localSettings)) { Boolean setting = getBoolean_(localSettings, CUSTOM_SETTING); builder.declareBoolean(ANNOTATED_LINK_STRUCT_CUSTOM_PROPERTY_NAME, setting) } } -
If required, legacy data can be cleaned up by overriding
LegacyToAnnotatedLinkListAdapter#cleanupLegacyData. For example, remove a setting from localSettings, that is stored in the struct now:@Override protected void cleanupLegacyData(ContentWriteRequest request) { super.cleanupLegacyData(request); Content entity = request.getEntity(); Map<String, Object> properties = request.getProperties(); Struct localSettings = entity.getStruct("localSettings"); if (localSettings != null && localSettings.get(CUSTOM_SETTING) != null) { StructBuilder structBuilder = localSettings.builder(); structBuilder.remove(CUSTOM_SETTING); properties.put("localSettings", structBuilder.build()); } } -
Then, automatic migration of the legacy property
linkListwill be done automatically on demand, that is on write access. As soon asstructListis written (via the Studio Server), the formerlinkListand configurable properties are stored in the new struct propertystructList. -
As long as the
structListproperty has not been written yet, read access onstructList(via the Studio Server) will return thelinkListas a Struct linkList. -
After migration, read access on
structListwill return the struct linkList directly. If the legacy
linkListproperty is a weak link, then thestructListproperty will lose this feature.-
Note: The legacy property
linkListis still supported but it cannot be used alongside the new propertystructList. - Note: The linklist property and the struct linklist property are different properties, the source linklist property cannot be reused with this mechanism.


