Page 1 of 1

Error retrieving keys for insertion in contextualized topic

Posted: Tue Apr 04, 2023 4:32 pm
by Vince
Hello,

We define a custom view in oXygen Web Author. This custom view allow user to drag and drop reusable keyref phrase.
To do this, we try to load all keys available for insertion.

The context map is :

Code: Select all

<bookmap>
  <frontmatter>
        <keydef format="ditamap"
              href="VARIABLES.ditamap"
              keys="variables"
              processing-role="resource-only"/>
    </frontmatter>
    <chapter>
        <topicref href="EDITING_TOPIC.dita">
     </chapter>
</bookmap>
 
Why this error ?

Code: Select all

2023-04-04 15:12:47,317 WARN [ http-nio-8081-exec-5 ] ro.sync.ecss.dita.e - DITA keys will not be resolved for this request.
java.lang.IllegalStateException: null
	at ro.sync.ecss.dita.e.b(Unknown Source)
	at ro.sync.ecss.dita.DITAAccess.getKeysForInsertion(Unknown Source)
	...
Same operation with same topic and map in the oXygen desktop version is a successfull.

Thanks a lot
Vincent

Re: Error retrieving keys for insertion in contextualized topic

Posted: Wed Apr 05, 2023 10:29 am
by cristi_talau
Hello,

You are using the DITAAccess.getKeysForInsertion API. However, this API works correctly only in Oxygen XML Editor / Author and it returns the keys from the "Context" DITA Map (opened in the DITA Maps Manager side-view. In Web Author this API does not work correctly as it does not know for which map you want to get the keys.
If you want to get a list with all the keys in the DITA Map, you can use the following code:

Code: Select all

    
    AuthorEditorAccess editorAccess = authorAccess.getEditorAccess();
    ContextKeyManager keyManager = editorAccess.getEditingContext().getContextKeyManager();
    if (keyManager != null) {
      LinkedHashMap<String, KeyInfo> keys = keyManager.getKeys(editorAccess.getEditorLocation());
    }
Best,
Cristian

Re: Error retrieving keys for insertion in contextualized topic

Posted: Wed Apr 05, 2023 1:44 pm
by Vince
Hello,

Thanks for reply. Your suggestion works well.

As I took DITAAccess.getKeysForInsertion API call from the ro.sync.ecss.extensions.dita.DITAExternalObjectInsertionHandler#ro.sync.ecss.extensions.dita.DITAExternalObjectInsertionHandler#detectKeyInfo, it means your handler does not work in Web Author.

Do you plan to make it works ?

Regards,
Vincent

Re: Error retrieving keys for insertion in contextualized topic

Posted: Thu Apr 06, 2023 11:33 am
by cristi_talau
Hello,

DITAAccess.getKeysForInsertion cannot be made to work in Web Author unless we create a new override which has an extra parameter that is the ContextKeyManager.

Regarding, the handler DITAExternalObjectInsertionHandler we will start from a user-facing feature: support for drag&drop with keys from a side-view, and if we decide to use the DITAExternalObjectInsertionHandler, then we will make it compatible with Web Author. However this feature is not on our short-term roadmap.

Best,
Cristian