// 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:   CreateDocFromTemplateCloseWindowFormTaskDelegate.java

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

import java.io.PrintStream;
import java.util.Properties;
import wt.content.*;
import wt.templateutil.processor.DefaultTemplateProcessor;
import wt.templateutil.processor.FormTaskDelegate;
import wt.util.WTMessage;
import wt.util.WTProperties;

/**
 * @deprecated Class CreateDocFromTemplateCloseWindowFormTaskDelegate is deprecated
 */

public class CreateDocFromTemplateCloseWindowFormTaskDelegate extends FormTaskDelegate
{

    public CreateDocFromTemplateCloseWindowFormTaskDelegate()
    {
    }

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

    public void processAction(ContentHTTPStream contentStream)
        throws Exception
    {
        if(VERBOSE)
            System.err.println("Entering CloseWindowFormTaskDelegate.processAction");
        if(VERBOSE)
            System.err.println("Entering CloseWindowFormTaskDelegate.processAction");
        Properties props = getQueryData();
        String formName = (String)props.get("formName");
        String downloaded = (String)props.get("downloaded");
        if(downloaded != null && downloaded.equalsIgnoreCase("true"))
        {
            String downloadPath = (String)props.get("downloadPath");
            long checksum = 0L;
            String checksumString = (String)props.get("checksum");
            if(checksumString != null)
                try
                {
                    checksum = Long.parseLong(checksumString);
                    FormatContentHolder holder = (FormatContentHolder)getContextObj();
                    holder = (FormatContentHolder)ContentHelper.service.getContents(holder);
                    wt.content.ContentItem item = ContentHelper.getPrimary(holder);
                    if(item instanceof ApplicationData)
                    {
                        ApplicationData app = (ApplicationData)item;
                        app.setChecksum(checksum);
                        app.setUploadedFromPath(downloadPath);
                        try
                        {
                            ContentHelper.service.updateAppData(holder, app);
                        }
                        catch(Exception e)
                        {
                            e.printStackTrace();
                        }
                    }
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
        }
        DefaultTemplateProcessor.addToFeedbackCookie(new WTMessage("com.ptc.windchill.pdmlink.doc.server.processors.processorsResource", "76", null), getState());
        deleteFormDataFromSession(formName);
        setContextAction("ComplexCloseWizardWindow");
        getContextProperties().put("refreshOnly", "true");
    }

    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;
    private static boolean VERBOSE;

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