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.type.datasource.core;
020
021import java.io.IOException;
022import java.io.InputStream;
023import java.sql.SQLException;
024import java.util.List;
025
026import lucee.commons.io.res.type.datasource.Attr;
027import lucee.runtime.db.DatasourceConnection;
028
029public interface Core {
030
031        /**
032         * @return return true if this core support concatination of existing data with new data (getOutputStream(append:true))
033         */
034        public boolean concatSupported();
035        
036        /**
037         * return a single Attr, if Attr does not exist it returns null
038         * @param dc
039         * @param path
040         * @param name
041         * @param name2 
042         * @return
043         * @throws SQLException
044         */
045        public abstract Attr getAttr(DatasourceConnection dc, String prefix,
046                        int fullPathHash, String path, String name) throws SQLException;
047
048        /**
049         * return all child Attrs of a given path
050         * @param dc
051         * @param prefix
052         * @param path
053         * @return
054         * @throws SQLException
055         */
056        public abstract List getAttrs(DatasourceConnection dc, String prefix,
057                        int pathHash, String path) throws SQLException;
058
059        /**
060         * create a new entry (file or directory)
061         * @param dc
062         * @param prefix
063         * @param path
064         * @param name
065         * @param type
066         * @throws SQLException
067         */
068        public abstract void create(DatasourceConnection dc, String prefix,
069                        int fullPatHash, int pathHash, String path, String name, int type)
070                        throws SQLException;
071
072        /**
073         * deletes a entry (file or directory)
074         * @param dc
075         * @param prefix
076         * @param attr
077         * @return
078         * @throws SQLException
079         */
080        public abstract boolean delete(DatasourceConnection dc, String prefix,
081                        Attr attr) throws SQLException;
082
083        /**
084         * returns a inputStram to a entry data
085         * @param dc
086         * @param prefix
087         * @param attr
088         * @return
089         * @throws SQLException
090         * @throws IOException
091         */
092        public abstract InputStream getInputStream(DatasourceConnection dc,
093                        String prefix, Attr attr) throws SQLException, IOException;
094
095        public abstract void write(DatasourceConnection dc, String prefix,
096                        Attr attr, InputStream is, boolean append) throws SQLException;
097
098        public abstract void setLastModified(DatasourceConnection dc,
099                        String prefix, Attr attr, long time) throws SQLException;
100
101        public abstract void setMode(DatasourceConnection dc, String prefix,
102                        Attr attr, int mode) throws SQLException;
103
104        public abstract void setAttributes(DatasourceConnection dc, String prefix,
105                        Attr attr, int attributes) throws SQLException;
106
107}