Hi, Alex
Thank you for your suggestions, but I have not solved problem.
As I wrote above, I am using integrated Oxygen Web Component for our web application - when Oxygen Auhtor Component need resolve conref or other links we send http request for special HttpServlet and return InputStream in Oxygen.
In your examples you used file(contextMap.ditamap) from local filesystem and you create URL for this as
Code: Select all
URLUtil.correct(new File("D:\\Desktop\\support\\alexmprog\\contextMap.ditamap"))
.
But I have not this file in local filesystem - I load this file from ContentRepository with special HttpServlet: I generate URL as
Code: Select all
StringBuilder request = new StringBuilder(urlServerBaseHref);
request.append('/').append("repository_root?");
request.append("sourceDocPath").append("=null");
request.append('&').append("destDocPath").append('=');
request.append(URLEncoder.encode(path, "UTF-8"));
So my URL look like as
.
Then I create create DITAMapTreeComponentProvider
Code: Select all
if (ditaMapTreeComponentProvider == null) {
try {
ditaMapTreeComponentProvider = AuthorComponentFactory.getInstance().createDITAMapTreeComponentProvider();
} catch (AuthorComponentException e) {
e.printStackTrace();
}
}
Then I try load my contexMap
Code: Select all
StringBuilder request = new StringBuilder(urlServerBaseHref);
request.append('/').append("repository_root?");
request.append("sourceDocPath").append("=null");
request.append('&').append("destDocPath").append('=');
request.append(URLEncoder.encode(path, "UTF-8"));
String urlText = request.toString();
URL url = new URL(urlText);
ditaMapTreeComponentProvider.load(url, null);
but nothing changes - map not download. I think, that Oxygen wrong resolve URL like this
So I decide load map before call ditaMapTreeComponentProvider.load() - I used this code
Code: Select all
protected InputStream loadBufferingContent(final URL url) {
final Future<InputStream> future = BACKGROUND_EXECUTOR.submit(new Callable<InputStream>() {
@Override
public InputStream call() throws Exception {
final URLConnection connection = url.openConnection();
connection.setUseCaches(false);
final InputStream source = connection.getInputStream();
try {
final ByteArrayOutputStream temp = new ByteArrayOutputStream();
final byte[] buffer = new byte[512];
for (int lenght = source.read(buffer); lenght != -1; lenght = source.read(buffer)) {
temp.write(buffer, 0, lenght);
}
if (temp.size() < 1) {
return null;
}
return new ByteArrayInputStream(temp.toByteArray());
} finally {
source.close();
}
}
});
try {
return future.get();
} catch (final InterruptedException e) {
e.printStackTrace();
} catch (final ExecutionException e) {
e.printStackTrace();
}
return null;
}
and then
Code: Select all
URL url = new URL(urlText);
InputStream loadBufferingContent = loadBufferingContent(url);
ditaMapTreeComponentProvider.load(url, new InputStreamReader(loadBufferingContent));
and map load correctly - all keywords resolved.
I have DITAReferenceResolver class(implements AuthorReferenceResolver) for resolving conrefs. I this class I make some changes for resolving links as this
<keydef keys="reuseTopic" href="reuseTopic.dita" format="dita"/>
- I used the same method for load contextMap( loadBufferingContent ) - but then nothing changes if I insert content like this
<p conkeyref="reuseTopic/keyP"/>
.
How I can solved this problem?
I try to used your first suggestion -
Code: Select all
AuthorComponentFactory.getInstance().setDITAKeyDefinitionManager(new KeyDefinitionManager() {
@Override
public List<KeyDefinitionInfo> getContextKeyDefinitions() {
List<KeyDefinitionInfo> kds = new ArrayList<KeyDefinitionInfo>();
}
}
I create KeyDefinitionInfo objects with NAME and DEFINITION_LOCATION properties but when Oxygen try to load object thrown exception - NullPointerException in URLUtil.getEditorLocationKey()
I set in DEFINITION_LOCATION property URL like this
.
How I can solved URL problems?
Best regards, Alex