]> git.argeo.org Git - lgpl/argeo-commons.git/blob - FsContentProviderService.java
4e986f6f29b1628e757c0825b0901bf29f2e5ae9
[lgpl/argeo-commons.git] / FsContentProviderService.java
1 package org.argeo.cms.acr.fs;
2
3 import java.io.IOException;
4 import java.nio.file.Files;
5 import java.util.Map;
6 import java.util.Objects;
7
8 import org.argeo.api.cms.CmsConstants;
9 import org.argeo.api.cms.CmsState;
10
11 public class FsContentProviderService extends FsContentProvider {
12 private CmsState cmsState;
13
14 public void start(Map<String, String> properties) {
15 mountPath = properties.get(CmsConstants.ACR_MOUNT_PATH);
16 Objects.requireNonNull(mountPath);
17 if (!mountPath.startsWith("/"))
18 throw new IllegalArgumentException("Mount path must start with /");
19
20 String relPath = mountPath.substring(1);
21 rootPath = cmsState.getDataPath(relPath);
22 try {
23 Files.createDirectories(rootPath);
24 } catch (IOException e) {
25 throw new IllegalStateException(
26 "Cannot initialize FS content provider " + mountPath + " with base" + rootPath, e);
27 }
28
29 initNamespaces();
30 }
31
32 public void stop() {
33 }
34
35 public void setCmsState(CmsState cmsState) {
36 this.cmsState = cmsState;
37 }
38
39 }