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

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

import java.beans.PropertyChangeEvent;
import java.io.*;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import wt.doc.WTDocumentDependencyLink;
import wt.fc.EvolvableHelper;
import wt.fc.ReferenceFactory;
import wt.httpgw.GatewayServletHelper;
import wt.introspection.PropertyDisplayName;
import wt.pds.PDSObjectInput;
import wt.templateutil.processor.*;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;

// Referenced classes of package com.ptc.windchill.pdmlink.doc.server.processors:
//            DocumentDetailReferenceActionDelegate

public class DocumentDetailReferenceURLActionDelegate extends DocumentDetailReferenceActionDelegate
    implements NavBarURLActionDelegate, Externalizable
{

    public void writeExternal(ObjectOutput output)
        throws IOException
    {
        output.writeLong(0x631515873e2ff3d6L);
        super.writeExternal(output);
        output.writeObject(actionName);
        output.writeObject(classURL);
    }

    public void readExternal(ObjectInput input)
        throws IOException, ClassNotFoundException
    {
        long readSerialVersionUID = input.readLong();
        readVersion(this, input, readSerialVersionUID, false, false);
    }

    protected boolean readVersion(DocumentDetailReferenceURLActionDelegate thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
        throws IOException, ClassNotFoundException
    {
        boolean success = true;
        if(readSerialVersionUID == 0x631515873e2ff3d6L)
        {
            if(!superDone)
                super.readExternal(input);
            actionName = (String)input.readObject();
            classURL = (String)input.readObject();
        } else
        {
            success = readOldVersion(input, readSerialVersionUID, passThrough, superDone);
            if(input instanceof PDSObjectInput)
                EvolvableHelper.requestRewriteOfEvolvedBlobbedObject();
        }
        return success;
    }

    private boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
        throws IOException, ClassNotFoundException
    {
        boolean success = true;
        if(readSerialVersionUID == 0xe60350c432628f79L)
        {
            actionName = (String)input.readObject();
            classURL = (String)input.readObject();
        } else
        if(!superDone)
        {
            success = super.readVersion(this, input, readSerialVersionUID, false, false);
            if(success && !passThrough && readSerialVersionUID != 0xd4b6b5eeea339daL)
                readVersion(this, input, input.readLong(), false, true);
        } else
        {
            throw new InvalidClassException(CLASSNAME, "Local class not compatible: stream classdesc externalizationVersionUID=" + readSerialVersionUID + " local class externalizationVersionUID=" + 0x631515873e2ff3d6L);
        }
        return success;
    }

    public DocumentDetailReferenceURLActionDelegate()
    {
        actionName = null;
        classURL = null;
        helper = null;
        helper = new NavBarURLActionDelegateHelper();
        helper.setIsOidAdded(true);
    }

    public HTTPState getState()
    {
        return helper.getState();
    }

    /**
     * @deprecated Method isURLProvider is deprecated
     */

    public boolean isURLProvider(HashMap queryValueMap, Object object)
    {
        return helper.isURLProvider(queryValueMap, object);
    }

    public void setResourceKey(String key)
    {
        helper.setResourceKey(key);
    }

    public void setResourceBundleStr(String resourceBundle)
    {
        helper.setResourceBundleStr(resourceBundle);
    }

    public void setState(HTTPState state)
    {
        helper.setState(state);
    }

    /**
     * @deprecated Method setMethod is deprecated
     */

    public void setMethod(String method)
    {
        helper.setMethod(method);
    }

    public String getActionName()
    {
        return helper.getActionName();
    }

    public void setActionName(String a_ActionName)
        throws WTPropertyVetoException
    {
        try
        {
            helper.setActionName(a_ActionName);
        }
        catch(WTPropertyVetoException wpve)
        {
            wpve.printStackTrace();
        }
    }

    private void actionNameValidate(String a_ActionName)
        throws WTPropertyVetoException
    {
        if(a_ActionName != null && a_ActionName.length() > 200)
        {
            Object args[] = {
                new PropertyDisplayName(CLASSNAME, "actionName"), "200"
            };
            throw new WTPropertyVetoException("wt.introspection.introspectionResource", "20", args, new PropertyChangeEvent(this, "actionName", actionName, a_ActionName));
        } else
        {
            return;
        }
    }

    public String getClassURL()
    {
        return null;
    }

    public void setClassURL(String s)
        throws WTPropertyVetoException
    {
    }

    private void classURLValidate(String a_ClassURL)
        throws WTPropertyVetoException
    {
        if(a_ClassURL != null && a_ClassURL.length() > 200)
        {
            Object args[] = {
                new PropertyDisplayName(CLASSNAME, "classURL"), "200"
            };
            throw new WTPropertyVetoException("wt.introspection.introspectionResource", "20", args, new PropertyChangeEvent(this, "classURL", classURL, a_ClassURL));
        } else
        {
            return;
        }
    }

    /**
     * @deprecated Method URL is deprecated
     */

    public String URL(Object object)
        throws WTException
    {
        ReferenceFactory factory = new ReferenceFactory();
        String gwUrl = null;
        if(enableable(object).booleanValue())
            try
            {
                WTDocumentDependencyLink link = (WTDocumentDependencyLink)object;
                wt.doc.WTDocument doc = link.getDependsOn();
                ReferenceFactory rf = new ReferenceFactory();
                String oidStr = rf.getReferenceString(doc);
                wt.httpgw.URLFactory urlFactory = getState().getURLFactory();
                HashMap map = new HashMap();
                map.put("action", "ObjProps");
                map.put("oid", oidStr);
                URL url = GatewayServletHelper.buildAuthenticatedURL(urlFactory, "wt.enterprise.URLProcessor", "URLTemplateAction", map);
                gwUrl = url.toExternalForm();
            }
            catch(Exception e)
            {
                throw new WTException(e, "com.ptc.windchill.pdmlink.doc.server.processors.processorsResource", "100", null);
            }
        return gwUrl;
    }

    /**
     * @deprecated Method getURLLabel is deprecated
     */

    public String getURLLabel(Locale locale)
    {
        return helper.getURLLabel(locale);
    }

    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 String actionName;
    private String classURL;
    static final long serialVersionUID = 1L;
    public static final long EXTERNALIZATION_VERSION_UID = 0x631515873e2ff3d6L;
    protected static final long OLD_FORMAT_VERSION_UID = 0xe60350c432628f79L;
    protected NavBarURLActionDelegateHelper helper;

    static 
    {
        CLASSNAME = (com.ptc.windchill.pdmlink.doc.server.processors.DocumentDetailReferenceURLActionDelegate.class).getName();
    }
}
