001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.commons.io.res.util;
020
021import java.io.IOException;
022import java.io.OutputStream;
023
024public abstract class ReadOnlyResourceSupport extends ResourceSupport {
025
026        @Override
027        public void createDirectory(boolean createParentWhenNotExists) throws IOException {
028                throw new IOException("this is a read-only resource, can't create directory ["+this+"]");
029        }
030
031        @Override
032        public void createFile(boolean createParentWhenNotExists) throws IOException {
033                throw new IOException("this is a read-only resource, can't create file ["+this+"]");
034        }
035
036        @Override
037        public boolean isWriteable() {
038                return false;
039        }
040
041        @Override
042        public void remove(boolean force) throws IOException {
043                throw new IOException("this is a read-only resource, can't remove ["+this+"]");
044
045        }
046
047        @Override
048        public boolean setLastModified(long time) {
049                return false;
050        }
051
052        @Override
053        public void setMode(int mode) throws IOException {
054                throw new IOException("this is a read-only resource, can't change mode of ["+this+"]");
055        }
056
057        @Override
058        public boolean setReadable(boolean value) {
059                //throw new IOException("this is a read-only resource, can't change access of ["+this+"]");
060                return false;
061        }
062
063        @Override
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        @Override
074        public int getMode() {
075                return 0444;
076        }
077}