Package: DelegateZipFileSystemsDiscoverer
DelegateZipFileSystemsDiscoverer
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DelegateZipFileSystemsDiscoverer() |
|
|
|
|
|
||||||||||||||||||||
getFileSystemProviders() |
|
|
|
|
|
||||||||||||||||||||
getFileSystemsFolder() |
|
|
|
|
|
||||||||||||||||||||
getLocalFileSystemProvider() |
|
|
|
|
|
||||||||||||||||||||
setFileSystemsFolder(String) |
|
|
|
|
|
||||||||||||||||||||
setLocalFileSystemProvider(ResourceFileSystemProvider) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.filesystem.basic.layered;
28:
29: import javax.annotation.Nonnull;
30: import java.util.ArrayList;
31: import java.util.List;
32: import java.io.IOException;
33: import it.tidalwave.northernwind.core.model.ResourceFileSystemProvider;
34: import it.tidalwave.northernwind.frontend.filesystem.basic.FileSystemProvidersProvider;
35: import it.tidalwave.northernwind.frontend.filesystem.basic.ZipFileSystemProvider;
36: import lombok.Getter;
37: import lombok.Setter;
38: import lombok.extern.slf4j.Slf4j;
39:
40: /***********************************************************************************************************************
41: *
42: * @author Fabrizio Giudici
43: *
44: **********************************************************************************************************************/
45: @Slf4j
46: public class DelegateZipFileSystemsDiscoverer implements FileSystemProvidersProvider
47: {
48: @Getter @Setter
49: private String fileSystemsFolder = "filesystems";
50:
51: @Getter @Setter
52: private ResourceFileSystemProvider localFileSystemProvider;
53:
54: @Override @Nonnull
55: public List<? extends ResourceFileSystemProvider> getFileSystemProviders()
56: {
57: final List<ResourceFileSystemProvider> fileSystemProviders = new ArrayList<>();
58:
59: try
60: {
61: final var zipFolder = localFileSystemProvider.getFileSystem().findFileByPath(fileSystemsFolder);
62:
63:• if (zipFolder != null)
64: {
65:• for (final var fo : zipFolder.findChildren().results())
66: {
67: // if (fo.hasExt("zip") || fo.hasExt("jar"))
68: final var name = fo.getName();
69:• if (name.endsWith(".zip") || name.endsWith(".jar"))
70: {
71: final var zipFileSystemProvider = new ZipFileSystemProvider();
72: zipFileSystemProvider.setZipFilePath(fo.toFile().getAbsolutePath());
73: fileSystemProviders.add(zipFileSystemProvider);
74: }
75: }
76: }
77: }
78: catch (IOException e)
79: {
80: log.error("", e);
81: }
82:
83: fileSystemProviders.add(localFileSystemProvider);
84: log.info("delegate filesystems: {}", fileSystemProviders);
85:
86: return fileSystemProviders;
87: }
88: }