Skip to content

Commit

Permalink
fixed nullpointer exception, documentation
Browse files Browse the repository at this point in the history
Issue #108
  • Loading branch information
rsoika committed May 21, 2021
1 parent 029b197 commit 1536b21
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
30 changes: 26 additions & 4 deletions imixs-adapters-wopi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,31 @@ The [frame-ancestors](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/

Find more details [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).




**3. Allow wopi storage in loolwsd.xml**

In the section storage/wop of the loolwsd.xml file you also need to add the host names for your worklfow applications.


....
<storage desc="Backend storage">
<filesystem allow="false" />
<wopi desc="Allow/deny wopi storage. Mutually exclusive with webdav." allow="true">
<host desc="Regex pattern of hostname to allow or deny." allow="true">workflow.foo.com</host>
....

Here you can use again regexepression.

**4. Using the WOPI_HOST_ENDPOINT in Kubernetes**

Running in Kubernetes you should not use internal host names from the internal Kubernetes Proxy Network. For the "WOPI\_HOST\_ENDPOINT" use the public Internet domain instead:

...
spec:
containers:
- name: imixs-documents
image: imixs/imixs-documents:latest
env:
...
- name: WOPI_HOST_ENDPOINT
value: "https://workflow.foo.com/api/wopi/"
...
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,20 @@ public List<FileData> getAllFileData(String accessToken) {
String prafix = accessToken.hashCode() + "";
logger.finest("......getAllFileData by prafix " + prafix);
try {

File dir = new File(searchPath.toString());
File[] foundFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith(prafix);
}
});

// if no files found then exit
if (foundFiles==null) {
return result;
}

// Process files
for (File file : foundFiles) {
// Process file
byte[] content = Files.readAllBytes(Paths.get(wopiFileCache + file.getName()));
String filename=file.getName();
// cut prefix
Expand Down Expand Up @@ -227,16 +231,17 @@ public void clearFileCache(String accessToken) {
String prafix = accessToken.hashCode() + "";
logger.finest("......clearFileCache by prafix " + prafix);
try {

File dir = new File(searchPath.toString());
File[] foundFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith(prafix);
}
});
// delete files...
for (File file : foundFiles) {
Files.delete(Paths.get(wopiFileCache + file.getName()));
if (foundFiles!=null) {
// delete files...
for (File file : foundFiles) {
Files.delete(Paths.get(wopiFileCache + file.getName()));
}
}
} catch (IOException e) {
logger.severe("..failed to delete file: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ 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 + "&NotWOPIButIframe=true";
if (baseURL.startsWith("http://")) {
logger.warning("...WOPI Client is running without SSL - this is not recommended for production!");
logger.fine("...WOPI Client is running without SSL - this is not recommended for production!");
}

return baseURL;
Expand Down

0 comments on commit 1536b21

Please sign in to comment.