CEContentInfoHandler.java :  » Content-Management-System » webman » de » webman » content » eventhandler » Java Open Source

Java Open Source » Content Management System » webman 
webman » de » webman » content » eventhandler » CEContentInfoHandler.java
package de.webman.content.eventhandler;

import com.teamkonzept.web.*;
import com.teamkonzept.webman.*;
import com.teamkonzept.webman.db.TKWebmanDBManager;
import com.teamkonzept.webman.mainint.*;
import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetParentInfo;
import de.webman.content.db.queries.*;
import com.teamkonzept.webman.mainint.events.*;
import com.teamkonzept.lib.*;
import com.teamkonzept.field.*;
import com.teamkonzept.field.db.*;
import com.teamkonzept.db.*;
import de.webman.content.workflow.*;
import java.sql.*;
import com.teamkonzept.international.LanguageManager;
import de.webman.util.legacy.Legacy;

/**
* Infos ber Content anzeigen
*
 * @author  $Author: uli $
 * @version $Revision: 1.11 $
*/
public class CEContentInfoHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
{
  private CEContentInfoHandler()
  {}

    /** Singleton Instance */
  private static CEContentInfoHandler instance = new CEContentInfoHandler();

  public static CEContentInfoHandler getInstance()
  {
    return instance;
  }

    public void handleEvent(TKEvent evt) throws TKException
  {
    try
    {
      CEUtils.checkEvent(evt);
      Integer contentNodeId = new Integer(evt.getParameter(PARAMETER, "CONTENT_NODE_ID"));
      String type = evt.getParameter(PARAMETER, "CONTENT_NODE_TYPE");
      String name = evt.getParameter(PARAMETER, "CONTENT_NODE_NAME");
      TKVector depends = new TKVector();
      boolean groupDepend = false;
      // hier noch feststellen - ob ein Mitglied einer Contentgruppe
      TKQuery q;
      ResultSet rs;
      if (type.equals(SINGLE))
      {
        q = TKDBManager.newQuery(TKDBContentTreeGetParentInfo.class);
        q.setQueryParams("CONTENT_NODE_ID", contentNodeId);
        q.execute();
        rs = q.fetchResultSet();
        rs.next();
        // Vater informationen lesen
        String parentType = rs.getString("CONTENT_NODE_TYPE");
        if (parentType.equals(GROUP))
        {
          // wenn ja, auch noch die Abhaengigkeiten der Gruppe checken
          Integer groupId = new Integer(rs.getInt("CONTENT_NODE_ID"));
          if (CEUtils.checkDependencies(groupId, depends, false))
          {
            groupDepend = true;
            // Dependency gefunden !
          }
        }
      }
      CEUtils.checkDependencies(contentNodeId, depends, true);
        TKHTMLTemplate t = evt.getPrepHTMLTemplate("dependency.tmpl");
        q = TKDBManager.newQuery(SelectContentTreeAndForm.class);
        q.setQueryParams("CONTENT_NODE_ID", contentNodeId);
        q.execute();
        rs = q.fetchResultSet();

      String text = null;
        
        if (rs.next())
        {
          Object[] arguments = new Object[2];
        arguments[0] = name;
        arguments[1] = rs.getString("FORM_NAME");

          text = LanguageManager.getText("content", "CONTENT_DEPENDENCY", arguments);
        }
        else
        {
          text = LanguageManager.getText("content", "CONTENT_DIRECTORY_DEPENDENCY", new Object[]{name});
        }
        
      t.set("TITLE", text);
            t.setListIterator( new TKStandardPluginIterator("REFERENCES", null, depends, false, t.getListIterator()));

        evt.finishTemplate(t);
    }
    catch (Throwable e)
    {
      // TO DO : Analyze Exception !
      throw WebmanExceptionHandler.getException(e);
    }
  }

  public boolean isHandler(TKEvent evt)
  {
    return evt.getName().equalsIgnoreCase("CE_INFO");
  }
}
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.