001    package railo.commons.io.res.util;
002    
003    import java.io.IOException;
004    import java.io.OutputStream;
005    
006    public abstract class ReadOnlyResourceSupport extends ResourceSupport {
007    
008            /**
009             * @see railo.commons.io.res.Resource#createDirectory(boolean)
010             */
011            public void createDirectory(boolean createParentWhenNotExists) throws IOException {
012                    throw new IOException("this is a read-only resource, can't create directory ["+this+"]");
013            }
014    
015            /**
016             * @see railo.commons.io.res.Resource#createFile(boolean)
017             */
018            public void createFile(boolean createParentWhenNotExists) throws IOException {
019                    throw new IOException("this is a read-only resource, can't create file ["+this+"]");
020            }
021    
022            /**
023             * @see railo.commons.io.res.Resource#isWriteable()
024             */
025            public boolean isWriteable() {
026                    return false;
027            }
028    
029            /**
030             * @see railo.commons.io.res.Resource#remove(boolean)
031             */
032            public void remove(boolean force) throws IOException {
033                    throw new IOException("this is a read-only resource, can't remove ["+this+"]");
034    
035            }
036    
037            /**
038             * @see railo.commons.io.res.Resource#setLastModified(long)
039             */
040            public boolean setLastModified(long time) {
041                    return false;
042            }
043    
044            /**
045             * @see railo.commons.io.res.Resource#setMode(int)
046             */
047            public void setMode(int mode) throws IOException {
048                    throw new IOException("this is a read-only resource, can't change mode of ["+this+"]");
049            }
050    
051            /**
052             *
053             * @see railo.commons.io.res.Resource#setReadable(boolean)
054             */
055            public boolean setReadable(boolean value) {
056                    //throw new IOException("this is a read-only resource, can't change access of ["+this+"]");
057                    return false;
058            }
059    
060            /**
061             *
062             * @see railo.commons.io.res.Resource#setWritable(boolean)
063             */
064            public boolean setWritable(boolean value) {
065                    //throw new IOException("this is a read-only resource, can't change access of ["+this+"]");
066                    return false;
067            }
068    
069            public OutputStream getOutputStream(boolean append) throws IOException {
070                    throw new IOException("this is a read-only resource, can't write to it ["+this+"]");
071            }
072    
073            /**
074             * @see railo.commons.io.res.Resource#getMode()
075             */
076            public int getMode() {
077                    return 0444;
078            }
079    }