alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*  $Id: compositionMode.java,v 1.13 2001/04/23 03:15:31 agarcia3 Exp $ 
    webEditor. The new way in content management
    Copyright (C) 2001  Alfredo Garcia

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*/

package webEditor.interfaces;

import java.io.*;
import java.lang.reflect.*;

import javax.servlet.*;
import javax.servlet.http.*;
import org.w3c.dom.*;

import webEditor.core.*;

/**
 * HomePage interface; This class manage all the composition operations
 * @author <a href="mailto:agarcia@mundofree.com">Alfredo Garcia
 */

public class compositionMode {

   /**
    * Initial configuration values 
    */
   private configuration initValues;

   /**
    * Presentation management
    */
   private presentation myEditor= null;

   /**
    * HomePage management
    */
   private page myDocument= null;

    /**
     * Class constructor
     * @param initParam		Initial values
     */
    public compositionMode (configuration initParam) { 
    	// We are going to use the values in the hash table when we
	// create another kind of core object
   	this.initValues = initParam;
    }
    
    /**
     * Interface for the presentation operations
     * @param request		HTTP request
     * @param out		Servlet Output
     * @return void
     */
    public void presentation (HttpServletRequest request, PrintWriter out) 
    throws ServletException, 
    	   IOException {

	this.myEditor = new presentation (this.initValues);
	this.myDocument = new page (this.initValues);

	String opCode = this.initValues.readValue ("HTTP Parameters", "code");

	if (opCode != null) {
try { 
	// We use reflection to invoque the proper method
	Method m = getClass().getMethod(opCode, new Class[0]); 
	m.invoke(this,new Object[0]); 
} 
catch (Exception e) { 
	out.println ("Code not supported");
} 
	}

	Document indexDoc = this.myDocument.homePageList ();

	String outputString = this.myEditor.showIndex (indexDoc,"edit");
	out.println (outputString);
    }

   /**
    * Delete the document from the homePage
    * @return void
    */
    public void delete ()
	throws ServletException, IOException 
    {
	String docID = this.initValues.readValue ("HTTP Parameters", "docID");
	if (docID != null) {
		this.myDocument.removeDoc (docID);	
	}
    }

   /**
    * Rises the given document
    * @return void
    */
    public void rise ()
	throws ServletException, IOException 
    {
	String docID = this.initValues.readValue ("HTTP Parameters", "docID");
	if (docID != null) {
		this.myDocument.riseDoc (docID);	
	}
    }

   /**
    * Lowers the given document
    * @return void
    */
    public void lower ()
	throws ServletException, IOException 
    {
	String docID = this.initValues.readValue ("HTTP Parameters", "docID");
	if (docID != null) {
		this.myDocument.lowerDoc (docID);	
	}
    }

   /**
    * Publish the given Home Page
    * @return void
    */
    public void publish ()
	throws ServletException, IOException 
    {
    	Document indexDoc = this.myDocument.homePageList ();

	String outputString = this.myEditor.showIndex (indexDoc,"presentation");
	if ( outputString != null ) {
		this.myDocument.saveHtmlFile (outputString);
	}
    }


}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.