Skip to content
Snippets Groups Projects
Commit 4b3e1ce0 authored by uhensler's avatar uhensler
Browse files

OO-3932: Refactoring: Move discovery client to WOPI service

parent 4ff2e4b7
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,6 @@ import org.olat.core.commons.services.doceditor.collabora.CollaboraService;
import org.olat.core.commons.services.doceditor.wopi.Access;
import org.olat.core.commons.services.doceditor.wopi.Action;
import org.olat.core.commons.services.doceditor.wopi.Discovery;
import org.olat.core.commons.services.doceditor.wopi.WopiDiscoveryClient;
import org.olat.core.commons.services.doceditor.wopi.WopiService;
import org.olat.core.commons.services.vfs.VFSMetadata;
import org.olat.core.commons.services.vfs.VFSRepositoryService;
......@@ -71,8 +70,6 @@ public class CollaboraServiceImpl implements CollaboraService, GenericEventListe
@Autowired
private WopiService wopiService;
@Autowired
private WopiDiscoveryClient discoveryClient;
@Autowired
private VFSRepositoryService vfsRepositoryService;
@Autowired
private VFSLockManager lockManager;
......@@ -155,14 +152,14 @@ public class CollaboraServiceImpl implements CollaboraService, GenericEventListe
public Discovery getDiscovery() {
if (discovery == null) {
String discoveryUrl = getDiscoveryUrl();
discovery = discoveryClient.getDiscovery(discoveryUrl);
discovery = wopiService.getDiscovery(discoveryUrl);
log.info("Recieved new WOPI discovery from " + discoveryUrl);
}
return discovery;
}
private String getDiscoveryUrl() {
return collaboraModule.getBaseUrl() + discoveryClient.getRegularDiscoveryPath();
return collaboraModule.getBaseUrl() + wopiService.getRegularDiscoveryPath();
}
@Override
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.commons.services.doceditor.wopi;
/**
*
* Initial date: 5 Mar 2019<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface WopiDiscoveryClient {
public String getRegularDiscoveryPath();
/**
* Download the discovery file from the WOPI client.
*
* @param discoveryUrl
* @return
*/
public Discovery getDiscovery(String discoveryUrl);
}
\ No newline at end of file
......@@ -33,6 +33,16 @@ import org.olat.core.util.vfs.VFSLeaf;
*
*/
public interface WopiService {
public String getRegularDiscoveryPath();
/**
* Download the discovery file from the WOPI client.
*
* @param discoveryUrl
* @return
*/
public Discovery getDiscovery(String discoveryUrl);
boolean fileExists(String fileId);
......
......@@ -27,7 +27,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.olat.core.commons.services.doceditor.wopi.Discovery;
import org.olat.core.commons.services.doceditor.wopi.WopiDiscoveryClient;
import org.olat.core.commons.services.doceditor.wopi.model.DiscoveryImpl;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
......@@ -40,9 +39,9 @@ import org.springframework.stereotype.Service;
*
*/
@Service
public class WopiDiscoveryClientImpl implements WopiDiscoveryClient {
class WopiDiscoveryClient {
private static final OLog log = Tracing.createLoggerFor(WopiDiscoveryClientImpl.class);
private static final OLog log = Tracing.createLoggerFor(WopiDiscoveryClient.class);
private static final int TIMEOUT_5000_MILLIS = 5000;
private static final RequestConfig REQUEST_CONFIG = RequestConfig.custom()
......@@ -51,13 +50,11 @@ public class WopiDiscoveryClientImpl implements WopiDiscoveryClient {
.setConnectionRequestTimeout(TIMEOUT_5000_MILLIS)
.build();
@Override
public String getRegularDiscoveryPath() {
String getRegularDiscoveryPath() {
return "hosting/discovery";
}
@Override
public Discovery getDiscovery(String discoveryUrl) {
Discovery getDiscovery(String discoveryUrl) {
HttpGet request = new HttpGet(discoveryUrl);
request.setConfig(REQUEST_CONFIG);
......
......@@ -27,8 +27,8 @@ import java.util.UUID;
import javax.annotation.PostConstruct;
import org.olat.core.commons.services.doceditor.DocEditorSecurityCallback;
import org.olat.core.commons.services.doceditor.DocEditor.Mode;
import org.olat.core.commons.services.doceditor.DocEditorSecurityCallback;
import org.olat.core.commons.services.doceditor.wopi.Access;
import org.olat.core.commons.services.doceditor.wopi.Action;
import org.olat.core.commons.services.doceditor.wopi.App;
......@@ -61,6 +61,8 @@ public class WopiServiceImpl implements WopiService {
private CacheWrapper<String, Access> accessCache;
@Autowired
private WopiDiscoveryClient dicoveryClient;
@Autowired
private CoordinatorManager coordinator;
@Autowired
......@@ -70,6 +72,16 @@ public class WopiServiceImpl implements WopiService {
public void init() {
accessCache = coordinator.getCoordinator().getCacher().getCache(WopiService.class.getSimpleName(), "access");
}
@Override
public String getRegularDiscoveryPath() {
return dicoveryClient.getRegularDiscoveryPath();
}
@Override
public Discovery getDiscovery(String discoveryUrl) {
return dicoveryClient.getDiscovery(discoveryUrl);
}
@Override
public boolean fileExists(String fileId) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment