Skip to content

Commit

Permalink
logging docu
Browse files Browse the repository at this point in the history
Issue #122
  • Loading branch information
rsoika committed Jul 8, 2022
1 parent 5af80ca commit 3db909d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
11 changes: 5 additions & 6 deletions imixs-adapters-wopi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ In this example we are calling the JavaScript method to open the viewer componen
## JavaScript

The Imixs-WOPI Adapter provides a JavaScript library to open and control the Wopi Editor (Wopi Client).
The Integration of the Wopi Client into your application is done by a iframe. This necessary to isolate the editor form your surrounding application.
To display the editor in a iframe the script library *imixs-wopi.js* provides a method imixsWopi.openViewer. The method expects a DIV element in your existing web page and the access URL to place the iframe with the editor.

The Integration of the Wopi Client into your application is done by a iframe. This is necessary to isolate the editor form your surrounding application.
To display the editor in a iframe the script library *imixs-wopi.js* provides a method `imixsWopi.openViewer`. The method expects a DIV element in your existing web page to place the iframe with the editor and the access URL to load the document.


<script type="text/javascript" src="/js/imixs-core.js"></script>
Expand All @@ -143,7 +142,7 @@ To display the editor in a iframe the script library *imixs-wopi.js* provides a

....
...........
<!-- LibreOffice Editor -->
<!-- Office Editor -->
<div id="wopi_controlls">
<button onclick="imixsWopi.save(); return false;">Update</button><button onclick="imixsWopi.closeViewer(); return false;">Close</button>
<hr />
Expand All @@ -153,11 +152,11 @@ To display the editor in a iframe the script library *imixs-wopi.js* provides a

## UI Controls

The control of closing the editor or saving the content is in this concept part of your application. So in the example above the application shows two buttons to save the content and to close the editor.
The control of closing the editor or saving the content in this concept is part of your application. So in the example above the application shows two buttons to save the content and to close the editor.

## Updating the File Content by Callback method

When a file was saved by LibreOffice Online, the data is posted to the WOPI Host endpoint '/wopi/files/{name}/contents'. The file content is not directly stored. It is cached into the local wopi file cache on the Wopi Host. An application can provide a saveCallback method to be triggered after a file was updated.
When a file was saved by the Office interface, the data is posted to the WOPI Host endpoint '/wopi/files/{name}/contents'. The file content is not directly stored. It is cached into the local wopi file cache on the Wopi Host. An application can provide a saveCallback method to be triggered after a file was updated.

// define save callback when a file was updated....
imixsWopi.saveCallback = uiSaveCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public String getClientEndpointByMimeType(String mimeType) {
* @return
*/
private String resolvePublicEndpoint(String uri) {
String result = null;
String result = uri;
if (wopiPublicEndpoint != null && wopiPublicEndpoint.isPresent() && !wopiPublicEndpoint.get().isEmpty()) {

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public String getWopiAccessURL(String uniqueid, String file, String userid, Stri
logger.warning("...no wopi client endpoint found!");
return null;
}

// cut onlyoffice hints
if (baseURL.indexOf("&<rs=")>-1) {
baseURL=baseURL.substring(0,baseURL.indexOf("&<rs="));
}

// test file extension
String[] extensions = wopiFileExtensions.split(",");
Expand All @@ -185,11 +190,12 @@ public String getWopiAccessURL(String uniqueid, String file, String userid, Stri
}

String token = generateAccessToken(userid, username);
baseURL = baseURL + "WOPISrc=" + wopiHostEndpoint + uniqueid + "/files/" + file + "&access_token=" + token;
baseURL = baseURL + "WOPISrc=" + wopiHostEndpoint + uniqueid + "/files/" + file + "?access_token=" + token;
if (baseURL.startsWith("http://")) {
logger.fine("...WOPI Client is running without SSL - this is not recommended for production!");
}

logger.info("WOP Access URL=" + baseURL);
return baseURL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public Response getFileContents(@PathParam("uniqueid") String uniqueid, @PathPar
* <p>
* The method expects a $uniqueID and filename
* <p>
* <code> /wopi/xxxxxxx-0000-0000-0000-yyyy/files/{FILENAME}</code>
* <code> /wopi/xxxxxxx-0000-0000-0000-yyyy/files/{FILENAME}/contents</code>
* <p>
* The method returns a json file info object
* <p>
Expand All @@ -269,19 +269,18 @@ public Response getFileContents(@PathParam("uniqueid") String uniqueid, @PathPar
public Response postFileContents(@PathParam("uniqueid") String uniqueid, @PathParam("file") String file,
InputStream contentStream, @QueryParam("access_token") String accessToken, @Context UriInfo info) {

logger.info("...... POST postFileContents: " + uniqueid + "/" + file);
// analyze header X-LOOL-WOPI-Timestamp, X-LOOL-WOPI-IsAutosave, X-LOOL-WOPI-IsExitSave
// We do ignroe the X-LOOL-WOPI-IsExitSave event
String wopiHeader=servletRequest.getHeader("X-LOOL-WOPI-IsExitSave");
if (wopiHeader!=null && "true".equalsIgnoreCase(wopiHeader)) {
logger.fine("...ignroe X-LOOL-WOPI-IsExitSave = " + wopiHeader);
logger.info("...ignore X-LOOL-WOPI-IsExitSave = " + wopiHeader);
return Response.ok().build();
}

logger.info("...updating file content...");

// clean unexpected query params
accessToken = wopiAccessHandler.purgeAccessToken(accessToken);
logger.finest("...... POST postFileContents: " + uniqueid + "/" + file);


// validate access_token
JsonObject acessTokenPayload = wopiAccessHandler.validateAccessToken(accessToken);
Expand Down

0 comments on commit 3db909d

Please sign in to comment.