/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.imp.PersistentEntityImp
 *  com.l7tech.util.GoidUpgradeMapper
 *  jakarta.persistence.Column
 *  jakarta.persistence.Entity
 *  jakarta.persistence.Table
 *  jakarta.persistence.Version
 *  org.hibernate.annotations.Proxy
 *  org.hibernate.annotations.Type
 */
package com.l7tech.server.wsdm.subscription;

import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.imp.PersistentEntityImp;
import com.l7tech.server.wsdm.faults.TopicNotSupportedFaultException;
import com.l7tech.server.wsdm.method.Subscribe;
import com.l7tech.util.GoidUpgradeMapper;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Type;

@Entity
@Proxy(lazy=false)
@Table(name="wsdm_subscription")
public class Subscription
extends PersistentEntityImp {
    public static final int TOPIC_METRICS_CAPABILITY = 1;
    public static final int TOPIC_OPERATIONAL_STATUS = 2;
    public static final String NS;
    private String uuid;
    private Goid esmServiceGoid;
    private Goid publishedServiceGoid;
    private String referenceCallback;
    private int topic;
    private volatile long termination;
    private String notificationPolicyGuid;
    private String ownerNodeId;
    private long lastNotificationTime;
    private static final String OPERATIONAL_STATUS_CAPABILITY;
    private static final String OPERATIONAL_STATUS_CAPABILITY_PREFIX;
    private static final String METRICS_CAPABILITY;
    private static final String METRICS_CAPABILITY_PREFIX;
    private String referenceParams;
    static final long serialVersionUID = -6997413458179829069L;
    private static final String[] b;

    public Subscription(Subscribe subscribe, String string, String string2) throws TopicNotSupportedFaultException {
        block15: {
            block16: {
                String string3;
                String string4;
                block14: {
                    this.topic = -1;
                    this.uuid = string;
                    this.esmServiceGoid = subscribe.getEsmServiceGoid();
                    this.publishedServiceGoid = GoidUpgradeMapper.mapId((EntityType)EntityType.SERVICE, (String)subscribe.getServiceId());
                    this.ownerNodeId = string2;
                    if (subscribe.isTerminationParsed()) {
                        this.termination = subscribe.getTermination();
                    }
                    this.referenceParams = subscribe.getReferenceParams();
                    string4 = subscribe.getTopicValue();
                    string3 = null;
                    if (string4.contains(":")) {
                        String[] stringArray = string4.split(":", 2);
                        string3 = stringArray[0];
                        string4 = stringArray[1];
                    }
                    try {
                        try {
                            try {
                                if (!string4.equals(b[2]) || string3 == null) break block14;
                            }
                            catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                                throw Subscription.a(topicNotSupportedFaultException);
                            }
                            if (!string3.equals(b[3])) break block14;
                        }
                        catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                            throw Subscription.a(topicNotSupportedFaultException);
                        }
                        this.topic = 1;
                        break block15;
                    }
                    catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                        throw Subscription.a(topicNotSupportedFaultException);
                    }
                }
                try {
                    try {
                        try {
                            if (!string4.equals(b[9]) || string3 == null) break block16;
                        }
                        catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                            throw Subscription.a(topicNotSupportedFaultException);
                        }
                        if (!string3.equals(b[8])) break block16;
                    }
                    catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                        throw Subscription.a(topicNotSupportedFaultException);
                    }
                    this.topic = 2;
                    break block15;
                }
                catch (TopicNotSupportedFaultException topicNotSupportedFaultException) {
                    throw Subscription.a(topicNotSupportedFaultException);
                }
            }
            throw new TopicNotSupportedFaultException(subscribe.getTopicValue() + b[4]);
        }
        this.referenceCallback = subscribe.getCallBackAddress();
    }

    @Version
    @Column(name="version")
    public int getVersion() {
        return super.getVersion();
    }

    @Column(name="uuid", nullable=false, unique=true, length=36)
    public String getUuid() {
        return this.uuid;
    }

    @Column(name="esm_service_goid", nullable=false)
    @Type(type="com.l7tech.server.util.GoidType")
    public Goid getEsmServiceGoid() {
        return this.esmServiceGoid;
    }

    @Column(name="callback_url", nullable=false, length=255)
    public String getReferenceCallback() {
        return this.referenceCallback;
    }

    @Column(name="termination_time", nullable=false)
    public long getTermination() {
        return this.termination;
    }

    @Column(name="topic", nullable=false)
    public int getTopic() {
        return this.topic;
    }

    @Column(name="published_service_goid", nullable=false)
    @Type(type="com.l7tech.server.util.GoidType")
    public Goid getPublishedServiceGoid() {
        return this.publishedServiceGoid;
    }

    @Column(name="notification_policy_guid", length=36)
    public String getNotificationPolicyGuid() {
        return this.notificationPolicyGuid;
    }

    @Column(name="reference_parameters", length=16384)
    public String getReferenceParams() {
        return this.referenceParams;
    }

    @Deprecated
    public void setReferenceParams(String string) {
        this.referenceParams = string;
    }

    public void setNotificationPolicyGuid(String string) {
        this.notificationPolicyGuid = string;
    }

    public void setTermination(long l2) {
        this.termination = l2;
    }

    @Deprecated
    protected void setPublishedServiceGoid(Goid goid) {
        this.publishedServiceGoid = goid;
    }

    @Deprecated
    protected Subscription() {
        this.topic = -1;
    }

    @Deprecated
    protected void setUuid(String string) {
        this.uuid = string;
    }

    @Deprecated
    public void setEsmServiceGoid(Goid goid) {
        this.esmServiceGoid = goid;
    }

    @Deprecated
    protected void setReferenceCallback(String string) {
        this.referenceCallback = string;
    }

    @Deprecated
    protected void setTopic(int n2) {
        this.topic = n2;
    }

    @Column(name="owner_node_id", length=64)
    public String getOwnerNodeId() {
        return this.ownerNodeId;
    }

    public void setOwnerNodeId(String string) {
        this.ownerNodeId = string;
    }

    @Column(name="last_notification")
    public long getLastNotificationTime() {
        return this.lastNotificationTime;
    }

    public void setLastNotificationTime(long l2) {
        this.lastNotificationTime = l2;
    }

    private static TopicNotSupportedFaultException a(TopicNotSupportedFaultException topicNotSupportedFaultException) {
        return topicNotSupportedFaultException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[10];
                var3_1 = 0;
                var2_2 = "\u001ab^~\\\n9\u0014fZmW\u0000&>sS.?s^|\u000fFe p]\"Y\b32u\u001dxP\n\"ydEa\u001a\u00079xpYhXF9\"eYoG\u0000:#nEb\u0011\u001ab^~\\\n9\u0014fZmW\u0000&>sS\u0005:h]\u007fP\u0019wnY,[\u0006>wf\n\u007f@\u0019:8u^iQI\u001e8wCo\u0005:h]\u007fP\u001b\u0018wO~T\u001d#8iK`f\u001d+#rYOT\u0019+5nFeA\u0010\u0007:r]\u007f\u0018\f<";
                var4_3 = "\u001ab^~\\\n9\u0014fZmW\u0000&>sS.?s^|\u000fFe p]\"Y\b32u\u001dxP\n\"ydEa\u001a\u00079xpYhXF9\"eYoG\u0000:#nEb\u0011\u001ab^~\\\n9\u0014fZmW\u0000&>sS\u0005:h]\u007fP\u0019wnY,[\u0006>wf\n\u007f@\u0019:8u^iQI\u001e8wCo\u0005:h]\u007fP\u001b\u0018wO~T\u001d#8iK`f\u001d+#rYOT\u0019+5nFeA\u0010\u0007:r]\u007f\u0018\f<".length();
                var1_4 = 17;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 15;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = Subscription.b(v0, Subscription.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u000eFiK,8\b\u001b,C{J`)\u0017\f]\u007fTR)\u001f\u0017Fm{`-\u001f\u0001ZrQu$";
                    var4_3 = "\u000eFiK,8\b\u001b,C{J`)\u0017\f]\u007fTR)\u001f\u0017Fm{`-\u001f\u0001ZrQu$".length();
                    var1_4 = 7;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 59;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = Subscription.b(v0, Subscription.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        Subscription.b = var5;
        Subscription.OPERATIONAL_STATUS_CAPABILITY_PREFIX = Subscription.b[7];
        Subscription.OPERATIONAL_STATUS_CAPABILITY = Subscription.b[6];
        Subscription.METRICS_CAPABILITY = Subscription.b[0];
        Subscription.METRICS_CAPABILITY_PREFIX = Subscription.b[5];
        Subscription.NS = Subscription.b[1];
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x45);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 88;
                    case 1 -> 8;
                    case 2 -> 37;
                    case 3 -> 3;
                    case 4 -> 58;
                    case 5 -> 102;
                    default -> 69;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

