Skip to content

Does not work config property "Use the main wiki configuration" #78

@quest4sanity

Description

@quest4sanity

Describe the bug
Does not work configeration option "Use the main wiki configuration" when we use subwiki (selected in Wiki index)

Steps to reproduce
Steps to reproduce the problematic behavior:

  1. Go to "Wiki index" and select subwiki (not main)
  2. Configure OnlyOffice extention with option "Use the main wiki configuration"
  3. Go to page with attached document in subwiki
  4. Go to attachments tab
  5. Click "Edit" on attached document
  6. See error

Expected behavior
We shoud have ability toi edit selected document.

Actual behavior
OnlyOffice server shows error.

Environment (please complete the following information):

  • OS: Windows, Linux
  • Browser: chrome
  • XWiki version: 16.10.10
  • App version: 2.4.2

Additional context
Found bug in com.xwiki.onlyofficeconnector.internal.DefaultOnlyOfficeManager#getSecret()
Always used secret key from current wiki.

Somehing like code bellow needed:

private static final String ONLYOFFICE_SPACE = "XWikiOnlyOfficeCode";
private static final String ONLYOFFICE_DOCUMENT = "ConfigurationClass";

private String getSecret()
{
    XWikiContext context = contextProvider.get();

    try {
        // Current wiki
        DocumentReference configReference = new DocumentReference(context.getWikiId(),
                ONLYOFFICE_SPACE, ONLYOFFICE_DOCUMENT);
        DocumentReference configClassReference = configReference;
        XWikiDocument document = context.getWiki().getDocument(configReference, context);
        BaseObject baseObject = document.getXObject(configClassReference);
        
        String global = baseObject.getStringValue("useGlobalConfig");
        if (!"0".equals(global)) {
            // Global wiki
            configReference = new DocumentReference(context.getMainXWiki(), 
                    ONLYOFFICE_SPACE, ONLYOFFICE_DOCUMENT);
            configClassReference = configReference;
            document = context.getWiki().getDocument(configReference, context);
            baseObject = document.getXObject(configClassReference);
        }
        String secret = baseObject.getStringValue("serverSecret");
        return secret;
        
    } catch (XWikiException e) {
        logger.warn("Failed to retrieve the secret for generating/verifying a JWT.");
        return "";
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions