Package: LocalFileSystemProvider
LocalFileSystemProvider
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LocalFileSystemProvider() |
|
|
|
|
|
||||||||||||||||||||
getFileSystem() |
|
|
|
|
|
||||||||||||||||||||
getRootPath() |
|
|
|
|
|
||||||||||||||||||||
setRootPath(String) |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
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;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.Nullable;
31: import java.beans.PropertyVetoException;
32: import java.io.File;
33: import java.io.FileNotFoundException;
34: import java.io.IOException;
35: import org.openide.filesystems.LocalFileSystem;
36: import it.tidalwave.northernwind.core.model.ResourceFileSystem;
37: import it.tidalwave.northernwind.core.model.ResourceFileSystemProvider;
38: import it.tidalwave.northernwind.frontend.filesystem.impl.ResourceFileSystemNetBeansPlatform;
39: import lombok.Getter;
40: import lombok.Setter;
41: import lombok.ToString;
42:
43: /***********************************************************************************************************************
44: *
45: * A provider for a {@link ResourceFileSystemProvider} implemented on Netbeans' {@code LocalFileSystem}.
46: *
47: * @author Fabrizio Giudici
48: *
49: **********************************************************************************************************************/
50: @ToString(of = "rootPath")
51: public class LocalFileSystemProvider implements ResourceFileSystemProvider
52: {
53: @Getter @Setter @Nonnull
54: private String rootPath = "";
55:
56: @Nullable
57: private ResourceFileSystem fileSystem;
58:
59: @Nullable
60: private LocalFileSystem fileSystemDelegate;
61:
62: /*******************************************************************************************************************
63: *
64: * {@inheritDoc}
65: *
66: ******************************************************************************************************************/
67: @Override @Nonnull
68: public synchronized ResourceFileSystem getFileSystem()
69: throws IOException
70: {
71:• if (fileSystem == null)
72: {
73: try
74: {
75: fileSystemDelegate = new LocalFileSystem();
76: fileSystemDelegate.setRootDirectory(new File(rootPath));
77:
78: final var rootFolder = fileSystemDelegate.getRoot();
79:
80:• if (rootFolder == null)
81: {
82: throw new FileNotFoundException(rootPath);
83: }
84:
85: fileSystem = new ResourceFileSystemNetBeansPlatform(fileSystemDelegate);
86: }
87: catch (PropertyVetoException e)
88: {
89: throw new FileNotFoundException(e.toString());
90: }
91: }
92:
93: return fileSystem;
94: }
95: }