001    /*
002     * 
003     * $Revision: 15621 $ $Date: 2009-07-25 08:32:01 +0200 (Sat, 25 Jul 2009) $
004     *
005     * This file is part of ***  M y C o R e  ***
006     * See http://www.mycore.de/ for details.
007     *
008     * This program is free software; you can use it, redistribute it
009     * and / or modify it under the terms of the GNU General Public License
010     * (GPL) as published by the Free Software Foundation; either version 2
011     * of the License or (at your option) any later version.
012     *
013     * This program is distributed in the hope that it will be useful, but
014     * WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program, in a file called gpl.txt or license.txt.
020     * If not, write to the Free Software Foundation Inc.,
021     * 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
022     */
023    
024    package org.mycore.datamodel.common;
025    
026    import java.io.InputStream;
027    import java.util.Date;
028    import java.util.List;
029    
030    import org.mycore.common.MCRPersistenceException;
031    
032    /**
033     * This interface is designed to choose the Persistence for the XML tables.
034     * 
035     * @author Jens Kupferschmidt
036     * @version $Revision: 15621 $ $Date: 2009-07-25 08:32:01 +0200 (Sat, 25 Jul 2009) $
037     */
038    public interface MCRXMLTableInterface {
039        /**
040         * The initializer for the class MCRSQLXMLStore. It reads the configuration
041         * and checks the table names and create the table if they does'n exist..
042         * 
043         * @param type
044         *            the type String of the MCRObjectID
045         * @exception MCRPersistenceException
046         *                throws if the type is not correct
047         */
048        public void init(String type) throws MCRPersistenceException;
049    
050        /**
051         * The method create a new item in the datastore.
052         * 
053         * @param mcrid
054         *            a MCRObjectID
055         * @param xml
056         *            a byte array with the XML file
057         * @exception MCRPersistenceException
058         *                if the method arguments are not correct
059         */
060        public void create(String mcrid, byte[] xml, Date lastModified) throws MCRPersistenceException;
061    
062        /**
063         * The method remove a item for the MCRObjectID from the datastore.
064         * 
065         * @param mcrid
066         *            a MCRObjectID
067         * @exception MCRPersistenceException
068         *                if the method argument is not correct
069         */
070        public void delete(String mcrid) throws MCRPersistenceException;
071    
072        /**
073         * The method update an item in the datastore.
074         * 
075         * @param mcrid
076         *            a MCRObjectID
077         * @param xml
078         *            a byte array with the XML file
079         * @exception MCRPersistenceException
080         *                if the method arguments are not correct
081         */
082        public void update(String mcrid, byte[] xml, Date lastModified) throws MCRPersistenceException;
083    
084        /**
085         * The method retrieve a dataset for the given MCRObjectID and returns the
086         * corresponding XML file as InputStream.
087         * 
088         * @param mcrid
089         *            a MCRObjectID
090         * @exception MCRPersistenceException
091         *                if the method arguments are not correct
092         */
093        public InputStream retrieve(String mcrid) throws MCRPersistenceException;
094    
095        /**
096         * This method returns the highest stored ID number, 
097         * or 0 if no object is stored for this type and project.
098         * 
099         * @exception MCRPersistenceException
100         *                if a persistence problem is occured
101         * 
102         * @return the highest stored ID number as a String
103         */
104        public abstract int getHighestStoredID() throws MCRPersistenceException;
105    
106        /**
107         * This method check that the MCRObjectID exist in this store.
108         * 
109         * @param mcrid
110         *            a MCRObjectID
111         * @return true if the MCRObjectID exist, else return false
112         */
113        public boolean exists(String mcrid);
114    
115        /**
116         * The method return a Array list with all stored MCRObjectID's of the XML
117         * table.
118         * 
119         * @return a ArrayList of MCRObjectID's
120         */
121        public List<String> retrieveAllIDs();
122        
123        /**
124         * lists objects of the specified <code>type</code> and their last modified date. 
125         * @param type type of object
126         * @return
127         */
128        public List<MCRObjectIDDate> listObjectDates(String type);
129    }