1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.vfs.internal.attach

File AttachController.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

4
16
14
1
146
97
17
1.06
1.14
14
1.21

Classes

Class Line # Actions
AttachController 50 16 0% 17 14
0.588235358.8%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.vfs.internal.attach;
21   
22    import java.io.IOException;
23   
24    import org.xwiki.component.manager.ComponentManager;
25   
26    import net.java.truecommons.cio.Entry;
27    import net.java.truecommons.cio.Entry.Access;
28    import net.java.truecommons.cio.Entry.Type;
29    import net.java.truecommons.cio.InputSocket;
30    import net.java.truecommons.cio.OutputSocket;
31    import net.java.truecommons.shed.BitField;
32    import net.java.truevfs.kernel.spec.FsAbstractController;
33    import net.java.truevfs.kernel.spec.FsAccessOption;
34    import net.java.truevfs.kernel.spec.FsController;
35    import net.java.truevfs.kernel.spec.FsModel;
36    import net.java.truevfs.kernel.spec.FsNodeName;
37    import net.java.truevfs.kernel.spec.FsNodePath;
38    import net.java.truevfs.kernel.spec.FsReadOnlyFileSystemException;
39    import net.java.truevfs.kernel.spec.FsSyncOption;
40   
41    import static net.java.truecommons.cio.Entry.Access.READ;
42    import static net.java.truecommons.cio.Entry.Type.FILE;
43   
44    /**
45    * TrueVFS Controller for the Attach driver.
46    *
47    * @version $Id: 215f55ae05651d0702bc5793a9cde9c91ac7fc45 $
48    * @since 7.4M2
49    */
 
50    public class AttachController extends FsAbstractController
51    {
52    private static final BitField<Access> READ_ONLY = BitField.of(READ);
53   
54    private final AttachDriver driver;
55   
56    private ComponentManager componentManager;
57   
 
58  2 toggle AttachController(AttachDriver driver, FsModel model, ComponentManager componentManager)
59    {
60  2 super(model);
61  2 this.driver = driver;
62  2 this.componentManager = componentManager;
63    }
64   
 
65  4 toggle private AttachNode newEntry(FsNodeName name)
66    {
67  4 return new AttachNode(this, name);
68    }
69   
 
70  8 toggle final FsNodePath resolve(FsNodeName name)
71    {
72  8 return getMountPoint().resolve(name);
73    }
74   
 
75  0 toggle @Override
76    public FsController getParent()
77    {
78  0 return null;
79    }
80   
 
81  2 toggle @Override
82    public AttachNode node(BitField<FsAccessOption> options, FsNodeName name) throws IOException
83    {
84  2 AttachNode entry = newEntry(name);
85  2 return entry.isType(FILE) ? entry : null;
86    }
87   
 
88  2 toggle @Override
89    public void checkAccess(BitField<FsAccessOption> options, FsNodeName name, BitField<Access> types)
90    throws IOException
91    {
92    // We only support READ at the moment
93  2 if (!types.isEmpty() && !READ_ONLY.equals(types)) {
94  2 throw new FsReadOnlyFileSystemException(getMountPoint());
95    }
96    }
97   
 
98  0 toggle @Override
99    public void setReadOnly(BitField<FsAccessOption> options, FsNodeName name) throws IOException
100    {
101    // All the Nodes (attachments) are already readonly, no need to set anything!
102    }
103   
 
104  0 toggle @Override
105    public boolean setTime(BitField<FsAccessOption> options, FsNodeName name, BitField<Access> types, long value)
106    throws IOException
107    {
108  0 throw new FsReadOnlyFileSystemException(getMountPoint());
109    }
110   
 
111  2 toggle @Override
112    public InputSocket<?> input(BitField<FsAccessOption> options, FsNodeName name)
113    {
114  2 return newEntry(name).input(options);
115    }
116   
 
117  0 toggle @Override
118    public OutputSocket<?> output(BitField<FsAccessOption> options, FsNodeName name, Entry template)
119    {
120  0 return newEntry(name).output(options, template);
121    }
122   
 
123  0 toggle @Override
124    public void make(final BitField<FsAccessOption> options, final FsNodeName name, Type type, Entry template)
125    throws IOException
126    {
127  0 throw new FsReadOnlyFileSystemException(getMountPoint());
128    }
129   
 
130  0 toggle @Override
131    public void unlink(BitField<FsAccessOption> options, FsNodeName name) throws IOException
132    {
133  0 throw new FsReadOnlyFileSystemException(getMountPoint());
134    }
135   
 
136  0 toggle @Override
137    public void sync(BitField<FsSyncOption> options)
138    {
139    // Empty
140    }
141   
 
142  4 toggle ComponentManager getComponentManager()
143    {
144  4 return this.componentManager;
145    }
146    }