Skip to content

Package: DelegateZipFileSystemsDiscoverer

DelegateZipFileSystemsDiscoverer

nameinstructionbranchcomplexitylinemethod
DelegateZipFileSystemsDiscoverer()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getFileSystemProviders()
M: 68 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

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