package com.worklight.jsonstore.api;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.worklight.androidgap.jsonstore.security.SecurityManager;
import com.worklight.jsonstore.database.DatabaseAccessor;
import com.worklight.jsonstore.database.DatabaseManager;
import com.worklight.jsonstore.database.DatabaseSchema;
import com.worklight.jsonstore.exceptions.JSONStoreChangePasswordException;
import com.worklight.jsonstore.exceptions.JSONStoreCloseAllException;
import com.worklight.jsonstore.exceptions.JSONStoreDatabaseClosedException;
import com.worklight.jsonstore.exceptions.JSONStoreDestroyFailureException;
import com.worklight.jsonstore.exceptions.JSONStoreFileAccessException;
import com.worklight.jsonstore.exceptions.JSONStoreInvalidPasswordException;
import com.worklight.jsonstore.exceptions.JSONStoreInvalidSchemaException;
import com.worklight.jsonstore.exceptions.JSONStoreMigrationException;
import com.worklight.jsonstore.exceptions.JSONStoreSchemaMismatchException;
import com.worklight.jsonstore.exceptions.JSONStoreTransactionDuringInitException;
import com.worklight.jsonstore.exceptions.JSONStoreTransactionFailureException;
import com.worklight.jsonstore.util.JSONStoreLogger;
import com.worklight.jsonstore.util.JSONStoreLogger.JSONStoreAnalyticsLogInstance;
import com.worklight.jsonstore.util.JSONStoreUtil;
import com.worklight.nativeandroid.common.WLUtils;
import com.worklight.wlclient.api.SecurityUtils;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class WLJSONStore
{
  private static final String LIBCRYPTO_FILE_NAME = "libcrypto.so.1.0.0";
  private static final int NUM_BYTES_FOR_SALT = 32;
  private static WLJSONStore instance;
  private static boolean transactionInProgress = false;
  private Map<String, JSONStoreCollection> collectionMap = new HashMap();
  private Context context = null;
  private JSONStoreLogger logger = JSONStoreUtil.getCoreLogger();
  private String username;

  private WLJSONStore(Context paramContext)
  {
    this.context = paramContext;
    WLUtils.loadLib(paramContext, "libcrypto.so.1.0.0");
  }

  private void checkVersionMigration(Context paramContext)
    throws JSONStoreFileAccessException, JSONStoreMigrationException
  {
    JSONStoreLogger.logFileInfo(getFileInfo());
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("JsonstorePrefs", 0);
    if (localSharedPreferences.getString("JsonstoreVer", null) == null)
    {
      this.logger.logTrace("Performing migration to JSONStore 2.0");
      File localFile1 = paramContext.getDatabasePath("wljsonstore");
      if ((!localFile1.exists()) && (!localFile1.mkdirs()))
      {
        JSONStoreFileAccessException localJSONStoreFileAccessException = new JSONStoreFileAccessException("Unable to create jsonstore directory.");
        this.logger.logTrace("Unable to create jsonstore directory.");
        throw localJSONStoreFileAccessException;
      }
      File localFile2 = paramContext.getDatabasePath("com.ibm.worklight.database");
      if (localFile2.exists())
      {
        if (localFile2.renameTo(new File(localFile1, "jsonstore.sqlite")))
          this.logger.logTrace("Migration to JSONStore 2.0 successful.");
      }
      else
      {
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        localEditor.putString("JsonstoreVer", "2.0");
        localEditor.commit();
      }
    }
    else
    {
      return;
    }
    JSONStoreMigrationException localJSONStoreMigrationException = new JSONStoreMigrationException("Unable to migrate existing JSONStore database to version 2.0");
    this.logger.logTrace("Unable to migrate existing JSONStore database to version 2.0");
    throw localJSONStoreMigrationException;
  }

  private void disownAllCollections()
  {
    Iterator localIterator = this.collectionMap.values().iterator();
    while (localIterator.hasNext())
      ((JSONStoreCollection)localIterator.next()).disown();
    this.collectionMap.clear();
  }

  private Context getContext()
  {
    return this.context;
  }

  public static WLJSONStore getInstance(Context paramContext)
  {
    if (instance == null)
    {
      WLUtils.loadLib(paramContext, "libcrypto.so.1.0.0");
      instance = new WLJSONStore(paramContext);
    }
    return instance;
  }

  private void handleUsernameAndPassword(DatabaseManager paramDatabaseManager, String paramString1, String paramString2, String paramString3)
    throws JSONStoreCloseAllException, JSONStoreInvalidPasswordException
  {
    if (paramString1 == null)
    {
      if (paramDatabaseManager.getDbPath() == null)
        paramDatabaseManager.setDbPath("jsonstore.sqlite");
      if (!paramDatabaseManager.getDbPath().equalsIgnoreCase("jsonstore.sqlite"))
      {
        JSONStoreCloseAllException localJSONStoreCloseAllException2 = new JSONStoreCloseAllException("You tried to login with a user that is not the default user that is currently logged in. Call closeAll first.");
        this.logger.logTrace("You tried to login with a user that is not the default user that is currently logged in. Call closeAll first.");
        throw localJSONStoreCloseAllException2;
      }
    }
    else
    {
      if (paramDatabaseManager.getDbPath() != null)
        break label127;
      paramDatabaseManager.setDbPath(paramString1);
    }
    while (true)
    {
      String str2;
      if ((paramString2 != null) && (!paramString2.equals("")))
        str2 = SecurityUtils.getRandomString(32);
      try
      {
        if (!SecurityManager.getInstance(getContext()).isDPKAvailable(paramString1))
          SecurityManager.getInstance(getContext()).storeDPK(paramString2, paramString1, paramString3, str2, false);
        paramDatabaseManager.setDatabaseKey(getContext(), paramString2, paramString1);
        return;
        label127: if (paramDatabaseManager.getDbPath().equals(paramString1 + ".sqlite"))
          continue;
        String str1 = "You tried to login with a user that is not " + paramDatabaseManager.getDbPath() + ". Call closeAll first.";
        JSONStoreCloseAllException localJSONStoreCloseAllException1 = new JSONStoreCloseAllException(str1);
        this.logger.logTrace(str1);
        throw localJSONStoreCloseAllException1;
      }
      catch (Throwable localThrowable)
      {
        JSONStoreInvalidPasswordException localJSONStoreInvalidPasswordException = new JSONStoreInvalidPasswordException("Error setting key.", localThrowable);
        this.logger.logTrace("Error setting key.");
        throw localJSONStoreInvalidPasswordException;
      }
    }
  }

  private boolean provisionDatabase(JSONStoreCollection paramJSONStoreCollection, DatabaseSchema paramDatabaseSchema, String paramString1, String paramString2, boolean paramBoolean, String paramString3)
    throws JSONStoreFileAccessException, JSONStoreMigrationException, JSONStoreCloseAllException, JSONStoreInvalidPasswordException, JSONStoreSchemaMismatchException
  {
    checkVersionMigration(getContext());
    DatabaseManager localDatabaseManager = DatabaseManager.getInstance();
    handleUsernameAndPassword(localDatabaseManager, paramString1, paramString2, paramString3);
    if ((!paramBoolean) && (paramDatabaseSchema.isSchemaMismatched(paramJSONStoreCollection.getName(), paramDatabaseSchema, getContext())))
    {
      JSONStoreSchemaMismatchException localJSONStoreSchemaMismatchException = new JSONStoreSchemaMismatchException("Table schema mismatch for existing collection.");
      this.logger.logTrace("Table schema mismatch for existing collection.");
      throw localJSONStoreSchemaMismatchException;
    }
    if (!localDatabaseManager.provisionDatabase(getContext(), paramDatabaseSchema, paramBoolean))
      try
      {
        localDatabaseManager.getDatabase(paramJSONStoreCollection.getName()).getReadableDatabase();
        return false;
      }
      catch (Exception localException)
      {
        JSONStoreFileAccessException localJSONStoreFileAccessException = new JSONStoreFileAccessException("Could not retreive a database accessor.", localException);
        this.logger.logTrace("Could not retreive a database accessor.");
        throw localJSONStoreFileAccessException;
      }
    return true;
  }

  public void changePassword(String paramString1, String paramString2, String paramString3)
    throws JSONStoreDatabaseClosedException, JSONStoreChangePasswordException
  {
    JSONStoreLogger.JSONStoreAnalyticsLogInstance localJSONStoreAnalyticsLogInstance = JSONStoreLogger.startAnalyticsInstance(paramString1, "", JSONStoreLogger.OPERATION_CHANGE_PASSWORD);
    try
    {
      DatabaseManager.getInstance().getDatabase();
      if (!DatabaseManager.getInstance().isDatabaseOpen())
        throw new JSONStoreDatabaseClosedException();
    }
    catch (Exception localException)
    {
      throw new JSONStoreDatabaseClosedException();
    }
    finally
    {
      localJSONStoreAnalyticsLogInstance.end();
    }
    SecurityManager localSecurityManager = SecurityManager.getInstance(this.context);
    try
    {
      localSecurityManager.storeDPK(paramString3, paramString1, localSecurityManager.getDPK(paramString2, paramString1), localSecurityManager.getSalt(paramString1), true);
      localJSONStoreAnalyticsLogInstance.end();
      return;
    }
    catch (Throwable localThrowable)
    {
      throw new JSONStoreChangePasswordException(localThrowable);
    }
  }

  public void closeAll()
    throws JSONStoreCloseAllException, JSONStoreDatabaseClosedException, JSONStoreTransactionFailureException
  {
    JSONStoreLogger.JSONStoreAnalyticsLogInstance localJSONStoreAnalyticsLogInstance = JSONStoreLogger.startAnalyticsInstance(this.username, "", JSONStoreLogger.OPERATION_CLOSE_ALL);
    try
    {
      if (transactionInProgress)
        throw new JSONStoreTransactionFailureException("Cannot close collections while executing a transaction.");
    }
    finally
    {
      localJSONStoreAnalyticsLogInstance.end();
    }
    DatabaseManager localDatabaseManager = DatabaseManager.getInstance();
    if (!localDatabaseManager.isDatabaseOpen())
    {
      JSONStoreDatabaseClosedException localJSONStoreDatabaseClosedException = new JSONStoreDatabaseClosedException("Could not close all collections. The database is not open.");
      this.logger.logTrace("Could not close all collections. The database is not open.");
      throw localJSONStoreDatabaseClosedException;
    }
    try
    {
      localDatabaseManager.clearDbPath();
      localDatabaseManager.clearDatabaseKey();
      localDatabaseManager.closeDatabase();
      disownAllCollections();
      localJSONStoreAnalyticsLogInstance.end();
      return;
    }
    catch (Throwable localThrowable)
    {
      JSONStoreCloseAllException localJSONStoreCloseAllException = new JSONStoreCloseAllException("Could not close the database. An exception occurred.", localThrowable);
      this.logger.logTrace("Could not close the database. An exception occurred.");
      throw localJSONStoreCloseAllException;
    }
  }

  // ERROR //
  public boolean commitTransaction()
    throws com.worklight.jsonstore.exceptions.JSONStoreNoTransactionInProgressException, JSONStoreTransactionFailureException, JSONStoreDatabaseClosedException
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 335	com/worklight/jsonstore/api/WLJSONStore:username	Ljava/lang/String;
    //   6: ldc 205
    //   8: getstatic 364	com/worklight/jsonstore/util/JSONStoreLogger:OPERATION_COMMIT_TRANSACTION	Ljava/lang/String;
    //   11: invokestatic 308	com/worklight/jsonstore/util/JSONStoreLogger:startAnalyticsInstance	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance;
    //   14: astore_2
    //   15: invokestatic 265	com/worklight/jsonstore/database/DatabaseManager:getInstance	()Lcom/worklight/jsonstore/database/DatabaseManager;
    //   18: invokevirtual 311	com/worklight/jsonstore/database/DatabaseManager:getDatabase	()Lcom/worklight/jsonstore/database/DatabaseAccessor;
    //   21: astore 5
    //   23: aload_0
    //   24: invokevirtual 367	com/worklight/jsonstore/api/WLJSONStore:isTransactionInProgress	()Z
    //   27: ifne +37 -> 64
    //   30: new 361	com/worklight/jsonstore/exceptions/JSONStoreNoTransactionInProgressException
    //   33: dup
    //   34: ldc_w 369
    //   37: invokespecial 370	com/worklight/jsonstore/exceptions/JSONStoreNoTransactionInProgressException:<init>	(Ljava/lang/String;)V
    //   40: athrow
    //   41: astore 4
    //   43: aload_2
    //   44: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   47: aload 4
    //   49: athrow
    //   50: astore_1
    //   51: aload_0
    //   52: monitorexit
    //   53: aload_1
    //   54: athrow
    //   55: astore_3
    //   56: new 299	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException
    //   59: dup
    //   60: invokespecial 315	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException:<init>	()V
    //   63: athrow
    //   64: aload 5
    //   66: invokeinterface 374 1 0
    //   71: invokevirtual 379	net/sqlcipher/database/SQLiteDatabase:setTransactionSuccessful	()V
    //   74: aload 5
    //   76: invokeinterface 374 1 0
    //   81: invokevirtual 382	net/sqlcipher/database/SQLiteDatabase:endTransaction	()V
    //   84: iconst_0
    //   85: putstatic 27	com/worklight/jsonstore/api/WLJSONStore:transactionInProgress	Z
    //   88: aload_2
    //   89: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   92: aload_0
    //   93: monitorexit
    //   94: iconst_1
    //   95: ireturn
    //   96: astore 6
    //   98: new 333	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException
    //   101: dup
    //   102: aload 6
    //   104: invokespecial 383	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException:<init>	(Ljava/lang/Throwable;)V
    //   107: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   15	23	41	finally
    //   23	41	41	finally
    //   56	64	41	finally
    //   64	88	41	finally
    //   98	108	41	finally
    //   2	15	50	finally
    //   43	50	50	finally
    //   88	92	50	finally
    //   15	23	55	java/lang/Exception
    //   64	88	96	java/lang/Throwable
  }

  public void destroy()
    throws JSONStoreDestroyFailureException, JSONStoreTransactionFailureException
  {
    JSONStoreLogger.JSONStoreAnalyticsLogInstance localJSONStoreAnalyticsLogInstance = JSONStoreLogger.startAnalyticsInstance(this.username, "", JSONStoreLogger.OPERATION_DESTROY);
    try
    {
      if (transactionInProgress)
        throw new JSONStoreTransactionFailureException("Cannot destroy store while executing a transaction.");
    }
    finally
    {
      localJSONStoreAnalyticsLogInstance.end();
    }
    DatabaseManager localDatabaseManager = DatabaseManager.getInstance();
    localDatabaseManager.destroyKeychain(getContext());
    localDatabaseManager.destroyPreferences(getContext());
    localDatabaseManager.clearDbPath();
    localDatabaseManager.clearDatabaseKey();
    if (localDatabaseManager.isDatabaseOpen())
      localDatabaseManager.closeDatabase();
    disownAllCollections();
    transactionInProgress = false;
    if (localDatabaseManager.destroyDatabase(getContext()) != 0)
    {
      JSONStoreDestroyFailureException localJSONStoreDestroyFailureException = new JSONStoreDestroyFailureException("There was an error when destroying the JSONStore. The destroyDatabase failed.");
      this.logger.logTrace("There was an error when destroying the JSONStore. The destroyDatabase failed.");
      throw localJSONStoreDestroyFailureException;
    }
    localJSONStoreAnalyticsLogInstance.end();
  }

  public JSONStoreCollection getCollectionByName(String paramString)
  {
    JSONStoreCollection localJSONStoreCollection = (JSONStoreCollection)this.collectionMap.get(paramString);
    if (localJSONStoreCollection == null)
      return null;
    try
    {
      DatabaseManager.getInstance().getDatabase(paramString);
      return localJSONStoreCollection;
    }
    catch (Exception localException)
    {
      removeCollectionReference(localJSONStoreCollection);
    }
    return null;
  }

  // ERROR //
  public List<JSONStoreFileInfo> getFileInfo()
  {
    // Byte code:
    //   0: new 418	java/util/TreeMap
    //   3: dup
    //   4: invokespecial 419	java/util/TreeMap:<init>	()V
    //   7: astore_1
    //   8: aload_0
    //   9: getfield 33	com/worklight/jsonstore/api/WLJSONStore:context	Landroid/content/Context;
    //   12: ldc 91
    //   14: invokevirtual 95	android/content/Context:getDatabasePath	(Ljava/lang/String;)Ljava/io/File;
    //   17: astore_2
    //   18: aload_2
    //   19: invokevirtual 101	java/io/File:exists	()Z
    //   22: ifeq +271 -> 293
    //   25: aload_2
    //   26: invokevirtual 422	java/io/File:isDirectory	()Z
    //   29: ifeq +264 -> 293
    //   32: aload_2
    //   33: invokevirtual 426	java/io/File:listFiles	()[Ljava/io/File;
    //   36: astore_3
    //   37: aload_3
    //   38: arraylength
    //   39: istore 4
    //   41: iconst_0
    //   42: istore 5
    //   44: aconst_null
    //   45: astore 6
    //   47: iload 5
    //   49: iload 4
    //   51: if_icmpge +239 -> 290
    //   54: aload_3
    //   55: iload 5
    //   57: aaload
    //   58: astore 8
    //   60: aload 8
    //   62: ifnull +255 -> 317
    //   65: aload 8
    //   67: invokevirtual 429	java/io/File:isFile	()Z
    //   70: ifeq +247 -> 317
    //   73: aload 8
    //   75: invokevirtual 430	java/io/File:getName	()Ljava/lang/String;
    //   78: ldc 242
    //   80: invokevirtual 433	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   83: ifeq +234 -> 317
    //   86: aload 8
    //   88: invokevirtual 430	java/io/File:getName	()Ljava/lang/String;
    //   91: astore 10
    //   93: aload 10
    //   95: iconst_0
    //   96: aload 10
    //   98: invokevirtual 437	java/lang/String:length	()I
    //   101: ldc 242
    //   103: invokevirtual 437	java/lang/String:length	()I
    //   106: isub
    //   107: invokevirtual 441	java/lang/String:substring	(II)Ljava/lang/String;
    //   110: astore 11
    //   112: aload 8
    //   114: invokevirtual 444	java/io/File:length	()J
    //   117: lstore 12
    //   119: iconst_1
    //   120: istore 14
    //   122: new 446	java/io/FileInputStream
    //   125: dup
    //   126: aload 8
    //   128: invokespecial 449	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   131: astore 9
    //   133: bipush 6
    //   135: newarray byte
    //   137: astore 20
    //   139: aload 9
    //   141: aload 20
    //   143: iconst_0
    //   144: bipush 6
    //   146: invokevirtual 453	java/io/FileInputStream:read	([BII)I
    //   149: pop
    //   150: new 196	java/lang/String
    //   153: dup
    //   154: aload 20
    //   156: invokespecial 456	java/lang/String:<init>	([B)V
    //   159: ldc_w 458
    //   162: invokevirtual 200	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   165: istore 22
    //   167: iload 22
    //   169: ifeq +6 -> 175
    //   172: iconst_0
    //   173: istore 14
    //   175: aload 9
    //   177: ifnull +8 -> 185
    //   180: aload 9
    //   182: invokevirtual 461	java/io/FileInputStream:close	()V
    //   185: aload_1
    //   186: aload 11
    //   188: new 463	com/worklight/jsonstore/api/JSONStoreFileInfo
    //   191: dup
    //   192: aload 11
    //   194: lload 12
    //   196: iload 14
    //   198: invokespecial 466	com/worklight/jsonstore/api/JSONStoreFileInfo:<init>	(Ljava/lang/String;JZ)V
    //   201: invokeinterface 470 3 0
    //   206: pop
    //   207: iinc 5 1
    //   210: aload 9
    //   212: astore 6
    //   214: goto -167 -> 47
    //   217: astore 23
    //   219: aload 23
    //   221: invokevirtual 473	java/io/IOException:printStackTrace	()V
    //   224: goto -39 -> 185
    //   227: astore 15
    //   229: aload 6
    //   231: astore 9
    //   233: aload 15
    //   235: invokevirtual 473	java/io/IOException:printStackTrace	()V
    //   238: aload 9
    //   240: ifnull -55 -> 185
    //   243: aload 9
    //   245: invokevirtual 461	java/io/FileInputStream:close	()V
    //   248: goto -63 -> 185
    //   251: astore 18
    //   253: aload 18
    //   255: invokevirtual 473	java/io/IOException:printStackTrace	()V
    //   258: goto -73 -> 185
    //   261: astore 16
    //   263: aload 6
    //   265: astore 9
    //   267: aload 9
    //   269: ifnull +8 -> 277
    //   272: aload 9
    //   274: invokevirtual 461	java/io/FileInputStream:close	()V
    //   277: aload 16
    //   279: athrow
    //   280: astore 17
    //   282: aload 17
    //   284: invokevirtual 473	java/io/IOException:printStackTrace	()V
    //   287: goto -10 -> 277
    //   290: aload 6
    //   292: pop
    //   293: new 475	java/util/ArrayList
    //   296: dup
    //   297: aload_1
    //   298: invokeinterface 146 1 0
    //   303: invokespecial 478	java/util/ArrayList:<init>	(Ljava/util/Collection;)V
    //   306: areturn
    //   307: astore 16
    //   309: goto -42 -> 267
    //   312: astore 15
    //   314: goto -81 -> 233
    //   317: aload 6
    //   319: astore 9
    //   321: goto -114 -> 207
    //
    // Exception table:
    //   from	to	target	type
    //   180	185	217	java/io/IOException
    //   122	133	227	java/io/IOException
    //   243	248	251	java/io/IOException
    //   122	133	261	finally
    //   272	277	280	java/io/IOException
    //   133	167	307	finally
    //   233	238	307	finally
    //   133	167	312	java/io/IOException
  }

  String getUsername()
  {
    return this.username;
  }

  public boolean isTransactionInProgress()
  {
    try
    {
      boolean bool = transactionInProgress;
      return bool;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public void openCollections(List<JSONStoreCollection> paramList)
    throws JSONStoreInvalidSchemaException, JSONStoreFileAccessException, JSONStoreMigrationException, JSONStoreCloseAllException, JSONStoreInvalidPasswordException, JSONStoreSchemaMismatchException, JSONStoreTransactionDuringInitException
  {
    openCollections(paramList, null);
  }

  public void openCollections(List<JSONStoreCollection> paramList, JSONStoreInitOptions paramJSONStoreInitOptions)
    throws JSONStoreInvalidSchemaException, JSONStoreFileAccessException, JSONStoreMigrationException, JSONStoreCloseAllException, JSONStoreInvalidPasswordException, JSONStoreSchemaMismatchException, JSONStoreTransactionDuringInitException
  {
    if (transactionInProgress)
      throw new JSONStoreTransactionDuringInitException("Cannot open collections while executing a transaction.");
    label21: boolean bool1;
    String str1;
    String str2;
    Iterator localIterator;
    if (paramList == null)
    {
      return;
    }
    else
    {
      if (paramJSONStoreInitOptions == null)
        paramJSONStoreInitOptions = new JSONStoreInitOptions();
      bool1 = paramJSONStoreInitOptions.isClear();
      str1 = paramJSONStoreInitOptions.getPassword();
      this.username = paramJSONStoreInitOptions.getUsername();
      str2 = paramJSONStoreInitOptions.getSecureRandom();
      JSONStoreLogger.setAnalyticsEnabled(paramJSONStoreInitOptions.isAnalyticsEnabled());
      localIterator = paramList.iterator();
    }
    while (true)
    {
      if (!localIterator.hasNext())
        break label21;
      JSONStoreCollection localJSONStoreCollection = (JSONStoreCollection)localIterator.next();
      if (localJSONStoreCollection == null)
        break;
      JSONStoreLogger.JSONStoreAnalyticsLogInstance localJSONStoreAnalyticsLogInstance = JSONStoreLogger.startAnalyticsInstance(this.username, localJSONStoreCollection.getName(), JSONStoreLogger.OPERATION_OPEN);
      try
      {
        DatabaseSchema localDatabaseSchema = new DatabaseSchema(localJSONStoreCollection.getName(), localJSONStoreCollection.getAllSearchFields());
        boolean bool2 = provisionDatabase(localJSONStoreCollection, localDatabaseSchema, this.username, str1, bool1, str2);
        this.collectionMap.put(localJSONStoreCollection.getName(), localJSONStoreCollection);
        localJSONStoreCollection.initialize(this, localDatabaseSchema, bool2);
        localJSONStoreAnalyticsLogInstance.end();
      }
      catch (Throwable localThrowable)
      {
        JSONStoreInvalidSchemaException localJSONStoreInvalidSchemaException = new JSONStoreInvalidSchemaException("Error when validating schema.", localThrowable);
        this.logger.logTrace("Error when validating schema.");
        throw localJSONStoreInvalidSchemaException;
      }
    }
  }

  void removeCollectionReference(JSONStoreCollection paramJSONStoreCollection)
  {
    paramJSONStoreCollection.disown();
    this.collectionMap.remove(paramJSONStoreCollection);
  }

  // ERROR //
  public boolean rollbackTransaction()
    throws com.worklight.jsonstore.exceptions.JSONStoreNoTransactionInProgressException, JSONStoreDatabaseClosedException, JSONStoreTransactionFailureException
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 335	com/worklight/jsonstore/api/WLJSONStore:username	Ljava/lang/String;
    //   6: ldc 205
    //   8: getstatic 540	com/worklight/jsonstore/util/JSONStoreLogger:OPERATION_ROLLBACK_TRANSACTION	Ljava/lang/String;
    //   11: invokestatic 308	com/worklight/jsonstore/util/JSONStoreLogger:startAnalyticsInstance	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance;
    //   14: astore_2
    //   15: invokestatic 265	com/worklight/jsonstore/database/DatabaseManager:getInstance	()Lcom/worklight/jsonstore/database/DatabaseManager;
    //   18: invokevirtual 311	com/worklight/jsonstore/database/DatabaseManager:getDatabase	()Lcom/worklight/jsonstore/database/DatabaseAccessor;
    //   21: astore 5
    //   23: aload_0
    //   24: invokevirtual 367	com/worklight/jsonstore/api/WLJSONStore:isTransactionInProgress	()Z
    //   27: ifne +37 -> 64
    //   30: new 361	com/worklight/jsonstore/exceptions/JSONStoreNoTransactionInProgressException
    //   33: dup
    //   34: ldc_w 542
    //   37: invokespecial 370	com/worklight/jsonstore/exceptions/JSONStoreNoTransactionInProgressException:<init>	(Ljava/lang/String;)V
    //   40: athrow
    //   41: astore 4
    //   43: aload_2
    //   44: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   47: aload 4
    //   49: athrow
    //   50: astore_1
    //   51: aload_0
    //   52: monitorexit
    //   53: aload_1
    //   54: athrow
    //   55: astore_3
    //   56: new 299	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException
    //   59: dup
    //   60: invokespecial 315	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException:<init>	()V
    //   63: athrow
    //   64: aload 5
    //   66: invokeinterface 374 1 0
    //   71: invokevirtual 382	net/sqlcipher/database/SQLiteDatabase:endTransaction	()V
    //   74: iconst_0
    //   75: putstatic 27	com/worklight/jsonstore/api/WLJSONStore:transactionInProgress	Z
    //   78: aload_2
    //   79: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   82: aload_0
    //   83: monitorexit
    //   84: iconst_1
    //   85: ireturn
    //   86: astore 6
    //   88: new 333	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException
    //   91: dup
    //   92: aload 6
    //   94: invokespecial 383	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException:<init>	(Ljava/lang/Throwable;)V
    //   97: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   15	23	41	finally
    //   23	41	41	finally
    //   56	64	41	finally
    //   64	78	41	finally
    //   88	98	41	finally
    //   2	15	50	finally
    //   43	50	50	finally
    //   78	82	50	finally
    //   15	23	55	java/lang/Exception
    //   64	78	86	java/lang/Throwable
  }

  public void setAnalyticsEnabled(boolean paramBoolean)
  {
    JSONStoreLogger.setAnalyticsEnabled(paramBoolean);
  }

  // ERROR //
  public void startTransaction()
    throws com.worklight.jsonstore.exceptions.JSONStoreTransactionInProgressException, JSONStoreTransactionFailureException, JSONStoreDatabaseClosedException
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 335	com/worklight/jsonstore/api/WLJSONStore:username	Ljava/lang/String;
    //   6: ldc 205
    //   8: getstatic 548	com/worklight/jsonstore/util/JSONStoreLogger:OPERATION_START_TRANSACTION	Ljava/lang/String;
    //   11: invokestatic 308	com/worklight/jsonstore/util/JSONStoreLogger:startAnalyticsInstance	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance;
    //   14: astore_2
    //   15: invokestatic 265	com/worklight/jsonstore/database/DatabaseManager:getInstance	()Lcom/worklight/jsonstore/database/DatabaseManager;
    //   18: invokevirtual 311	com/worklight/jsonstore/database/DatabaseManager:getDatabase	()Lcom/worklight/jsonstore/database/DatabaseAccessor;
    //   21: astore 5
    //   23: aload_0
    //   24: invokevirtual 367	com/worklight/jsonstore/api/WLJSONStore:isTransactionInProgress	()Z
    //   27: ifeq +37 -> 64
    //   30: new 545	com/worklight/jsonstore/exceptions/JSONStoreTransactionInProgressException
    //   33: dup
    //   34: ldc_w 550
    //   37: invokespecial 551	com/worklight/jsonstore/exceptions/JSONStoreTransactionInProgressException:<init>	(Ljava/lang/String;)V
    //   40: athrow
    //   41: astore 4
    //   43: aload_2
    //   44: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   47: aload 4
    //   49: athrow
    //   50: astore_1
    //   51: aload_0
    //   52: monitorexit
    //   53: aload_1
    //   54: athrow
    //   55: astore_3
    //   56: new 299	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException
    //   59: dup
    //   60: invokespecial 315	com/worklight/jsonstore/exceptions/JSONStoreDatabaseClosedException:<init>	()V
    //   63: athrow
    //   64: aload 5
    //   66: invokeinterface 374 1 0
    //   71: invokevirtual 554	net/sqlcipher/database/SQLiteDatabase:beginTransaction	()V
    //   74: iconst_1
    //   75: putstatic 27	com/worklight/jsonstore/api/WLJSONStore:transactionInProgress	Z
    //   78: aload_2
    //   79: invokevirtual 320	com/worklight/jsonstore/util/JSONStoreLogger$JSONStoreAnalyticsLogInstance:end	()V
    //   82: aload_0
    //   83: monitorexit
    //   84: return
    //   85: astore 6
    //   87: new 333	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException
    //   90: dup
    //   91: aload 6
    //   93: invokespecial 383	com/worklight/jsonstore/exceptions/JSONStoreTransactionFailureException:<init>	(Ljava/lang/Throwable;)V
    //   96: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   15	23	41	finally
    //   23	41	41	finally
    //   56	64	41	finally
    //   64	78	41	finally
    //   87	97	41	finally
    //   2	15	50	finally
    //   43	50	50	finally
    //   78	82	50	finally
    //   15	23	55	java/lang/Exception
    //   64	78	85	java/lang/Throwable
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.worklight.jsonstore.api.WLJSONStore
 * JD-Core Version:    0.6.2
 */