Tabnine Logo
CacheSavingException
Code IndexAdd Tabnine to your IDE (free)

How to use
CacheSavingException
in
com.octo.android.robospice.persistence.exception

Best Java code snippets using com.octo.android.robospice.persistence.exception.CacheSavingException (Showing top 11 results out of 315)

origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = mJsonMapper.writeValueAsString(data);
  // finally store the json in the cache
  if (!StringUtils.isEmpty(resultJson)) {
    FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
  } else {
    throw new CacheSavingException("Data was null and could not be serialized in json");
  }
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = gson.toJson(data);
  // finally store the json in the cache
  if (!StringUtils.isEmpty(resultJson)) {
    FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
  } else {
    throw new CacheSavingException("Data was null and could not be serialized in json");
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public Bitmap saveDataToCacheAndReturnData(Bitmap data, Object cacheKey) throws CacheSavingException {
  BufferedOutputStream out = null;
  try {
    File cacheFile = getCacheFile(cacheKey);
    out = new BufferedOutputStream(new FileOutputStream(cacheFile));
    boolean didCompress = data.compress(compressFormat, quality, out);
    if (!didCompress) {
      throw new CacheSavingException(String.format("Could not compress bitmap for path: %s", getCacheFile(cacheKey).getAbsolutePath()));
    }
    return data;
  } catch (IOException e) {
    throw new CacheSavingException(e);
  } finally {
    IOUtils.closeQuietly(out);
  }
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = mJsonMapper.writeValueAsString(data);
  synchronized (getCacheFile(cacheKey).getAbsolutePath().intern()) {
    // finally store the json in the cache
    if (!StringUtils.isEmpty(resultJson)) {
      FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
    } else {
      throw new CacheSavingException("Data was null and could not be serialized in json");
    }
  }
}
origin: com.octo.android.robospice/robospice-spring-android

  @Override
  protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
    try {
      serializer.write(data, getCacheFile(cacheKey));
    } catch (Exception e) {
      throw new CacheSavingException("Data was null and could not be serialized in xml");
    }
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, Object cacheKey) throws CacheSavingException {
  FileOutputStream output = null;
  // special case for big inputstream object : as it can be read
  // only once and is too big to be locally
  // duplicated,
  // 1) we save it in file
  // 2) we load and return it from the file
  try {
    output = new FileOutputStream(getCacheFile(cacheKey));
    IOUtils.copy(data, output);
    return new FileInputStream(getCacheFile(cacheKey));
  } catch (IOException e) {
    throw new CacheSavingException(e);
  } finally {
    IOUtils.closeQuietly(output);
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, final Object cacheKey) throws CacheSavingException {
  // special case for inputstream object : as it can be read only
  // once,
  // 0) we extract the content of the input stream as a byte[]
  // 1) we save it in file asynchronously if enabled
  // 2) the result will be a new InputStream on the byte[]
  final byte[] byteArray;
  try {
    byteArray = IOUtils.toByteArray(data);
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    }
    return new ByteArrayInputStream(byteArray);
  } catch (IOException e) {
    throw new CacheSavingException(e);
  }
}
origin: com.octo.android.robospice/robospice-retrofit

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-google-http-client

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-cache

  @Override
  public String saveDataToCacheAndReturnData(final String data, final Object cacheKey) throws CacheSavingException {
    Ln.v("Saving String " + data + " into cacheKey = " + cacheKey);
    try {
      if (isAsyncSaveEnabled()) {

        Thread t = new Thread() {
          @Override
          public void run() {
            try {
              FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
            } catch (IOException e) {
              Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
            }
          };
        };
        t.start();
      } else {
        FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
      }
    } catch (Exception e) {
      throw new CacheSavingException(e);
    }
    return data;
  }
}
com.octo.android.robospice.persistence.exceptionCacheSavingException

Javadoc

Exception thrown when a problem occurs while saving data to cache. Those exceptions are not thrown by default in the framework.

Most used methods

  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Notification (javax.management)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now