// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   DocumentAddCommentsReferenceDelegate.java

package com.ptc.windchill.pdmlink.doc.server.processors;

import java.io.PrintStream;
import java.io.Serializable;
import java.util.Properties;
import java.util.Vector;
import wt.content.ContentHTTPStream;
import wt.doc.*;
import wt.fc.WTObject;
import wt.introspection.ClassInfo;
import wt.templateutil.processor.FormTaskDelegate;
import wt.templateutil.processor.RedirectObject;
import wt.util.WTException;
import wt.util.WTProperties;

public class DocumentAddCommentsReferenceDelegate extends FormTaskDelegate
    implements Serializable
{

    public DocumentAddCommentsReferenceDelegate()
    {
    }

    /**
     * @deprecated Method processAction is deprecated
     */

    public void processAction(ContentHTTPStream contentStream)
        throws Exception
    {
        if(VERBOSE)
            System.out.println("DEBUG:DocumentAddReferenceDelegate.processAction object ci:" + getContextObj());
        Properties formData = getFormData();
        WTDocumentDependencyLink link = null;
        WTObject cobj = (WTObject)getContextObj();
        if(cobj instanceof WTDocumentDependencyLink)
        {
            link = (WTDocumentDependencyLink)getContextObj();
        } else
        {
            Object params[] = {
                cobj.getClassInfo().getClassname()
            };
            throw new WTException("com.ptc.windchill.pdmlink.doc.server.processors.processorsResource", "101", params);
        }
        String comment = (String)formData.get("Comment");
        if(VERBOSE)
            System.out.println("DEBUG:DocumentAddReferenceDelegate.processAction comment = " + comment);
        Vector comments = new Vector();
        if(comment != null)
            comments.addElement(comment);
        else
            comments.addElement("");
        WTDocument doc = link.getHasDependent();
        if(VERBOSE)
            System.out.println("DEBUG:DocumentAddReferenceDelegate.processAction document = " + doc.getName());
        Vector links = new Vector();
        links.addElement(link);
        doc = WTDocumentHelper.service.updateDependencyLink(doc, links, comments, "", "");
        setContextAction("DocumentAddReferenceSuccess");
        setContextObj(doc);
        RedirectObject redirectObj = new RedirectObject();
        redirectObj.setRedirection(getState());
        return;
        WTException wte;
        wte;
        wte.printStackTrace();
        addToResponseHeaders(wte);
        setContextAction("DocumentAddCommentsFailed");
        RedirectObject redirectObj = new RedirectObject();
        redirectObj.setRedirection(getState());
        break MISSING_BLOCK_LABEL_342;
        Exception exception;
        exception;
        RedirectObject redirectObj = new RedirectObject();
        redirectObj.setRedirection(getState());
        throw exception;
    }

    static Class _mthclass$(String x0)
    {
        return Class.forName(x0);
        ClassNotFoundException x1;
        x1;
        throw (new NoClassDefFoundError()).initCause(x1);
    }

    private static final String RESOURCE = "com.ptc.windchill.pdmlink.doc.server.processors.processorsResource";
    private static final String CLASSNAME;
    protected static boolean VERBOSE = false;

    static 
    {
        CLASSNAME = (com.ptc.windchill.pdmlink.doc.server.processors.DocumentAddCommentsReferenceDelegate.class).getName();
        try
        {
            WTProperties properties = WTProperties.getLocalProperties();
            VERBOSE = properties.getProperty("com.ptc.windchill.pdmlink.doc.client.verbose", false);
        }
        catch(Throwable t)
        {
            t.printStackTrace(System.err);
            throw new ExceptionInInitializerError(t);
        }
    }
}
