/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.io.XmlUtil
 *  com.l7tech.message.Message
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.util.InvalidDocumentFormatException
 */
package com.l7tech.server.wsdm.method;

import com.l7tech.common.io.XmlUtil;
import com.l7tech.message.Message;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.wsdm.faults.FaultMappableException;
import com.l7tech.server.wsdm.faults.GenericWSRFExceptionFault;
import com.l7tech.server.wsdm.faults.InvalidResourcePropertyQNameFault;
import com.l7tech.server.wsdm.method.ESMMethod;
import com.l7tech.server.wsdm.method.ResourceProperty;
import com.l7tech.util.InvalidDocumentFormatException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class GetMultipleResourceProperties
extends ESMMethod {
    private ArrayList<ResourceProperty> g = new ArrayList();
    private Element h;
    private boolean i;
    private static final String[] j;

    private GetMultipleResourceProperties(Element element, Document document, Message message, Goid goid) throws InvalidResourcePropertyQNameFault, MalformedURLException {
        super(document, message, goid);
        this.h = element;
        this.i = this.b();
        if (!this.i) {
            String string = XmlUtil.getTextValue((Element)this.h);
            ResourceProperty resourceProperty = ResourceProperty.fromValue(string);
            this.g.add(resourceProperty);
        } else {
            NodeList nodeList = this.h.getChildNodes();
            for (int i2 = 0; i2 < nodeList.getLength(); ++i2) {
                Node node = nodeList.item(i2);
                if (node.getNodeType() != 1) continue;
                Element element2 = (Element)node;
                try {
                    if (element2.getLocalName() == null || !element2.getLocalName().equals(j[2])) continue;
                }
                catch (InvalidResourcePropertyQNameFault invalidResourcePropertyQNameFault) {
                    throw GetMultipleResourceProperties.b(invalidResourcePropertyQNameFault);
                }
                String string = XmlUtil.getTextValue((Element)element2);
                ResourceProperty resourceProperty = ResourceProperty.fromValue(string);
                try {
                    if (this.g.contains(resourceProperty)) continue;
                    this.g.add(resourceProperty);
                    continue;
                }
                catch (InvalidResourcePropertyQNameFault invalidResourcePropertyQNameFault) {
                    throw GetMultipleResourceProperties.b(invalidResourcePropertyQNameFault);
                }
            }
        }
    }

    public List<ResourceProperty> getRequestedProperties() {
        return this.g;
    }

    public static GetMultipleResourceProperties resolve(Message message, Goid goid) throws FaultMappableException, SAXException, IOException {
        Element element;
        Document document = message.getXmlKnob().getDocumentReadOnly();
        try {
            element = GetMultipleResourceProperties.a(document);
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            String[] stringArray = j;
            throw new GenericWSRFExceptionFault(stringArray[3]);
        }
        try {
            if (element == null) {
                return null;
            }
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            throw GetMultipleResourceProperties.b((Exception)((Object)invalidDocumentFormatException));
        }
        try {
            if (GetMultipleResourceProperties.a(element, j[0])) {
                return new GetMultipleResourceProperties(element, document, message, goid);
            }
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            throw GetMultipleResourceProperties.b((Exception)((Object)invalidDocumentFormatException));
        }
        return null;
    }

    private boolean b() {
        NodeList nodeList = this.h.getChildNodes();
        for (int i2 = 0; i2 < nodeList.getLength(); ++i2) {
            Element element;
            Node node = nodeList.item(i2);
            if (!(node instanceof Element) || !(element = (Element)node).getLocalName().equals(j[1])) continue;
            return true;
        }
        return false;
    }

    public boolean isReallyMultiResource() {
        return this.i;
    }

    private static Exception b(Exception exception) {
        return exception;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[4];
                var3_1 = 0;
                var2_2 = "em#35XCKx;\u001b\u0012QDM}%\u001d%dEMx2\f4]RQ\u0010pm$\u00115FTGX%\u00110QEVq";
                var4_3 = "em#35XCKx;\u001b\u0012QDM}%\u001d%dEMx2\f4]RQ\u0010pm$\u00115FTGX%\u00110QEVq".length();
                var1_4 = 29;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = GetMultipleResourceProperties.b(v0, GetMultipleResourceProperties.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "B_\u0016#\u0007tfuj\u0017#\u0002cwdC\u001fET\u0004.\u001ec%dUE>\u0017rwy_\u0013)RDjtCE)\u001echuT\u0011";
                    var4_3 = "B_\u0016#\u0007tfuj\u0017#\u0002cwdC\u001fET\u0004.\u001ec%dUE>\u0017rwy_\u0013)RDjtCE)\u001echuT\u0011".length();
                    var1_4 = 16;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 19;
                        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++] = GetMultipleResourceProperties.b(v0, GetMultipleResourceProperties.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;
            }
        }
        GetMultipleResourceProperties.j = var5;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x16);
        }
        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 -> 3;
                    case 1 -> 41;
                    case 2 -> 118;
                    case 3 -> 95;
                    case 4 -> 97;
                    case 5 -> 21;
                    default -> 22;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

