STEventDistributor.java :  » Content-Management-System » webman » de » webman » sitetree » Java Open Source

Java Open Source » Content Management System » webman 
webman » de » webman » sitetree » STEventDistributor.java
package de.webman.sitetree;

import java.util.*;
import java.sql.*;
import java.io.*;
import com.teamkonzept.web.*;
import com.teamkonzept.lib.*;
import com.teamkonzept.field.*;
import com.teamkonzept.field.db.*;
import com.teamkonzept.db.*;
import com.teamkonzept.webman.mainint.*;
import com.teamkonzept.webman.mainint.events.*;
import com.teamkonzept.webman.*;
import com.teamkonzept.webman.db.*;
import com.teamkonzept.webman.mainint.db.*;
import com.teamkonzept.webman.mainint.db.queries.*;
import de.webman.sitetree.eventhandler.*;
import de.webman.generator.*;

/**
 * The distributor for all site tree related events.
 *
 * @author $Author: uli $
 * @version $Revision: 1.41
 */
public class STEventDistributor
  extends CachedEventDistributor
  implements ParameterTypes,
         DatabaseDefaults,
         FrameConstants
{

  /**
   * Constructs a new event distributor.
   */
  public STEventDistributor ()
  {
    addEventHandler(STArrangeMoveHandler.getInstance());
    addEventHandler(STArrangeOpenDirHandler.getInstance());
    addEventHandler(STArrangeShowHandler.getInstance());
    addEventHandler(STArrangeStartHandler.getInstance());
    addEventHandler(STCancelContentSelectionHandler.getInstance());
    addEventHandler(STChangeDocumentHandler.getInstance());
    addEventHandler(STDeleteDocumentHandler.getInstance());
    addEventHandler(STDeleteStructureDocHandler.getInstance());
    addEventHandler(STDuplicateDocumentHandler.getInstance());
    addEventHandler(STEditDocumentHandler.getInstance());
    addEventHandler(STEditHandler.getInstance());
    addEventHandler(STEditNodeHandler.getInstance());
    addEventHandler(STEditPresRefFreeComponentHandler.getInstance());
    addEventHandler(STEditPresentationComponentHandler.getInstance());
    addEventHandler(STEditStructureDocHandler.getInstance());
    addEventHandler(STExtModifyHandler.getInstance());
    addEventHandler(STForwardHandler.getInstance());
    addEventHandler(STFrameHandler.getInstance());
    addEventHandler(STInfoHandler.getInstance());
    addEventHandler(STModifyHandler.getInstance());
    addEventHandler(STNewDocumentHandler.getInstance());
    addEventHandler(STNewNodeHandler.getInstance());
    addEventHandler(STNewStructureDocHandler.getInstance());
    addEventHandler(STNodeDeleteHandler.getInstance());
    addEventHandler(STNodeListMultHandler.getInstance());
    addEventHandler(STOpenMultDirHandler.getInstance());
    addEventHandler(STOverwriteDocumentHandler.getInstance());
    addEventHandler(STRefineSelectionHandler.getInstance());
    addEventHandler(STSaveComponentHandler.getInstance());
    addEventHandler(STSaveNewNodeHandler.getInstance());
    addEventHandler(STSaveRefDocHandler.getInstance());
    addEventHandler(STSaveStructureDocHandler.getInstance());
    addEventHandler(STSelectRefDocHandler.getInstance());
    addEventHandler(STSetContentSelectionHandler.getInstance());
    addEventHandler(STUpdateComponentHandler.getInstance());
    addEventHandler(STUpdateDocumentHandler.getInstance());
    addEventHandler(STUpdateNodeHandler.getInstance());
    addEventHandler(STUpdateRefDocHandler.getInstance());
  }

  /**
   * Handles the specified event.
   *
   * @param event the event to be handled.
   * @throws TKException if any error occurred during event handling.
   */
    public void handleEvent (TKEvent event)
      throws TKException
    {
      try
      {
        super.handleEvent(event);
      }
      catch (TKException tke)
      {
        // hier die Exception Klasse abfragen !!!
        if (tke.getErrorCode() == INVALID_EVENT)
        {
          try
          {
          WebManEvent.checkEvent(event.getRemoteUser(), event.getName(), ContextConstants.SITE_TREE);
            String name = event.getName();

          if (name.equalsIgnoreCase("ST_PREV_INDEX"))
          {
              Preview preview = new Preview(event);
            preview.doPreviewIndexPerSiteNode();
            return;
          }

          if (name.equalsIgnoreCase("ST_EMPTY"))
          {
            event.doEmptyPage();
            return;
          }

          throw tke;
            }
            catch (FileNotFoundException fnfe)
        {
                  throw new TKUserException("Template not Found",
                                            UserCodes.TEMPLATE_NOT_FOUND,
                                            ErrorCodes.USER_SEVERITY,
                                            false,
                                            new Object[]{fnfe.getMessage()},
                                            fnfe);
        }
        catch (TKTemplateSyntaxException tktse)
        {
          throw new TKUserException("Template Syntax Error",
                                    UserCodes.WRONG_TEMPLATE_SYNTAX,
                                    ErrorCodes.USER_SEVERITY,
                                    false,
                                    new Object[]{tktse.getMessage()},
                                    tktse);
        }
            catch (Throwable t)
            {
              throw WebmanExceptionHandler.getException(t);
            }
          }
          else
          {
            throw tke;
          }
        }
  }

  /**
   * Checks wether this handler is capable to handle the specified event.
   *
   * @param event the event to be handled.
   * @return <CODE>true</CODE> if this handler is capable to handle the
   * specified event, otherwise <CODE>false</CODE>.
   */
    public boolean isHandler (TKEvent event)
    {
        return event.getName().startsWith("ST");
    }

/*
    private void startPreview(TKEvent event)
    {
    TKHttpInterface httpInf = event.getHttpInterface();
    PrintWriter out = new PrintWriter(httpInf.getOutputStream());
      PrintWriter log = new PrintWriter(httpInf.getLogStream());

      //out.print("<HTML><HEAD></HEAD><BODY>");

      ProcessStarter ps = new ProcessStarter(out, log);
      boolean successful = false;
      try {
          String args = getArgumentString(event);
          successful = ps.start("WebManPreview", args,
              ProcessStarter.getWMClasspath(httpInf.getDocumentRoot()));
      }
      catch (Exception e) {
          out.print(e);
          log.println(e);
      }
    }

    private String getArgumentString(TKEvent event)
    {
        TKParams params = event.getParams();
        Enumeration en = params.elements();

        while (en.hasMoreElements()) {
            Object obj = en.nextElement();
            String snode = event.getParameter(PARAMETER, "SNODE");
            String docName = event.getParameter(PARAMETER, "DOCNAME");
            String index = event.getParameter(PARAMETER, "INDEX");
            String trace = event.getParameter(PARAMETER, "TRACE");
            String checker = event.getParameter(PARAMETER, "CHECKER");
            int ii=0;
        }
        return "";
    }
*/

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.