/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.MessageProcessingMessages
 *  com.l7tech.gateway.common.cluster.ServiceUsage
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.gateway.common.service.ServiceStatistics
 *  com.l7tech.message.Message
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.ObjectModelException
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.objectmodel.imp.PersistentEntityUtil
 *  com.l7tech.policy.Policy
 *  com.l7tech.policy.PolicyHeader
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.Pair
 *  org.jetbrains.annotations.Nullable
 *  org.springframework.beans.factory.DisposableBean
 *  org.springframework.beans.factory.InitializingBean
 *  org.springframework.context.ApplicationEvent
 *  org.springframework.context.support.ApplicationObjectSupport
 *  org.springframework.jmx.export.annotation.ManagedAttribute
 *  org.springframework.jmx.export.annotation.ManagedOperation
 *  org.springframework.jmx.export.annotation.ManagedResource
 *  org.springframework.transaction.PlatformTransactionManager
 *  org.springframework.transaction.support.TransactionCallback
 *  org.springframework.transaction.support.TransactionSynchronization
 *  org.springframework.transaction.support.TransactionSynchronizationManager
 *  org.springframework.transaction.support.TransactionTemplate
 */
package com.l7tech.server.service;

import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.MessageProcessingMessages;
import com.l7tech.gateway.common.cluster.ServiceUsage;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.gateway.common.service.ServiceStatistics;
import com.l7tech.message.Message;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.objectmodel.imp.PersistentEntityUtil;
import com.l7tech.policy.Policy;
import com.l7tech.policy.PolicyHeader;
import com.l7tech.server.audit.Auditor;
import com.l7tech.server.cluster.ClusterInfoManager;
import com.l7tech.server.cluster.ServiceUsageManager;
import com.l7tech.server.event.PolicyCacheEvent;
import com.l7tech.server.event.ServiceEnablementEvent;
import com.l7tech.server.event.system.ServiceCacheEvent;
import com.l7tech.server.event.system.ServiceReloadEvent;
import com.l7tech.server.event.system.Started;
import com.l7tech.server.policy.PolicyCache;
import com.l7tech.server.policy.PolicyMetadata;
import com.l7tech.server.policy.ServerPolicyException;
import com.l7tech.server.policy.ServerPolicyHandle;
import com.l7tech.server.policy.ServerPolicyInstantiationException;
import com.l7tech.server.service.ServiceAndPolicyCacheSharedLock;
import com.l7tech.server.service.ServiceCacheResolver;
import com.l7tech.server.service.ServiceManager;
import com.l7tech.server.service.ar;
import com.l7tech.server.service.aw;
import com.l7tech.server.service.ay;
import com.l7tech.server.service.az;
import com.l7tech.server.service.resolution.ServiceResolutionException;
import com.l7tech.server.service.resolution.ServiceResolutionHelper;
import com.l7tech.server.service.resolution.ServiceResolutionManager;
import com.l7tech.server.service.resolution.UriResolver;
import com.l7tech.server.service.v;
import com.l7tech.server.service.w;
import com.l7tech.server.service.x;
import com.l7tech.server.util.PostStartupApplicationListener;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Pair;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.transaction.support.TransactionTemplate;

public class ServiceCache
extends ApplicationObjectSupport
implements InitializingBean,
DisposableBean,
PostStartupApplicationListener,
ServiceCacheResolver {
    private static final Logger a;
    public static final long INTEGRITY_CHECK_FREQUENCY = 4000L;
    private final Map<Goid, PublishedService> b = new HashMap<Goid, PublishedService>();
    private final ConcurrentMap<Goid, ServiceStatistics> c = new ConcurrentHashMap<Goid, ServiceStatistics>();
    private final Map<Goid, String> d = new HashMap<Goid, String>();
    private final Set<Goid> e = new HashSet<Goid>();
    private final PlatformTransactionManager f;
    private final ServiceManager g;
    private final ServiceUsageManager h;
    private final ClusterInfoManager i;
    private final ExecutorService j = Executors.newSingleThreadExecutor();
    private final Timer k;
    private final ReadWriteLock l = ServiceAndPolicyCacheSharedLock.getLock();
    private boolean m = false;
    private Auditor n;
    private Goid o = null;
    private final PolicyCache p;
    private final ServiceResolutionManager q;
    private final AtomicBoolean r = new AtomicBoolean(true);
    private static final String[] s;

    public ServiceCache(PolicyCache policyCache, PlatformTransactionManager platformTransactionManager, ServiceManager serviceManager, ServiceUsageManager serviceUsageManager, ServiceResolutionManager serviceResolutionManager, ClusterInfoManager clusterInfoManager, Timer timer) {
        if (policyCache == null) {
            String[] stringArray = s;
            throw new IllegalArgumentException(stringArray[40]);
        }
        if (timer == null) {
            timer = new Timer(s[34], true);
        }
        this.p = policyCache;
        this.q = serviceResolutionManager;
        this.k = timer;
        this.f = platformTransactionManager;
        this.g = serviceManager;
        this.h = serviceUsageManager;
        this.i = clusterInfoManager;
        this.q.setServiceResolutionHelper(new ServiceResolutionHelper(this.b));
    }

    @ManagedOperation(description="Check Cache Integrity")
    public synchronized void initiateIntegrityCheckProcess() {
        if (!this.m) {
            ServiceCache serviceCache = this;
            ar ar2 = new ar(this, serviceCache);
            this.k.schedule((TimerTask)ar2, 4000L, 4000L);
            this.m = true;
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        block18: {
            block19: {
                block17: {
                    try {
                        if (!(applicationEvent instanceof ServiceCacheEvent.Updated)) break block17;
                        this.a((ServiceCacheEvent.Updated)applicationEvent);
                        this.r.set(true);
                        break block18;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ServiceCache.a(illegalArgumentException);
                    }
                }
                try {
                    if (!(applicationEvent instanceof ServiceCacheEvent.Deleted)) break block19;
                    this.a((ServiceCacheEvent.Deleted)applicationEvent);
                    this.r.set(true);
                    break block18;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
            }
            if (applicationEvent instanceof PolicyCacheEvent.Invalid) {
                PolicyCacheEvent.Invalid invalid = (PolicyCacheEvent.Invalid)applicationEvent;
                Lock lock = this.l.writeLock();
                lock.lock();
                try {
                    this.a(null, invalid.getPolicyId(), invalid.getException());
                }
                finally {
                    lock.unlock();
                }
                this.r.set(true);
            } else if (applicationEvent instanceof PolicyCacheEvent.Updated) {
                PolicyCacheEvent.Updated updated = (PolicyCacheEvent.Updated)applicationEvent;
                Lock lock = this.l.writeLock();
                lock.lock();
                try {
                    this.a(updated.getPolicy());
                }
                finally {
                    lock.unlock();
                }
                this.r.set(true);
            } else {
                try {
                    if (applicationEvent instanceof Started) {
                        new TransactionTemplate(this.f).execute((TransactionCallback)new aw(this));
                        this.r.set(true);
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
            }
        }
    }

    private void a(ServiceCacheEvent.Deleted deleted) {
        TransactionSynchronizationManager.registerSynchronization((TransactionSynchronization)new ay(this, deleted));
    }

    private void a(ServiceCacheEvent.Updated updated) {
        TransactionSynchronizationManager.registerSynchronization((TransactionSynchronization)new az(this, updated));
    }

    private void a(Goid goid) {
        PublishedService publishedService;
        try {
            publishedService = (PublishedService)this.g.findByPrimaryKey(goid);
        }
        catch (FindException findException) {
            publishedService = null;
            String[] stringArray = s;
            a.log(Level.WARNING, stringArray[22], findException);
        }
        if (publishedService != null) {
            try {
                PersistentEntityUtil.lock((PersistentEntity)publishedService);
                PersistentEntityUtil.lock((PersistentEntity)publishedService.getPolicy());
                this.cache(publishedService);
            }
            catch (Exception exception) {
                a.log(Level.WARNING, s[14] + ExceptionUtils.getMessage((Throwable)exception), exception);
            }
        }
    }

    protected void initializeServiceCache() throws ObjectModelException {
        try {
            String[] stringArray;
            block13: {
                block12: {
                    try {
                        if (this.size() <= 0) break block12;
                        a.finest(s[29]);
                        break block13;
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        throw ServiceCache.a((Exception)((Object)serverPolicyException));
                    }
                }
                stringArray = s;
                a.info(stringArray[13]);
                long l2 = System.currentTimeMillis();
                Collection collection = this.g.findAll();
                for (PublishedService publishedService : collection) {
                    Object object;
                    try {
                        this.cache(new PublishedService(publishedService, true));
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        Object object2;
                        Object object3;
                        object = serverPolicyException.getAssertion();
                        try {
                            object3 = object == null ? "" : "#" + Integer.toString(object.getOrdinal());
                        }
                        catch (ServerPolicyException serverPolicyException2) {
                            throw ServiceCache.a((Exception)((Object)serverPolicyException2));
                        }
                        String string = object3;
                        try {
                            object2 = object == null ? s[7] : "(" + object.getClass().getSimpleName() + ")";
                        }
                        catch (ServerPolicyException serverPolicyException3) {
                            throw ServiceCache.a((Exception)((Object)serverPolicyException3));
                        }
                        Object object4 = object2;
                        stringArray = s;
                        String string2 = MessageFormat.format(stringArray[31], publishedService.getGoid(), publishedService.getName(), string, object4);
                        a.log(Level.WARNING, string2, (Throwable)((Object)serverPolicyException));
                    }
                    catch (Exception exception) {
                        stringArray = s;
                        object = MessageFormat.format(stringArray[38], publishedService.getGoid(), publishedService.getName());
                        a.log(Level.WARNING, (String)object, exception);
                    }
                }
                stringArray = s;
                a.info(stringArray[15] + (System.currentTimeMillis() - l2) + stringArray[12]);
            }
            stringArray = s;
            a.info(stringArray[27]);
            this.initiateIntegrityCheckProcess();
        }
        catch (Exception exception) {
            throw new ObjectModelException(s[21], (Throwable)exception);
        }
    }

    private void a() throws ObjectModelException {
        try {
            Collection collection = this.g.findAll();
            HashSet<Goid> hashSet = new HashSet<Goid>(collection.size());
            ServiceUsage[] serviceUsageArray = collection.iterator();
            while (serviceUsageArray.hasNext()) {
                ServiceUsage[] serviceUsageArray2 = (ServiceUsage[])serviceUsageArray.next();
                hashSet.add(serviceUsageArray2.getGoid());
            }
            for (ServiceUsage serviceUsage : serviceUsageArray = this.h.findByNode(this.i.thisNodeId())) {
                Goid goid = serviceUsage.getServiceid();
                if (!hashSet.contains(goid)) continue;
                ServiceStatistics serviceStatistics = new ServiceStatistics(serviceUsage.getServiceid(), serviceUsage.getRequests(), serviceUsage.getAuthorized(), serviceUsage.getCompleted());
                this.c.put(serviceStatistics.getServiceGoid(), serviceStatistics);
            }
        }
        catch (FindException findException) {
            throw new ObjectModelException(s[17], (Throwable)findException);
        }
    }

    public int size() {
        this.l.readLock().lock();
        try {
            int n2 = this.b.size();
            return n2;
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    private Map<Goid, Integer> b() {
        HashMap<Goid, Integer> hashMap = new HashMap<Goid, Integer>();
        for (PublishedService publishedService : this.b.values()) {
            hashMap.put(publishedService.getGoid(), publishedService.getVersion());
        }
        return hashMap;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public ServerPolicyHandle getServerPolicy(Goid goid) {
        this.l.readLock().lock();
        try {
            PublishedService publishedService = this.b.get(goid);
            if (publishedService == null) {
                ServerPolicyHandle serverPolicyHandle = null;
                return serverPolicyHandle;
            }
            ServerPolicyHandle serverPolicyHandle = this.b(publishedService);
            return serverPolicyHandle;
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     */
    @Override
    public PublishedService resolve(Message message, ResolutionListener resolutionListener) throws ServiceResolutionException {
        this.l.readLock().lock();
        try {
            PublishedService publishedService;
            block12: {
                block13: {
                    Collection<PublishedService> collection = Collections.unmodifiableCollection(this.b.values());
                    publishedService = this.a(message, resolutionListener, collection);
                    if (publishedService != null) break block12;
                    if (!resolutionListener.notifyResolveCatchAll()) break block12;
                    break block13;
                    catch (ServiceResolutionException serviceResolutionException) {
                        throw ServiceCache.a(serviceResolutionException);
                    }
                }
                try {
                    block14: {
                        if (this.o == null) break block12;
                        break block14;
                        catch (ServiceResolutionException serviceResolutionException) {
                            throw ServiceCache.a(serviceResolutionException);
                        }
                    }
                    if (!UriResolver.canResolveByURI(message)) break block12;
                }
                catch (ServiceResolutionException serviceResolutionException) {
                    throw ServiceCache.a(serviceResolutionException);
                }
                publishedService = this.b.get(this.o);
                try {
                    if (publishedService != null) {
                        this.n.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVICE_CACHE_RESOLVED_CATCHALL, publishedService.getName(), publishedService.getId());
                    }
                }
                catch (ServiceResolutionException serviceResolutionException) {
                    throw ServiceCache.a(serviceResolutionException);
                }
            }
            PublishedService publishedService2 = publishedService;
            return publishedService2;
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public Collection<PublishedService> resolve(@Nullable String string, @Nullable String string2, @Nullable String string3) throws ServiceResolutionException {
        this.l.readLock().lock();
        try {
            Collection<PublishedService> collection = Collections.unmodifiableCollection(this.b.values());
            Collection<PublishedService> collection2 = this.q.resolve(string, string2, string3, collection);
            return collection2;
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    @Override
    public void checkResolution(PublishedService publishedService) throws ServiceResolutionException {
        this.l.readLock().lock();
        try {
            Collection<PublishedService> collection = Collections.unmodifiableCollection(this.b.values());
            this.q.checkResolution(publishedService, collection);
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    private PublishedService a(Message message, ResolutionListener resolutionListener, Collection<PublishedService> collection) throws ServiceResolutionException {
        return this.q.resolve((Audit)this.n, message, new v(this, resolutionListener), collection);
    }

    private Set<ServiceMetadata> a(Collection<PublishedService> collection) {
        Set<ServiceMetadata> set;
        if (collection.isEmpty()) {
            set = Collections.emptySet();
        } else if (collection.size() == 1) {
            set = Collections.singleton(this.a(collection.iterator().next()));
        } else {
            set = new LinkedHashSet<ServiceMetadata>();
            for (PublishedService publishedService : collection) {
                set.add(this.a(publishedService));
            }
        }
        return set;
    }

    private ServiceMetadata a(PublishedService publishedService) {
        PolicyMetadata policyMetadata;
        block5: {
            PolicyHeader policyHeader;
            block7: {
                Policy policy;
                block6: {
                    policyMetadata = null;
                    policy = publishedService.getPolicy();
                    if (policy != null) {
                        policyMetadata = this.p.getPolicyMetadata(policy);
                    }
                    try {
                        try {
                            if (policyMetadata != null) break block5;
                            if (policy != null) break block6;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw ServiceCache.a(illegalArgumentException);
                        }
                        policyHeader = null;
                        break block7;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ServiceCache.a(illegalArgumentException);
                    }
                }
                policyHeader = new PolicyHeader(policy);
            }
            PolicyHeader policyHeader2 = policyHeader;
            policyMetadata = new w(this, policyHeader2);
        }
        return new ServiceMetadata(policyMetadata, publishedService.isWssProcessingEnabled());
    }

    public void cache(PublishedService publishedService) throws ServerPolicyException {
        LinkedList<Pair<Goid, CachedServiceNotificationType>> linkedList = new LinkedList<Pair<Goid, CachedServiceNotificationType>>();
        this.l.writeLock().lock();
        try {
            this.a(publishedService, linkedList);
            this.d();
        }
        finally {
            this.l.writeLock().unlock();
        }
        try {
            if (!linkedList.isEmpty()) {
                this.a((List<Pair<Goid, CachedServiceNotificationType>>)linkedList);
            }
        }
        catch (ServerPolicyException serverPolicyException) {
            throw ServiceCache.a((Exception)((Object)serverPolicyException));
        }
    }

    private void a(List<Pair<Goid, CachedServiceNotificationType>> list) {
        this.j.execute(new x(this, list));
    }

    private void a(List<Goid> list, boolean bl2) {
        String string;
        Level level;
        Logger logger;
        block6: {
            try {
                try {
                    if (list != null && !list.isEmpty()) break block6;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
                return;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ServiceCache.a(illegalArgumentException);
            }
        }
        try {
            logger = a;
            level = Level.INFO;
            string = bl2 ? s[4] : s[8];
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ServiceCache.a(illegalArgumentException);
        }
        logger.log(level, string + String.valueOf(list));
        this.getApplicationContext().publishEvent((ApplicationEvent)new ServiceEnablementEvent(this, list.toArray(new Goid[list.size()]), bl2));
    }

    private void a(PublishedService publishedService, List<Pair<Goid, CachedServiceNotificationType>> list) throws ServerPolicyException {
        boolean bl2;
        Goid goid;
        block22: {
            goid = publishedService.getGoid();
            PublishedService publishedService2 = this.b.get(goid);
            if (publishedService2 == null) {
                bl2 = false;
            } else {
                block21: {
                    bl2 = true;
                    try {
                        try {
                            if (!publishedService2.isDisabled() || publishedService.isDisabled()) break block21;
                        }
                        catch (ServerPolicyException serverPolicyException) {
                            throw ServiceCache.a((Exception)((Object)serverPolicyException));
                        }
                        list.add((Pair<Goid, CachedServiceNotificationType>)new Pair((Object)goid, (Object)CachedServiceNotificationType.ENABLED));
                        break block22;
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        throw ServiceCache.a((Exception)((Object)serverPolicyException));
                    }
                }
                try {
                    try {
                        if (!publishedService.isDisabled() || publishedService2.isDisabled()) break block22;
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        throw ServiceCache.a((Exception)((Object)serverPolicyException));
                    }
                    list.add((Pair<Goid, CachedServiceNotificationType>)new Pair((Object)goid, (Object)CachedServiceNotificationType.DISABLED));
                }
                catch (ServerPolicyException serverPolicyException) {
                    throw ServiceCache.a((Exception)((Object)serverPolicyException));
                }
            }
        }
        if (bl2) {
            this.q.notifyServiceUpdated((Audit)this.n, publishedService);
            list.add((Pair<Goid, CachedServiceNotificationType>)new Pair((Object)goid, (Object)CachedServiceNotificationType.UPDATED));
            int n2 = publishedService.getVersion();
            String string = String.valueOf(publishedService.getGoid());
            String string2 = publishedService.getName();
            String[] stringArray = s;
            a.finest(stringArray[9] + string2 + stringArray[35] + string + stringArray[19] + n2);
        } else {
            this.q.notifyServiceCreated((Audit)this.n, publishedService);
            list.add((Pair<Goid, CachedServiceNotificationType>)new Pair((Object)goid, (Object)CachedServiceNotificationType.CREATED));
            String[] stringArray = s;
            a.finest(stringArray[10] + publishedService.getName() + stringArray[20] + String.valueOf(publishedService.getGoid()));
        }
        try {
            if (!PersistentEntityUtil.isLocked((PersistentEntity)publishedService)) {
                throw new IllegalArgumentException(s[32]);
            }
        }
        catch (ServerPolicyException serverPolicyException) {
            throw ServiceCache.a((Exception)((Object)serverPolicyException));
        }
        this.b.put(goid, publishedService);
        Policy policy = publishedService.getPolicy();
        try {
            if (policy == null) {
                throw new ServerPolicyException(null, s[36] + String.valueOf(publishedService.getGoid()) + s[0] + publishedService.getName() + s[30]);
            }
        }
        catch (ServerPolicyException serverPolicyException) {
            throw ServiceCache.a((Exception)((Object)serverPolicyException));
        }
        try {
            if (!PersistentEntityUtil.isLocked((PersistentEntity)policy)) {
                throw new IllegalArgumentException(s[3]);
            }
        }
        catch (ServerPolicyException serverPolicyException) {
            throw ServiceCache.a((Exception)((Object)serverPolicyException));
        }
        this.p.update(policy);
    }

    public void removeFromCache(PublishedService publishedService) {
        this.l.writeLock().lock();
        try {
            this.d(publishedService);
            this.d();
        }
        finally {
            this.l.writeLock().unlock();
        }
    }

    private ServerPolicyHandle b(PublishedService publishedService) {
        ServerPolicyHandle serverPolicyHandle = null;
        Policy policy = publishedService.getPolicy();
        if (policy != null) {
            serverPolicyHandle = this.p.getServerPolicy(policy);
        }
        return serverPolicyHandle;
    }

    private void a(PublishedService publishedService, Goid goid, Exception exception) {
        block7: {
            PublishedService publishedService2;
            block8: {
                publishedService2 = publishedService;
                if (publishedService2 == null) {
                    publishedService2 = this.getCachedServiceByPolicy(goid);
                }
                try {
                    try {
                        try {
                            if (publishedService2 == null || publishedService2.isDisabled()) break block7;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw ServiceCache.a(illegalArgumentException);
                        }
                        if (!(exception instanceof ServerPolicyInstantiationException)) break block8;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ServiceCache.a(illegalArgumentException);
                    }
                    this.n.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVICE_CACHE_BAD_POLICY_FORMAT, publishedService2.getName(), publishedService2.getId());
                    this.a(publishedService2, true);
                    break block7;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
            }
            this.n.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVICE_CACHE_BAD_POLICY, publishedService2.getName(), publishedService2.getId());
            this.n.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVICE_CACHE_DISABLING_SERVICE, publishedService2.getId(), publishedService2.getName());
            this.a(publishedService2, true);
        }
    }

    private void a(Policy policy) {
        block11: {
            PublishedService publishedService;
            block10: {
                publishedService = this.getCachedServiceByPolicy(policy.getGoid());
                try {
                    try {
                        try {
                            if (publishedService == null || publishedService.getPolicy() == null) break block10;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw ServiceCache.a(illegalArgumentException);
                        }
                        if (publishedService.getPolicy().getVersion() == policy.getVersion()) break block10;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ServiceCache.a(illegalArgumentException);
                    }
                    a.fine(s[23] + String.valueOf(publishedService.getGoid()) + s[1]);
                    this.a(publishedService.getGoid());
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
            }
            try {
                try {
                    if (publishedService == null || !this.c(publishedService)) break block11;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
                this.n.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVICE_CACHE_ENABLING_SERVICE, publishedService.getName(), publishedService.getId());
                this.a(publishedService, false);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ServiceCache.a(illegalArgumentException);
            }
        }
    }

    private boolean c(PublishedService publishedService) {
        return this.e.contains(publishedService.getGoid());
    }

    private void a(PublishedService publishedService, boolean bl2) {
        block3: {
            block2: {
                try {
                    if (!bl2) break block2;
                    this.e.add(publishedService.getGoid());
                    break block3;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
            }
            this.e.remove(publishedService.getGoid());
        }
    }

    private void d(PublishedService publishedService) {
        Goid goid = publishedService.getGoid();
        Policy policy = publishedService.getPolicy();
        try {
            this.b.remove(goid);
            if (policy != null) {
                this.p.remove(policy.getGoid());
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ServiceCache.a(illegalArgumentException);
        }
        try {
            this.c.remove(goid);
            this.q.notifyServiceDeleted(publishedService);
            if (policy != null) {
                policy.forceRecompile();
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ServiceCache.a(illegalArgumentException);
        }
        String[] stringArray = s;
        a.finest(stringArray[16] + publishedService.getName() + stringArray[6] + String.valueOf(publishedService.getGoid()));
    }

    public Collection<PublishedService> getCachedServices() {
        this.l.readLock().lock();
        try {
            Collection<PublishedService> collection = Collections.unmodifiableCollection(this.b.values());
            return collection;
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    public PublishedService getCachedService(Goid goid) {
        PublishedService publishedService = null;
        this.l.readLock().lock();
        try {
            publishedService = this.b.get(goid);
        }
        finally {
            this.l.readLock().unlock();
        }
        return publishedService;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public PublishedService getCachedServiceByPolicy(Goid goid) {
        PublishedService publishedService = null;
        this.l.readLock().lock();
        try {
            for (PublishedService publishedService2 : this.b.values()) {
                Policy policy = publishedService2.getPolicy();
                try {
                    if (policy == null || !policy.getGoid().equals((Object)goid)) continue;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
                publishedService = publishedService2;
                break;
            }
        }
        finally {
            this.l.readLock().unlock();
        }
        return publishedService;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public List<PublishedService> getInternalServices() {
        ArrayList<PublishedService> arrayList = new ArrayList<PublishedService>();
        this.l.readLock().lock();
        try {
            for (PublishedService publishedService : this.b.values()) {
                try {
                    if (!publishedService.isInternal()) continue;
                    arrayList.add(publishedService);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                    return arrayList;
                }
            }
        }
        finally {
            this.l.readLock().unlock();
        }
    }

    public Collection<ServiceStatistics> getAllServiceStatistics() {
        return new ArrayList<ServiceStatistics>(this.c.values());
    }

    public ServiceStatistics getServiceStatistics(Goid goid) {
        ServiceStatistics serviceStatistics = (ServiceStatistics)this.c.get(goid);
        if (serviceStatistics == null) {
            serviceStatistics = new ServiceStatistics(goid);
            ServiceStatistics serviceStatistics2 = this.c.putIfAbsent(goid, serviceStatistics);
            try {
                if (serviceStatistics2 != null) {
                    return serviceStatistics2;
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ServiceCache.a(illegalArgumentException);
            }
        }
        return serviceStatistics;
    }

    public void afterPropertiesSet() throws Exception {
        this.n = new Auditor(this, this.getApplicationContext(), a);
        this.a();
    }

    public void destroy() throws Exception {
        try {
            this.k.cancel();
            if (this.j != null) {
                this.j.shutdown();
            }
        }
        catch (Exception exception) {
            throw ServiceCache.a(exception);
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Could not resolve type clashes
     * Unable to fully structure code
     */
    private void c() {
        block45: {
            var1_1 = new LinkedList<Pair<Goid, CachedServiceNotificationType>>();
            var2_2 = this.l.readLock();
            var2_2.lock();
            var3_3 = this.b();
            try {
                var4_4 = this.g.findVersionMap();
            }
            catch (FindException var5_5) {
                var18_7 = ServiceCache.s;
                ServiceCache.a.log(Level.SEVERE, var18_7[5], var5_5);
                if (var2_2 != null) {
                    var2_2.unlock();
                }
                this.getApplicationContext().publishEvent((ApplicationEvent)new ServiceReloadEvent(this));
                return;
            }
            try {
                block44: {
                    var5_6 = new ArrayList<Object>();
                    var6_9 = new ArrayList<Object>();
                    for (Object var8_11 : var4_4.keySet()) {
                        var9_12 = var3_3.get(var8_11);
                        try {
                            if (var9_12 == null) {
                                ServiceCache.a.info(ServiceCache.s[18] + String.valueOf(var8_11) + ServiceCache.s[37]);
                                var5_6.add(var8_11);
                                continue;
                            }
                        }
                        catch (FindException v0) {
                            throw ServiceCache.a((Exception)v0);
                        }
                        var10_13 = (Integer)var4_4.get(var8_11);
                        try {
                            if (var10_13.equals(var9_12)) continue;
                            var5_6.add(var8_11);
                            ServiceCache.a.info(ServiceCache.s[23] + String.valueOf(var8_11) + ServiceCache.s[2]);
                        }
                        catch (FindException v1) {
                            throw ServiceCache.a((Exception)v1);
                        }
                    }
                    for (Object var8_11 : var3_3.keySet()) {
                        try {
                            if (var4_4.get(var8_11) != null) continue;
                            var1_1.add(new Pair(var8_11, (Object)CachedServiceNotificationType.DELETED));
                            var6_9.add(var8_11);
                            ServiceCache.a.info(ServiceCache.s[23] + String.valueOf(var8_11) + ServiceCache.s[28]);
                        }
                        catch (FindException v2) {
                            throw ServiceCache.a((Exception)v2);
                        }
                    }
                    try {
                        if (!var5_6.isEmpty() || !var6_9.isEmpty()) break block44;
                    }
                    catch (FindException v3) {
                        throw ServiceCache.a((Exception)v3);
                    }
                    var2_2.unlock();
                    var2_2 = null;
                    break block45;
                }
                var2_2.unlock();
                var2_2 = null;
                var7_10 = this.l.writeLock();
                var7_10.lock();
                try {
                    for (Integer var9_12 : var5_6) {
                        try {
                            var10_13 = (PublishedService)this.g.findByPrimaryKey((Goid)var9_12);
                        }
                        catch (FindException var11_15) {
                            var10_13 = null;
                            var18_8 = ServiceCache.s;
                            ServiceCache.a.log(Level.WARNING, var18_8[26], var11_15);
                        }
                        if (var10_13 == null) continue;
                        var11_14 = var10_13.getGoid();
                        var12_16 = var10_13.getPolicy();
                        var13_17 = null;
                        if (var12_16 != null) {
                            var13_17 = this.p.getUniquePolicyVersionIdentifer(var12_16.getGoid());
                        }
                        if (var13_17 == null) {
                            var13_17 = Integer.toString(var10_13.getVersion());
                        }
                        var14_18 = var13_17;
                        try {
                            block47: {
                                var15_19 = this.d.get(var11_14);
                                if (var15_19 == null) ** GOTO lbl90
                                if (var15_19.equals(var14_18)) continue;
                                break block47;
                                catch (FindException v4) {
                                    throw ServiceCache.a((Exception)v4);
                                }
                            }
                            try {
                                block48: {
                                    this.a(new PublishedService((PublishedService)var10_13, true), var1_1);
                                    if (var15_19 == null) continue;
                                    break block48;
                                    catch (FindException v5) {
                                        throw ServiceCache.a((Exception)v5);
                                    }
                                }
                                ServiceCache.a.log(Level.INFO, ServiceCache.s[24] + String.valueOf(var11_14) + ServiceCache.s[25]);
                                this.d.remove(var11_14);
                            }
                            catch (FindException v6) {
                                throw ServiceCache.a((Exception)v6);
                            }
                        }
                        catch (ServerPolicyException var15_20) {
                            var18_8 = ServiceCache.s;
                            ServiceCache.a.log(Level.WARNING, var18_8[11] + String.valueOf(var11_14) + var18_8[33] + ExceptionUtils.getMessage((Throwable)var15_20), (Throwable)var15_20);
                            this.d.put(var11_14, var14_18);
                        }
                    }
                    for (Integer var9_12 : var6_9) {
                        var10_13 = this.b.get(var9_12);
                        try {
                            if (var10_13 == null) continue;
                            this.d((PublishedService)var10_13);
                        }
                        catch (FindException v7) {
                            throw ServiceCache.a((Exception)v7);
                        }
                    }
                    this.d();
                }
                finally {
                    var7_10.unlock();
                }
                try {
                    if (!var1_1.isEmpty()) {
                        this.a((List<Pair<Goid, CachedServiceNotificationType>>)var1_1);
                    }
                }
                catch (FindException v8) {
                    throw ServiceCache.a((Exception)v8);
                }
            }
            catch (Throwable var17_22) {
                try {
                    if (var2_2 != null) {
                        var2_2.unlock();
                    }
                }
                catch (FindException v9) {
                    throw ServiceCache.a((Exception)v9);
                }
                this.getApplicationContext().publishEvent((ApplicationEvent)new ServiceReloadEvent(this));
                throw var17_22;
            }
        }
        try {
            if (var2_2 == null) ** GOTO lbl147
            var2_2.unlock();
        }
        catch (FindException v10) {
            throw ServiceCache.a((Exception)v10);
        }
lbl147:
        // 2 sources

        this.getApplicationContext().publishEvent((ApplicationEvent)new ServiceReloadEvent(this));
    }

    private void d() {
        for (PublishedService publishedService : this.b.values()) {
            try {
                try {
                    try {
                        if (publishedService.isDisabled() || publishedService.isSoap()) continue;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ServiceCache.a(illegalArgumentException);
                    }
                    if (!s[39].equals(publishedService.getRoutingUri())) continue;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ServiceCache.a(illegalArgumentException);
                }
                this.o = publishedService.getGoid();
                return;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ServiceCache.a(illegalArgumentException);
            }
        }
        this.o = null;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[41];
                var3_1 = 0;
                var2_2 = "#13#m\u001c\u00114\u0002\u0006vi\u0017P\"\u0002B#p\u001d\u00115\u0006Ek|SS3\u0004Gvj\u0016\u00119\u0001\u0006ll\u0007U7\u0013Cg9\u0003^:\u000eEz7)#m\u001c\u00114\u0002\u0006vi\u0017P\"\u0002B#p\u001d\u00115\u0006Ek|SS3\u0004Gvj\u0016\u00119\u0012Rgx\u0007T2I@Vw\u001f^5\fCg9\u0000T$\u0011O`|SA9\u000bO``S\\7\u001e\u0006mv\u0007\u00114\u0002\u0006su\u0012R3\u0003\u0006jw\u0007^v\u0013Nf9\u0000T$\u0011O`|SR7\u0004Nf\u0007Fw\u0012S:\u0002BDfk\u0001^$GAfm\u0007X8\u0000\u0006u|\u0001B?\bHp7SE>\u000eU#p\u001dE3\u0000Tjm\n\u00115\u000fC`rSX%GUwv\u0003A?\tA#i\u0001T;\u0006Rvk\u0016]/\u0012#\u007f\u0001^;GEbz\u001bTxGAlp\u0017\f\t?l\u001dZ8\bQm'\nGp\u0000P4\u000bCg#S\u0010vi\u0017P\"\u0002B#j\u0016C \u000eEf9\u000eb}\u0017T2GUfk\u0005X5\u0002\u0006\u0014Sv\u001fX5\u001e\u0006ev\u0001\u0011%\u0002Tup\u0010TvD\u0003nj]\u0016Al\u001a]2\u000eHd9\u0000T$\u0011O`|SR7\u0004Nf `v\u0006]2GHlmSD&\u0003Gw|SB3\u0015Pjz\u0016\u00115\u0006Ek|I\u0011\u0017Al\u001a]\"GUfk\u0005X5\u0002\u0006`x\u0010Y3GOm9\u0010q|\u001e^ \u0002B#j\u0016C \u000eEf9(Ex\u001a]3\u0003\u0006wvSX8\u000eRjx\u001fX,\u0002\u0006p|\u0001G?\u0004C#j\u0007P\"\u000eUwp\u0010Bx\bp|\u0001G?\u0004C#\t#o\u0016C%\u000eIm$\u000f#p\u001d\u00115\u0006Ek|]\u00119\u000eB>\u0018Fa\u0010T&\u0013OlwSS#\u000eJgp\u001dVv\u0004G`q\u0016\u001a`v\u0006]2GHlmSV3\u0013\u0006p|\u0001G?\u0004C#{\u0012R=\bp|\u0001G?\u0004C#\u0014Sv\u001fX5\u001e\u0006ev\u0001\u0011%\u0002Tup\u0010TvD\u0015#p\u0000\u00118\b\u0006ov\u001dV3\u0015\u0006jw\u0005P:\u000eB;p|\u0001G?\u0004C#j\u0010Y3\u0003So|\u0017\u00110\bT#l\u0003U7\u0013C#v\u0001\u00117\u0003Bjm\u001a^8\u0004Gmw\u001cEv\u0005C#k\u0016E$\u000eCu|\u0017,jw\u001aE?\u0006Rf9\u0000T$\u0011O`|SR7\u0004Nf9\u0005T$\u0014OlwSR>\u0002Eh9\u0003C9\u0004Cpj8#m\u001c\u00114\u0002\u0006g|\u001fT\"\u0002B#\u007f\u0001^;GEbz\u001bTv\u0005C`x\u0006B3GHl9\u001f^8\u0000Cq9\u001a_v\u0003Gwx\u0011P%\u0002\b\u0017`x\u0010Y3GGok\u0016P2\u001e\u0006al\u001a]\"G\u000e<0\u000f*9\u001bP%GHl9\u0003^:\u000eEzWGp\u0000P4\u000bOm~Sa#\u0005Jjj\u001bT24Cqo\u001aR3G\u0005x)\u000e\u0011~\u001c\u0017~0H\u0011&\bJjz\n\u00115\bSo}S_9\u0013\u0006a|SR9\nVju\u0016UvOGpj\u0016C\"\u000eIm9\b\u0003+G]0dZ9Vw\u001f^5\fCg9\u0000T$\u0011O`|S\\7\u001e\u0006mv\u0007\u00114\u0002\u0006su\u0012R3\u0003\u0006jw\u0007^v\u0013Nf9\u0000T$\u0011O`|SR7\u0004Nf\r#p\u0000\u0011?\tPbu\u001aUlG\u0015P|\u0001G?\u0004C#z\u0012R>\u0002\u0006q|\u0015C3\u0014N\u000f#p\u001d\u00115\u0006Ek|]\u00119\u000eB>\tP|\u0001G?\u0004C#:\u0016#m\u001c\u00114\u0002\u0006b}\u0017T2GRl9\u0010P5\u000fC-CGp\u0000P4\u000bOm~Sa#\u0005Jjj\u001bT24Cqo\u001aR3G\u0005x)\u000e\u0011~\u001c\u0017~0H\u0011&\bJjz\n\u00115\bSo}S_9\u0013\u0006a|SR9\nVju\u0016U";
                var4_3 = "#13#m\u001c\u00114\u0002\u0006vi\u0017P\"\u0002B#p\u001d\u00115\u0006Ek|SS3\u0004Gvj\u0016\u00119\u0001\u0006ll\u0007U7\u0013Cg9\u0003^:\u000eEz7)#m\u001c\u00114\u0002\u0006vi\u0017P\"\u0002B#p\u001d\u00115\u0006Ek|SS3\u0004Gvj\u0016\u00119\u0012Rgx\u0007T2I@Vw\u001f^5\fCg9\u0000T$\u0011O`|SA9\u000bO``S\\7\u001e\u0006mv\u0007\u00114\u0002\u0006su\u0012R3\u0003\u0006jw\u0007^v\u0013Nf9\u0000T$\u0011O`|SR7\u0004Nf\u0007Fw\u0012S:\u0002BDfk\u0001^$GAfm\u0007X8\u0000\u0006u|\u0001B?\bHp7SE>\u000eU#p\u001dE3\u0000Tjm\n\u00115\u000fC`rSX%GUwv\u0003A?\tA#i\u0001T;\u0006Rvk\u0016]/\u0012#\u007f\u0001^;GEbz\u001bTxGAlp\u0017\f\t?l\u001dZ8\bQm'\nGp\u0000P4\u000bCg#S\u0010vi\u0017P\"\u0002B#j\u0016C \u000eEf9\u000eb}\u0017T2GUfk\u0005X5\u0002\u0006\u0014Sv\u001fX5\u001e\u0006ev\u0001\u0011%\u0002Tup\u0010TvD\u0003nj]\u0016Al\u001a]2\u000eHd9\u0000T$\u0011O`|SR7\u0004Nf `v\u0006]2GHlmSD&\u0003Gw|SB3\u0015Pjz\u0016\u00115\u0006Ek|I\u0011\u0017Al\u001a]\"GUfk\u0005X5\u0002\u0006`x\u0010Y3GOm9\u0010q|\u001e^ \u0002B#j\u0016C \u000eEf9(Ex\u001a]3\u0003\u0006wvSX8\u000eRjx\u001fX,\u0002\u0006p|\u0001G?\u0004C#j\u0007P\"\u000eUwp\u0010Bx\bp|\u0001G?\u0004C#\t#o\u0016C%\u000eIm$\u000f#p\u001d\u00115\u0006Ek|]\u00119\u000eB>\u0018Fa\u0010T&\u0013OlwSS#\u000eJgp\u001dVv\u0004G`q\u0016\u001a`v\u0006]2GHlmSV3\u0013\u0006p|\u0001G?\u0004C#{\u0012R=\bp|\u0001G?\u0004C#\u0014Sv\u001fX5\u001e\u0006ev\u0001\u0011%\u0002Tup\u0010TvD\u0015#p\u0000\u00118\b\u0006ov\u001dV3\u0015\u0006jw\u0005P:\u000eB;p|\u0001G?\u0004C#j\u0010Y3\u0003So|\u0017\u00110\bT#l\u0003U7\u0013C#v\u0001\u00117\u0003Bjm\u001a^8\u0004Gmw\u001cEv\u0005C#k\u0016E$\u000eCu|\u0017,jw\u001aE?\u0006Rf9\u0000T$\u0011O`|SR7\u0004Nf9\u0005T$\u0014OlwSR>\u0002Eh9\u0003C9\u0004Cpj8#m\u001c\u00114\u0002\u0006g|\u001fT\"\u0002B#\u007f\u0001^;GEbz\u001bTv\u0005C`x\u0006B3GHl9\u001f^8\u0000Cq9\u001a_v\u0003Gwx\u0011P%\u0002\b\u0017`x\u0010Y3GGok\u0016P2\u001e\u0006al\u001a]\"G\u000e<0\u000f*9\u001bP%GHl9\u0003^:\u000eEzWGp\u0000P4\u000bOm~Sa#\u0005Jjj\u001bT24Cqo\u001aR3G\u0005x)\u000e\u0011~\u001c\u0017~0H\u0011&\bJjz\n\u00115\bSo}S_9\u0013\u0006a|SR9\nVju\u0016UvOGpj\u0016C\"\u000eIm9\b\u0003+G]0dZ9Vw\u001f^5\fCg9\u0000T$\u0011O`|S\\7\u001e\u0006mv\u0007\u00114\u0002\u0006su\u0012R3\u0003\u0006jw\u0007^v\u0013Nf9\u0000T$\u0011O`|SR7\u0004Nf\r#p\u0000\u0011?\tPbu\u001aUlG\u0015P|\u0001G?\u0004C#z\u0012R>\u0002\u0006q|\u0015C3\u0014N\u000f#p\u001d\u00115\u0006Ek|]\u00119\u000eB>\tP|\u0001G?\u0004C#:\u0016#m\u001c\u00114\u0002\u0006b}\u0017T2GRl9\u0010P5\u000fC-CGp\u0000P4\u000bOm~Sa#\u0005Jjj\u001bT24Cqo\u001aR3G\u0005x)\u000e\u0011~\u001c\u0017~0H\u0011&\bJjz\n\u00115\bSo}S_9\u0013\u0006a|SR9\nVju\u0016U".length();
                var1_4 = 2;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ServiceCache.a(v0, ServiceCache.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u001f\u0000\u0018`E,k\u0006-5sK#j\u0000t|C\n2g\u0014!|BO$";
                    var4_3 = "\u001f\u0000\u0018`E,k\u0006-5sK#j\u0000t|C\n2g\u0014!|BO$".length();
                    var1_4 = 2;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 92;
                        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++] = ServiceCache.a(v0, ServiceCache.a(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;
            }
        }
        ServiceCache.s = var5;
        ServiceCache.a = Logger.getLogger(ServiceCache.class.getName());
    }

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

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(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 -> 108;
                    case 1 -> 118;
                    case 2 -> 28;
                    case 3 -> 94;
                    case 4 -> 57;
                    case 5 -> 8;
                    default -> 73;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    public static interface ResolutionListener {
        public boolean notifyPreParseServices(Message var1, Set<ServiceMetadata> var2);

        public boolean notifyResolveCatchAll();
    }

    public static final class ServiceMetadata {
        private final PolicyMetadata a;
        private final boolean b;

        public ServiceMetadata(PolicyMetadata policyMetadata, boolean bl2) {
            this.a = policyMetadata;
            this.b = bl2;
        }

        public boolean isMultipart() {
            return this.a.isMultipart();
        }

        public boolean isWssInPolicy() {
            return this.a.isWssInPolicy();
        }

        public boolean isWssProcessingRequired() {
            return this.b;
        }
    }

    private static final class CachedServiceNotificationType
    extends Enum<CachedServiceNotificationType> {
        public static final /* enum */ CachedServiceNotificationType CREATED;
        public static final /* enum */ CachedServiceNotificationType ENABLED;
        public static final /* enum */ CachedServiceNotificationType DISABLED;
        public static final /* enum */ CachedServiceNotificationType UPDATED;
        public static final /* enum */ CachedServiceNotificationType DELETED;
        private static final /* synthetic */ CachedServiceNotificationType[] $VALUES;

        public static CachedServiceNotificationType[] values() {
            return (CachedServiceNotificationType[])$VALUES.clone();
        }

        public static CachedServiceNotificationType valueOf(String string) {
            return Enum.valueOf(CachedServiceNotificationType.class, string);
        }

        private static /* synthetic */ CachedServiceNotificationType[] $values() {
            return new CachedServiceNotificationType[]{CREATED, ENABLED, DISABLED, UPDATED, DELETED};
        }

        /*
         * Unable to fully structure code
         */
        static {
            block10: {
                block9: {
                    var0 = new String[5];
                    var4_1 = 0;
                    var3_2 = "KR2!64\u0012K\u0007ZK%! =\u0013\u0007JU \"8=\u0013";
                    var5_3 = "KR2!64\u0012K\u0007ZK%! =\u0013\u0007JU \"8=\u0013".length();
                    var2_4 = 8;
                    var1_5 = -1;
lbl7:
                    // 2 sources

                    while (true) {
                        v0 = 67;
                        v1 = ++var1_5;
                        v2 = var3_2.substring(v1, v1 + var2_4);
                        v3 = -1;
                        break block9;
                        break;
                    }
lbl13:
                    // 1 sources

                    while (true) {
                        var0[var4_1++] = CachedServiceNotificationType.a(v0, CachedServiceNotificationType.a(v2));
                        if ((var1_5 += var2_4) < var5_3) {
                            var2_4 = var3_2.charAt(var1_5);
                            ** continue;
                        }
                        var3_2 = "\n\u001flda|R\u0007\r\be`a|R";
                        var5_3 = "\n\u001flda|R\u0007\r\be`a|R".length();
                        var2_4 = 7;
                        var1_5 = -1;
lbl22:
                        // 2 sources

                        while (true) {
                            v0 = 2;
                            v4 = ++var1_5;
                            v2 = var3_2.substring(v4, v4 + var2_4);
                            v3 = 0;
                            break block9;
                            break;
                        }
                        break;
                    }
lbl28:
                    // 1 sources

                    while (true) {
                        var0[var4_1++] = CachedServiceNotificationType.a(v0, CachedServiceNotificationType.a(v2));
                        if ((var1_5 += var2_4) < var5_3) {
                            var2_4 = var3_2.charAt(var1_5);
                            ** continue;
                        }
                        break block10;
                        break;
                    }
                }
                switch (v3) {
                    default: {
                        ** continue;
                    }
                    ** case 0:
lbl39:
                    // 1 sources

                    ** continue;
                }
            }
            CachedServiceNotificationType.CREATED = new CachedServiceNotificationType();
            CachedServiceNotificationType.ENABLED = new CachedServiceNotificationType();
            CachedServiceNotificationType.DISABLED = new CachedServiceNotificationType();
            CachedServiceNotificationType.UPDATED = new CachedServiceNotificationType();
            CachedServiceNotificationType.DELETED = new CachedServiceNotificationType();
            CachedServiceNotificationType.$VALUES = CachedServiceNotificationType.$values();
        }

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

        /*
         * Handled impossible loop by duplicating code
         * Enabled aggressive block sorting
         */
        private static String a(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 -> 76;
                        case 1 -> 88;
                        case 2 -> 34;
                        case 3 -> 35;
                        case 4 -> 55;
                        case 5 -> 59;
                        default -> 20;
                    })));
                    ++n3;
                    n4 = n4;
                } while (n4 > n3);
            }
            return new String(cArray2).intern();
        }
    }

    @ManagedResource(description="Service Cache", objectName="l7tech:type=ServiceCache")
    public static class ManagedServiceCache {
        private final ServiceCache a;

        protected ManagedServiceCache(ServiceCache serviceCache) {
            this.a = serviceCache;
        }

        @ManagedAttribute(description="Cache Size", currencyTimeLimit=30)
        public int getSize() {
            return this.a.size();
        }

        @ManagedAttribute(description="Cached Services", currencyTimeLimit=30)
        public Set<Goid> getServices() {
            this.a.l.readLock().lock();
            try {
                TreeSet<Goid> treeSet = new TreeSet<Goid>(this.a.b.keySet());
                return treeSet;
            }
            finally {
                this.a.l.readLock().unlock();
            }
        }

        @ManagedAttribute(description="Services With Errors", currencyTimeLimit=30)
        public Set<Goid> getServicesWithErrors() {
            this.a.l.readLock().lock();
            try {
                TreeSet<Goid> treeSet = new TreeSet<Goid>(this.a.d.keySet());
                return treeSet;
            }
            finally {
                this.a.l.readLock().unlock();
            }
        }

        @ManagedAttribute(description="Disabled Services", currencyTimeLimit=30)
        public Set<Goid> getDisabledServices() {
            this.a.l.readLock().lock();
            try {
                TreeSet<Goid> treeSet = new TreeSet<Goid>(this.a.e);
                return treeSet;
            }
            finally {
                this.a.l.readLock().unlock();
            }
        }
    }
}

