001    /*
002     * 
003     * $Revision: 15202 $ $Date: 2009-05-15 17:00:44 +0200 (Fri, 15 May 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.frontend.servlets;
025    
026    import java.util.List;
027    
028    import org.mycore.common.MCRConfiguration;
029    import org.mycore.datamodel.common.MCRActiveLinkException;
030    import org.mycore.datamodel.metadata.MCRObjectID;
031    import org.mycore.frontend.workflow.MCRSimpleWorkflowManager;
032    import org.mycore.user.MCRUserMgr;
033    
034    /**
035     * This class is the superclass of servlets which checks the MCREditorServlet
036     * output XML for metadata object and derivate objects.
037     * 
038     * @author Jens Kupferschmidt
039     * @version $Revision: 15202 $ $Date: 2009-05-15 17:00:44 +0200 (Fri, 15 May 2009) $
040     */
041    abstract public class MCRCheckBase extends MCRServlet {
042    
043        private static final long serialVersionUID = 1L;
044    
045        // The file separator
046        String NL = System.getProperty("file.separator");
047    
048        // The Workflow Manager
049        protected static MCRSimpleWorkflowManager WFM = MCRSimpleWorkflowManager.instance();
050    
051        // The User Manager
052        protected static MCRUserMgr UM = MCRUserMgr.instance();
053    
054        // pagedir
055        protected static String pagedir = MCRConfiguration.instance().getString("MCR.SWF.PageDir", "");
056    
057        protected List<String> errorlog;
058    
059        protected static String usererrorpage = pagedir + MCRConfiguration.instance().getString("MCR.SWF.PageErrorUser", "editor_error_user.xml");
060    
061        /**
062         * The method return an URL with the next working step. If okay flag is
063         * true, the object will present else it shows the error page.
064         * 
065         * @param ID
066         *            the MCRObjectID of the MCRObject
067         * @param okay
068         *            the return value of the store operation
069         * @return the next URL as String
070         */
071        abstract protected String getNextURL(MCRObjectID ID, boolean okay) throws MCRActiveLinkException;
072    
073        /**
074         * The method send a message to the mail address for the MCRObjectType.
075         * 
076         * @param ID
077         *            the MCRObjectID of the MCRObject
078         */
079        abstract protected void sendMail(MCRObjectID ID);
080    
081        /**
082         * A method to handle IO errors.
083         * 
084         * @param job
085         *            the MCRServletJob
086         */
087        protected void errorHandlerIO(MCRServletJob job) throws Exception {
088            String pagedir = MCRConfiguration.instance().getString("MCR.SWF.PageDir", "");
089            String page = MCRConfiguration.instance().getString("MCR.SWF.PageErrorStore", "");
090            job.getResponse().sendRedirect(job.getResponse().encodeRedirectURL(getBaseURL() + pagedir + page));
091        }
092    
093        /**
094         * check the access permission
095         * @param ID the mycore ID
096         * @return true if the access is set
097         */
098        protected boolean checkAccess(MCRObjectID ID) {
099            return false;
100        }
101    
102    }