IncludeText with network paths permission

Hi,

We are experiencing an issue with our web application running on Tomcat, where a mail merge process is unable to access include texts located on a network share.

The template used for the mail merge is also located on the network share and is taken using a set of credentials from a setting in the application, which differs from the credentials used by the Tomcat server.

This results in the mail merge process failing to access the include texts, as we assume that the mail merge process is using the tomcat user.

We cannot predict which file paths will be available on a template.
We only know that the credentials from the setting has an access over these include texts.

We verified that this is likely the case as we tried to specify an include text in a local directory on the tomcat server.

Allowing the tomcat user to have access on the network share is not an option for us.

We are using aspose words for java 22.5.0

We would like to explore possible solutions, including configuring the mail merge process to use the same credentials as the ones used for the network share.

@n.reyes I think Document.ResourceLoadingCallback would be a right place for specifying permissions for external files used upon updating fields. However, at the moment this callback is not used upon updating fields.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25362

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

However, there is another callback, which you can use to specify a custom value upon updating fields. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertField("INCLUDETEXT \"C:\\\\Temp\\\\test.txt\"");

doc.getFieldOptions().setFieldUpdatingCallback(new FieldUpdatingCallback());

doc.updateFields();

doc.save("C:\\Temp\\out.docx");
private static class FieldUpdatingCallback implements IFieldUpdatingCallback
{
    
    @Override
    public void fieldUpdating(Field field) {
        // Do nothing here
    }
    
    @Override
    public void fieldUpdated(Field field) {
    
        if(field.getType() == FieldType.FIELD_INCLUDE_TEXT)
        {
            FieldIncludeText includeText = (FieldIncludeText)field;
            // Here you can access to the source file name.
            System.out.println(includeText.getSourceFullName());
        
            // Read text from the source...
            // .....
        
            // Specify the field value.
            try {
                includeText.setResult("This is some value read from the source");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
            
    }
}

The issues you have found earlier (filed as WORDSNET-25362) have been fixed in this Aspose.Words for Java 23.6 update.