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 @Override 009 public void createDirectory(boolean createParentWhenNotExists) throws IOException { 010 throw new IOException("this is a read-only resource, can't create directory ["+this+"]"); 011 } 012 013 @Override 014 public void createFile(boolean createParentWhenNotExists) throws IOException { 015 throw new IOException("this is a read-only resource, can't create file ["+this+"]"); 016 } 017 018 @Override 019 public boolean isWriteable() { 020 return false; 021 } 022 023 @Override 024 public void remove(boolean force) throws IOException { 025 throw new IOException("this is a read-only resource, can't remove ["+this+"]"); 026 027 } 028 029 @Override 030 public boolean setLastModified(long time) { 031 return false; 032 } 033 034 @Override 035 public void setMode(int mode) throws IOException { 036 throw new IOException("this is a read-only resource, can't change mode of ["+this+"]"); 037 } 038 039 @Override 040 public boolean setReadable(boolean value) { 041 //throw new IOException("this is a read-only resource, can't change access of ["+this+"]"); 042 return false; 043 } 044 045 @Override 046 public boolean setWritable(boolean value) { 047 //throw new IOException("this is a read-only resource, can't change access of ["+this+"]"); 048 return false; 049 } 050 051 public OutputStream getOutputStream(boolean append) throws IOException { 052 throw new IOException("this is a read-only resource, can't write to it ["+this+"]"); 053 } 054 055 @Override 056 public int getMode() { 057 return 0444; 058 } 059 }